Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Actionable Observability] update alerts table rule details link to point to o11y rule detail page #132479

Merged
merged 10 commits into from
May 19, 2022
Merged
7 changes: 6 additions & 1 deletion x-pack/plugins/observability/public/config/paths.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,14 @@
* 2.0.
*/

export const ALERT_PAGE_LINK = '/app/observability/alerts';
export const RULES_PAGE_LINK = `${ALERT_PAGE_LINK}/rules`;

export const paths = {
observability: {
alerts: '/app/observability/alerts',
alerts: ALERT_PAGE_LINK,
rules: RULES_PAGE_LINK,
ruleDetails: (ruleId: string) => `${RULES_PAGE_LINK}/${encodeURI(ruleId)}`,
},
management: {
rules: '/app/management/insightsAndAlerting/triggersActions/rules',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,7 @@ export function AlertsFlyout({
}

const ruleId = alertData.fields['kibana.alert.rule.uuid'] ?? null;
const linkToRule = ruleId && prepend ? prepend(paths.management.ruleDetails(ruleId)) : null;

const linkToRule = ruleId && prepend ? prepend(paths.observability.ruleDetails(ruleId)) : null;
const overviewListItems = [
{
title: translations.alertsFlyout.statusLabel,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,7 @@ function ObservabilityActions({

const casePermissions = useGetUserCasesPermissions();
const ruleId = alert.fields['kibana.alert.rule.uuid'] ?? null;
const linkToRule = ruleId ? http.basePath.prepend(paths.management.ruleDetails(ruleId)) : null;

const linkToRule = ruleId ? http.basePath.prepend(paths.observability.ruleDetails(ruleId)) : null;
const caseAttachments: CaseAttachments = useMemo(() => {
return ecsData?._id
? [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,3 @@ export function hasAllPrivilege(rule: InitialRule, ruleType?: RuleType): boolean

export const hasExecuteActionsCapability = (capabilities: Capabilities) =>
capabilities?.actions?.execute;

export const RULES_PAGE_LINK = '/app/observability/alerts/rules';
export const ALERT_PAGE_LINK = '/app/observability/alerts';
16 changes: 6 additions & 10 deletions x-pack/plugins/observability/public/pages/rule_details/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,8 @@ import { PageTitle, ItemTitleRuleSummary, ItemValueRuleSummary, Actions } from '
import { useKibana } from '../../utils/kibana_react';
import { useFetchLast24hAlerts } from '../../hooks/use_fetch_last24h_alerts';
import { formatInterval } from './utils';
import {
hasExecuteActionsCapability,
hasAllPrivilege,
RULES_PAGE_LINK,
ALERT_PAGE_LINK,
} from './config';
import { hasExecuteActionsCapability, hasAllPrivilege } from './config';
import { paths } from '../../config/paths';

export function RuleDetailsPage() {
const {
Expand Down Expand Up @@ -117,10 +113,10 @@ export function RuleDetailsPage() {
text: i18n.translate('xpack.observability.breadcrumbs.alertsLinkText', {
defaultMessage: 'Alerts',
}),
href: http.basePath.prepend(ALERT_PAGE_LINK),
href: http.basePath.prepend(paths.observability.alerts),
},
{
href: http.basePath.prepend(RULES_PAGE_LINK),
href: http.basePath.prepend(paths.observability.rules),
text: RULES_BREADCRUMB_TEXT,
},
{
Expand Down Expand Up @@ -462,11 +458,11 @@ export function RuleDetailsPage() {
<DeleteModalConfirmation
onDeleted={async () => {
setRuleToDelete([]);
navigateToUrl(http.basePath.prepend(RULES_PAGE_LINK));
navigateToUrl(http.basePath.prepend(paths.observability.rules));
}}
onErrors={async () => {
setRuleToDelete([]);
navigateToUrl(http.basePath.prepend(RULES_PAGE_LINK));
navigateToUrl(http.basePath.prepend(paths.observability.rules));
}}
onCancel={() => {}}
apiDeleteCall={deleteRules}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ import React from 'react';
import { EuiFlexGroup, EuiFlexItem, EuiLink, EuiText } from '@elastic/eui';
import { RuleNameProps } from '../types';
import { useKibana } from '../../../utils/kibana_react';
import { paths } from '../../../config/paths';

export function Name({ name, rule }: RuleNameProps) {
const { http } = useKibana().services;
const detailsLink = http.basePath.prepend(`/app/observability/alerts/rules/${rule.id}`);
const detailsLink = http.basePath.prepend(paths.observability.ruleDetails(rule.id));
const link = (
<EuiFlexGroup direction="column" gutterSize="xs">
<EuiFlexItem grow={false}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,9 @@ export default ({ getService }: FtrProviderContext) => {
const actionsButton = await observability.alerts.common.getActionsButtonByIndex(0);
await actionsButton.click();
await observability.alerts.common.viewRuleDetailsButtonClick();
expect(await find.existsByCssSelector('[title="Rules and Connectors"]')).to.eql(true);
expect(
await (await find.byCssSelector('[data-test-subj="breadcrumb first"]')).getVisibleText()
).to.eql('Observability');
});
});

Expand Down