From db6dcbd84dbc8655ac076024303780b28b32062b Mon Sep 17 00:00:00 2001 From: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> Date: Tue, 8 Oct 2024 03:42:21 +1100 Subject: [PATCH] [8.x] [Fleet] Disable button in logstash output based on correct privileges (#195210) (#195275) # Backport This will backport the following commits from `main` to `8.x`: - [[Fleet] Disable button in logstash output based on correct privileges (#195210)](https://github.com/elastic/kibana/pull/195210) ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) Co-authored-by: Cristina Amico --- .../logstash_instructions/index.tsx | 29 +++++++++++++------ 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/settings/components/logstash_instructions/index.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/settings/components/logstash_instructions/index.tsx index 675aa6cdfd28c..b03d4cb700530 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/settings/components/logstash_instructions/index.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/settings/components/logstash_instructions/index.tsx @@ -21,7 +21,8 @@ import type { EuiCallOutProps } from '@elastic/eui'; import { FormattedMessage } from '@kbn/i18n-react'; import { i18n } from '@kbn/i18n'; -import { useStartServices } from '../../../../hooks'; +import { useStartServices, useAuthz } from '../../../../hooks'; +import { MissingPrivilegesToolTip } from '../../../../../../components/missing_privileges_tooltip'; import { getLogstashPipeline, LOGSTASH_CONFIG_PIPELINES } from './helpers'; import { useLogstashApiKey } from './hooks'; @@ -64,7 +65,8 @@ export const LogstashInstructions = () => { const CollapsibleCallout: React.FunctionComponent = ({ children, ...props }) => { const [isOpen, setIsOpen] = useState(false); - + const authz = useAuthz(); + const hasAllSettings = authz.fleet.allSettings; return ( @@ -76,12 +78,17 @@ const CollapsibleCallout: React.FunctionComponent = ({ children /> ) : ( - setIsOpen(true)} fill={true}> - - + + setIsOpen(true)} fill={true} disabled={!hasAllSettings}> + + + )} {isOpen && ( <> @@ -96,6 +103,8 @@ const CollapsibleCallout: React.FunctionComponent = ({ children const LogstashInstructionSteps = () => { const { docLinks } = useStartServices(); const logstashApiKey = useLogstashApiKey(); + const authz = useAuthz(); + const hasAllSettings = authz.fleet.allSettings; const steps = useMemo( () => [ @@ -120,6 +129,7 @@ const LogstashInstructionSteps = () => { onClick={copy} iconType="copyClipboard" color="text" + disabled={!hasAllSettings} aria-label={i18n.translate( 'xpack.fleet.settings.logstashInstructions.copyApiKeyButtonLabel', { @@ -136,6 +146,7 @@ const LogstashInstructionSteps = () => { { ), }, ], - [logstashApiKey, docLinks] + [logstashApiKey, docLinks, hasAllSettings] ); return (