Skip to content

Commit

Permalink
[Security Solution] Add Endpoint RBAC documentation url to `NoPrivile…
Browse files Browse the repository at this point in the history
…ges` page (#145084)

## Summary

When a user doesn't have the needed Kibana Privileges, more precisely
the sub-feature privileges for Security Management pages, they will see
a _Privileges Required_ page. It is already merged, see
elastic/security-team#5222

What is missing is the correct URL for the documentation page. The goal
of this PR is to add this link.
  • Loading branch information
gergoabraham authored Nov 15, 2022
1 parent a16c2ac commit ff09e80
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 16 deletions.
1 change: 1 addition & 0 deletions packages/kbn-doc-links/src/get_doc_links.ts
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,7 @@ export const getDocLinks = ({ kibanaBranch }: GetDocLinkOptions): DocLinks => {
exceptions: {
value_lists: `${SECURITY_SOLUTION_DOCS}detections-ui-exceptions.html#manage-value-lists`,
},
privileges: `${SECURITY_SOLUTION_DOCS}endpoint-management-req.html`,
},
query: {
eql: `${ELASTICSEARCH_DOCS}eql.html`,
Expand Down
1 change: 1 addition & 0 deletions packages/kbn-doc-links/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@ export interface DocLinks {
readonly exceptions: {
value_lists: string;
};
readonly privileges: string;
};
readonly query: {
readonly eql: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,37 +10,37 @@ import React, { useMemo } from 'react';
import { EuiPageTemplate_Deprecated as EuiPageTemplate } from '@elastic/eui';
import { SecuritySolutionPageWrapper } from '../page_wrapper';
import { EmptyPage } from '../empty_page';
import { useKibana } from '../../lib/kibana';
import * as i18n from './translations';

interface NoPrivilegesPageProps {
documentationUrl: string;
pageName?: string;
}

export const NoPrivilegesPage = React.memo<NoPrivilegesPageProps>(({ pageName }) => {
return (
<SecuritySolutionPageWrapper>
<EuiPageTemplate template="centeredContent">
<NoPrivileges pageName={pageName} />
</EuiPageTemplate>
</SecuritySolutionPageWrapper>
);
});
export const NoPrivilegesPage = React.memo<NoPrivilegesPageProps>(
({ pageName, documentationUrl }) => {
return (
<SecuritySolutionPageWrapper>
<EuiPageTemplate template="centeredContent">
<NoPrivileges pageName={pageName} documentationUrl={documentationUrl} />
</EuiPageTemplate>
</SecuritySolutionPageWrapper>
);
}
);
NoPrivilegesPage.displayName = 'NoPrivilegePage';

export const NoPrivileges = React.memo<NoPrivilegesPageProps>(({ pageName }) => {
const { docLinks } = useKibana().services;

export const NoPrivileges = React.memo<NoPrivilegesPageProps>(({ pageName, documentationUrl }) => {
const emptyPageActions = useMemo(
() => ({
feature: {
icon: 'documents',
label: i18n.GO_TO_DOCUMENTATION,
url: `${docLinks.links.siem.privileges}`,
url: documentationUrl,
target: '_blank',
},
}),
[docLinks]
[documentationUrl]
);

const message = pageName
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { Route } from '@kbn/kibana-react-plugin/public';
import { NoPrivilegesPage } from '../../../common/components/no_privileges';
import { useIsExperimentalFeatureEnabled } from '../../../common/hooks/use_experimental_features';
import { NoPermissions } from '../no_permissons';
import { useKibana } from '../../../common/lib/kibana';
import { MANAGEMENT_ROUTING_RESPONSE_ACTIONS_HISTORY_PATH } from '../../common/constants';

export interface PrivilegedRouteProps {
Expand All @@ -19,6 +20,7 @@ export interface PrivilegedRouteProps {
}

export const PrivilegedRoute = memo(({ component, hasPrivilege, path }: PrivilegedRouteProps) => {
const { docLinks } = useKibana().services;
const isEndpointRbacEnabled = useIsExperimentalFeatureEnabled('endpointRbacEnabled');
const isEndpointRbacV1Enabled = useIsExperimentalFeatureEnabled('endpointRbacV1Enabled');

Expand All @@ -30,7 +32,7 @@ export const PrivilegedRoute = memo(({ component, hasPrivilege, path }: Privileg
(isEndpointRbacV1Enabled && path === MANAGEMENT_ROUTING_RESPONSE_ACTIONS_HISTORY_PATH);

componentToRender = shouldUseMissingPrivilegesScreen
? () => <NoPrivilegesPage />
? () => <NoPrivilegesPage documentationUrl={docLinks.links.securitySolution.privileges} />
: NoPermissions;
}

Expand Down

0 comments on commit ff09e80

Please sign in to comment.