From ddbd9dfdc8296a13e51ac44a9a0a5beddc94a5e6 Mon Sep 17 00:00:00 2001 From: Aaryan Khandelwal <65252264+aaryan610@users.noreply.github.com> Date: Thu, 12 Sep 2024 14:32:54 +0530 Subject: [PATCH] chore: add toast alerts post access change of a page (#5569) --- .../pages/dropdowns/quick-actions.tsx | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/web/core/components/pages/dropdowns/quick-actions.tsx b/web/core/components/pages/dropdowns/quick-actions.tsx index 21c9502000..6bed6be2c6 100644 --- a/web/core/components/pages/dropdowns/quick-actions.tsx +++ b/web/core/components/pages/dropdowns/quick-actions.tsx @@ -48,7 +48,26 @@ export const PageQuickActions: React.FC = observer((props) => { const MENU_ITEMS: TContextMenuItem[] = [ { key: "make-public-private", - action: access === 0 ? makePrivate : makePublic, + action: async () => { + const changedPageType = access === 0 ? "private" : "public"; + + try { + if (access === 0) await makePrivate(); + else await makePublic(); + + setToast({ + type: TOAST_TYPE.SUCCESS, + title: "Success!", + message: `The page has been marked ${changedPageType} and moved to the ${changedPageType} section.`, + }); + } catch (err) { + setToast({ + type: TOAST_TYPE.ERROR, + title: "Error!", + message: `The page couldn't be marked ${changedPageType}. Please try again.`, + }); + } + }, title: access === 0 ? "Make private" : "Make public", icon: access === 0 ? Lock : UsersRound, shouldRender: canCurrentUserChangeAccess && !archived_at,