webpack/scenes/ContentViews/Details/ComponentContentViews/ContentViewComponents.js in katello-4.8.4 vs webpack/scenes/ContentViews/Details/ComponentContentViews/ContentViewComponents.js in katello-4.9.0.rc1

- old
+ new

@@ -28,11 +28,11 @@ } from '../ContentViewDetailActions'; import AddedStatusLabel from '../../../../components/AddedStatusLabel'; import ComponentVersion from './ComponentVersion'; import ComponentEnvironments from './ComponentEnvironments'; import ContentViewIcon from '../../components/ContentViewIcon'; -import { ADDED, ALL_STATUSES, NOT_ADDED } from '../../ContentViewsConstants'; +import { ADDED, ALL_STATUSES, CONTENT_VIEW_NEEDS_PUBLISH, NOT_ADDED } from '../../ContentViewsConstants'; import SelectableDropdown from '../../../../components/SelectableDropdown/SelectableDropdown'; import '../../../../components/EditableTextInput/editableTextInput.scss'; import ComponentContentViewAddModal from './ComponentContentViewAddModal'; import ComponentContentViewBulkAddModal from './ComponentContentViewBulkAddModal'; import { hasPermission } from '../../helpers'; @@ -71,11 +71,11 @@ ]; const loading = status === STATUS.PENDING; const addComponentsResolved = componentAddedStatus === STATUS.RESOLVED; const removeComponentsResolved = componentRemovedStatus === STATUS.RESOLVED; - const { label, permissions } = details || {}; + const { permissions } = details || {}; const bulkRemoveEnabled = () => rows.some(row => row.selected && row.added); const bulkAddEnabled = () => rows.some(row => row.selected && !row.added); const onAdd = useCallback(({ @@ -90,21 +90,21 @@ setComponentId(added); } else { // if no versions are present, default to always latest and add cv without modal dispatch(addComponent({ compositeContentViewId: cvId, components: [{ latest: true, content_view_id: componentCvId }], - })); + }, () => dispatch({ type: CONTENT_VIEW_NEEDS_PUBLISH }))); } }, [cvId, dispatch]); const removeBulk = () => { const componentIds = []; rows.forEach(row => row.selected && componentIds.push(row.added)); dispatch(removeComponent({ compositeContentViewId: cvId, component_ids: componentIds, - })); + }, () => dispatch({ type: CONTENT_VIEW_NEEDS_PUBLISH }))); }; const addBulk = () => { const rowsToAdd = rows.filter(row => row.selected && !row.added); setSelectedComponentsToAdd(rowsToAdd); @@ -114,11 +114,11 @@ const onRemove = (componentIdToRemove) => { dispatch(removeComponent({ compositeContentViewId: cvId, component_ids: [componentIdToRemove], - })); + }, () => dispatch({ type: CONTENT_VIEW_NEEDS_PUBLISH }))); }; const toggleBulkAction = () => { setBulkActionOpen(!bulkActionOpen); }; @@ -214,12 +214,12 @@ <DropdownItem ouiaId="bulk-remove" aria-label="bulk_remove" key="bulk_remove" isDisabled={!(bulkRemoveEnabled())} component="button" onClick={removeBulk}> {__('Remove')} </DropdownItem>, ]; - const emptyContentTitle = __(`No content views belong to ${label}`); - const emptyContentBody = __('Please add some content views.'); + const emptyContentTitle = __('No content views to add yet'); + const emptyContentBody = __('Please create some content views.'); const emptySearchTitle = __('No matching content views found'); const emptySearchBody = __('Try changing your search settings.'); const activeFilters = [statusSelected]; const defaultFilters = [ALL_STATUSES]; @@ -255,24 +255,25 @@ autocompleteEndpoint="/katello/api/v2/content_views" bookmarkController="katello_content_views" fetchItems={useCallback(params => getContentViewComponents(cvId, params, statusSelected), [cvId, statusSelected])} additionalListeners={[statusSelected, addComponentsResolved, removeComponentsResolved]} - actionButtons={ - <> - <Split hasGutter> - <SplitItem> - <SelectableDropdown - items={[ALL_STATUSES, ADDED, NOT_ADDED]} - title={__('Status')} - selected={statusSelected} - setSelected={setStatusSelected} - placeholderText={__('Status')} - /> - </SplitItem> - {hasPermission(permissions, 'edit_content_views') && + actionButtons={hasPermission(permissions, 'edit_content_views') && + status === STATUS.RESOLVED && rows.length !== 0 && + <> + <Split hasGutter> <SplitItem> + <SelectableDropdown + items={[ALL_STATUSES, ADDED, NOT_ADDED]} + title={__('Status')} + selected={statusSelected} + setSelected={setStatusSelected} + placeholderText={__('Status')} + /> + </SplitItem> + {hasPermission(permissions, 'edit_content_views') && + <SplitItem> <ActionList> <ActionListItem> <Button ouiaId="add-content-views" onClick={addBulk} isDisabled={!(bulkAddEnabled())} variant="primary" aria-label="bulk_add_components"> {__('Add content views')} </Button> @@ -287,28 +288,28 @@ /> </ActionListItem> </ActionList> </SplitItem> } - </Split> - {versionEditing && + </Split> + {versionEditing && <ComponentContentViewAddModal cvId={compositeCvEditing} componentCvId={componentCvEditing} componentId={componentId} latest={componentLatest} show={versionEditing} setIsOpen={setVersionEditing} aria-label="edit_component_modal" />} - {bulkAdding && + {bulkAdding && <ComponentContentViewBulkAddModal cvId={compositeCvEditing} rowsToAdd={selectedComponentsToAdd} onClose={() => setBulkAdding(false)} aria-label="bulk_add_components_modal" />} - </> + </> } /> ); };