From feb04efee38145cb4533f6615f8c7fc1d3af3267 Mon Sep 17 00:00:00 2001 From: criamico Date: Mon, 7 Oct 2024 12:00:50 +0200 Subject: [PATCH 1/2] [Fleet] Disable button in logstash output based on correct privileges --- .../components/logstash_instructions/index.tsx | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 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..45129d60d7b00 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,7 @@ 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 { getLogstashPipeline, LOGSTASH_CONFIG_PIPELINES } from './helpers'; import { useLogstashApiKey } from './hooks'; @@ -64,7 +64,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,7 +77,7 @@ const CollapsibleCallout: React.FunctionComponent = ({ children /> ) : ( - setIsOpen(true)} fill={true}> + setIsOpen(true)} fill={true} disabled={!hasAllSettings}> = ({ children const LogstashInstructionSteps = () => { const { docLinks } = useStartServices(); const logstashApiKey = useLogstashApiKey(); + const authz = useAuthz(); + const hasAllSettings = authz.fleet.allSettings; const steps = useMemo( () => [ @@ -120,6 +123,7 @@ const LogstashInstructionSteps = () => { onClick={copy} iconType="copyClipboard" color="text" + disabled={!hasAllSettings} aria-label={i18n.translate( 'xpack.fleet.settings.logstashInstructions.copyApiKeyButtonLabel', { @@ -136,6 +140,7 @@ const LogstashInstructionSteps = () => { { ), }, ], - [logstashApiKey, docLinks] + [logstashApiKey, docLinks, hasAllSettings] ); return ( From 4f3ed59bdeb826a93ab9b72844eddc0dfebca017 Mon Sep 17 00:00:00 2001 From: criamico Date: Mon, 7 Oct 2024 14:49:50 +0200 Subject: [PATCH 2/2] Add tooltip --- .../components/logstash_instructions/index.tsx | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 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 45129d60d7b00..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 @@ -22,6 +22,7 @@ import { FormattedMessage } from '@kbn/i18n-react'; import { i18n } from '@kbn/i18n'; import { useStartServices, useAuthz } from '../../../../hooks'; +import { MissingPrivilegesToolTip } from '../../../../../../components/missing_privileges_tooltip'; import { getLogstashPipeline, LOGSTASH_CONFIG_PIPELINES } from './helpers'; import { useLogstashApiKey } from './hooks'; @@ -77,12 +78,17 @@ const CollapsibleCallout: React.FunctionComponent = ({ children /> ) : ( - setIsOpen(true)} fill={true} disabled={!hasAllSettings}> - - + + setIsOpen(true)} fill={true} disabled={!hasAllSettings}> + + + )} {isOpen && ( <>