Skip to content

Commit

Permalink
[8.15] [UII] Only show beta integrations setting for settings write p…
Browse files Browse the repository at this point in the history
…rivilege (#187513) (#189146)

Resolves #184639.

# Backport

This will backport the following commits from `main` to `8.15`:
- [[UII] Only show beta integrations setting for settings write
privilege (#187513)](#187513)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Jen
Huang","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-07-04T08:07:31Z","message":"[UII]
Only show beta integrations setting for settings write privilege
(#187513)\n\n## Summary\r\n\r\nResolves
[#184639](https://github.com/elastic/kibana/issues/184639).\r\n\r\nThis
PR hides the beta integrations toggle if user does not
have\r\nsufficient privileges to write this to Fleet settings SO. The
real fix\r\nshould be handled with
#187511.","sha":"3dfcb859c4e5c7f9ec0deef7fc15cae655e0b17a","branchLabelMapping":{"^v8.15.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","Team:Fleet","backport:prev-minor","v8.16.0"],"title":"[UII]
Only show beta integrations setting for settings write
privilege","number":187513,"url":"https://github.com/elastic/kibana/pull/187513","mergeCommit":{"message":"[UII]
Only show beta integrations setting for settings write privilege
(#187513)\n\n## Summary\r\n\r\nResolves
[#184639](https://github.com/elastic/kibana/issues/184639).\r\n\r\nThis
PR hides the beta integrations toggle if user does not
have\r\nsufficient privileges to write this to Fleet settings SO. The
real fix\r\nshould be handled with
#187511.","sha":"3dfcb859c4e5c7f9ec0deef7fc15cae655e0b17a"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"8.16","label":"v8.16.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Jen Huang <[email protected]>
  • Loading branch information
kibanamachine and jen-huang authored Jul 25, 2024
1 parent 9d62937 commit c350b46
Showing 1 changed file with 18 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {
EuiSwitch,
} from '@elastic/eui';

import { usePutSettingsMutation, useStartServices } from '../../../hooks';
import { usePutSettingsMutation, useStartServices, useAuthz } from '../../../hooks';

export type IntegrationPreferenceType = 'recommended' | 'beats' | 'agent';

Expand Down Expand Up @@ -92,7 +92,7 @@ export const IntegrationPreference = ({
const [prereleaseIntegrationsChecked, setPrereleaseIntegrationsChecked] = React.useState<
boolean | undefined
>(undefined);

const authz = useAuthz();
const { docLinks, notifications } = useStartServices();

const { mutateAsync: mutateSettingsAsync } = usePutSettingsMutation();
Expand Down Expand Up @@ -153,18 +153,24 @@ export const IntegrationPreference = ({
updateSettings(event.target.checked);
};

const canUpdateBetaSetting = authz.fleet.allSettings;

return (
<EuiPanel hasShadow={false} paddingSize="none">
<EuiSwitchNoWrap
label="Display beta integrations"
checked={
typeof prereleaseIntegrationsChecked !== 'undefined'
? prereleaseIntegrationsChecked
: prereleaseIntegrationsEnabled
}
onChange={onPrereleaseSwitchChange}
/>
<EuiSpacer size="l" />
{canUpdateBetaSetting && (
<>
<EuiSwitchNoWrap
label="Display beta integrations"
checked={
typeof prereleaseIntegrationsChecked !== 'undefined'
? prereleaseIntegrationsChecked
: prereleaseIntegrationsEnabled
}
onChange={onPrereleaseSwitchChange}
/>
<EuiSpacer size="l" />
</>
)}
<EuiText size="s">{title}</EuiText>
<EuiSpacer size="m" />
<EuiForm>
Expand Down

0 comments on commit c350b46

Please sign in to comment.