Skip to content

Commit

Permalink
Creating alert link with alert id and rule id (#140634)
Browse files Browse the repository at this point in the history
* creating alert link with alert id and rule id

* fixing failing test

* fixing failing tests
  • Loading branch information
benakansara authored Sep 13, 2022
1 parent c9b8098 commit 8647bd8
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 8 deletions.
6 changes: 4 additions & 2 deletions x-pack/plugins/observability/public/config/paths.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ export const paths = {
rules: RULES_PAGE_LINK,
ruleDetails: (ruleId?: string | null) =>
ruleId ? `${RULES_PAGE_LINK}/${encodeURI(ruleId)}` : RULES_PAGE_LINK,
alertDetails: (alertId?: string | null) =>
alertId ? `${ALERT_PAGE_LINK}/${encodeURI(alertId)}` : ALERT_PAGE_LINK,
alertDetails: (alertId?: string | null, ruleId?: string | null) =>
alertId && ruleId
? `${ALERT_PAGE_LINK}/rules/${encodeURI(ruleId)}/alerts/${encodeURI(alertId)}`
: ALERT_PAGE_LINK,
},
management: {
rules: '/app/management/insightsAndAlerting/triggersActions/rules',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ export function ObservabilityActions({
: null;
const alertId = alert.fields['kibana.alert.uuid'] ?? null;
const linkToAlert =
pageId !== ALERT_DETAILS_PAGE_ID && alertId
? http.basePath.prepend(paths.observability.alertDetails(alertId))
pageId !== ALERT_DETAILS_PAGE_ID && alertId && ruleId
? http.basePath.prepend(paths.observability.alertDetails(alertId, ruleId))
: null;
const caseAttachments: CaseAttachmentsWithoutOwner = useMemo(() => {
return ecsData?._id
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/observability/public/routes/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ export const routes = {
params: {},
exact: true,
},
'/alerts/:alertId': {
'/alerts/rules/:ruleId/alerts/:alertId': {
handler: () => {
return <AlertDetailsPage />;
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ export function ObservabilityAlertsCommonProvider({
);
};

const navigateToAlertDetails = async (alertId: string) => {
const navigateToAlertDetails = async (alertId: string, ruleId: string) => {
return await pageObjects.common.navigateToUrlWithBrowserHistory(
'observability',
`/alerts/${alertId}`,
`/alerts/rules/${ruleId}/alerts/${alertId}`,
'',
{ ensureCurrentUrl: false }
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export default ({ getService }: FtrProviderContext) => {
});

it('should show 404 page when the feature flag is disabled', async () => {
await observability.alerts.common.navigateToAlertDetails(uuid.v4());
await observability.alerts.common.navigateToAlertDetails(uuid.v4(), uuid.v4());
await retry.waitFor(
'Alerts page to be visible',
async () => await testSubjects.exists('pageNotFound')
Expand Down

0 comments on commit 8647bd8

Please sign in to comment.