This is an automated email from the ASF dual-hosted git repository.
likyh pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git
The following commit(s) were added to refs/heads/main by this push:
new 77092828a refactor(config-ui): adjust the interface to respond to
error prompts (#5199)
77092828a is described below
commit 77092828a1a5037a4a2e23f0b04a61764d97d71a
Author: 青湛 <[email protected]>
AuthorDate: Wed May 17 10:49:55 2023 +0800
refactor(config-ui): adjust the interface to respond to error prompts
(#5199)
---
config-ui/src/pages/blueprint/detail/use-detail.ts | 1 -
config-ui/src/pages/project/home/use-project.ts | 1 -
config-ui/src/utils/operator.ts | 16 ++++------------
3 files changed, 4 insertions(+), 14 deletions(-)
diff --git a/config-ui/src/pages/blueprint/detail/use-detail.ts
b/config-ui/src/pages/blueprint/detail/use-detail.ts
index 7837c02ec..994989f5e 100644
--- a/config-ui/src/pages/blueprint/detail/use-detail.ts
+++ b/config-ui/src/pages/blueprint/detail/use-detail.ts
@@ -52,7 +52,6 @@ export const useDetail = ({ id }: UseDetailProps) => {
const handleRun = async () => {
const [success] = await operator(() => API.runBlueprint(id), {
setOperating,
- formatReason: (err) => (err as any).response?.data?.message,
});
if (success) {
diff --git a/config-ui/src/pages/project/home/use-project.ts
b/config-ui/src/pages/project/home/use-project.ts
index be902d630..b241de813 100644
--- a/config-ui/src/pages/project/home/use-project.ts
+++ b/config-ui/src/pages/project/home/use-project.ts
@@ -72,7 +72,6 @@ export const useProject = <T>({ name, enableDora,
onHideDialog }: Props) => {
const [success] = await operator(() => API.createProject(payload), {
setOperating,
- formatReason: () => 'This project name is been used. Please use a new
one.',
});
if (success) {
diff --git a/config-ui/src/utils/operator.ts b/config-ui/src/utils/operator.ts
index 5a63584bd..e144179f9 100644
--- a/config-ui/src/utils/operator.ts
+++ b/config-ui/src/utils/operator.ts
@@ -18,7 +18,7 @@
import { Intent } from '@blueprintjs/core';
-import { Toast } from '@/components';
+import { toast } from '@/components';
export type OperateConfig = {
setOperating?: (success: boolean) => void;
@@ -44,22 +44,14 @@ export const operator = async <T>(request: () =>
Promise<T>, config?: OperateCon
const res = await request();
const message = formatMessage?.() ?? 'Operation successfully completed';
if (!config?.hideToast) {
- Toast.show({
- intent: Intent.SUCCESS,
- message,
- icon: 'endorsed',
- });
+ toast.success(message);
}
return [true, res];
} catch (err) {
console.error('Operation failed.', err);
- const reason = formatReason?.(err) ?? 'Operation failed.';
+ const reason = formatReason?.(err) ?? (err as any).response?.data?.message
?? 'Operation failed.';
if (!config?.hideToast) {
- Toast.show({
- intent: Intent.DANGER,
- message: reason,
- icon: 'error',
- });
+ toast.error(reason);
}
return [false];