[WEB-570] chore: toast refactor (#3836)

* new toast setup

* chore: new toast implementation.

* chore: move toast component to ui package.

* chore: replace `setToast` with `setPromiseToast` in required places for better UX.
* chore: code cleanup.

* chore: update theme.

* fix: theme switching issue.

* chore: remove toast from issue update operations.

* chore: add promise toast for add/ remove issue to cycle/ module and remove local spinners.

---------

Co-authored-by: rahulramesha <rahulramesham@gmail.com>
This commit is contained in:
Prateek Shourya 2024-03-06 14:18:41 +05:30 committed by GitHub
parent c06ef4d1d7
commit 53367a6bc4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
167 changed files with 1827 additions and 1896 deletions

View file

@ -5,9 +5,8 @@ import { observer } from "mobx-react-lite";
import { AlertTriangle } from "lucide-react";
// store hooks
import { useGlobalView, useEventTracker } from "hooks/store";
import useToast from "hooks/use-toast";
// ui
import { Button } from "@plane/ui";
import { Button, TOAST_TYPE, setToast } from "@plane/ui";
// types
import { IWorkspaceView } from "@plane/types";
// constants
@ -29,8 +28,6 @@ export const DeleteGlobalViewModal: React.FC<Props> = observer((props) => {
// store hooks
const { deleteGlobalView } = useGlobalView();
const { captureEvent } = useEventTracker();
// toast alert
const { setToastAlert } = useToast();
const handleClose = () => {
onClose();
@ -53,8 +50,8 @@ export const DeleteGlobalViewModal: React.FC<Props> = observer((props) => {
view_id: data.id,
state: "FAILED",
});
setToastAlert({
type: "error",
setToast({
type: TOAST_TYPE.ERROR,
title: "Error!",
message: "Something went wrong while deleting the view. Please try again.",
});

View file

@ -4,7 +4,8 @@ import { observer } from "mobx-react-lite";
import { Dialog, Transition } from "@headlessui/react";
// store hooks
import { useEventTracker, useGlobalView } from "hooks/store";
import useToast from "hooks/use-toast";
// ui
import { TOAST_TYPE, setToast } from "@plane/ui";
// components
import { WorkspaceViewForm } from "components/workspace";
// types
@ -27,8 +28,6 @@ export const CreateUpdateWorkspaceViewModal: React.FC<Props> = observer((props)
// store hooks
const { createGlobalView, updateGlobalView } = useGlobalView();
const { captureEvent } = useEventTracker();
// toast alert
const { setToastAlert } = useToast();
const handleClose = () => {
onClose();
@ -51,8 +50,8 @@ export const CreateUpdateWorkspaceViewModal: React.FC<Props> = observer((props)
applied_filters: res.filters,
state: "SUCCESS",
});
setToastAlert({
type: "success",
setToast({
type: TOAST_TYPE.SUCCESS,
title: "Success!",
message: "View created successfully.",
});
@ -65,8 +64,8 @@ export const CreateUpdateWorkspaceViewModal: React.FC<Props> = observer((props)
applied_filters: payload?.filters,
state: "FAILED",
});
setToastAlert({
type: "error",
setToast({
type: TOAST_TYPE.ERROR,
title: "Error!",
message: "View could not be created. Please try again.",
});
@ -90,8 +89,8 @@ export const CreateUpdateWorkspaceViewModal: React.FC<Props> = observer((props)
applied_filters: res.filters,
state: "SUCCESS",
});
setToastAlert({
type: "success",
setToast({
type: TOAST_TYPE.SUCCESS,
title: "Success!",
message: "View updated successfully.",
});
@ -103,8 +102,8 @@ export const CreateUpdateWorkspaceViewModal: React.FC<Props> = observer((props)
applied_filters: data.filters,
state: "FAILED",
});
setToastAlert({
type: "error",
setToast({
type: TOAST_TYPE.ERROR,
title: "Error!",
message: "View could not be updated. Please try again.",
});