Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(RHINENG-11884): Remove groups -> workspaces rename feature flag #2250

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
10 changes: 2 additions & 8 deletions src/Routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {
} from './Utilities/edge';
import { inventoryHasConventionalSystems } from './Utilities/conventional';
import Fallback from './components/SpinnerFallback';
import useWorkspaceFeatureFlag from './Utilities/hooks/useWorkspaceFeatureFlag';
import Redirect from './Utilities/Redirect';
import { AccountStatContext } from './Contexts';

Expand Down Expand Up @@ -52,7 +51,6 @@ export const Routes = () => {
);

const isBifrostEnabled = useFeatureFlag('hbi.ui.bifrost');
const isWorkspaceEnabled = useWorkspaceFeatureFlag();

useEffect(() => {
// zero state check
Expand Down Expand Up @@ -90,21 +88,17 @@ export const Routes = () => {
{ path: '/:inventoryId/:modalId', element: <InventoryDetail /> },
{
path: '/groups',
element: isWorkspaceEnabled ? (
element: (
<Redirect to="/insights/inventory/workspaces" replace="replace" />
) : (
<InventoryOrEdgeView />
),
},
{
path: '/groups/:groupId',
element: isWorkspaceEnabled ? (
element: (
<Redirect
to="/insights/inventory/workspaces/:groupId"
replace="replace"
/>
) : (
<InventoryOrEdgeGroupDetailsView />
),
},
{
Expand Down
6 changes: 0 additions & 6 deletions src/Utilities/hooks/useWorkspaceFeatureFlag.js

This file was deleted.

11 changes: 2 additions & 9 deletions src/components/GroupSystems/GroupImmutableSystems.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { useLocation, useNavigate, useParams } from 'react-router-dom';
import RemoveHostsFromGroupModal from '../InventoryGroups/Modals/RemoveHostsFromGroupModal';
import { usePermissionsWithContext } from '@redhat-cloud-services/frontend-components-utilities/RBACHook';
import {
NO_MODIFY_GROUP_TOOLTIP_MESSAGE,
NO_MODIFY_WORKSPACE_TOOLTIP_MESSAGE,
REQUIRED_PERMISSIONS_TO_MODIFY_GROUP,
} from '../../constants';
Expand All @@ -31,18 +30,12 @@ import {
import { edgeColumns } from '../ImmutableDevices/columns';
import { mergeArraysByKey } from '@redhat-cloud-services/frontend-components-utilities/helpers';
import { hybridInventoryTabKeys } from '../../Utilities/constants';
import useWorkspaceFeatureFlag from '../../Utilities/hooks/useWorkspaceFeatureFlag';
import { prepareColumnsImmutable as prepareColumns } from './helpers';

const GroupImmutableSystems = ({ groupName, groupId, ...props }) => {
const dispatch = useDispatch();
const isWorkspaceEnabled = useWorkspaceFeatureFlag();
const noAccessTooltip = isWorkspaceEnabled
? NO_MODIFY_WORKSPACE_TOOLTIP_MESSAGE
: NO_MODIFY_GROUP_TOOLTIP_MESSAGE;
const removeLabel = isWorkspaceEnabled
? 'Remove from workspace'
: 'Remove from group';
const noAccessTooltip = NO_MODIFY_WORKSPACE_TOOLTIP_MESSAGE;
const removeLabel = 'Remove from workspace';
const mergeColumns = (inventoryColumns) => {
const filteredColumns = inventoryColumns.filter(
(column) => column.key !== 'groups'
Expand Down
11 changes: 2 additions & 9 deletions src/components/GroupSystems/GroupSystems.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { useSearchParams } from 'react-router-dom';
import RemoveHostsFromGroupModal from '../InventoryGroups/Modals/RemoveHostsFromGroupModal';
import { usePermissionsWithContext } from '@redhat-cloud-services/frontend-components-utilities/RBACHook';
import {
NO_MODIFY_GROUP_TOOLTIP_MESSAGE,
NO_MODIFY_WORKSPACE_TOOLTIP_MESSAGE,
REQUIRED_PERMISSIONS_TO_MODIFY_GROUP,
getSearchParams,
Expand All @@ -25,7 +24,6 @@ import useGlobalFilter from '../filters/useGlobalFilter';
import { hybridInventoryTabKeys } from '../../Utilities/constants';
import useOnRefresh from '../filters/useOnRefresh';
import { generateFilter } from '../../Utilities/constants';
import useWorkspaceFeatureFlag from '../../Utilities/hooks/useWorkspaceFeatureFlag';
import { prepareColumnsCoventional as prepareColumns } from './helpers';

const GroupSystems = ({ groupName, groupId }) => {
Expand All @@ -52,13 +50,8 @@ const GroupSystems = ({ groupName, groupId }) => {
);

const [searchParams] = useSearchParams();
const isWorkspaceEnabled = useWorkspaceFeatureFlag();
const noAccessTooltip = isWorkspaceEnabled
? NO_MODIFY_WORKSPACE_TOOLTIP_MESSAGE
: NO_MODIFY_GROUP_TOOLTIP_MESSAGE;
const removeLabel = isWorkspaceEnabled
? 'Remove from workspace'
: 'Remove from group';
const noAccessTooltip = NO_MODIFY_WORKSPACE_TOOLTIP_MESSAGE;
const removeLabel = 'Remove from workspace';

useEffect(() => {
const { page, perPage } = getSearchParams(searchParams);
Expand Down
44 changes: 10 additions & 34 deletions src/components/GroupsTable/GroupsTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,13 @@ import { useDispatch, useSelector } from 'react-redux';
import { Link } from 'react-router-dom';
import {
GENERAL_GROUPS_WRITE_PERMISSION,
NO_MODIFY_GROUPS_TOOLTIP_MESSAGE,
NO_MODIFY_WORKSPACES_TOOLTIP_MESSAGE,
NO_MODIFY_GROUP_TOOLTIP_MESSAGE,
NO_MODIFY_WORKSPACE_TOOLTIP_MESSAGE,
REQUIRED_PERMISSIONS_TO_MODIFY_GROUP,
TABLE_DEFAULT_PAGINATION,
} from '../../constants';
import { fetchGroups } from '../../store/inventory-actions';
import useFetchBatched from '../../Utilities/hooks/useFetchBatched';
import useWorkspaceFeatureFlag from '../../Utilities/hooks/useWorkspaceFeatureFlag';
import DeleteGroupModal from '../InventoryGroups/Modals/DeleteGroupModal';
import RenameGroupModal from '../InventoryGroups/Modals/RenameGroupModal';
import { getGroups } from '../InventoryGroups/utils/api';
Expand Down Expand Up @@ -125,7 +122,6 @@ const GroupsTable = ({ onCreateGroupClick }) => {
const [deleteModalOpen, setDeleteModalOpen] = useState(false);
const groups = useMemo(() => data?.results || [], [data]);
const { fetchBatched } = useFetchBatched();
const isWorkspaceEnabled = useWorkspaceFeatureFlag();
const loadingState = uninitialized || loading;

const fetchData = useCallback(
Expand Down Expand Up @@ -258,7 +254,7 @@ const GroupsTable = ({ onCreateGroupClick }) => {
{
title: (
<NoEntitiesFound
entities={isWorkspaceEnabled ? 'workspaces' : 'groups'}
entities="workspaces"
onClearAll={onResetFilters}
/>
),
Expand Down Expand Up @@ -325,11 +321,7 @@ const GroupsTable = ({ onCreateGroupClick }) => {
requiredPermissions={REQUIRED_PERMISSIONS_TO_MODIFY_GROUP(
rowData?.groupId
)}
noAccessTooltip={
isWorkspaceEnabled
? NO_MODIFY_WORKSPACE_TOOLTIP_MESSAGE
: NO_MODIFY_GROUP_TOOLTIP_MESSAGE
}
noAccessTooltip={NO_MODIFY_WORKSPACE_TOOLTIP_MESSAGE}
onClick={() => {
setSelectedGroup({
id: rowData?.groupId,
Expand All @@ -338,7 +330,7 @@ const GroupsTable = ({ onCreateGroupClick }) => {
setRenameModalOpen(true);
}}
>
{isWorkspaceEnabled ? 'Rename workspace' : 'Rename group'}
Rename workspace
</ActionDropdownItem>
),
},
Expand All @@ -348,11 +340,7 @@ const GroupsTable = ({ onCreateGroupClick }) => {
requiredPermissions={REQUIRED_PERMISSIONS_TO_MODIFY_GROUP(
rowData?.groupId
)}
noAccessTooltip={
isWorkspaceEnabled
? NO_MODIFY_WORKSPACE_TOOLTIP_MESSAGE
: NO_MODIFY_GROUP_TOOLTIP_MESSAGE
}
noAccessTooltip={NO_MODIFY_WORKSPACE_TOOLTIP_MESSAGE}
onClick={() => {
setSelectedGroup({
id: rowData?.groupId,
Expand All @@ -361,7 +349,7 @@ const GroupsTable = ({ onCreateGroupClick }) => {
setDeleteModalOpen(true);
}}
>
{isWorkspaceEnabled ? 'Delete workspace' : 'Delete group'}
Delete workspace
</ActionDropdownItem>
),
},
Expand Down Expand Up @@ -468,38 +456,26 @@ const GroupsTable = ({ onCreateGroupClick }) => {
<ActionButton
key="create-group-btn"
requiredPermissions={[GENERAL_GROUPS_WRITE_PERMISSION]}
noAccessTooltip={
isWorkspaceEnabled
? NO_MODIFY_WORKSPACES_TOOLTIP_MESSAGE
: NO_MODIFY_GROUPS_TOOLTIP_MESSAGE
}
noAccessTooltip={NO_MODIFY_WORKSPACES_TOOLTIP_MESSAGE}
onClick={onCreateGroupClick}
ouiaId="CreateGroupButton"
>
{isWorkspaceEnabled ? 'Create workspace' : 'Create group'}
Create workspace
</ActionButton>,
{
label: (
<ActionDropdownItem
requiredPermissions={selectedIds.flatMap((id) =>
REQUIRED_PERMISSIONS_TO_MODIFY_GROUP(id)
)}
noAccessTooltip={
isWorkspaceEnabled
? NO_MODIFY_WORKSPACES_TOOLTIP_MESSAGE
: NO_MODIFY_GROUPS_TOOLTIP_MESSAGE
}
noAccessTooltip={NO_MODIFY_WORKSPACES_TOOLTIP_MESSAGE}
onClick={() => setDeleteModalOpen(true)}
isAriaDisabled={selectedIds.length === 0}
checkAll
>
{selectedIds.length > 1
? isWorkspaceEnabled
? 'Delete workspaces'
: 'Delete groups'
: isWorkspaceEnabled
? 'Delete workspace'
: 'Delete group'}
? 'Delete workspaces'
: 'Delete workspace'}
</ActionDropdownItem>
),
},
Expand Down
115 changes: 43 additions & 72 deletions src/components/InventoryGroupDetail/EmptyStateNoAccess.js
Original file line number Diff line number Diff line change
@@ -1,80 +1,51 @@
import React from 'react';
import AccessDenied from '../../Utilities/AccessDenied';
import useWorkspaceFeatureFlag from '../../Utilities/hooks/useWorkspaceFeatureFlag';

const EmptyStateNoAccessToSystems = () => {
const isWorkspaceEnabled = useWorkspaceFeatureFlag();
const EmptyStateNoAccessToSystems = () => (
<AccessDenied
title="Access needed for systems in this workspace"
showReturnButton={false}
description={
<div>
You do not have the necessary inventory host permissions to see the
systems in this workspace. Contact your organization administrator for
access.
</div>
}
variant="large" // overrides the default "full" value
requiredPermission="inventory:hosts:read"
/>
);

return (
<AccessDenied
title={`Access needed for systems in this ${
isWorkspaceEnabled ? 'workspace' : 'group'
}`}
showReturnButton={false}
description={
<div>
{`You do not have the necessary inventory host permissions to see the
systems in this ${
isWorkspaceEnabled ? 'workspace' : 'group'
}. Contact your organization administrator for
access.`}
</div>
}
variant="large" // overrides the default "full" value
requiredPermission="inventory:hosts:read"
/>
);
};

const EmptyStateNoAccessToGroup = () => {
const isWorkspaceEnabled = useWorkspaceFeatureFlag();

return (
<AccessDenied
title={`${
isWorkspaceEnabled ? 'Workspace' : 'Inventory group'
} access permissions needed`}
showReturnButton={false}
description={
<div>
{`You do not have the necessary ${
isWorkspaceEnabled ? 'workspace' : 'inventory group'
} permissions to see this
${
isWorkspaceEnabled ? 'workspace' : 'inventory group'
}. Contact your organization administrator for access.`}
</div>
}
variant="large" // overrides the default "full" value
requiredPermission="inventory:groups:read"
/>
);
};

const EmptyStateNoAccessToGroups = () => {
const isWorkspaceEnabled = useWorkspaceFeatureFlag();
const EmptyStateNoAccessToGroup = () => (
<AccessDenied
title="Workspace access permissions needed"
showReturnButton={false}
description={
<div>
You do not have the necessary workspace permissions to see this
workspace. Contact your organization administrator for access.
</div>
}
variant="large" // overrides the default "full" value
requiredPermission="inventory:groups:read"
/>
);

return (
<AccessDenied
title={`${
isWorkspaceEnabled ? 'Workspace' : 'Inventory group'
} access permissions needed`}
showReturnButton={false}
description={
<div>
{`You do not have the necessary ${
isWorkspaceEnabled ? 'workspace' : 'inventory group'
} permissions to see
${
isWorkspaceEnabled ? 'workspaces' : 'inventory groups'
}. Contact your organization administrator for access.`}
</div>
}
variant="large" // overrides the default "full" value
requiredPermission="inventory:groups:read"
/>
);
};
const EmptyStateNoAccessToGroups = () => (
<AccessDenied
title="Workspace access permissions needed"
showReturnButton={false}
description={
<div>
You do not have the necessary workspace permissions to see workspaces.
Contact your organization administrator for access.
</div>
}
variant="large" // overrides the default "full" value
requiredPermission="inventory:groups:read"
/>
);

export {
EmptyStateNoAccessToGroup,
Expand Down
Loading