webpack/scenes/AlternateContentSources/MainTable/ACSTable.js in katello-4.5.0.rc1 vs webpack/scenes/AlternateContentSources/MainTable/ACSTable.js in katello-4.5.0.rc2

- old
+ new

@@ -7,23 +7,26 @@ import { selectAlternateContentSources, selectAlternateContentSourcesError, selectAlternateContentSourcesStatus, } from '../ACSSelectors'; import { useTableSort } from '../../../components/Table/TableHooks'; -import getAlternateContentSources, { deleteACS } from '../ACSActions'; +import getAlternateContentSources, { deleteACS, refreshACS } from '../ACSActions'; +import ACSCreateWizard from '../Create/ACSCreateWizard'; +import LastSync from '../../ContentViews/Details/Repositories/LastSync'; const ACSTable = () => { const response = useSelector(selectAlternateContentSources); const status = useSelector(selectAlternateContentSourcesStatus); const error = useSelector(selectAlternateContentSourcesError); const [searchQuery, updateSearchQuery] = useState(''); + const [isCreateWizardOpen, setIsCreateWizardOpen] = useState(false); const dispatch = useDispatch(); const { results, ...metadata } = response; const columnHeaders = [ __('Name'), __('Type'), - __('Id'), + __('Last Refresh'), ]; const COLUMNS_TO_SORT_PARAMS = { [columnHeaders[0]]: 'name', [columnHeaders[1]]: 'alternate_content_source_type', @@ -45,41 +48,39 @@ ...params, }), [apiSortParams], ); - // const createButtonOnclick = () => { - // let params = { - // name: `test_acs-${Math.random()}`, - // label: `test_acs-${Math.random()}`, - // base_url: "https://fixtures.pulpproject.org/", - // subpaths: ["file/", "package/"], - // smart_proxy_ids:[1], - // content_type:"yum", - // alternate_content_source_type:"custom" - // }; - // dispatch(createACS(params)); - // }; - const onDelete = (id) => { dispatch(deleteACS(id, () => dispatch(getAlternateContentSources()))); }; + const onRefresh = (id) => { + dispatch(refreshACS(id, () => + dispatch(getAlternateContentSources()))); + }; + const createButtonOnclick = () => { - /* eslint-disable-next-line no-console */ - console.log('Dispatch create!'); + setIsCreateWizardOpen(true); }; const rowDropdownItems = ({ id }) => [ { - title: 'Delete', + title: __('Delete'), ouiaId: `remove-acs-${id}`, onClick: () => { onDelete(id); }, }, + { + title: __('Refresh'), + ouiaId: `remove-acs-${id}`, + onClick: () => { + onRefresh(id); + }, + }, ]; const emptyContentTitle = __("You currently don't have any alternate content sources."); const emptyContentBody = __('An alternate content source can be added by using the "Add source" button above.'); const emptySearchTitle = __('No matching alternate content sources found'); @@ -102,13 +103,21 @@ ouiaId="alternate-content-sources-table" variant={TableVariant.compact} additionalListeners={[activeSortColumn, activeSortDirection]} autocompleteEndpoint="/alternate_content_sources/auto_complete_search" actionButtons={ - <Button ouiaId="create-acs" onClick={createButtonOnclick} variant="primary" aria-label="create_acs"> - {__('Add source')} - </Button> + <> + <Button ouiaId="create-acs" onClick={createButtonOnclick} variant="primary" aria-label="create_acs"> + {__('Add source')} + </Button> + {isCreateWizardOpen && + <ACSCreateWizard + show={isCreateWizardOpen} + setIsOpen={setIsCreateWizardOpen} + /> + } + </> } > <Thead> <Tr> {columnHeaders.map(col => ( @@ -122,18 +131,19 @@ </Tr> </Thead> <Tbody> {results?.map((acs, index) => { const { - id, name, alternate_content_source_type: acsType, + last_refresh: lastTask, } = acs; + const { last_refresh_words: lastRefreshWords, started_at: startedAt } = lastTask ?? {}; return ( <Tr key={index}> <Td>{name}</Td> <Td>{acsType}</Td> - <Td>{id}</Td> + <Td><LastSync startedAt={startedAt} lastSync={lastTask} lastSyncWords={lastRefreshWords} emptyMessage="N/A" /></Td> <Td actions={{ items: rowDropdownItems(acs), }} />