chore: add toast alerts post access change of a page (#5569)
This commit is contained in:
parent
09578c9a7d
commit
ddbd9dfdc8
1 changed files with 20 additions and 1 deletions
|
|
@ -48,7 +48,26 @@ export const PageQuickActions: React.FC<Props> = observer((props) => {
|
||||||
const MENU_ITEMS: TContextMenuItem[] = [
|
const MENU_ITEMS: TContextMenuItem[] = [
|
||||||
{
|
{
|
||||||
key: "make-public-private",
|
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",
|
title: access === 0 ? "Make private" : "Make public",
|
||||||
icon: access === 0 ? Lock : UsersRound,
|
icon: access === 0 ? Lock : UsersRound,
|
||||||
shouldRender: canCurrentUserChangeAccess && !archived_at,
|
shouldRender: canCurrentUserChangeAccess && !archived_at,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue