This is an automated email from the ASF dual-hosted git repository.

abeizn 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 4baed97c1 fix: no error message when hideToast is true (#7777)
4baed97c1 is described below

commit 4baed97c116fb4322069ae3982fc2b056f3bb85d
Author: 青湛 <[email protected]>
AuthorDate: Wed Jul 24 20:26:56 2024 +1200

    fix: no error message when hideToast is true (#7777)
---
 config-ui/src/plugins/components/scope-config-form/index.tsx |  3 +--
 config-ui/src/utils/operator.ts                              | 11 ++---------
 2 files changed, 3 insertions(+), 11 deletions(-)

diff --git a/config-ui/src/plugins/components/scope-config-form/index.tsx 
b/config-ui/src/plugins/components/scope-config-form/index.tsx
index 2466e9bac..5c27d84d4 100644
--- a/config-ui/src/plugins/components/scope-config-form/index.tsx
+++ b/config-ui/src/plugins/components/scope-config-form/index.tsx
@@ -106,8 +106,7 @@ export const ScopeConfigForm = ({
           : API.scopeConfig.update(plugin, connectionId, scopeConfigId, { 
name, entities, ...transformation }),
       {
         setOperating,
-        hideSuccessToast: !!scopeConfigId,
-        formatMessage: () => 'Create scope config successful.',
+        hideToast: true,
       },
     );
 
diff --git a/config-ui/src/utils/operator.ts b/config-ui/src/utils/operator.ts
index af3126ec9..d183bc4f1 100644
--- a/config-ui/src/utils/operator.ts
+++ b/config-ui/src/utils/operator.ts
@@ -23,8 +23,6 @@ export type OperateConfig = {
   formatMessage?: () => string;
   formatReason?: (err: unknown) => string;
   hideToast?: boolean;
-  hideSuccessToast?: boolean;
-  hideErrorToast?: boolean;
 };
 
 /**
@@ -35,8 +33,6 @@ export type OperateConfig = {
  * @param config.formatMessage -> Show the message for the success
  * @param config.formatReason -> Show the reason for the failure
  * @param config.hideToast -> Hide all the toast
- * @param config.hideSuccessToast -> Hide the success toast
- * @param config.hideErrorToast -> Hide the error toast
  * @returns
  */
 export const operator = async <T>(request: () => Promise<T>, config?: 
OperateConfig): Promise<[boolean, any?]> => {
@@ -46,17 +42,14 @@ export const operator = async <T>(request: () => 
Promise<T>, config?: OperateCon
     setOperating?.(true);
     const res = await request();
     const content = formatMessage?.() ?? 'Operation successfully completed';
-    if (!config?.hideToast && !config?.hideSuccessToast) {
+    if (!config?.hideToast) {
       message.success(content);
     }
     return [true, res];
   } catch (err) {
     console.error('Operation failed.', err);
     const reason = formatReason?.(err) ?? (err as any).response?.data?.message 
?? 'Operation failed.';
-    if (!config?.hideToast && !config?.hideErrorToast) {
-      message.error(reason);
-    }
-
+    message.error(reason);
     return [false, err];
   } finally {
     setOperating?.(false);

Reply via email to