@@ -85,10 +77,10 @@ export const TemplatesTable = ({ config, alertManagerName }: Props) => {
/>
|
- {name} {provenance && }
+ {name} {isProvisioned && }
|
- {provenance && (
+ {isProvisioned && (
{
icon="file-alt"
/>
)}
- {!provenance && (
+ {!isProvisioned && (
{
icon="copy"
/>
- {!provenance && (
+ {!isProvisioned && (
setTemplateToDelete(name)}
@@ -163,7 +155,7 @@ export const TemplatesTable = ({ config, alertManagerName }: Props) => {
title="Delete template"
body={`Are you sure you want to delete template "${templateToDelete}"?`}
confirmText="Yes, delete"
- onConfirm={deleteTemplate}
+ onConfirm={onDeleteTemplate}
onDismiss={() => setTemplateToDelete(undefined)}
/>
)}
diff --git a/public/app/features/alerting/unified/state/actions.ts b/public/app/features/alerting/unified/state/actions.ts
index c9bc1ca5ebc..a1c3ad5afa6 100644
--- a/public/app/features/alerting/unified/state/actions.ts
+++ b/public/app/features/alerting/unified/state/actions.ts
@@ -519,39 +519,6 @@ export const deleteReceiverAction = (receiverName: string, alertManagerSourceNam
};
};
-export const deleteTemplateAction = (templateName: string, alertManagerSourceName: string): ThunkResult => {
- return async (dispatch) => {
- const config = await dispatch(
- alertmanagerApi.endpoints.getAlertmanagerConfiguration.initiate(alertManagerSourceName)
- ).unwrap();
-
- if (!config) {
- throw new Error(`Config for ${alertManagerSourceName} not found`);
- }
- if (typeof config.template_files?.[templateName] !== 'string') {
- throw new Error(`Cannot delete template ${templateName}: not found in config.`);
- }
- const newTemplates = { ...config.template_files };
- delete newTemplates[templateName];
- const newConfig: AlertManagerCortexConfig = {
- ...config,
- alertmanager_config: {
- ...config.alertmanager_config,
- templates: config.alertmanager_config.templates?.filter((existing) => existing !== templateName),
- },
- template_files: newTemplates,
- };
- return dispatch(
- updateAlertManagerConfigAction({
- newConfig,
- oldConfig: config,
- alertManagerSourceName,
- successMessage: 'Template deleted.',
- })
- );
- };
-};
-
export const fetchFolderAction = createAsyncThunk(
'unifiedalerting/fetchFolder',
(uid: string): Promise => withSerializedError(backendSrv.getFolderByUid(uid, { withAccessControl: true }))
|