Skip to content

Commit ddea0de

Browse files
committed
handle Virtualization perspective
1 parent 3155891 commit ddea0de

2 files changed

Lines changed: 24 additions & 4 deletions

File tree

config/incidents.patch.json

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,22 @@
55
"value": {
66
"type": "console.tab",
77
"properties": {
8-
"contextId": "admin-console-observe",
8+
"contextId": "admin-alerts-nav",
9+
"name": "%plugin__monitoring-console-plugin~Incidents%",
10+
"href": "incidents",
11+
"component": {
12+
"$codeRef": "IncidentsPage"
13+
}
14+
}
15+
}
16+
},
17+
{
18+
"op": "add",
19+
"path": "/extensions/1",
20+
"value": {
21+
"type": "console.tab",
22+
"properties": {
23+
"contextId": "virtualization-perspective-alerts-nav",
924
"name": "%plugin__monitoring-console-plugin~Incidents%",
1025
"href": "incidents",
1126
"component": {

web/src/components/alerting/AlertingPage.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import { PageSection, Title } from '@patternfly/react-core';
22
import * as React from 'react';
33
import { useTranslation } from 'react-i18next';
4-
5-
import { HorizontalNav } from '@openshift-console/dynamic-plugin-sdk';
4+
import { HorizontalNav, useActivePerspective } from '@openshift-console/dynamic-plugin-sdk';
65

76
const AlertsPage = React.lazy(
87
() => import(/* webpackChunkName: "AlertsPage" */ '../alerting/AlertsPage'),
@@ -17,6 +16,12 @@ const AlertRulesPage = React.lazy(
1716
const AlertingPage: React.FC = () => {
1817
const { t } = useTranslation(process.env.I18N_NAMESPACE);
1918

19+
const [perspective] = useActivePerspective();
20+
21+
// contextId allow console.tab extensions to be injected
22+
// https://github.com/openshift/console/blob/main/frontend/packages/console-dynamic-plugin-sdk/docs/console-extensions.md#consoletab
23+
const contextId = `${perspective}-alerts-nav`;
24+
2025
const pages = [
2126
{
2227
href: 'alerts',
@@ -45,7 +50,7 @@ const AlertingPage: React.FC = () => {
4550
<>
4651
<PageSection hasBodyWrapper={false}>
4752
<Title headingLevel="h1">{t('Alerting')}</Title>
48-
<HorizontalNav contextId="admin-console-observe" pages={pages} />
53+
<HorizontalNav contextId={contextId} pages={pages} />
4954
</PageSection>
5055
</>
5156
);

0 commit comments

Comments
 (0)