Add tag invalidation to updateRule mutation

...so the alert detail view updates appropriately
This commit is contained in:
Tom Ratcliffe
2024-04-03 18:38:49 +01:00
committed by Tom Ratcliffe
parent 9ca2f7bece
commit b037236b9c
2 changed files with 5 additions and 0 deletions
@@ -180,6 +180,7 @@ export const alertRuleApi = alertingApi.injectEndpoints({
transformResponse: (response: PromRulesResponse, _, args): RuleNamespace[] => { transformResponse: (response: PromRulesResponse, _, args): RuleNamespace[] => {
return groupRulesByFileName(response.data.groups, args.ruleSourceName); return groupRulesByFileName(response.data.groups, args.ruleSourceName);
}, },
providesTags: ['AlertRulerRule'],
}), }),
rulerRules: build.query< rulerRules: build.query<
@@ -190,6 +191,7 @@ export const alertRuleApi = alertingApi.injectEndpoints({
const { path, params } = rulerUrlBuilder(rulerConfig).rules(filter); const { path, params } = rulerUrlBuilder(rulerConfig).rules(filter);
return { url: path, params }; return { url: path, params };
}, },
providesTags: ['AlertRulerRule'],
}), }),
// TODO This should be probably a separate ruler API file // TODO This should be probably a separate ruler API file
@@ -201,6 +203,7 @@ export const alertRuleApi = alertingApi.injectEndpoints({
const { path, params } = rulerUrlBuilder(rulerConfig).namespaceGroup(namespace, group); const { path, params } = rulerUrlBuilder(rulerConfig).namespaceGroup(namespace, group);
return { url: path, params }; return { url: path, params };
}, },
providesTags: ['AlertRulerRule'],
}), }),
exportRules: build.query<string, ExportRulesParams>({ exportRules: build.query<string, ExportRulesParams>({
@@ -270,6 +273,7 @@ export const alertRuleApi = alertingApi.injectEndpoints({
data: payload, data: payload,
method: 'POST', method: 'POST',
}), }),
invalidatesTags: ['AlertRulerRule'],
}), }),
}), }),
}); });
@@ -38,6 +38,7 @@ export const alertingApi = createApi({
'OnCallIntegrations', 'OnCallIntegrations',
'OrgMigrationState', 'OrgMigrationState',
'DataSourceSettings', 'DataSourceSettings',
'AlertRulerRule',
], ],
endpoints: () => ({}), endpoints: () => ({}),
}); });