mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
[Fleet] Disable button in logstash output based on correct privileges (#195210)
Fixes https://github.com/elastic/kibana/issues/191951 ## Summary Disable button in logstash output based on correct privileges. ### Testing - Enable feature flag `subfeaturePrivileges` - Follow testing steps in above ticket The button "view steps" in logstash output should be disabled if role doesn'thave `fleet.allSettings` privileges   ### Checklist - [ ] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios --------- Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
This commit is contained in:
parent
b4ba131409
commit
71c8d6fddc
1 changed files with 20 additions and 9 deletions
|
@ -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<EuiCallOutProps> = ({ children, ...props }) => {
|
||||
const [isOpen, setIsOpen] = useState(false);
|
||||
|
||||
const authz = useAuthz();
|
||||
const hasAllSettings = authz.fleet.allSettings;
|
||||
return (
|
||||
<EuiCallOut {...props}>
|
||||
<EuiSpacer size="s" />
|
||||
|
@ -76,12 +78,17 @@ const CollapsibleCallout: React.FunctionComponent<EuiCallOutProps> = ({ children
|
|||
/>
|
||||
</EuiButton>
|
||||
) : (
|
||||
<EuiButton onClick={() => setIsOpen(true)} fill={true}>
|
||||
<FormattedMessage
|
||||
id="xpack.fleet.settings.logstashInstructions.viewInstructionButtonLabel"
|
||||
defaultMessage="View steps"
|
||||
/>
|
||||
</EuiButton>
|
||||
<MissingPrivilegesToolTip
|
||||
missingPrivilege={!hasAllSettings ? 'Settings All' : undefined}
|
||||
position="left"
|
||||
>
|
||||
<EuiButton onClick={() => setIsOpen(true)} fill={true} disabled={!hasAllSettings}>
|
||||
<FormattedMessage
|
||||
id="xpack.fleet.settings.logstashInstructions.viewInstructionButtonLabel"
|
||||
defaultMessage="View steps"
|
||||
/>
|
||||
</EuiButton>
|
||||
</MissingPrivilegesToolTip>
|
||||
)}
|
||||
{isOpen && (
|
||||
<>
|
||||
|
@ -96,6 +103,8 @@ const CollapsibleCallout: React.FunctionComponent<EuiCallOutProps> = ({ 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 = () => {
|
|||
<EuiButton
|
||||
isLoading={logstashApiKey.isLoading}
|
||||
onClick={logstashApiKey.generateApiKey}
|
||||
disabled={!hasAllSettings}
|
||||
>
|
||||
<FormattedMessage
|
||||
id="xpack.fleet.settings.logstashInstructions.generateApiKeyButtonLabel"
|
||||
|
@ -214,7 +225,7 @@ const LogstashInstructionSteps = () => {
|
|||
),
|
||||
},
|
||||
],
|
||||
[logstashApiKey, docLinks]
|
||||
[logstashApiKey, docLinks, hasAllSettings]
|
||||
);
|
||||
|
||||
return (
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue