Skip to content

Commit 1a61000

Browse files
authored
Merge pull request #294 from taosdata/fix-verify
Fix verify
2 parents f655176 + fb153a5 commit 1a61000

File tree

3 files changed

+15
-16
lines changed

3 files changed

+15
-16
lines changed

src/components/ConfigEditor/ConfigEditor.tsx

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, {ReactElement,useEffect} from 'react'
2-
import {Button, ConfirmModal, FieldSet, LegacyForms, Switch, Tab, TabContent, TabsBar} from '@grafana/ui'
2+
import {Button, Modal, ConfirmModal, FieldSet, LegacyForms, Switch, Tab, TabContent, TabsBar, Icon} from '@grafana/ui'
33
import type {EditorProps} from './types'
44
import {useChangeSecureOptions} from './useChangeSecureOptions'
55
import {useResetSecureOptions} from './useResetSecureOptions'
@@ -48,6 +48,10 @@ export function ConfigEditor(props: EditorProps): ReactElement {
4848
}, []);
4949

5050
const [openConfirm, setOpenConfirm] = React.useState(false);
51+
52+
const [openAlert, setOpenAlert] = React.useState(false);
53+
54+
const [openAlertMessage, setOpenAlertMessage] = React.useState("");
5155
/**
5256
* Here is the cleaning of alarm rules.
5357
* When executing the onConfirm method, the testDatasource() function will be called,making it difficult to distinguish whether to delete or add.
@@ -57,9 +61,11 @@ export function ConfigEditor(props: EditorProps): ReactElement {
5761
updateLoadStatus(false);
5862
setOpenConfirm(false);
5963
deleteAlerts(props.options.uid).then(()=>{
60-
console.info("alert deleted!");
64+
return;
6165
}).catch((e: any) => {
62-
alert("Failed to delete alarm rules, reason: " + e.message)
66+
setOpenAlert(true);
67+
setOpenAlertMessage("Failed to delete alarm rules, reason: " + e.message)
68+
throw e;
6369
});
6470

6571
};
@@ -203,6 +209,12 @@ export function ConfigEditor(props: EditorProps): ReactElement {
203209
onConfirm={() => setOpenConfirm(false)}
204210
onDismiss={() => clearAlertRules()}
205211
/>
212+
213+
<Modal isOpen={openAlert} title={<div><Icon name='x' color='red' size='xxl' /> <label style={{ color: 'red', fontSize: '16px' }}>Failed to delete rules</label></div>} onDismiss={() => setOpenAlert(false)}>
214+
<p style={{ fontSize: '16px' }}>{openAlertMessage}</p>
215+
</Modal>
216+
217+
206218
</FieldSet>
207219
)}
208220
</div>

src/datasource.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ export class DataSource extends DataSourceApi<Query, DataSourceOptions> {
8383
return new Promise((resolve, reject) => {
8484
let req = {uid: getFolderUid(`${this.uid}`), title: this.name + '-alert-' + this.folderUidSuffix}
8585
this.backendSrv.post("/api/folders", req).then(response=>{
86-
console.info(response);
8786
resolve(true)
8887
}).catch((e: any) => {
8988
console.error(e)

src/utils.ts

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -55,18 +55,6 @@ export function getFolderUid(datasourceUid: string): string {
5555
return `alert-${datasourceUid}-`;
5656
}
5757

58-
59-
export async function getRules(): Promise<void> {
60-
try {
61-
let response = await getBackendSrv().get(`/api/v1/provisioning/alert-rules`);
62-
console.info(response);
63-
} catch(e) {
64-
console.error(e);
65-
throw e;
66-
}
67-
68-
}
69-
7058
export function checkGrafanaVersion(): boolean {
7159
const version = config.buildInfo.version;
7260
const versionParts = version.split(".");

0 commit comments

Comments
 (0)