Skip to content
This repository has been archived by the owner on Sep 5, 2024. It is now read-only.

Conversion Host Configuration - List view #3 - Polling for tasks and rendering enable/disable status #889

Merged
merged 21 commits into from
Mar 12, 2019
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
ee33fdc
Set up polling, don't poll when modal is visible, reset polling when …
mturley Mar 1, 2019
d0d32ae
Better distinguish some redux properties
mturley Mar 4, 2019
528e3c1
Add action and reducer handlers for loading filtered tasks
mturley Mar 4, 2019
88916d4
Be explicit with importing redux actions and properties
mturley Mar 4, 2019
b7960ef
Let polling handle post-modal resource fetching, rename a redux property
mturley Mar 4, 2019
62d2308
Disable delete button while deletion in progress
mturley Mar 5, 2019
e43317a
Change Delete to Remove in the modal
mturley Mar 5, 2019
9b2bf98
Parse operation and resource type/id from the task names with regex
mturley Mar 5, 2019
6e61cdb
Index parsed tasks by resource type and id
mturley Mar 5, 2019
d81f23d
Associate hosts and tasks for the list view
mturley Mar 5, 2019
d80341c
Refactor helpers, combine hosts and tasks in list view
mturley Mar 6, 2019
c29bbc9
Render status info for hosts and tasks
mturley Mar 7, 2019
8e458ab
Change Disable terminology to Remove
mturley Mar 8, 2019
e01b415
Disable buttons with no backend support, but pass the right tasks around
mturley Mar 8, 2019
42687fe
Fix layout issues in list view
mturley Mar 8, 2019
a8f3fdf
Add heading
mturley Mar 8, 2019
7ab26b7
Filter out hosts from wizard that are configured or being configured
mturley Mar 10, 2019
b5dedae
Only display the most recent enable task for each resource (filter ou…
mturley Mar 10, 2019
30a8faf
Refactor list item logic into its own component
mturley Mar 10, 2019
b355fe9
Lint fixes, update snapshots, fix existing tests
mturley Mar 10, 2019
197e0de
Filter out tasks matching enabled conversion hosts
mturley Mar 11, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/javascript/react/screens/App/Settings/Settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const Settings = props => {
</React.Fragment>
) : (
<div style={{ marginTop: 10 }}>
<Tabs id="settings-tabs" activeKey={match.path} onSelect={key => redirectTo(key)}>
<Tabs id="settings-tabs" activeKey={match.path} onSelect={key => redirectTo(key)} unmountOnExit>
<Tab eventKey="/settings" title={__('Migration Throttling')}>
<GeneralSettings />
</Tab>
Expand Down
9 changes: 9 additions & 0 deletions app/javascript/react/screens/App/Settings/Settings.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,12 @@
.conversion-hosts-list .list-view-pf-main-info {
padding: 10px 0;
}

.conversion-hosts-list .spinner.spinner-inline {
margin-right: 10px;
}

.conversion-hosts-list-actions {
min-width: 150px;
text-align: right;
}
12 changes: 12 additions & 0 deletions app/javascript/react/screens/App/Settings/SettingsActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
V2V_FETCH_SETTINGS,
V2V_PATCH_SETTINGS,
FETCH_V2V_CONVERSION_HOSTS,
FETCH_V2V_CONVERSION_HOST_TASKS,
SHOW_V2V_CONVERSION_HOST_WIZARD,
HIDE_V2V_CONVERSION_HOST_WIZARD,
V2V_CONVERSION_HOST_WIZARD_EXITED,
Expand Down Expand Up @@ -69,6 +70,17 @@ export const fetchConversionHostsAction = url => {
return _getConversionHostsActionCreator(uri.toString());
};

const _getConversionHostTasksActionCreator = url => dispatch =>
dispatch({
type: FETCH_V2V_CONVERSION_HOST_TASKS,
payload: API.get(url)
});

export const fetchConversionHostTasksAction = url => {
const uri = new URI(url);
return _getConversionHostTasksActionCreator(uri.toString());
};

export const showConversionHostWizardAction = () => dispatch => dispatch({ type: SHOW_V2V_CONVERSION_HOST_WIZARD });

export const hideConversionHostWizardAction = () => dispatch => dispatch({ type: HIDE_V2V_CONVERSION_HOST_WIZARD });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ export const V2V_FETCH_SERVERS = 'V2V_FETCH_SERVERS';
export const V2V_FETCH_SETTINGS = 'V2V_FETCH_SETTINGS';
export const V2V_PATCH_SETTINGS = 'V2V_PATCH_SETTINGS';
export const FETCH_V2V_CONVERSION_HOSTS = 'FETCH_V2V_CONVERSION_HOSTS';
export const FETCH_V2V_CONVERSION_HOST_TASKS = 'FETCH_V2V_CONVERSION_HOST_TASKS';
export const SHOW_V2V_CONVERSION_HOST_WIZARD = 'SHOW_V2V_CONVERSION_HOST_WIZARD';
export const HIDE_V2V_CONVERSION_HOST_WIZARD = 'HIDE_V2V_CONVERSION_HOST_WIZARD';
export const V2V_CONVERSION_HOST_WIZARD_EXITED = 'V2V_CONVERSION_HOST_WIZARD_EXITED';
Expand Down
63 changes: 47 additions & 16 deletions app/javascript/react/screens/App/Settings/SettingsReducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
V2V_FETCH_SETTINGS,
V2V_PATCH_SETTINGS,
FETCH_V2V_CONVERSION_HOSTS,
FETCH_V2V_CONVERSION_HOST_TASKS,
SHOW_V2V_CONVERSION_HOST_WIZARD,
HIDE_V2V_CONVERSION_HOST_WIZARD,
V2V_CONVERSION_HOST_WIZARD_EXITED,
Expand All @@ -15,15 +16,23 @@ import {
DELETE_V2V_CONVERSION_HOST
} from './SettingsConstants';

import { getFormValuesFromApiSettings } from './helpers';
import {
getFormValuesFromApiSettings,
parseConversionHostTasksMetadata,
indexConversionHostTasksByResource
} from './helpers';

export const initialState = Immutable({
conversionHosts: [],
conversionHostTasks: [],
conversionHostTasksByResource: {},
conversionHostToDelete: null,
conversionHostDeleteModalVisible: false,
conversionHostWizardMounted: false,
conversionHostWizardVisible: false,
errorDeleteConversionHost: false,
errorFetchingConversionHosts: null,
errorFetchingConversionHostTasks: null,
errorFetchingServers: null,
errorFetchingSettings: null,
errorPostingConversionHosts: null,
Expand All @@ -32,18 +41,19 @@ export const initialState = Immutable({
fetchingSettingsRejected: false,
isDeletingConversionHost: false,
isFetchingConversionHosts: false,
isFetchingConversionHostTasks: false,
isFetchingServers: false,
isFetchingSettings: false,
isRejectedConversionHost: false,
isRejectedConversionHosts: false,
isPostingConversionHosts: false,
isRejectedDeletingConversionHost: false,
isRejectedFetchingConversionHosts: false,
isRejectedFetchingConversionHostTasks: false,
isRejectedPostingConversionHosts: false,
isSavingSettings: false,
postConversionHostsResults: [],
savedSettings: {},
savingSettingsRejected: false,
servers: [],
showConversionHostDeleteModal: false
servers: []
});

export default (state = initialState, action) => {
Expand Down Expand Up @@ -102,22 +112,41 @@ export default (state = initialState, action) => {
case `${FETCH_V2V_CONVERSION_HOSTS}_PENDING`:
return state
.set('isFetchingConversionHosts', true)
.set('isRejectedConversionHosts', false)
.set('isRejectedFetchingConversionHosts', false)
.set('errorFetchingConversionHosts', null);
case `${FETCH_V2V_CONVERSION_HOSTS}_FULFILLED`:
return state
.set('conversionHosts', action.payload.data.resources)
.set('isFetchingConversionHosts', false)
.set('isRejectedConversionHosts', false)
.set('showConversionHostDeleteModal', false)
.set('isRejectedFetchingConversionHosts', false)
.set('errorFetchingConversionHosts', null);
case `${FETCH_V2V_CONVERSION_HOSTS}_REJECTED`:
return state
.set('isFetchingConversionHosts', false)
.set('isRejectedConversionHosts', true)
.set('showConversionHostDeleteModal', false)
.set('isRejectedFetchingConversionHosts', true)
.set('errorFetchingConversionHosts', action.payload);

case `${FETCH_V2V_CONVERSION_HOST_TASKS}_PENDING`:
return state
.set('isFetchingConversionHostTasks', true)
.set('isRejectedFetchingConversionHostTasks', false)
.set('errorFetchingConversionHostTasks', null);
case `${FETCH_V2V_CONVERSION_HOST_TASKS}_FULFILLED`: {
const tasksWithMetadata = parseConversionHostTasksMetadata(action.payload.data.resources);
const tasksByResource = indexConversionHostTasksByResource(tasksWithMetadata);
return state
mturley marked this conversation as resolved.
Show resolved Hide resolved
.set('conversionHostTasks', tasksWithMetadata)
.set('conversionHostTasksByResource', tasksByResource)
.set('isFetchingConversionHostTasks', false)
.set('isRejectedFetchingConversionHostTasks', false)
.set('errorFetchingConversionHostTasks', null);
}
case `${FETCH_V2V_CONVERSION_HOST_TASKS}_REJECTED`:
return state
.set('isFetchingConversionHostTasks', false)
.set('isRejectedFetchingConversionHostTasks', true)
.set('errorFetchingConversionHostTasks', action.payload);

case SHOW_V2V_CONVERSION_HOST_WIZARD:
return state.set('conversionHostWizardMounted', true).set('conversionHostWizardVisible', true);
case HIDE_V2V_CONVERSION_HOST_WIZARD:
Expand All @@ -144,23 +173,25 @@ export default (state = initialState, action) => {
case SET_V2V_CONVERSION_HOST_TO_DELETE:
return state.set('conversionHostToDelete', action.payload);
case SHOW_V2V_CONVERSION_HOST_DELETE_MODAL:
return state.set('showConversionHostDeleteModal', true);
return state.set('conversionHostDeleteModalVisible', true);
case HIDE_V2V_CONVERSION_HOST_DELETE_MODAL:
return state.set('showConversionHostDeleteModal', false);
return state.set('conversionHostDeleteModalVisible', false);

case `${DELETE_V2V_CONVERSION_HOST}_PENDING`:
return state.set('isDeletingConversionHost', action.payload);
case `${DELETE_V2V_CONVERSION_HOST}_FULFILLED`:
return state
.set('deleteConversionHostResponse', action.payload.data)
.set('isDeletingConversionHost', null)
.set('isRejectedConversionHost', false)
.set('errorDeleteConversionHost', null);
.set('isRejectedDeletingConversionHost', false)
.set('errorDeleteConversionHost', null)
.set('conversionHostDeleteModalVisible', false);
case `${DELETE_V2V_CONVERSION_HOST}_REJECTED`:
return state
.set('errorDeleteConversionHost', action.payload)
.set('isRejectedConversionHost', true)
.set('isDeletingConversionHost', null);
.set('isRejectedDeletingConversionHost', true)
.set('isDeletingConversionHost', null)
.set('conversionHostDeleteModalVisible', false);

default:
return state;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ describe('fetching conversion hosts', () => {
const action = {
type: `${FETCH_V2V_CONVERSION_HOSTS}_PENDING`
};
const prevState = initialState.set('isRejectedConversionHosts', true);
const prevState = initialState.set('isRejectedFetchingConversionHosts', true);
const state = settingsReducer(prevState, action);
expect(state).toMatchSnapshot();
});
Expand All @@ -135,7 +135,9 @@ describe('fetching conversion hosts', () => {
type: `${FETCH_V2V_CONVERSION_HOSTS}_FULFILLED`,
payload: { data: { resources: [{ mock: 'conversionHost' }] } }
};
const prevState = initialState.set('isRejectedConversionHosts', true).set('isFetchingConversionHosts', true);
const prevState = initialState
.set('isRejectedFetchingConversionHosts', true)
.set('isFetchingConversionHosts', true);
const state = settingsReducer(prevState, action);
expect(state).toMatchSnapshot();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ exports[`Settings component renders correctly 1`] = `
activeKey="/settings"
id="settings-tabs"
onSelect={[Function]}
unmountOnExit={true}
>
<Tab
eventKey="/settings"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ Object {
"isFetchingServers": false,
"isFetchingSettings": false,
"isPostingConversionHosts": false,
"isRejectedConversionHost": false,
"isRejectedConversionHosts": false,
"isRejectedDeletingConversionHost": false,
"isRejectedFetchingConversionHosts": false,
"isRejectedPostingConversionHosts": false,
"isSavingSettings": false,
"postConversionHostsResults": Array [],
Expand Down Expand Up @@ -50,8 +50,8 @@ Object {
"isFetchingServers": false,
"isFetchingSettings": false,
"isPostingConversionHosts": false,
"isRejectedConversionHost": false,
"isRejectedConversionHosts": true,
"isRejectedDeletingConversionHost": false,
"isRejectedFetchingConversionHosts": true,
"isRejectedPostingConversionHosts": false,
"isSavingSettings": false,
"postConversionHostsResults": Array [],
Expand Down Expand Up @@ -85,8 +85,8 @@ Object {
"isFetchingServers": false,
"isFetchingSettings": false,
"isPostingConversionHosts": false,
"isRejectedConversionHost": false,
"isRejectedConversionHosts": false,
"isRejectedDeletingConversionHost": false,
"isRejectedFetchingConversionHosts": false,
"isRejectedPostingConversionHosts": false,
"isSavingSettings": false,
"postConversionHostsResults": Array [],
Expand Down Expand Up @@ -116,8 +116,8 @@ Object {
"isFetchingServers": true,
"isFetchingSettings": false,
"isPostingConversionHosts": false,
"isRejectedConversionHost": false,
"isRejectedConversionHosts": false,
"isRejectedDeletingConversionHost": false,
"isRejectedFetchingConversionHosts": false,
"isRejectedPostingConversionHosts": false,
"isSavingSettings": false,
"postConversionHostsResults": Array [],
Expand Down Expand Up @@ -147,8 +147,8 @@ Object {
"isFetchingServers": false,
"isFetchingSettings": false,
"isPostingConversionHosts": false,
"isRejectedConversionHost": false,
"isRejectedConversionHosts": false,
"isRejectedDeletingConversionHost": false,
"isRejectedFetchingConversionHosts": false,
"isRejectedPostingConversionHosts": false,
"isSavingSettings": false,
"postConversionHostsResults": Array [],
Expand Down Expand Up @@ -178,8 +178,8 @@ Object {
"isFetchingServers": false,
"isFetchingSettings": true,
"isPostingConversionHosts": false,
"isRejectedConversionHost": false,
"isRejectedConversionHosts": false,
"isRejectedDeletingConversionHost": false,
"isRejectedFetchingConversionHosts": false,
"isRejectedPostingConversionHosts": false,
"isSavingSettings": false,
"postConversionHostsResults": Array [],
Expand Down Expand Up @@ -209,8 +209,8 @@ Object {
"isFetchingServers": false,
"isFetchingSettings": false,
"isPostingConversionHosts": false,
"isRejectedConversionHost": false,
"isRejectedConversionHosts": false,
"isRejectedDeletingConversionHost": false,
"isRejectedFetchingConversionHosts": false,
"isRejectedPostingConversionHosts": false,
"isSavingSettings": false,
"postConversionHostsResults": Array [],
Expand Down Expand Up @@ -240,8 +240,8 @@ Object {
"isFetchingServers": false,
"isFetchingSettings": false,
"isPostingConversionHosts": false,
"isRejectedConversionHost": false,
"isRejectedConversionHosts": false,
"isRejectedDeletingConversionHost": false,
"isRejectedFetchingConversionHosts": false,
"isRejectedPostingConversionHosts": false,
"isSavingSettings": false,
"postConversionHostsResults": Array [],
Expand Down Expand Up @@ -273,8 +273,8 @@ Object {
"isFetchingServers": false,
"isFetchingSettings": false,
"isPostingConversionHosts": false,
"isRejectedConversionHost": false,
"isRejectedConversionHosts": false,
"isRejectedDeletingConversionHost": false,
"isRejectedFetchingConversionHosts": false,
"isRejectedPostingConversionHosts": false,
"isSavingSettings": true,
"postConversionHostsResults": Array [],
Expand Down Expand Up @@ -304,8 +304,8 @@ Object {
"isFetchingServers": false,
"isFetchingSettings": false,
"isPostingConversionHosts": false,
"isRejectedConversionHost": false,
"isRejectedConversionHosts": false,
"isRejectedDeletingConversionHost": false,
"isRejectedFetchingConversionHosts": false,
"isRejectedPostingConversionHosts": false,
"isSavingSettings": false,
"postConversionHostsResults": Array [],
Expand Down Expand Up @@ -335,8 +335,8 @@ Object {
"isFetchingServers": false,
"isFetchingSettings": false,
"isPostingConversionHosts": false,
"isRejectedConversionHost": false,
"isRejectedConversionHosts": false,
"isRejectedDeletingConversionHost": false,
"isRejectedFetchingConversionHosts": false,
"isRejectedPostingConversionHosts": false,
"isSavingSettings": false,
"postConversionHostsResults": Array [],
Expand Down Expand Up @@ -368,8 +368,8 @@ Object {
"isFetchingServers": false,
"isFetchingSettings": false,
"isPostingConversionHosts": false,
"isRejectedConversionHost": false,
"isRejectedConversionHosts": false,
"isRejectedDeletingConversionHost": false,
"isRejectedFetchingConversionHosts": false,
"isRejectedPostingConversionHosts": false,
"isSavingSettings": false,
"postConversionHostsResults": Array [],
Expand Down
Loading