mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
[Entity Analytics] Use docLinks service for documentation links (#172172)
## Summary Using the docLinks service means documentation links will always point to the correct version of the docs for the current Kibana version, not just the latest docs. --------- Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
parent
7ad94e9c4b
commit
f08f40a97e
4 changed files with 23 additions and 22 deletions
|
@ -460,6 +460,9 @@ export const getDocLinks = ({ kibanaBranch }: GetDocLinkOptions): DocLinks => {
|
|||
createEsqlRuleType: `${SECURITY_SOLUTION_DOCS}rules-ui-create.html#create-esql-rule`,
|
||||
entityAnalytics: {
|
||||
riskScorePrerequisites: `${SECURITY_SOLUTION_DOCS}ers-requirements.html`,
|
||||
hostRiskScore: `${SECURITY_SOLUTION_DOCS}host-risk-score.html`,
|
||||
userRiskScore: `${SECURITY_SOLUTION_DOCS}user-risk-score.html`,
|
||||
entityRiskScoring: `${SECURITY_SOLUTION_DOCS}advanced-entity-analytics-overview.html#entity-risk-scoring`,
|
||||
},
|
||||
},
|
||||
query: {
|
||||
|
|
|
@ -351,6 +351,9 @@ export interface DocLinks {
|
|||
readonly createEsqlRuleType: string;
|
||||
readonly entityAnalytics: {
|
||||
readonly riskScorePrerequisites: string;
|
||||
readonly hostRiskScore: string;
|
||||
readonly userRiskScore: string;
|
||||
readonly entityRiskScoring: string;
|
||||
};
|
||||
};
|
||||
readonly query: {
|
||||
|
|
|
@ -455,13 +455,6 @@ export enum BulkActionsDryRunErrCode {
|
|||
ESQL_INDEX_PATTERN = 'ESQL_INDEX_PATTERN',
|
||||
}
|
||||
|
||||
export const RISKY_HOSTS_DOC_LINK =
|
||||
'https://www.elastic.co/guide/en/security/current/host-risk-score.html';
|
||||
export const RISKY_USERS_DOC_LINK =
|
||||
'https://www.elastic.co/guide/en/security/current/user-risk-score.html';
|
||||
export const RISKY_ENTITY_SCORE_DOC_LINK =
|
||||
'https://www.elastic.co/guide/en/security/current/advanced-entity-analytics-overview.html#entity-risk-scoring';
|
||||
|
||||
export const MAX_NUMBER_OF_NEW_TERMS_FIELDS = 3;
|
||||
|
||||
export const BULK_ADD_TO_TIMELINE_LIMIT = 2000;
|
||||
|
|
|
@ -8,12 +8,22 @@
|
|||
import { EuiLink } from '@elastic/eui';
|
||||
import React, { useMemo } from 'react';
|
||||
import { RiskScoreEntity } from '../../../../../common/search_strategy';
|
||||
import {
|
||||
RISKY_HOSTS_DOC_LINK,
|
||||
RISKY_USERS_DOC_LINK,
|
||||
RISKY_ENTITY_SCORE_DOC_LINK,
|
||||
} from '../../../../../common/constants';
|
||||
import { LEARN_MORE } from '../../../../overview/components/entity_analytics/risk_score/translations';
|
||||
import { useKibana } from '../../../../common/lib/kibana';
|
||||
|
||||
const useLearnMoreLinkForEntity = (riskScoreEntity?: RiskScoreEntity) => {
|
||||
const { docLinks } = useKibana().services;
|
||||
const entityAnalyticsLinks = docLinks.links.securitySolution.entityAnalytics;
|
||||
return useMemo(() => {
|
||||
if (!riskScoreEntity) {
|
||||
return entityAnalyticsLinks.entityRiskScoring;
|
||||
}
|
||||
if (riskScoreEntity === RiskScoreEntity.user) {
|
||||
return entityAnalyticsLinks.userRiskScore;
|
||||
}
|
||||
return entityAnalyticsLinks.hostRiskScore;
|
||||
}, [riskScoreEntity, entityAnalyticsLinks]);
|
||||
};
|
||||
|
||||
const RiskScoreDocLinkComponent = ({
|
||||
riskScoreEntity,
|
||||
|
@ -22,18 +32,10 @@ const RiskScoreDocLinkComponent = ({
|
|||
riskScoreEntity?: RiskScoreEntity;
|
||||
title?: string | React.ReactNode;
|
||||
}) => {
|
||||
const docLink = useMemo(() => {
|
||||
if (!riskScoreEntity) {
|
||||
return RISKY_ENTITY_SCORE_DOC_LINK;
|
||||
}
|
||||
if (riskScoreEntity === RiskScoreEntity.user) {
|
||||
return RISKY_USERS_DOC_LINK;
|
||||
}
|
||||
return RISKY_HOSTS_DOC_LINK;
|
||||
}, [riskScoreEntity]);
|
||||
const learnMoreLink = useLearnMoreLinkForEntity(riskScoreEntity);
|
||||
|
||||
return (
|
||||
<EuiLink target="_blank" rel="noopener nofollow noreferrer" href={docLink}>
|
||||
<EuiLink target="_blank" rel="noopener nofollow noreferrer" href={learnMoreLink}>
|
||||
{title ? title : LEARN_MORE(riskScoreEntity)}
|
||||
</EuiLink>
|
||||
);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue