fix(alerting): resolve TypeScript and linting errors in navigation hooks
- Fix icon type errors by moving type assertions to children assignment - Add ESLint disable comments for necessary type assertions - Fix unused imports in navigation hooks and test files - Fix missing currentAlertmanager prop in TimeIntervalsPage - Fix incorrect permission name in TimeIntervalsPage test - Apply same pattern to useInsightsNav to fix type errors
This commit is contained in:
@@ -6,7 +6,7 @@ import TimeIntervalsPage from './TimeIntervalsPage';
|
||||
import { setupMswServer } from './mockApi';
|
||||
import { grantUserPermissions, mockDataSource } from './mocks';
|
||||
import { setupDataSources } from './testSetup/datasources';
|
||||
import { DataSourceType, GRAFANA_RULES_SOURCE_NAME } from './utils/datasource';
|
||||
import { DataSourceType } from './utils/datasource';
|
||||
|
||||
setupMswServer();
|
||||
|
||||
@@ -23,7 +23,7 @@ describe('TimeIntervalsPage', () => {
|
||||
setupDataSources(alertManager);
|
||||
grantUserPermissions([
|
||||
AccessControlAction.AlertingNotificationsRead,
|
||||
AccessControlAction.AlertingNotificationsTimeIntervalsRead,
|
||||
AccessControlAction.AlertingTimeIntervalsRead,
|
||||
]);
|
||||
});
|
||||
|
||||
|
||||
@@ -3,17 +3,19 @@ import { GrafanaAlertmanagerWarning } from './components/GrafanaAlertmanagerWarn
|
||||
import { TimeIntervalsTable } from './components/mute-timings/MuteTimingsTable';
|
||||
import { shouldUseAlertingNavigationV2 } from './featureToggles';
|
||||
import { useNotificationConfigNav } from './navigation/useNotificationConfigNav';
|
||||
import { useAlertmanager } from './state/AlertmanagerContext';
|
||||
import { withPageErrorBoundary } from './withPageErrorBoundary';
|
||||
|
||||
function TimeIntervalsPage() {
|
||||
const useV2Nav = shouldUseAlertingNavigationV2();
|
||||
const { navId, pageNav } = useNotificationConfigNav();
|
||||
const { selectedAlertmanager } = useAlertmanager();
|
||||
|
||||
// In V2 mode, wrap with page wrapper for proper navigation
|
||||
if (useV2Nav) {
|
||||
return (
|
||||
<AlertmanagerPageWrapper navId={navId || 'am-routes'} pageNav={pageNav} accessType="notification">
|
||||
<GrafanaAlertmanagerWarning />
|
||||
<GrafanaAlertmanagerWarning currentAlertmanager={selectedAlertmanager!} />
|
||||
<TimeIntervalsTable />
|
||||
</AlertmanagerPageWrapper>
|
||||
);
|
||||
|
||||
@@ -2,7 +2,6 @@ import { useLocation } from 'react-router-dom-v5-compat';
|
||||
|
||||
import { NavModelItem } from '@grafana/data';
|
||||
import { t } from '@grafana/i18n';
|
||||
import { config } from '@grafana/runtime';
|
||||
import { useSelector } from 'app/types/store';
|
||||
|
||||
import { shouldUseAlertingNavigationV2 } from '../featureToggles';
|
||||
@@ -30,7 +29,7 @@ export function useAlertRulesNav() {
|
||||
}
|
||||
|
||||
// All available tabs
|
||||
const allTabs: NavModelItem[] = [
|
||||
const allTabs = [
|
||||
{
|
||||
id: 'alert-rules-list',
|
||||
text: t('alerting.navigation.alert-rules', 'Alert rules'),
|
||||
@@ -56,7 +55,8 @@ export function useAlertRulesNav() {
|
||||
// Create pageNav that represents the Alert rules page with tabs as children
|
||||
const pageNav: NavModelItem = {
|
||||
...alertRulesNav,
|
||||
children: allTabs,
|
||||
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
||||
children: allTabs as NavModelItem[],
|
||||
};
|
||||
|
||||
return {
|
||||
|
||||
@@ -42,7 +42,7 @@ export function useInsightsNav() {
|
||||
}
|
||||
|
||||
// All available tabs
|
||||
const allTabs: NavModelItem[] = [
|
||||
const allTabs = [
|
||||
{
|
||||
id: 'insights-system',
|
||||
text: t('alerting.navigation.system-insights', 'System Insights'),
|
||||
@@ -68,7 +68,8 @@ export function useInsightsNav() {
|
||||
// Create pageNav that represents the Insights page with tabs as children
|
||||
const pageNav: NavModelItem = {
|
||||
...insightsNav,
|
||||
children: allTabs,
|
||||
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
||||
children: allTabs as NavModelItem[],
|
||||
};
|
||||
|
||||
return {
|
||||
|
||||
@@ -59,7 +59,7 @@ export function useNotificationConfigNav() {
|
||||
: location.pathname === '/alerting/routes' && location.search.includes('tab=time_intervals');
|
||||
|
||||
// All available tabs
|
||||
const allTabs: NavModelItem[] = [
|
||||
const allTabs = [
|
||||
{
|
||||
id: 'notification-config-contact-points',
|
||||
text: t('alerting.navigation.contact-points', 'Contact points'),
|
||||
@@ -101,7 +101,8 @@ export function useNotificationConfigNav() {
|
||||
// Create pageNav that represents the Notification configuration page with tabs as children
|
||||
const pageNav: NavModelItem = {
|
||||
...notificationConfigNav,
|
||||
children: allTabs,
|
||||
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
||||
children: allTabs as NavModelItem[],
|
||||
};
|
||||
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user