-
Notifications
You must be signed in to change notification settings - Fork 174
ROX-13378: Group new resources with deprecated in UI #3690
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
Changes from all commits
6b6d26b
85744f8
2052116
0f9af8e
2ebbe71
1acbc0c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,6 +11,7 @@ const resourceDescriptions: Record<ResourceName, string> = { | |
| Alert: 'Read: View policy violations. Write: Resolve or edit policy violations.', | ||
| CVE: 'Internal use only', | ||
| Cluster: 'Read: View secured clusters. Write: Add, modify, or delete secured clusters.', | ||
| ClusterCVE: 'Internal use only', | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we have to add it within the UI as a new resource? I know we have other resources that are being leaked to the UI that are for internal use only, but why add another one?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see. It's unfortunate that we return it then in the first place, I suppose such is life then for the internal resources. |
||
| Compliance: | ||
| 'Read: View compliance standards, results, and runs. Write: Add, modify, or delete scheduled compliance runs.', | ||
| Deployment: 'Read: View deployments (workloads) in secured clusters. Write: N/A', | ||
|
|
@@ -72,7 +73,7 @@ export type ResourceDescriptionProps = { | |
| resource: string; | ||
| }; | ||
|
|
||
| function ResourceDescription({ resource }: ResourceDescriptionProps): ReactElement { | ||
| export function ResourceDescription({ resource }: ResourceDescriptionProps): ReactElement { | ||
| // The description becomes the prop for possible future request from backend. | ||
| const description = resourceDescriptions[resource] ?? ''; | ||
| const readIndex = description.indexOf('Read: '); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| import React, { ReactElement } from 'react'; | ||
| import { | ||
| Alert, | ||
| AlertVariant, | ||
| Divider, | ||
| PageSection, | ||
| PageSectionVariants, | ||
| Title, | ||
| } from '@patternfly/react-core'; | ||
|
|
||
| function IntegrationsNoPermission(): ReactElement { | ||
| return ( | ||
| <> | ||
| <PageSection variant="light"> | ||
| <Title headingLevel="h1">Integrations</Title> | ||
| </PageSection> | ||
| <Divider component="div" /> | ||
| <PageSection variant={PageSectionVariants.light}> | ||
| <Alert | ||
| className="pf-u-mt-md" | ||
| title="You do not have permission to view Integrations" | ||
| variant={AlertVariant.info} | ||
| isInline | ||
| /> | ||
| </PageSection> | ||
| </> | ||
| ); | ||
| } | ||
|
|
||
| export default IntegrationsNoPermission; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,16 +15,28 @@ import IntegrationsListPage from './IntegrationsListPage'; | |
| import CreateIntegrationPage from './CreateIntegrationPage'; | ||
| import EditIntegrationPage from './EditIntegrationPage'; | ||
| import IntegrationDetailsPage from './IntegrationDetailsPage'; | ||
| import usePermissions from '../../hooks/usePermissions'; | ||
| import IntegrationsNoPermission from './IntegrationsNoPermission'; | ||
|
|
||
| const Page = (): ReactElement => ( | ||
| <Switch> | ||
| <Route exact path={integrationsPath} component={IntegrationTilesPage} /> | ||
| <Route exact path={integrationsListPath} component={IntegrationsListPage} /> | ||
| <Route path={integrationCreatePath} component={CreateIntegrationPage} /> | ||
| <Route path={integrationEditPath} component={EditIntegrationPage} /> | ||
| <Route path={integrationDetailsPath} component={IntegrationDetailsPage} /> | ||
| <Route component={IntegrationsNotFoundPage} /> | ||
| </Switch> | ||
| ); | ||
| const Page = (): ReactElement => { | ||
| const { hasReadAccess } = usePermissions(); | ||
| const hasReadAccessForIntegrations = hasReadAccess('Integration'); | ||
| return ( | ||
| <> | ||
| {hasReadAccessForIntegrations ? ( | ||
| <Switch> | ||
| <Route exact path={integrationsPath} component={IntegrationTilesPage} /> | ||
| <Route exact path={integrationsListPath} component={IntegrationsListPage} /> | ||
| <Route path={integrationCreatePath} component={CreateIntegrationPage} /> | ||
| <Route path={integrationEditPath} component={EditIntegrationPage} /> | ||
| <Route path={integrationDetailsPath} component={IntegrationDetailsPage} /> | ||
| <Route component={IntegrationsNotFoundPage} /> | ||
| </Switch> | ||
| ) : ( | ||
| <IntegrationsNoPermission /> | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What’s done is done. Was this a broken page which requires this change just before release?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is related to this discussion: |
||
| )} | ||
| </> | ||
| ); | ||
| }; | ||
|
|
||
| export default Page; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,6 @@ | ||
| /* constants specific to Roles */ | ||
| import { ResourceName } from '../types/roleResources'; | ||
|
|
||
| export const NO_ACCESS = 'NO_ACCESS'; | ||
| export const READ_ACCESS = 'READ_ACCESS'; | ||
| export const READ_WRITE_ACCESS = 'READ_WRITE_ACCESS'; | ||
|
|
@@ -86,3 +88,51 @@ export const defaultSelectedRole = { | |
| name: '', | ||
| resourceToAccess: defaultNewRolePermissions, | ||
| }; | ||
|
|
||
| // TODO: ROX-12750 update with new list of replaced/deprecated resources | ||
| export const resourceSubstitutions: Record<string, string[]> = { | ||
| Access: ['AuthProvider', 'Group', 'Licenses', 'User'], | ||
| DeploymentExtension: ['Indicator', 'NetworkBaseline', 'ProcessWhitelist', 'Risk'], | ||
| Integration: [ | ||
| 'APIToken', | ||
| 'BackupPlugins', | ||
| 'ImageIntegration', | ||
| 'Notifier', | ||
| 'SignatureIntegration', | ||
| ], | ||
| Image: ['ImageComponent'], | ||
| }; | ||
|
|
||
| // TODO: ROX-12750 update with new list of replaced/deprecated resources | ||
| export const resourceRemovalReleaseVersions = new Map<ResourceName, string>([ | ||
| ['AllComments', '3.75'], | ||
| ['ComplianceRuns', '3.75'], | ||
| ['Config', '3.75'], | ||
| ['DebugLogs', '3.75'], | ||
| ['NetworkGraphConfig', '3.75'], | ||
| ['ProbeUpload', '3.75'], | ||
| ['ScannerBundle', '3.75'], | ||
| ['ScannerDefinitions', '3.75'], | ||
| ['SensorUpgradeConfig', '3.75'], | ||
| ['ServiceIdentity', '3.75'], | ||
| ['ClusterCVE', '3.74'], | ||
| ]); | ||
|
|
||
| // TODO(ROX-11453): Remove this mapping once the old resources are fully deprecated. | ||
| export const replacedResourceMapping = new Map<ResourceName, string>([ | ||
| // TODO: ROX-12750 Remove AllComments, ComplianceRunSchedule, ComplianceRuns, Config, DebugLogs, | ||
| // NetworkGraphConfig, ProbeUpload, ScannerBundle, ScannerDefinitions, SensorUpgradeConfig and ServiceIdentity. | ||
| ['AllComments', 'Administration'], | ||
| ['ComplianceRuns', 'Compliance'], | ||
| ['Config', 'Administration'], | ||
| ['DebugLogs', 'Administration'], | ||
| ['NetworkGraphConfig', 'Administration'], | ||
| ['ProbeUpload', 'Administration'], | ||
| ['ScannerBundle', 'Administration'], | ||
| ['ScannerDefinitions', 'Administration'], | ||
| ['SensorUpgradeConfig', 'Administration'], | ||
| ['ServiceIdentity', 'Administration'], | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Any reason why ClusterCVE is not in this list?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My understanding was that
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| ['ClusterCVE', 'Cluster'], | ||
| ]); | ||
|
|
||
| export const deprecatedResourceRowStyle = { backgroundColor: 'rgb(255,250,205)' }; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We will follow up with a PatternFly variable if explicit color does not work for dark mode |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,6 +4,7 @@ import { createStructuredSelector } from 'reselect'; | |
| import { selectors } from 'reducers'; | ||
| import { Access } from 'types/role.proto'; | ||
| import { ResourceName } from 'types/roleResources'; | ||
| import { replacedResourceMapping } from 'constants/accessControl'; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you need to make the corresponding change in this file: |
||
|
|
||
| export type HasNoAccess = (resourceName: ResourceName) => boolean; | ||
| export type HasReadAccess = (resourceName: ResourceName) => boolean; | ||
|
|
@@ -24,22 +25,6 @@ const stateSelector = createStructuredSelector<{ | |
| isLoadingPermissions: selectors.getIsLoadingUserRolePermissions, | ||
| }); | ||
|
|
||
| // TODO(ROX-11453): Remove this mapping once the old resources are fully deprecated. | ||
| const replacedResourceMapping = new Map<ResourceName, string>([ | ||
| // TODO: ROX-12750 Remove AllComments, ComplianceRunSchedule, ComplianceRuns, Config, DebugLogs, | ||
| // NetworkGraphConfig, ProbeUpload, ScannerBundle, ScannerDefinitions, SensorUpgradeConfig and ServiceIdentity. | ||
| ['AllComments', 'Administration'], | ||
| ['ComplianceRuns', 'Compliance'], | ||
| ['Config', 'Administration'], | ||
| ['DebugLogs', 'Administration'], | ||
| ['NetworkGraphConfig', 'Administration'], | ||
| ['ProbeUpload', 'Administration'], | ||
| ['ScannerBundle', 'Administration'], | ||
| ['ScannerDefinitions', 'Administration'], | ||
| ['SensorUpgradeConfig', 'Administration'], | ||
| ['ServiceIdentity', 'Administration'], | ||
| ]); | ||
|
|
||
| const usePermissions = (): UsePermissionsResponse => { | ||
| const { userRolePermissions, isLoadingPermissions } = useSelector(stateSelector); | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe a list for readability?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When I try to use a list within this
Alertcomponent, it does not show up as a list. Wanted to ask @pedrottimark or @vjwilson if they know what might be the reason for this behaviour.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There were were pretty strict style resets in pre-Red Hat style sheet, and we can't remove them until all the old style pages have been updated. We'd probably need to add a specific override in this file until then, to make a list show in this component.
https://github.com/stackrox/stackrox/blob/master/ui/apps/platform/src/css/trumps.css