Skip to content

Commit

Permalink
[UII] Only show beta integrations setting for settings write privilege (
Browse files Browse the repository at this point in the history
elastic#187513)

## Summary

Resolves [elastic#184639](elastic#184639).

This PR hides the beta integrations toggle if user does not have
sufficient privileges to write this to Fleet settings SO. The real fix
should be handled with elastic#187511.
  • Loading branch information
jen-huang authored Jul 4, 2024
1 parent 22c05b7 commit 3dfcb85
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 3dfcb85

Please sign in to comment.