Skip to content

Commit 13e13de

Browse files
prakhar10mosabua
authored andcommitted
Add UI popup messages for CRUD operations
1 parent fa85a7b commit 13e13de

File tree

5 files changed

+60
-21
lines changed

5 files changed

+60
-21
lines changed

webapp/src/components/cluster.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { useEffect, useState } from "react";
22
import styles from './cluster.module.scss';
33
import Locale from "../locales";
44
import { backendDeleteApi, backendSaveApi, backendUpdateApi, backendsApi } from "../api/webapp/cluster";
5-
import { Button, ButtonGroup, Card, Form, Modal, Popconfirm, Switch, Table, Tag, Typography } from "@douyinfe/semi-ui";
5+
import { Button, ButtonGroup, Card, Form, Modal, Popconfirm, Switch, Table, Tag, Toast, Typography } from "@douyinfe/semi-ui";
66
import Column from "@douyinfe/semi-ui/lib/es/table/Column";
77
import { FormApi } from "@douyinfe/semi-ui/lib/es/form";
88
import { Role, useAccessStore } from "../store";
@@ -55,7 +55,8 @@ export function Cluster() {
5555
backendDeleteApi({ name: record.name })
5656
.then(() => {
5757
list();
58-
}).catch(() => { });
58+
Toast.success(Locale.Cluster.Delete);
59+
}).catch(() => { Toast.error(Locale.Cluster.ErrorDelete) });
5960
}}
6061
>
6162
<Button>{Locale.UI.Delete}</Button>
@@ -142,14 +143,16 @@ export function Cluster() {
142143
backendSaveApi(values)
143144
.then(() => {
144145
list();
146+
Toast.success(Locale.Cluster.Create);
145147
setVisibleForm(false);
146-
}).catch(() => { });
148+
}).catch(() => { Toast.error(Locale.Cluster.ErrorCreate) });
147149
} else {
148150
backendUpdateApi(values)
149151
.then(() => {
150152
list();
153+
Toast.success(Locale.Cluster.Update);
151154
setVisibleForm(false);
152-
}).catch(() => { });
155+
}).catch(() => { Toast.error(Locale.Cluster.ErrorUpdate) });
153156
}
154157
}}
155158
getFormApi={setFormApi}

webapp/src/components/resource-group.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { useEffect, useState } from "react";
22
import styles from './resource-group.module.scss';
33
import Locale from "../locales";
4-
import { Button, ButtonGroup, Card, Form, Modal, Popconfirm, Table } from "@douyinfe/semi-ui";
4+
import { Button, ButtonGroup, Card, Form, Modal, Popconfirm, Table, Toast } from "@douyinfe/semi-ui";
55
import Column from "@douyinfe/semi-ui/lib/es/table/Column";
66
import { FormApi } from "@douyinfe/semi-ui/lib/es/form";
77
import { resourceGroupDeleteApi, resourceGroupSaveApi, resourceGroupUpdateApi, resourceGroupsApi } from "../api/webapp/resource-group";
@@ -46,7 +46,8 @@ export function ResourceGroup() {
4646
}
4747
}).then(() => {
4848
list();
49-
}).catch(() => { });
49+
Toast.success(Locale.ResourceGroup.Delete);
50+
}).catch(() => { Toast.error(Locale.ResourceGroup.ErrorDelete) });
5051
}}
5152
>
5253
<Button>{Locale.UI.Delete}</Button>
@@ -118,16 +119,18 @@ export function ResourceGroup() {
118119
data: values
119120
}).then(() => {
120121
list();
122+
Toast.success(Locale.ResourceGroup.Create);
121123
setVisibleForm(false);
122-
}).catch(() => { });
124+
}).catch(() => { Toast.error(Locale.ResourceGroup.ErrorCreate) });
123125
} else {
124126
resourceGroupUpdateApi({
125127
useSchema: useSchema,
126128
data: values
127129
}).then(() => {
128130
list();
131+
Toast.success(Locale.ResourceGroup.Update);
129132
setVisibleForm(false);
130-
}).catch(() => { });
133+
}).catch(() => { Toast.error(Locale.ResourceGroup.ErrorUpdate) });
131134
}
132135
}}
133136
getFormApi={setFormApi}

webapp/src/components/routing-rules.tsx

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
import {useEffect, useState} from "react";
2-
import {routingRulesApi, updateRoutingRulesApi} from "../api/webapp/routing-rules.ts";
3-
import {RoutingRulesData} from "../types/routing-rules";
4-
import {Button, Card, Form, Toast} from "@douyinfe/semi-ui";
5-
import {FormApi} from "@douyinfe/semi-ui/lib/es/form";
6-
import {Role, useAccessStore} from "../store";
1+
import { useEffect, useState } from "react";
2+
import { routingRulesApi, updateRoutingRulesApi } from "../api/webapp/routing-rules.ts";
3+
import { RoutingRulesData } from "../types/routing-rules";
4+
import { Button, Card, Form, Toast } from "@douyinfe/semi-ui";
5+
import { FormApi } from "@douyinfe/semi-ui/lib/es/form";
6+
import { Role, useAccessStore } from "../store";
7+
import Locale from "../locales";
78

89
export function RoutingRules() {
910
const [rules, setRules] = useState<RoutingRulesData[]>([]);
@@ -22,7 +23,7 @@ export function RoutingRules() {
2223
setEditingStates(new Array(data.length).fill(false));
2324
setFormApis(new Array(data.length).fill(null));
2425
}).catch(() => {
25-
Toast.error("Failed to fetch routing rules");
26+
Toast.error(Locale.RoutingRules.ErrorFetch);
2627
});
2728
};
2829

@@ -63,9 +64,9 @@ export function RoutingRules() {
6364
return newRules;
6465
});
6566

66-
Toast.success("Routing rule updated successfully");
67+
Toast.success(Locale.RoutingRules.Update);
6768
} catch (error) {
68-
Toast.error("Failed to update routing rule");
69+
Toast.error(Locale.RoutingRules.ErrorUpdate);
6970
}
7071
}
7172
};

webapp/src/components/selector.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { useEffect, useState } from "react";
22
import styles from './selector.module.scss';
33
import Locale from "../locales";
4-
import { Button, ButtonGroup, Card, Form, Modal, Popconfirm, Table } from "@douyinfe/semi-ui";
4+
import { Button, ButtonGroup, Card, Form, Modal, Popconfirm, Table, Toast } from "@douyinfe/semi-ui";
55
import Column from "@douyinfe/semi-ui/lib/es/table/Column";
66
import { FormApi } from "@douyinfe/semi-ui/lib/es/form";
77
import { selectorDeleteApi, selectorSaveApi, selectorUpdateApi, selectorsApi } from "../api/webapp/selector";
@@ -44,7 +44,8 @@ export function Selector() {
4444
data: record
4545
}).then(() => {
4646
list();
47-
}).catch(() => { });
47+
Toast.success(Locale.Selector.Delete);
48+
}).catch(() => { Toast.error(Locale.Selector.ErrorDelete) });
4849
}}
4950
>
5051
<Button>{Locale.UI.Delete}</Button>
@@ -110,17 +111,19 @@ export function Selector() {
110111
data: values
111112
}).then(() => {
112113
list();
114+
Toast.success(Locale.Selector.Create);
113115
setVisibleForm(false);
114-
}).catch(() => { });
116+
}).catch(() => { Toast.error(Locale.Selector.ErrorCreate) });
115117
} else {
116118
selectorUpdateApi({
117119
useSchema: useSchema,
118120
data: values,
119121
oldData: form
120122
}).then(() => {
121123
list();
124+
Toast.success(Locale.Selector.Update);
122125
setVisibleForm(false);
123-
}).catch(() => { });
126+
}).catch(() => { Toast.error(Locale.Selector.ErrorUpdate) });
124127
}
125128
}}
126129
getFormApi={setFormApi}

webapp/src/locales/en_US.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,35 @@ const en_US = {
6868
DeleteContent: "Once deleted, it cannot be recovered",
6969
Query: "Query",
7070
},
71+
Cluster: {
72+
Create: "Cluster created successfully",
73+
Update: "Cluster updated successfully",
74+
Delete: "Cluster deleted successfully",
75+
ErrorCreate: "Failed to create cluster",
76+
ErrorUpdate: "Failed to update cluster",
77+
ErrorDelete: "Failed to delete cluster",
78+
},
79+
ResourceGroup: {
80+
Create: "Resource group created successfully",
81+
Update: "Resource group updated successfully",
82+
Delete: "Resource group deleted successfully",
83+
ErrorCreate: "Failed to create resource group",
84+
ErrorUpdate: "Failed to update resource group",
85+
ErrorDelete: "Failed to delete resource group",
86+
},
87+
Selector: {
88+
Create: "Selector created successfully",
89+
Update: "Selector updated successfully",
90+
Delete: "Selector deleted successfully",
91+
ErrorCreate: "Failed to create selector",
92+
ErrorUpdate: "Failed to update selector",
93+
ErrorDelete: "Failed to delete selector",
94+
},
95+
RoutingRules: {
96+
Update: "Routing rule updated successfully",
97+
ErrorUpdate: "Failed to update routing rule",
98+
ErrorFetch: "Failed to fetch routing rules"
99+
},
71100
};
72101

73102
type DeepPartial<T> = T extends object

0 commit comments

Comments
 (0)