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

mintsweet pushed a commit to branch fix-no-error-message
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git

commit 88f484f635e11162c77c35e44a793f4484df2f9e
Author: mintsweet <[email protected]>
AuthorDate: Wed Jul 24 19:35:14 2024 +1200

    fix: no error message when hideToast is true
---
 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