1
1
import React from 'react' ;
2
2
import { useNavigate , useParams } from 'react-router-dom' ;
3
- import {
4
- Bullseye ,
5
- Button ,
6
- ButtonVariant ,
7
- Spinner ,
8
- Text ,
9
- TextVariants ,
10
- } from '@patternfly/react-core' ;
3
+ import { Bullseye , ButtonVariant , Spinner , Text , TextVariants } from '@patternfly/react-core' ;
11
4
import isFunction from 'lodash/isFunction' ;
12
5
import isObject from 'lodash/isObject' ;
13
6
import pipelineImg from '../../../assets/Pipeline.svg' ;
14
7
import { useComponent } from '../../../hooks/useComponents' ;
15
8
import { HttpError } from '../../../k8s/error' ;
16
- import { ComponentGroupVersionKind } from '../../../models' ;
9
+ import { ComponentGroupVersionKind , ComponentModel } from '../../../models' ;
17
10
import { RouterParams } from '../../../routes/utils' ;
18
11
import ErrorEmptyState from '../../../shared/components/empty-state/ErrorEmptyState' ;
19
12
import { useApplicationBreadcrumbs } from '../../../utils/breadcrumb-utils' ;
13
+ import { useAccessReviewForModel } from '../../../utils/rbac' ;
14
+ import { ButtonWithAccessTooltip } from '../../ButtonWithAccessTooltip' ;
20
15
import { createCustomizeComponentPipelineModalLauncher } from '../../CustomizedPipeline/CustomizePipelinesModal' ;
21
16
import { DetailsPage } from '../../DetailsPage' ;
22
17
import { Action } from '../../DetailsPage/types' ;
23
18
import { GettingStartedCard } from '../../GettingStartedCard/GettingStartedCard' ;
24
19
import { useModalLauncher } from '../../modal/ModalProvider' ;
25
20
import { useWorkspaceInfo } from '../../Workspace/useWorkspaceInfo' ;
26
21
import { useComponentActions } from '../component-actions' ;
27
-
28
22
import './ComponentDetailsView.scss' ;
29
23
30
24
export const COMPONENTS_GS_LOCAL_STORAGE_KEY = 'components-getting-started-modal' ;
@@ -36,6 +30,7 @@ const ComponentDetailsView: React.FC = () => {
36
30
const applicationBreadcrumbs = useApplicationBreadcrumbs ( ) ;
37
31
const showModal = useModalLauncher ( ) ;
38
32
const [ component , loaded , componentError ] = useComponent ( namespace , workspace , componentName ) ;
33
+ const [ canPatchComponent ] = useAccessReviewForModel ( ComponentModel , 'patch' ) ;
39
34
40
35
const componentActions = useComponentActions ( loaded ? component : undefined , componentName ) ;
41
36
const actions : Action [ ] = React . useMemo (
@@ -96,9 +91,11 @@ const ComponentDetailsView: React.FC = () => {
96
91
Using the Advanced or Custom build pipeline, you can enable all additional tasks for
97
92
added security.
98
93
</ div >
99
- < Button
94
+ < ButtonWithAccessTooltip
100
95
className = "pf-u-mt-xl"
101
96
variant = { ButtonVariant . secondary }
97
+ isDisabled = { ! canPatchComponent }
98
+ tooltip = "You don't have access to edit the build pipeline plan"
102
99
onClick = { ( ) =>
103
100
showModal (
104
101
createCustomizeComponentPipelineModalLauncher (
@@ -109,7 +106,7 @@ const ComponentDetailsView: React.FC = () => {
109
106
}
110
107
>
111
108
Edit build pipeline plan
112
- </ Button >
109
+ </ ButtonWithAccessTooltip >
113
110
</ GettingStartedCard >
114
111
}
115
112
breadcrumbs = { [
0 commit comments