Skip to content

Commit f67995d

Browse files
Merge pull request #637 from PeterYurkovich/ou-1058
[release-4.17] OU-1058: Don't show TP button in non-administrator
2 parents f01fb46 + 8fa0906 commit f67995d

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

web/src/components/alerting/AlertsDetailPage.tsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import {
1717
Silence,
1818
TableColumn,
1919
VirtualizedTable,
20+
useActivePerspective,
2021
} from '@openshift-console/dynamic-plugin-sdk';
2122
import {
2223
AlertingRuleChartExtension,
@@ -81,6 +82,7 @@ const AlertsDetailsPage_: React.FC<AlertsDetailsPageProps> = ({ history, match }
8182
const { t } = useTranslation('plugin__monitoring-plugin');
8283

8384
const { alertsKey, isDev } = usePerspective();
85+
const [perspective] = useActivePerspective();
8486

8587
const namespace = match.params?.ns;
8688
const hideGraphs = useSelector(({ observe }: RootState) => !!observe.get('hideGraphs'));
@@ -134,6 +136,14 @@ const AlertsDetailsPage_: React.FC<AlertsDetailsPageProps> = ({ history, match }
134136
[customExtensions, isDev],
135137
);
136138

139+
// Keep the default name for the admin perspective while providing specific
140+
// entrypoints for all other perspectives as wel
141+
const alertActionContextName = `alert-detail-toolbar-actions${
142+
perspective === 'admin' ? '' : '-' + perspective
143+
}`;
144+
const alertActionContext = {};
145+
alertActionContext[alertActionContextName] = { alert };
146+
137147
useRulesAlertsPoller(namespace, dispatch, alertsSource);
138148

139149
return (
@@ -189,7 +199,7 @@ const AlertsDetailsPage_: React.FC<AlertsDetailsPageProps> = ({ history, match }
189199
<SectionHeading text={t('Alert details')} />
190200
</ToolbarItem>
191201
<ToolbarGroup alignment={{ default: 'alignRight' }}>
192-
<ActionServiceProvider context={{ 'alert-detail-toolbar-actions': { alert } }}>
202+
<ActionServiceProvider context={alertActionContext}>
193203
{({ actions, loaded }) =>
194204
loaded
195205
? actions.map((action) => {

0 commit comments

Comments
 (0)