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

mintsweet pushed a commit to branch feat-hide-type-toast
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git

commit 28369e12ad0e24277407cbc7d67c539334c072b2
Author: mintsweet <[email protected]>
AuthorDate: Fri Jan 26 18:25:53 2024 +1300

    feat: support hide custom type toast in operator
---
 config-ui/src/utils/operator.ts | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/config-ui/src/utils/operator.ts b/config-ui/src/utils/operator.ts
index 1f570bb02..e14263b4f 100644
--- a/config-ui/src/utils/operator.ts
+++ b/config-ui/src/utils/operator.ts
@@ -23,6 +23,8 @@ export type OperateConfig = {
   formatMessage?: () => string;
   formatReason?: (err: unknown) => string;
   hideToast?: boolean;
+  hideSuccessToast?: boolean;
+  hideErrorToast?: boolean;
 };
 
 /**
@@ -32,6 +34,9 @@ export type OperateConfig = {
  * @param config.setOperating -> Control the status of the request
  * @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?]> => {
@@ -41,14 +46,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) {
+    if (!config?.hideToast || !config?.hideSuccessToast) {
       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) {
+    if (!config?.hideToast || !config?.hideErrorToast) {
       message.error(reason);
     }
 

Reply via email to