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

mintsweet pushed a commit to branch release-v0.21
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git


The following commit(s) were added to refs/heads/release-v0.21 by this push:
     new d66285439 fix: no error message when hideToast is true (#7777)
d66285439 is described below

commit d662854392a8ad2932788d035798455b5abc12cb
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 |  2 +-
 config-ui/src/utils/operator.ts                              | 11 ++---------
 2 files changed, 3 insertions(+), 10 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 8892c03dd..f4467e08e 100644
--- a/config-ui/src/plugins/components/scope-config-form/index.tsx
+++ b/config-ui/src/plugins/components/scope-config-form/index.tsx
@@ -104,7 +104,7 @@ export const ScopeConfigForm = ({
           : API.scopeConfig.update(plugin, connectionId, scopeConfigId, { 
name, entities, ...transformation }),
       {
         setOperating,
-        formatMessage: () => (!scopeConfigId ? 'Create scope config 
successful.' : 'Update 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