Skip to content

Commit 01f190f

Browse files
committed
disabling create/edit button when user does not have write permission
1 parent 32f5b60 commit 01f190f

File tree

2 files changed

+39
-23
lines changed
  • x-pack/plugins/apm/public/components/app/Settings/AgentConfigurations

2 files changed

+39
-23
lines changed

x-pack/plugins/apm/public/components/app/Settings/AgentConfigurations/List/index.tsx

Lines changed: 31 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ interface Props {
4141

4242
export function AgentConfigurationList({ status, data, refetch }: Props) {
4343
const { core } = useApmPluginContext();
44+
const canSave = core.application.capabilities.apm.save;
4445
const { basePath } = core.http;
4546
const { search } = useLocation();
4647
const theme = useTheme();
@@ -180,28 +181,36 @@ export function AgentConfigurationList({ status, data, refetch }: Props) {
180181
<TimestampTooltip time={value} timeUnit="minutes" />
181182
),
182183
},
183-
{
184-
width: px(units.double),
185-
name: '',
186-
render: (config: Config) => (
187-
<EuiButtonIcon
188-
aria-label="Edit"
189-
iconType="pencil"
190-
href={editAgentConfigurationHref(config.service, search, basePath)}
191-
/>
192-
),
193-
},
194-
{
195-
width: px(units.double),
196-
name: '',
197-
render: (config: Config) => (
198-
<EuiButtonIcon
199-
aria-label="Delete"
200-
iconType="trash"
201-
onClick={() => setConfigToBeDeleted(config)}
202-
/>
203-
),
204-
},
184+
...(canSave
185+
? [
186+
{
187+
width: px(units.double),
188+
name: '',
189+
render: (config: Config) => (
190+
<EuiButtonIcon
191+
aria-label="Edit"
192+
iconType="pencil"
193+
href={editAgentConfigurationHref(
194+
config.service,
195+
search,
196+
basePath
197+
)}
198+
/>
199+
),
200+
},
201+
{
202+
width: px(units.double),
203+
name: '',
204+
render: (config: Config) => (
205+
<EuiButtonIcon
206+
aria-label="Delete"
207+
iconType="trash"
208+
onClick={() => setConfigToBeDeleted(config)}
209+
/>
210+
),
211+
},
212+
]
213+
: []),
205214
];
206215

207216
return (

x-pack/plugins/apm/public/components/app/Settings/AgentConfigurations/index.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,18 @@ function CreateConfigurationButton() {
7373
const { basePath } = core.http;
7474
const { search } = useLocation();
7575
const href = createAgentConfigurationHref(search, basePath);
76+
const canSave = core.application.capabilities.apm.save;
7677
return (
7778
<EuiFlexItem>
7879
<EuiFlexGroup alignItems="center" justifyContent="flexEnd">
7980
<EuiFlexItem grow={false}>
80-
<EuiButton color="primary" fill iconType="plusInCircle" href={href}>
81+
<EuiButton
82+
color="primary"
83+
fill
84+
iconType="plusInCircle"
85+
href={href}
86+
isDisabled={!canSave}
87+
>
8188
{i18n.translate('xpack.apm.agentConfig.createConfigButtonLabel', {
8289
defaultMessage: 'Create configuration',
8390
})}

0 commit comments

Comments
 (0)