diff --git a/frontend/package-lock.json b/frontend/package-lock.json index 0d8eaa7942..4eb7e76fd2 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -85,6 +85,7 @@ "react-markdown": "^8.0.3", "react-redux": "^8.0.2", "react-table": "^7.8.0", + "react-toastify": "^9.1.3", "sanitize-html": "^2.12.1", "set-cookie-parser": "^2.5.1", "sharp": "^0.33.2", @@ -9913,13 +9914,13 @@ "dev": true }, "node_modules/body-parser": { - "version": "1.20.1", - "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.1.tgz", - "integrity": "sha512-jWi7abTbYwajOytWCQc37VulmWiRae5RyTpaCyDcS5/lMdtwSz5lOpDE67srw/HYe35f1z3fDQw+3txg7gNtWw==", + "version": "1.20.2", + "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.2.tgz", + "integrity": "sha512-ml9pReCu3M61kGlqoTm2umSXTlRTuGTx0bfYj+uIUKKYycG5NtSbeetV3faSU6R7ajOPw0g/J1PvK4qNy7s5bA==", "dev": true, "dependencies": { "bytes": "3.1.2", - "content-type": "~1.0.4", + "content-type": "~1.0.5", "debug": "2.6.9", "depd": "2.0.0", "destroy": "1.2.0", @@ -9927,7 +9928,7 @@ "iconv-lite": "0.4.24", "on-finished": "2.4.1", "qs": "6.11.0", - "raw-body": "2.5.1", + "raw-body": "2.5.2", "type-is": "~1.6.18", "unpipe": "1.0.0" }, @@ -10876,9 +10877,9 @@ "integrity": "sha512-ASFBup0Mz1uyiIjANan1jzLQami9z1PoYSZCiiYW2FczPbenXc45FZdBZLzOT+r6+iciuEModtmCti+hjaAk0A==" }, "node_modules/cookie": { - "version": "0.5.0", - "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.5.0.tgz", - "integrity": "sha512-YZ3GUyn/o8gfKJlnlX7g7xq4gyO6OSuhGPKaaGssGB2qgDUS0gPgtTvoyZLTt9Ab6dC4hfc9dV5arkvc/OCmrw==", + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.6.0.tgz", + "integrity": "sha512-U71cyTamuh1CRNCfpGY6to28lxvNwPG4Guz/EVjgf3Jmzv0vlDp1atT9eS5dDjMYHucpHbWns6Lwf3BKz6svdw==", "dev": true, "engines": { "node": ">= 0.6" @@ -13262,17 +13263,17 @@ } }, "node_modules/express": { - "version": "4.18.2", - "resolved": "https://registry.npmjs.org/express/-/express-4.18.2.tgz", - "integrity": "sha512-5/PsL6iGPdfQ/lKM1UuielYgv3BUoJfz1aUwU9vHZ+J7gyvwdQXFEBIEIaxeGf0GIcreATNyBExtalisDbuMqQ==", + "version": "4.19.2", + "resolved": "https://registry.npmjs.org/express/-/express-4.19.2.tgz", + "integrity": "sha512-5T6nhjsT+EOMzuck8JjBHARTHfMht0POzlA60WV2pMD3gyXw2LZnZ+ueGdNxG+0calOJcWKbpFcuzLZ91YWq9Q==", "dev": true, "dependencies": { "accepts": "~1.3.8", "array-flatten": "1.1.1", - "body-parser": "1.20.1", + "body-parser": "1.20.2", "content-disposition": "0.5.4", "content-type": "~1.0.4", - "cookie": "0.5.0", + "cookie": "0.6.0", "cookie-signature": "1.0.6", "debug": "2.6.9", "depd": "2.0.0", @@ -19793,9 +19794,9 @@ } }, "node_modules/raw-body": { - "version": "2.5.1", - "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.5.1.tgz", - "integrity": "sha512-qqJBtEyVgS0ZmPGdCFPWJ3FreoqvG4MVQln/kCgF7Olq95IbOp0/BWyMwbdtn4VTvkM8Y7khCQ2Xgk/tcrCXig==", + "version": "2.5.2", + "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.5.2.tgz", + "integrity": "sha512-8zGqypfENjCIqGhgXToC8aB2r7YrBX+AQAfIPs/Mlk+BtPTztOvTS01NRW/3Eh60J+a48lt8qsCzirQ6loCVfA==", "dev": true, "dependencies": { "bytes": "3.1.2", @@ -20300,6 +20301,26 @@ "react": "^16.8.3 || ^17.0.0-0 || ^18.0.0" } }, + "node_modules/react-toastify": { + "version": "9.1.3", + "resolved": "https://registry.npmjs.org/react-toastify/-/react-toastify-9.1.3.tgz", + "integrity": "sha512-fPfb8ghtn/XMxw3LkxQBk3IyagNpF/LIKjOBflbexr2AWxAH1MJgvnESwEwBn9liLFXgTKWgBSdZpw9m4OTHTg==", + "dependencies": { + "clsx": "^1.1.1" + }, + "peerDependencies": { + "react": ">=16", + "react-dom": ">=16" + } + }, + "node_modules/react-toastify/node_modules/clsx": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/clsx/-/clsx-1.2.1.tgz", + "integrity": "sha512-EcR6r5a8bj6pu3ycsa/E/cKVGuTgZJZdsyUYHOksG/UHIiKfjxzRxYJpyVBwYaQeOvghal9fcc4PidlgzugAQg==", + "engines": { + "node": ">=6" + } + }, "node_modules/read-cache": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/read-cache/-/read-cache-1.0.0.tgz", @@ -23701,9 +23722,9 @@ } }, "node_modules/webpack-dev-middleware": { - "version": "6.1.1", - "resolved": "https://registry.npmjs.org/webpack-dev-middleware/-/webpack-dev-middleware-6.1.1.tgz", - "integrity": "sha512-y51HrHaFeeWir0YO4f0g+9GwZawuigzcAdRNon6jErXy/SqV/+O6eaVAzDqE6t3e3NpGeR5CS+cCDaTC+V3yEQ==", + "version": "6.1.2", + "resolved": "https://registry.npmjs.org/webpack-dev-middleware/-/webpack-dev-middleware-6.1.2.tgz", + "integrity": "sha512-Wu+EHmX326YPYUpQLKmKbTyZZJIB8/n6R09pTmB03kJmnMsVPTo9COzHZFr01txwaCAuZvfBJE4ZCHRcKs5JaQ==", "dev": true, "dependencies": { "colorette": "^2.0.10", diff --git a/frontend/package.json b/frontend/package.json index def2a968b5..0dacef6b30 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -92,6 +92,7 @@ "react-markdown": "^8.0.3", "react-redux": "^8.0.2", "react-table": "^7.8.0", + "react-toastify": "^9.1.3", "sanitize-html": "^2.12.1", "set-cookie-parser": "^2.5.1", "sharp": "^0.33.2", diff --git a/frontend/src/components/context/Notifications/Notification.tsx b/frontend/src/components/context/Notifications/Notification.tsx deleted file mode 100644 index 14b0ba556f..0000000000 --- a/frontend/src/components/context/Notifications/Notification.tsx +++ /dev/null @@ -1,66 +0,0 @@ -import { useEffect, useRef } from "react"; -import { faXmark } from "@fortawesome/free-solid-svg-icons"; -import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; - -type NotificationType = "success" | "error" | "info"; - -export type TNotification = { - text: string; - type?: NotificationType; - timeoutMs?: number; -}; - -interface NotificationProps { - notification: Required; - clearNotification: (text: string) => void; -} - -const Notification = ({ notification, clearNotification }: NotificationProps) => { - const timeout = useRef(); - - const handleClearNotification = () => clearNotification(notification.text); - - const setNotifTimeout = () => { - timeout.current = window.setTimeout(handleClearNotification, notification.timeoutMs); - }; - - const cancelNotifTimeout = () => { - clearTimeout(timeout.current); - }; - - useEffect(() => { - setNotifTimeout(); - - return cancelNotifTimeout; - }, []); - - return ( -
- {notification.type === "error" && ( -
- )} - {notification.type === "success" && ( -
- )} - {notification.type === "info" && ( -
- )} -

{notification.text}

- -
- ); -}; - -export default Notification; diff --git a/frontend/src/components/context/Notifications/NotificationProvider.tsx b/frontend/src/components/context/Notifications/NotificationProvider.tsx deleted file mode 100644 index 0c10d1711e..0000000000 --- a/frontend/src/components/context/Notifications/NotificationProvider.tsx +++ /dev/null @@ -1,52 +0,0 @@ -import { createContext, ReactNode, useCallback, useContext, useMemo, useState } from "react"; - -import { TNotification } from "./Notification"; -import Notifications from "./Notifications"; - -type NotificationContextState = { - createNotification: (newNotification: TNotification) => void; -}; - -const NotificationContext = createContext({ - createNotification: () => console.log("createNotification not set!") -}); - -export const useNotificationContext = () => useContext(NotificationContext); - -interface NotificationProviderProps { - children: ReactNode; -} - -// TODO: Migration to radix toast -const NotificationProvider = ({ children }: NotificationProviderProps) => { - const [notifications, setNotifications] = useState[]>([]); - - const clearNotification = (text: string) => - setNotifications((state) => state.filter((notif) => notif.text !== text)); - - const createNotification = useCallback( - ({ text, type = "success", timeoutMs = 4000 }: TNotification) => { - const doesNotifExist = notifications.some((notif) => notif.text === text); - - if (doesNotifExist) { - return; - } - - const newNotification: Required = { text, type, timeoutMs }; - - setNotifications((state) => [...state, newNotification]); - }, - [notifications] - ); - - const value = useMemo(() => ({ createNotification }), [createNotification]); - - return ( - - - {children} - - ); -}; - -export default NotificationProvider; diff --git a/frontend/src/components/context/Notifications/Notifications.tsx b/frontend/src/components/context/Notifications/Notifications.tsx deleted file mode 100644 index 7a9e6af333..0000000000 --- a/frontend/src/components/context/Notifications/Notifications.tsx +++ /dev/null @@ -1,22 +0,0 @@ -import Notification, { TNotification } from "./Notification"; - -interface NoticationsProps { - notifications: Required[]; - clearNotification: (text: string) => void; -} - -const Notifications = ({ notifications, clearNotification }: NoticationsProps) => { - if (!notifications.length) { - return null; - } - - return ( -
- {notifications.map((notif) => ( - - ))} -
- ); -}; - -export default Notifications; diff --git a/frontend/src/components/dashboard/DropZone.tsx b/frontend/src/components/dashboard/DropZone.tsx index fdf3b1cbed..ba0b9efdba 100644 --- a/frontend/src/components/dashboard/DropZone.tsx +++ b/frontend/src/components/dashboard/DropZone.tsx @@ -8,7 +8,7 @@ import { parseDocument, Scalar, YAMLMap } from "yaml"; import Button from "../basic/buttons/Button"; import Error from "../basic/Error"; -import { useNotificationContext } from "../context/Notifications/NotificationProvider"; +import { createNotification } from "../notifications"; import { parseDotEnv } from "../utilities/parseDotEnv"; import guidGenerator from "../utilities/randomId"; @@ -33,7 +33,7 @@ const DropZone = ({ numCurrentRows }: DropZoneProps) => { const { t } = useTranslation(); - const { createNotification } = useNotificationContext(); + const handleDragEnter = (e: DragEvent) => { e.preventDefault(); @@ -133,7 +133,6 @@ const DropZone = ({ createNotification({ text: "You can't inject files from VS Code. Click 'Reveal in finder', and drag your file directly from the directory where it's located.", type: "error", - timeoutMs: 10000 }); setLoading(false); return; diff --git a/frontend/src/components/notifications/Notifications.tsx b/frontend/src/components/notifications/Notifications.tsx new file mode 100644 index 0000000000..0d6b0d0615 --- /dev/null +++ b/frontend/src/components/notifications/Notifications.tsx @@ -0,0 +1,29 @@ +import { ReactNode } from "react"; +import { Id, toast, ToastContainer, ToastOptions, TypeOptions } from "react-toastify"; + +export type TNotification = { + title?: string; + text: ReactNode; +}; + +export const NotificationContent = ({ title, text }: TNotification) => { + return ( +
+ {title &&
{title}
} +
{text}
+
+ ); +}; + +export const createNotification = ( + myProps: TNotification & { type?: TypeOptions }, + toastProps: ToastOptions = {} +): Id => + toast(, { + position: "bottom-right", + ...toastProps, + theme: "dark", + type: myProps?.type || "info", + }); + +export const NotificationContainer = () => ; diff --git a/frontend/src/components/notifications/index.tsx b/frontend/src/components/notifications/index.tsx new file mode 100644 index 0000000000..e752e6d267 --- /dev/null +++ b/frontend/src/components/notifications/index.tsx @@ -0,0 +1 @@ +export { createNotification, NotificationContainer } from "./Notifications"; diff --git a/frontend/src/components/signup/DonwloadBackupPDFStep.tsx b/frontend/src/components/signup/DonwloadBackupPDFStep.tsx index 22d278cc3f..bf9aabcffb 100644 --- a/frontend/src/components/signup/DonwloadBackupPDFStep.tsx +++ b/frontend/src/components/signup/DonwloadBackupPDFStep.tsx @@ -5,7 +5,7 @@ import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { useToggle } from "@app/hooks"; import { generateUserBackupKey } from "@app/lib/crypto"; -import { useNotificationContext } from "../context/Notifications/NotificationProvider"; +import { createNotification } from "../notifications"; import { generateBackupPDFAsync } from "../utilities/generateBackupPDF"; import { Button } from "../v2"; @@ -32,7 +32,7 @@ export default function DonwloadBackupPDFStep({ name }: DownloadBackupPDFStepProps): JSX.Element { const { t } = useTranslation(); - const { createNotification } = useNotificationContext(); + const [isLoading, setIsLoading] = useToggle(); const handleBackupKeyGenerate = async () => { diff --git a/frontend/src/components/signup/EnterEmailStep.tsx b/frontend/src/components/signup/EnterEmailStep.tsx index c42078dd61..2b5b0d1389 100644 --- a/frontend/src/components/signup/EnterEmailStep.tsx +++ b/frontend/src/components/signup/EnterEmailStep.tsx @@ -3,7 +3,7 @@ import { useTranslation } from "react-i18next"; import Link from "next/link"; import axios from "axios"; -import { useNotificationContext } from "@app/components/context/Notifications/NotificationProvider"; +import { createNotification } from "@app/components/notifications"; import { useSendVerificationEmail } from "@app/hooks/api"; import { Button, Input } from "../v2"; @@ -27,7 +27,7 @@ export default function EnterEmailStep({ setEmail, incrementStep }: DownloadBackupPDFStepProps): JSX.Element { - const { createNotification } = useNotificationContext(); + const { mutateAsync, isLoading } = useSendVerificationEmail(); const [emailError, setEmailError] = useState(false); const { t } = useTranslation(); diff --git a/frontend/src/components/tags/CreateTagModal/CreateTagModal.tsx b/frontend/src/components/tags/CreateTagModal/CreateTagModal.tsx index cfe685ae2e..c65229a869 100644 --- a/frontend/src/components/tags/CreateTagModal/CreateTagModal.tsx +++ b/frontend/src/components/tags/CreateTagModal/CreateTagModal.tsx @@ -5,7 +5,7 @@ import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { zodResolver } from "@hookform/resolvers/zod"; import { z } from "zod"; -import { useNotificationContext } from "@app/components/context/Notifications/NotificationProvider"; +import { createNotification } from "@app/components/notifications"; import { Button, FormControl, @@ -110,7 +110,7 @@ export const CreateTagModal = ({ isOpen, onToggle }: Props): JSX.Element => { } = useForm({ resolver: zodResolver(createTagSchema) }); - const { createNotification } = useNotificationContext(); + const { currentWorkspace } = useWorkspace(); const workspaceId = currentWorkspace?.id || ""; diff --git a/frontend/src/components/v2/UpgradeProjectAlert/UpgradeProjectAlert.tsx b/frontend/src/components/v2/UpgradeProjectAlert/UpgradeProjectAlert.tsx index 521f3ec85f..b4c8d99125 100644 --- a/frontend/src/components/v2/UpgradeProjectAlert/UpgradeProjectAlert.tsx +++ b/frontend/src/components/v2/UpgradeProjectAlert/UpgradeProjectAlert.tsx @@ -5,7 +5,7 @@ import { faWarning } from "@fortawesome/free-solid-svg-icons"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { twMerge } from "tailwind-merge"; -import { useNotificationContext } from "@app/components/context/Notifications/NotificationProvider"; +import { createNotification } from "@app/components/notifications"; import { useProjectPermission } from "@app/context"; import { useGetUpgradeProjectStatus, useUpgradeProject } from "@app/hooks/api"; import { Workspace } from "@app/hooks/api/types"; @@ -25,7 +25,7 @@ export const UpgradeProjectAlert = ({ project, transparent }: UpgradeProjectAlertProps): JSX.Element | null => { - const { createNotification } = useNotificationContext(); + const router = useRouter(); const { membership } = useProjectPermission(); const upgradeProject = useUpgradeProject(); diff --git a/frontend/src/hooks/api/types.ts b/frontend/src/hooks/api/types.ts index 6748db6ac2..d6b43d6749 100644 --- a/frontend/src/hooks/api/types.ts +++ b/frontend/src/hooks/api/types.ts @@ -1,3 +1,5 @@ +import { ZodIssue } from "zod"; + export type { GetAuthTokenAPI } from "./auth/types"; export type { IncidentContact } from "./incidentContacts/types"; export type { IntegrationAuth } from "./integrationAuth/types"; @@ -36,3 +38,23 @@ export type { WorkspaceEnv, WorkspaceTag } from "./workspace/types"; + +export enum ApiErrorTypes { + ValidationError = "ValidationFailure", + BadRequestError = "BadRequest", + UnauthorizedError = "UnauthorizedError", + ForbiddenError = "PermissionDenied" +} + +export type TApiErrors = + | { + error: ApiErrorTypes.ValidationError; + message: ZodIssue[]; + statusCode: 403; + } + | { error: ApiErrorTypes.ForbiddenError; message: string; statusCode: 401 } + | { + statusCode: 400; + message: string; + error: ApiErrorTypes.BadRequestError; + }; diff --git a/frontend/src/layouts/AppLayout/AppLayout.tsx b/frontend/src/layouts/AppLayout/AppLayout.tsx index 70a6b4326b..2550150f3a 100644 --- a/frontend/src/layouts/AppLayout/AppLayout.tsx +++ b/frontend/src/layouts/AppLayout/AppLayout.tsx @@ -31,7 +31,7 @@ import { DropdownMenuTrigger } from "@radix-ui/react-dropdown-menu"; import { twMerge } from "tailwind-merge"; import * as yup from "yup"; -import { useNotificationContext } from "@app/components/context/Notifications/NotificationProvider"; +import { createNotification } from "@app/components/notifications"; import { OrgPermissionCan } from "@app/components/permissions"; import { tempLocalStorage } from "@app/components/utilities/checks/tempLocalStorage"; import { @@ -115,7 +115,7 @@ type TAddProjectFormData = yup.InferType; export const AppLayout = ({ children }: LayoutProps) => { const router = useRouter(); - const { createNotification } = useNotificationContext(); + const { mutateAsync } = useGetOrgTrialUrl(); const { workspaces, currentWorkspace } = useWorkspace(); diff --git a/frontend/src/pages/_app.tsx b/frontend/src/pages/_app.tsx index 5c9b63b751..7de2e92abd 100644 --- a/frontend/src/pages/_app.tsx +++ b/frontend/src/pages/_app.tsx @@ -12,7 +12,7 @@ import { config } from "@fortawesome/fontawesome-svg-core"; import { QueryClientProvider } from "@tanstack/react-query"; import NProgress from "nprogress"; -import NotificationProvider from "@app/components/context/Notifications/NotificationProvider"; +import { NotificationContainer } from "@app/components/notifications"; import Telemetry from "@app/components/utilities/telemetry/Telemetry"; import { TooltipProvider } from "@app/components/v2"; import { publicPaths } from "@app/const"; @@ -30,6 +30,7 @@ import { AppLayout } from "@app/layouts"; import { queryClient } from "@app/reactQuery"; import "nprogress/nprogress.css"; +import "react-toastify/dist/ReactToastify.css"; import "@fortawesome/fontawesome-svg-core/styles.css"; import "react-day-picker/dist/style.css"; import "../styles/globals.css"; @@ -85,15 +86,14 @@ const App = ({ Component, pageProps, ...appProps }: NextAppProp): JSX.Element => ) { return ( - - - - - - - - - + + + + + + + + ); } @@ -103,27 +103,26 @@ const App = ({ Component, pageProps, ...appProps }: NextAppProp): JSX.Element => return ( - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + ); diff --git a/frontend/src/pages/integrations/cloudflare-pages/create.tsx b/frontend/src/pages/integrations/cloudflare-pages/create.tsx index 39d26a9376..c2eb1c61a4 100644 --- a/frontend/src/pages/integrations/cloudflare-pages/create.tsx +++ b/frontend/src/pages/integrations/cloudflare-pages/create.tsx @@ -3,7 +3,7 @@ import { useRouter } from "next/router"; import axios from "axios"; import queryString from "query-string"; -import { useNotificationContext } from "@app/components/context/Notifications/NotificationProvider"; +import { createNotification } from "@app/components/notifications"; import { useCreateIntegration, useGetWorkspaceById } from "@app/hooks/api"; import { @@ -27,7 +27,7 @@ const cloudflareEnvironments = [ export default function CloudflarePagesIntegrationPage() { const router = useRouter(); const { mutateAsync } = useCreateIntegration(); - const { createNotification } = useNotificationContext(); + const { integrationAuthId } = queryString.parse(router.asPath.split("?")[1]); const [secretPath, setSecretPath] = useState("/"); diff --git a/frontend/src/pages/integrations/cloudflare-workers/create.tsx b/frontend/src/pages/integrations/cloudflare-workers/create.tsx index 4813de36db..43808e98d3 100644 --- a/frontend/src/pages/integrations/cloudflare-workers/create.tsx +++ b/frontend/src/pages/integrations/cloudflare-workers/create.tsx @@ -3,7 +3,7 @@ import { useRouter } from "next/router"; import axios from "axios"; import queryString from "query-string"; -import { useNotificationContext } from "@app/components/context/Notifications/NotificationProvider"; +import { createNotification } from "@app/components/notifications"; import { useCreateIntegration, useGetWorkspaceById } from "@app/hooks/api"; import { @@ -23,7 +23,7 @@ import { export default function CloudflareWorkersIntegrationPage() { const router = useRouter(); const { mutateAsync } = useCreateIntegration(); - const { createNotification } = useNotificationContext(); + const { integrationAuthId } = queryString.parse(router.asPath.split("?")[1]); const { data: workspace } = useGetWorkspaceById(localStorage.getItem("projectData.id") ?? ""); diff --git a/frontend/src/pages/integrations/github/create.tsx b/frontend/src/pages/integrations/github/create.tsx index c1e2073c10..e42a7e9eb4 100644 --- a/frontend/src/pages/integrations/github/create.tsx +++ b/frontend/src/pages/integrations/github/create.tsx @@ -20,7 +20,7 @@ import queryString from "query-string"; import { twMerge } from "tailwind-merge"; import * as yup from "yup"; -import { useNotificationContext } from "@app/components/context/Notifications/NotificationProvider"; +import { createNotification } from "@app/components/notifications"; import { Button, Card, @@ -98,7 +98,7 @@ type FormData = yup.InferType; export default function GitHubCreateIntegrationPage() { const router = useRouter(); const { mutateAsync } = useCreateIntegration(); - const { createNotification } = useNotificationContext(); + const integrationAuthId = (queryString.parse(router.asPath.split("?")[1]).integrationAuthId as string) ?? ""; diff --git a/frontend/src/pages/login/select-organization.tsx b/frontend/src/pages/login/select-organization.tsx index 481b429666..586ed62f90 100644 --- a/frontend/src/pages/login/select-organization.tsx +++ b/frontend/src/pages/login/select-organization.tsx @@ -9,7 +9,7 @@ import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import axios from "axios"; import jwt_decode from "jwt-decode"; -import { useNotificationContext } from "@app/components/context/Notifications/NotificationProvider"; +import { createNotification } from "@app/components/notifications"; import { IsCliLoginSuccessful } from "@app/components/utilities/attemptCliLogin"; import { Button, Spinner } from "@app/components/v2"; import { useUser } from "@app/context"; @@ -35,7 +35,7 @@ export default function LoginPage() { const selectOrg = useSelectOrganization(); const { user, isLoading: userLoading } = useUser(); - const { createNotification } = useNotificationContext(); + const queryParams = new URLSearchParams(window.location.search); diff --git a/frontend/src/pages/org/[id]/overview/index.tsx b/frontend/src/pages/org/[id]/overview/index.tsx index 38be2f4b79..c009694d74 100644 --- a/frontend/src/pages/org/[id]/overview/index.tsx +++ b/frontend/src/pages/org/[id]/overview/index.tsx @@ -28,7 +28,7 @@ import { yupResolver } from "@hookform/resolvers/yup"; import * as Tabs from "@radix-ui/react-tabs"; import * as yup from "yup"; -import { useNotificationContext } from "@app/components/context/Notifications/NotificationProvider"; +import { createNotification } from "@app/components/notifications"; import { OrgPermissionCan } from "@app/components/permissions"; import onboardingCheck from "@app/components/utilities/checks/OnboardingCheck"; import { @@ -477,7 +477,7 @@ const OrganizationPage = withPermission( const { currentOrg } = useOrganization(); const routerOrgId = String(router.query.id); const orgWorkspaces = workspaces?.filter((workspace) => workspace.orgId === routerOrgId) || []; - const { createNotification } = useNotificationContext(); + const addUsersToProject = useAddUserToWsNonE2EE(); const { popUp, handlePopUpOpen, handlePopUpClose, handlePopUpToggle } = usePopUp([ diff --git a/frontend/src/reactQuery.ts b/frontend/src/reactQuery.tsx similarity index 50% rename from frontend/src/reactQuery.ts rename to frontend/src/reactQuery.tsx index 447f02fc6a..bf764d2d7a 100644 --- a/frontend/src/reactQuery.ts +++ b/frontend/src/reactQuery.tsx @@ -1,4 +1,9 @@ -import { QueryClient } from "@tanstack/react-query"; +import { MutationCache, QueryClient } from "@tanstack/react-query"; +import axios from "axios"; + +import { createNotification } from "@app/components/notifications"; + +import { ApiErrorTypes, TApiErrors } from "./hooks/api/types"; // this is saved in react-query cache export const SIGNUP_TEMP_TOKEN_CACHE_KEY = ["infisical__signup-temp-token"]; @@ -6,6 +11,40 @@ export const MFA_TEMP_TOKEN_CACHE_KEY = ["infisical__mfa-temp-token"]; export const AUTH_TOKEN_CACHE_KEY = ["infisical__auth-token"]; export const queryClient = new QueryClient({ + mutationCache: new MutationCache({ + onError: (error) => { + if (axios.isAxiosError(error)) { + const serverResponse = error.response?.data as TApiErrors; + if (serverResponse?.error === ApiErrorTypes.ValidationError) { + createNotification({ + title: "Validation Error", + type: "error", + text: ( +
+ {serverResponse.message?.map(({ message, path }) => ( +
+
+ Field {path.join(".")} {message.toLowerCase()} +
+
+ ))} +
+ ) + }); + return; + } + if (serverResponse.statusCode === 401) { + createNotification({ + title: "Forbidden Access", + type: "error", + text: serverResponse.message + }); + return; + } + createNotification({ title: "Bad Request", type: "error", text: serverResponse.message }); + } + } + }), defaultOptions: { queries: { refetchOnWindowFocus: false, diff --git a/frontend/src/styles/globals.css b/frontend/src/styles/globals.css index a47d388316..9a1295d191 100644 --- a/frontend/src/styles/globals.css +++ b/frontend/src/styles/globals.css @@ -5,6 +5,14 @@ html { @apply overflow-hidden; } +:root { + --toastify-color-dark: theme(colors.mineshaft.700); +} + +.Toastify__toast { + @apply rounded-md; +} + .rdp-day, .rdp-nav_button { @apply rounded-md hover:text-mineshaft-500; diff --git a/frontend/src/views/IntegrationsPage/IntegrationsPage.tsx b/frontend/src/views/IntegrationsPage/IntegrationsPage.tsx index be4bee7af1..9f51ac1375 100644 --- a/frontend/src/views/IntegrationsPage/IntegrationsPage.tsx +++ b/frontend/src/views/IntegrationsPage/IntegrationsPage.tsx @@ -1,7 +1,7 @@ import { useCallback, useEffect } from "react"; import { useTranslation } from "react-i18next"; -import { useNotificationContext } from "@app/components/context/Notifications/NotificationProvider"; +import { createNotification } from "@app/components/notifications"; import { Button, Modal, ModalContent } from "@app/components/v2"; import { ProjectPermissionActions, ProjectPermissionSub, useWorkspace } from "@app/context"; import { withProjectPermission } from "@app/hoc"; @@ -31,7 +31,7 @@ type Props = { export const IntegrationsPage = withProjectPermission( ({ frameworkIntegrations }: Props) => { const { t } = useTranslation(); - const { createNotification } = useNotificationContext(); + const { currentWorkspace } = useWorkspace(); const workspaceId = currentWorkspace?.id || ""; diff --git a/frontend/src/views/IntegrationsPage/components/CloudIntegrationSection/CloudIntegrationSection.tsx b/frontend/src/views/IntegrationsPage/components/CloudIntegrationSection/CloudIntegrationSection.tsx index a1b9787dd5..5a0d85851b 100644 --- a/frontend/src/views/IntegrationsPage/components/CloudIntegrationSection/CloudIntegrationSection.tsx +++ b/frontend/src/views/IntegrationsPage/components/CloudIntegrationSection/CloudIntegrationSection.tsx @@ -2,7 +2,7 @@ import { useTranslation } from "react-i18next"; import { faCheck, faXmark } from "@fortawesome/free-solid-svg-icons"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; -import { useNotificationContext } from "@app/components/context/Notifications/NotificationProvider"; +import { createNotification } from "@app/components/notifications"; import { DeleteActionModal, Skeleton, Tooltip } from "@app/components/v2"; import { ProjectPermissionActions, ProjectPermissionSub, useProjectPermission } from "@app/context"; import { usePopUp } from "@app/hooks"; @@ -31,7 +31,7 @@ export const CloudIntegrationSection = ({ "deleteConfirmation" ] as const); const { permission } = useProjectPermission(); - const { createNotification } = useNotificationContext(); + const isEmpty = !isLoading && !cloudIntegrations?.length; diff --git a/frontend/src/views/Login/components/InitialStep/InitialStep.tsx b/frontend/src/views/Login/components/InitialStep/InitialStep.tsx index aebe4e507b..2e2d8f79bc 100644 --- a/frontend/src/views/Login/components/InitialStep/InitialStep.tsx +++ b/frontend/src/views/Login/components/InitialStep/InitialStep.tsx @@ -7,7 +7,7 @@ import { faLock } from "@fortawesome/free-solid-svg-icons"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import Error from "@app/components/basic/Error"; -import { useNotificationContext } from "@app/components/context/Notifications/NotificationProvider"; +import { createNotification } from "@app/components/notifications"; import attemptCliLogin from "@app/components/utilities/attemptCliLogin"; import attemptLogin from "@app/components/utilities/attemptLogin"; import { Button, Input } from "@app/components/v2"; @@ -25,7 +25,7 @@ type Props = { export const InitialStep = ({ setStep, email, setEmail, password, setPassword }: Props) => { const router = useRouter(); - const { createNotification } = useNotificationContext(); + const { t } = useTranslation(); const [isLoading, setIsLoading] = useState(false); const [loginError, setLoginError] = useState(false); diff --git a/frontend/src/views/Login/components/LDAPStep/LDAPStep.tsx b/frontend/src/views/Login/components/LDAPStep/LDAPStep.tsx index f097d5ff04..e23f16e04d 100644 --- a/frontend/src/views/Login/components/LDAPStep/LDAPStep.tsx +++ b/frontend/src/views/Login/components/LDAPStep/LDAPStep.tsx @@ -1,7 +1,7 @@ import { useState } from "react"; import { useTranslation } from "react-i18next"; -import { useNotificationContext } from "@app/components/context/Notifications/NotificationProvider"; +import { createNotification } from "@app/components/notifications"; import { Button, Input } from "@app/components/v2"; import { loginLDAPRedirect } from "@app/hooks/api/auth/queries"; @@ -10,7 +10,7 @@ type Props = { }; export const LDAPStep = ({ setStep }: Props) => { - const { createNotification } = useNotificationContext(); + const [organizationSlug, setOrganizationSlug] = useState(""); const [username, setUsername] = useState(""); const [password, setPassword] = useState(""); diff --git a/frontend/src/views/Login/components/MFAStep/MFAStep.tsx b/frontend/src/views/Login/components/MFAStep/MFAStep.tsx index acef4c3b1a..eaaac88a9b 100644 --- a/frontend/src/views/Login/components/MFAStep/MFAStep.tsx +++ b/frontend/src/views/Login/components/MFAStep/MFAStep.tsx @@ -6,7 +6,7 @@ import axios from "axios"; import jwt_decode from "jwt-decode"; import Error from "@app/components/basic/Error"; // which to notification -import { useNotificationContext } from "@app/components/context/Notifications/NotificationProvider"; +import { createNotification } from "@app/components/notifications"; import attemptCliLoginMfa from "@app/components/utilities/attemptCliLoginMfa"; import attemptLoginMfa from "@app/components/utilities/attemptLoginMfa"; import { Button } from "@app/components/v2"; @@ -59,7 +59,7 @@ interface VerifyMfaTokenError { } export const MFAStep = ({ email, password, providerAuthToken }: Props) => { - const { createNotification } = useNotificationContext(); + const router = useRouter(); const [isLoading, setIsLoading] = useState(false); const [isLoadingResend, setIsLoadingResend] = useState(false); diff --git a/frontend/src/views/Login/components/PasswordStep/PasswordStep.tsx b/frontend/src/views/Login/components/PasswordStep/PasswordStep.tsx index 57250af518..f9b086f6d9 100644 --- a/frontend/src/views/Login/components/PasswordStep/PasswordStep.tsx +++ b/frontend/src/views/Login/components/PasswordStep/PasswordStep.tsx @@ -5,7 +5,7 @@ import { useRouter } from "next/router"; import axios from "axios"; import jwt_decode from "jwt-decode"; -import { useNotificationContext } from "@app/components/context/Notifications/NotificationProvider"; +import { createNotification } from "@app/components/notifications"; import attemptCliLogin from "@app/components/utilities/attemptCliLogin"; import attemptLogin from "@app/components/utilities/attemptLogin"; import { Button, Input } from "@app/components/v2"; @@ -31,7 +31,7 @@ export const PasswordStep = ({ setPassword, setStep }: Props) => { - const { createNotification } = useNotificationContext(); + const [isLoading, setIsLoading] = useState(false); const { t } = useTranslation(); const router = useRouter(); diff --git a/frontend/src/views/Org/MembersPage/components/OrgIdentityTab/components/IdentitySection/IdentityModal.tsx b/frontend/src/views/Org/MembersPage/components/OrgIdentityTab/components/IdentitySection/IdentityModal.tsx index f738bd2072..3038786063 100644 --- a/frontend/src/views/Org/MembersPage/components/OrgIdentityTab/components/IdentitySection/IdentityModal.tsx +++ b/frontend/src/views/Org/MembersPage/components/OrgIdentityTab/components/IdentitySection/IdentityModal.tsx @@ -3,7 +3,7 @@ import { Controller, useForm } from "react-hook-form"; import { yupResolver } from "@hookform/resolvers/yup"; import * as yup from "yup"; -import { useNotificationContext } from "@app/components/context/Notifications/NotificationProvider"; +import { createNotification } from "@app/components/notifications"; import { Button, FormControl, @@ -41,7 +41,7 @@ type Props = { }; export const IdentityModal = ({ popUp, /* handlePopUpOpen, */ handlePopUpToggle }: Props) => { - const { createNotification } = useNotificationContext(); + const { currentOrg } = useOrganization(); const orgId = currentOrg?.id || ""; diff --git a/frontend/src/views/Org/MembersPage/components/OrgIdentityTab/components/IdentitySection/IdentitySection.tsx b/frontend/src/views/Org/MembersPage/components/OrgIdentityTab/components/IdentitySection/IdentitySection.tsx index 1a67504eeb..c5ebf7c55b 100644 --- a/frontend/src/views/Org/MembersPage/components/OrgIdentityTab/components/IdentitySection/IdentitySection.tsx +++ b/frontend/src/views/Org/MembersPage/components/OrgIdentityTab/components/IdentitySection/IdentitySection.tsx @@ -2,7 +2,7 @@ import Link from "next/link"; import { faArrowUpRightFromSquare, faPlus } from "@fortawesome/free-solid-svg-icons"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; -import { useNotificationContext } from "@app/components/context/Notifications/NotificationProvider"; +import { createNotification } from "@app/components/notifications"; import { OrgPermissionCan } from "@app/components/permissions"; import { Button, DeleteActionModal } from "@app/components/v2"; import { OrgPermissionActions, OrgPermissionSubjects, useOrganization } from "@app/context"; @@ -20,7 +20,7 @@ export const IdentitySection = withPermission( const { currentOrg } = useOrganization(); const orgId = currentOrg?.id || ""; - const { createNotification } = useNotificationContext(); + const { mutateAsync: deleteMutateAsync } = useDeleteIdentity(); const { popUp, handlePopUpOpen, handlePopUpClose, handlePopUpToggle } = usePopUp([ "identity", diff --git a/frontend/src/views/Org/MembersPage/components/OrgIdentityTab/components/IdentitySection/IdentityTable.tsx b/frontend/src/views/Org/MembersPage/components/OrgIdentityTab/components/IdentitySection/IdentityTable.tsx index 9f58d7cdb6..804c2d0542 100644 --- a/frontend/src/views/Org/MembersPage/components/OrgIdentityTab/components/IdentitySection/IdentityTable.tsx +++ b/frontend/src/views/Org/MembersPage/components/OrgIdentityTab/components/IdentitySection/IdentityTable.tsx @@ -1,7 +1,7 @@ import { faKey, faLock, faPencil, faServer, faXmark } from "@fortawesome/free-solid-svg-icons"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; -import { useNotificationContext } from "@app/components/context/Notifications/NotificationProvider"; +import { createNotification } from "@app/components/notifications"; import { OrgPermissionCan } from "@app/components/permissions"; import { EmptyState, @@ -44,7 +44,7 @@ type Props = { }; export const IdentityTable = ({ handlePopUpOpen }: Props) => { - const { createNotification } = useNotificationContext(); + const { currentOrg } = useOrganization(); const orgId = currentOrg?.id || ""; diff --git a/frontend/src/views/Org/MembersPage/components/OrgIdentityTab/components/IdentitySection/IdentityUniversalAuthClientSecretModal.tsx b/frontend/src/views/Org/MembersPage/components/OrgIdentityTab/components/IdentitySection/IdentityUniversalAuthClientSecretModal.tsx index d10afd6f63..11ad28f7be 100644 --- a/frontend/src/views/Org/MembersPage/components/OrgIdentityTab/components/IdentitySection/IdentityUniversalAuthClientSecretModal.tsx +++ b/frontend/src/views/Org/MembersPage/components/OrgIdentityTab/components/IdentitySection/IdentityUniversalAuthClientSecretModal.tsx @@ -7,7 +7,7 @@ import { yupResolver } from "@hookform/resolvers/yup"; import { format } from "date-fns"; import * as yup from "yup"; -import { useNotificationContext } from "@app/components/context/Notifications/NotificationProvider"; +import { createNotification } from "@app/components/notifications"; import { Button, DeleteActionModal, @@ -66,7 +66,7 @@ export const IdentityUniversalAuthClientSecretModal = ({ handlePopUpToggle }: Props) => { const { t } = useTranslation(); - const { createNotification } = useNotificationContext(); + const [token, setToken] = useState(""); const [isClientSecretCopied, setIsClientSecretCopied] = useToggle(false); const [isClientIdCopied, setIsClientIdCopied] = useToggle(false); diff --git a/frontend/src/views/Org/MembersPage/components/OrgIdentityTab/components/IdentitySection/IdentityUniversalAuthForm.tsx b/frontend/src/views/Org/MembersPage/components/OrgIdentityTab/components/IdentitySection/IdentityUniversalAuthForm.tsx index 150f13808c..d8b4ac0429 100644 --- a/frontend/src/views/Org/MembersPage/components/OrgIdentityTab/components/IdentitySection/IdentityUniversalAuthForm.tsx +++ b/frontend/src/views/Org/MembersPage/components/OrgIdentityTab/components/IdentitySection/IdentityUniversalAuthForm.tsx @@ -5,7 +5,7 @@ import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { yupResolver } from "@hookform/resolvers/yup"; import * as yup from "yup"; -import { useNotificationContext } from "@app/components/context/Notifications/NotificationProvider"; +import { createNotification } from "@app/components/notifications"; import { Button, FormControl, IconButton, Input } from "@app/components/v2"; import { useOrganization, useSubscription } from "@app/context"; import { @@ -63,7 +63,7 @@ export const IdentityUniversalAuthForm = ({ handlePopUpToggle, identityAuthMethodData }: Props) => { - const { createNotification } = useNotificationContext(); + const { currentOrg } = useOrganization(); const orgId = currentOrg?.id || ""; const { subscription } = useSubscription(); diff --git a/frontend/src/views/Org/MembersPage/components/OrgMembersTab/components/OrgMembersSection/AddOrgMemberModal.tsx b/frontend/src/views/Org/MembersPage/components/OrgMembersTab/components/OrgMembersSection/AddOrgMemberModal.tsx index e893998e3b..aedeb369a7 100644 --- a/frontend/src/views/Org/MembersPage/components/OrgMembersTab/components/OrgMembersSection/AddOrgMemberModal.tsx +++ b/frontend/src/views/Org/MembersPage/components/OrgMembersTab/components/OrgMembersSection/AddOrgMemberModal.tsx @@ -4,7 +4,7 @@ import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { yupResolver } from "@hookform/resolvers/yup"; import * as yup from "yup"; -import { useNotificationContext } from "@app/components/context/Notifications/NotificationProvider"; +import { createNotification } from "@app/components/notifications"; import { Button, FormControl, IconButton, Input, Modal, ModalContent } from "@app/components/v2"; import { useOrganization } from "@app/context"; import { useToggle } from "@app/hooks"; @@ -30,7 +30,7 @@ export const AddOrgMemberModal = ({ completeInviteLink, setCompleteInviteLink }: Props) => { - const { createNotification } = useNotificationContext(); + const { currentOrg } = useOrganization(); const { data: serverDetails } = useFetchServerStatus(); diff --git a/frontend/src/views/Org/MembersPage/components/OrgMembersTab/components/OrgMembersSection/OrgMembersSection.tsx b/frontend/src/views/Org/MembersPage/components/OrgMembersTab/components/OrgMembersSection/OrgMembersSection.tsx index b022f7b623..17f32369c5 100644 --- a/frontend/src/views/Org/MembersPage/components/OrgMembersTab/components/OrgMembersSection/OrgMembersSection.tsx +++ b/frontend/src/views/Org/MembersPage/components/OrgMembersTab/components/OrgMembersSection/OrgMembersSection.tsx @@ -2,7 +2,7 @@ import { useState } from "react"; import { faPlus } from "@fortawesome/free-solid-svg-icons"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; -import { useNotificationContext } from "@app/components/context/Notifications/NotificationProvider"; +import { createNotification } from "@app/components/notifications"; import { OrgPermissionCan } from "@app/components/permissions"; import { Button, @@ -23,7 +23,7 @@ import { AddOrgMemberModal } from "./AddOrgMemberModal"; import { OrgMembersTable } from "./OrgMembersTable"; export const OrgMembersSection = () => { - const { createNotification } = useNotificationContext(); + const { subscription } = useSubscription(); const { currentOrg } = useOrganization(); const orgId = currentOrg?.id ?? ""; diff --git a/frontend/src/views/Org/MembersPage/components/OrgMembersTab/components/OrgMembersSection/OrgMembersTable.tsx b/frontend/src/views/Org/MembersPage/components/OrgMembersTab/components/OrgMembersSection/OrgMembersTable.tsx index c32a54cfef..e71ba14b8f 100644 --- a/frontend/src/views/Org/MembersPage/components/OrgMembersTab/components/OrgMembersSection/OrgMembersTable.tsx +++ b/frontend/src/views/Org/MembersPage/components/OrgMembersTab/components/OrgMembersSection/OrgMembersTable.tsx @@ -2,7 +2,7 @@ import { useCallback, useMemo, useState } from "react"; import { faMagnifyingGlass, faUsers, faXmark } from "@fortawesome/free-solid-svg-icons"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; -import { useNotificationContext } from "@app/components/context/Notifications/NotificationProvider"; +import { createNotification } from "@app/components/notifications"; import { OrgPermissionCan } from "@app/components/permissions"; import { Button, @@ -49,7 +49,7 @@ type Props = { }; export const OrgMembersTable = ({ handlePopUpOpen, setCompleteInviteLink }: Props) => { - const { createNotification } = useNotificationContext(); + const { subscription } = useSubscription(); const { currentOrg } = useOrganization(); const { user } = useUser(); diff --git a/frontend/src/views/Org/MembersPage/components/OrgRoleTabSection/OrgRoleModifySection/OrgRoleModifySection.tsx b/frontend/src/views/Org/MembersPage/components/OrgRoleTabSection/OrgRoleModifySection/OrgRoleModifySection.tsx index 106da70471..773b99cfc8 100644 --- a/frontend/src/views/Org/MembersPage/components/OrgRoleTabSection/OrgRoleModifySection/OrgRoleModifySection.tsx +++ b/frontend/src/views/Org/MembersPage/components/OrgRoleTabSection/OrgRoleModifySection/OrgRoleModifySection.tsx @@ -13,7 +13,7 @@ import { import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { zodResolver } from "@hookform/resolvers/zod"; -import { useNotificationContext } from "@app/components/context/Notifications/NotificationProvider"; +import { createNotification } from "@app/components/notifications"; import { Button, FormControl, Input } from "@app/components/v2"; import { useOrganization } from "@app/context"; import { useCreateOrgRole, useUpdateOrgRole } from "@app/hooks/api"; @@ -100,7 +100,7 @@ export const OrgRoleModifySection = ({ role, onGoBack }: Props) => { const isNonEditable = ["owner", "admin", "member", "no-access"].includes(role?.slug || ""); const isNewRole = !role?.slug; - const { createNotification } = useNotificationContext(); + const { currentOrg } = useOrganization(); const orgId = currentOrg?.id || ""; const { diff --git a/frontend/src/views/Org/MembersPage/components/OrgRoleTabSection/OrgRoleTable.tsx b/frontend/src/views/Org/MembersPage/components/OrgRoleTabSection/OrgRoleTable.tsx index 0b64b5674d..e2086a6ab2 100644 --- a/frontend/src/views/Org/MembersPage/components/OrgRoleTabSection/OrgRoleTable.tsx +++ b/frontend/src/views/Org/MembersPage/components/OrgRoleTabSection/OrgRoleTable.tsx @@ -2,7 +2,7 @@ import { useState } from "react"; import { faEdit, faMagnifyingGlass, faPlus, faTrash } from "@fortawesome/free-solid-svg-icons"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; -import { useNotificationContext } from "@app/components/context/Notifications/NotificationProvider"; +import { createNotification } from "@app/components/notifications"; import { OrgPermissionCan } from "@app/components/permissions"; import { Button, @@ -31,7 +31,7 @@ export const OrgRoleTable = ({ onSelectRole }: Props) => { const [searchRoles, setSearchRoles] = useState(""); const { currentOrg } = useOrganization(); const orgId = currentOrg?.id || ""; - const { createNotification } = useNotificationContext(); + const { popUp, handlePopUpOpen, handlePopUpClose } = usePopUp(["deleteRole"] as const); const { data: roles, isLoading: isRolesLoading } = useGetOrgRoles(orgId); diff --git a/frontend/src/views/Org/components/CreateOrgModal.tsx b/frontend/src/views/Org/components/CreateOrgModal.tsx index e7a17bb0be..a5eb4f9e1d 100644 --- a/frontend/src/views/Org/components/CreateOrgModal.tsx +++ b/frontend/src/views/Org/components/CreateOrgModal.tsx @@ -4,7 +4,7 @@ import { useRouter } from "next/router"; import { zodResolver } from "@hookform/resolvers/zod"; import z from "zod"; -import { useNotificationContext } from "@app/components/context/Notifications/NotificationProvider"; +import { createNotification } from "@app/components/notifications"; import { Button, FormControl, Input, Modal, ModalContent } from "@app/components/v2"; import { useCreateOrg, useSelectOrganization } from "@app/hooks/api"; @@ -22,7 +22,7 @@ interface CreateOrgModalProps { } export const CreateOrgModal: FC = ({ isOpen, onClose }) => { - const { createNotification } = useNotificationContext(); + const router = useRouter(); const { diff --git a/frontend/src/views/Project/IPAllowListPage/components/IPAllowlistModal.tsx b/frontend/src/views/Project/IPAllowListPage/components/IPAllowlistModal.tsx index 8cdbb11221..47c70208c8 100644 --- a/frontend/src/views/Project/IPAllowListPage/components/IPAllowlistModal.tsx +++ b/frontend/src/views/Project/IPAllowListPage/components/IPAllowlistModal.tsx @@ -3,7 +3,7 @@ import { Controller, useForm } from "react-hook-form"; import { yupResolver } from "@hookform/resolvers/yup"; import * as yup from "yup"; -import { useNotificationContext } from "@app/components/context/Notifications/NotificationProvider"; +import { createNotification } from "@app/components/notifications"; import { Button, FormControl, Input, Modal, ModalContent } from "@app/components/v2"; import { useWorkspace } from "@app/context"; import { useAddTrustedIp, useGetMyIp, useUpdateTrustedIp } from "@app/hooks/api"; @@ -25,7 +25,7 @@ type Props = { }; export const IPAllowlistModal = ({ popUp, handlePopUpClose, handlePopUpToggle }: Props) => { - const { createNotification } = useNotificationContext(); + const { data, isLoading } = useGetMyIp(); const { currentWorkspace } = useWorkspace(); diff --git a/frontend/src/views/Project/IPAllowListPage/components/IPAllowlistSection.tsx b/frontend/src/views/Project/IPAllowListPage/components/IPAllowlistSection.tsx index 8723512044..c09ff774e2 100644 --- a/frontend/src/views/Project/IPAllowListPage/components/IPAllowlistSection.tsx +++ b/frontend/src/views/Project/IPAllowListPage/components/IPAllowlistSection.tsx @@ -1,7 +1,7 @@ import { faPlus } from "@fortawesome/free-solid-svg-icons"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; -import { useNotificationContext } from "@app/components/context/Notifications/NotificationProvider"; +import { createNotification } from "@app/components/notifications"; import { ProjectPermissionCan } from "@app/components/permissions"; import { Button, DeleteActionModal, UpgradePlanModal } from "@app/components/v2"; import { @@ -17,7 +17,7 @@ import { IPAllowlistModal } from "./IPAllowlistModal"; import { IPAllowlistTable } from "./IPAllowlistTable"; export const IPAllowlistSection = () => { - const { createNotification } = useNotificationContext(); + const { mutateAsync } = useDeleteTrustedIp(); const { subscription } = useSubscription(); const { currentWorkspace } = useWorkspace(); diff --git a/frontend/src/views/Project/MembersPage/components/IdentityTab/components/IdentitySection/IdentityModal.tsx b/frontend/src/views/Project/MembersPage/components/IdentityTab/components/IdentitySection/IdentityModal.tsx index 309a43683b..72d39537ef 100644 --- a/frontend/src/views/Project/MembersPage/components/IdentityTab/components/IdentitySection/IdentityModal.tsx +++ b/frontend/src/views/Project/MembersPage/components/IdentityTab/components/IdentitySection/IdentityModal.tsx @@ -4,7 +4,7 @@ import Link from "next/link"; import { yupResolver } from "@hookform/resolvers/yup"; import * as yup from "yup"; -import { useNotificationContext } from "@app/components/context/Notifications/NotificationProvider"; +import { createNotification } from "@app/components/notifications"; import { Button, FormControl, Modal, ModalContent, Select, SelectItem } from "@app/components/v2"; import { useOrganization, useWorkspace } from "@app/context"; import { @@ -30,7 +30,7 @@ type Props = { }; export const IdentityModal = ({ popUp, handlePopUpToggle }: Props) => { - const { createNotification } = useNotificationContext(); + const { currentOrg } = useOrganization(); const { currentWorkspace } = useWorkspace(); diff --git a/frontend/src/views/Project/MembersPage/components/IdentityTab/components/IdentitySection/IdentityRoles.tsx b/frontend/src/views/Project/MembersPage/components/IdentityTab/components/IdentitySection/IdentityRoles.tsx index 82d9a81797..6ff10cfa83 100644 --- a/frontend/src/views/Project/MembersPage/components/IdentityTab/components/IdentitySection/IdentityRoles.tsx +++ b/frontend/src/views/Project/MembersPage/components/IdentityTab/components/IdentitySection/IdentityRoles.tsx @@ -6,7 +6,7 @@ import { zodResolver } from "@hookform/resolvers/zod"; import { twMerge } from "tailwind-merge"; import { z } from "zod"; -import { useNotificationContext } from "@app/components/context/Notifications/NotificationProvider"; +import { createNotification } from "@app/components/notifications"; import { Button, Checkbox, @@ -207,7 +207,7 @@ export const IdentityRoles = ({ identityId }: TMemberRolesProp) => { const { currentWorkspace } = useWorkspace(); - const { createNotification } = useNotificationContext(); + const { popUp, handlePopUpToggle } = usePopUp(["editRole"] as const); const [searchRoles, setSearchRoles] = useState(""); diff --git a/frontend/src/views/Project/MembersPage/components/IdentityTab/components/IdentitySection/IdentitySection.tsx b/frontend/src/views/Project/MembersPage/components/IdentityTab/components/IdentitySection/IdentitySection.tsx index e0770ad9aa..4410bc6391 100644 --- a/frontend/src/views/Project/MembersPage/components/IdentityTab/components/IdentitySection/IdentitySection.tsx +++ b/frontend/src/views/Project/MembersPage/components/IdentityTab/components/IdentitySection/IdentitySection.tsx @@ -2,7 +2,7 @@ import Link from "next/link"; import { faArrowUpRightFromSquare, faPlus } from "@fortawesome/free-solid-svg-icons"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; -import { useNotificationContext } from "@app/components/context/Notifications/NotificationProvider"; +import { createNotification } from "@app/components/notifications"; import { ProjectPermissionCan } from "@app/components/permissions"; import { Button, DeleteActionModal } from "@app/components/v2"; import { ProjectPermissionActions, ProjectPermissionSub, useWorkspace } from "@app/context"; @@ -15,7 +15,7 @@ import { IdentityTable } from "./IdentityTable"; export const IdentitySection = withProjectPermission( () => { - const { createNotification } = useNotificationContext(); + const { currentWorkspace } = useWorkspace(); const workspaceId = currentWorkspace?.id ?? ""; diff --git a/frontend/src/views/Project/MembersPage/components/MemberListTab/MemberListTab.tsx b/frontend/src/views/Project/MembersPage/components/MemberListTab/MemberListTab.tsx index cfe8c863fb..342b3b9203 100644 --- a/frontend/src/views/Project/MembersPage/components/MemberListTab/MemberListTab.tsx +++ b/frontend/src/views/Project/MembersPage/components/MemberListTab/MemberListTab.tsx @@ -7,7 +7,7 @@ import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { zodResolver } from "@hookform/resolvers/zod"; import { z } from "zod"; -import { useNotificationContext } from "@app/components/context/Notifications/NotificationProvider"; +import { createNotification } from "@app/components/notifications"; import { ProjectPermissionCan } from "@app/components/permissions"; import { Button, @@ -57,7 +57,7 @@ const addMemberFormSchema = z.object({ type TAddMemberForm = z.infer; export const MemberListTab = () => { - const { createNotification } = useNotificationContext(); + const { t } = useTranslation(); const { currentOrg } = useOrganization(); diff --git a/frontend/src/views/Project/MembersPage/components/MemberListTab/MemberRoles.tsx b/frontend/src/views/Project/MembersPage/components/MemberListTab/MemberRoles.tsx index b71b224e38..50d8cd0d93 100644 --- a/frontend/src/views/Project/MembersPage/components/MemberListTab/MemberRoles.tsx +++ b/frontend/src/views/Project/MembersPage/components/MemberListTab/MemberRoles.tsx @@ -6,7 +6,7 @@ import { zodResolver } from "@hookform/resolvers/zod"; import { twMerge } from "tailwind-merge"; import { z } from "zod"; -import { useNotificationContext } from "@app/components/context/Notifications/NotificationProvider"; +import { createNotification } from "@app/components/notifications"; import { Button, Checkbox, @@ -209,7 +209,7 @@ export const MemberRoles = ({ onOpenUpgradeModal }: TMemberRolesProp) => { const { currentWorkspace } = useWorkspace(); - const { createNotification } = useNotificationContext(); + const { popUp, handlePopUpToggle } = usePopUp(["editRole"] as const); const [searchRoles, setSearchRoles] = useState(""); const { subscription } = useSubscription(); diff --git a/frontend/src/views/Project/MembersPage/components/ProjectRoleListTab/components/ProjectRoleList/ProjectRoleList.tsx b/frontend/src/views/Project/MembersPage/components/ProjectRoleListTab/components/ProjectRoleList/ProjectRoleList.tsx index a1f8c6b21a..aa29a363bb 100644 --- a/frontend/src/views/Project/MembersPage/components/ProjectRoleListTab/components/ProjectRoleList/ProjectRoleList.tsx +++ b/frontend/src/views/Project/MembersPage/components/ProjectRoleListTab/components/ProjectRoleList/ProjectRoleList.tsx @@ -2,7 +2,7 @@ import { useState } from "react"; import { faEdit, faMagnifyingGlass, faPlus, faTrash } from "@fortawesome/free-solid-svg-icons"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; -import { useNotificationContext } from "@app/components/context/Notifications/NotificationProvider"; +import { createNotification } from "@app/components/notifications"; import { ProjectPermissionCan } from "@app/components/permissions"; import { Button, @@ -29,7 +29,7 @@ type Props = { export const ProjectRoleList = ({ onSelectRole }: Props) => { const [searchRoles, setSearchRoles] = useState(""); - const { createNotification } = useNotificationContext(); + const { popUp, handlePopUpOpen, handlePopUpClose } = usePopUp(["deleteRole"] as const); const { currentWorkspace } = useWorkspace(); const workspaceId = currentWorkspace?.id || ""; diff --git a/frontend/src/views/Project/MembersPage/components/ProjectRoleListTab/components/ProjectRoleModifySection/ProjectRoleModifySection.tsx b/frontend/src/views/Project/MembersPage/components/ProjectRoleListTab/components/ProjectRoleModifySection/ProjectRoleModifySection.tsx index 8f09527d81..cf2e7e8b99 100644 --- a/frontend/src/views/Project/MembersPage/components/ProjectRoleListTab/components/ProjectRoleModifySection/ProjectRoleModifySection.tsx +++ b/frontend/src/views/Project/MembersPage/components/ProjectRoleListTab/components/ProjectRoleModifySection/ProjectRoleModifySection.tsx @@ -18,7 +18,7 @@ import { import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { zodResolver } from "@hookform/resolvers/zod"; -import { useNotificationContext } from "@app/components/context/Notifications/NotificationProvider"; +import { createNotification } from "@app/components/notifications"; import { Button, FormControl, Input } from "@app/components/v2"; import { ProjectPermissionSub, useWorkspace } from "@app/context"; import { useCreateProjectRole, useUpdateProjectRole } from "@app/hooks/api"; @@ -119,7 +119,7 @@ export const ProjectRoleModifySection = ({ role, onGoBack }: Props) => { const isNonEditable = ["admin", "member", "viewer", "no-access"].includes(role?.slug || ""); const isNewRole = !role?.slug; - const { createNotification } = useNotificationContext(); + const { currentWorkspace } = useWorkspace(); const workspaceId = currentWorkspace?.id || ""; diff --git a/frontend/src/views/Project/MembersPage/components/ServiceTokenTab/components/ServiceTokenSection/AddServiceTokenModal.tsx b/frontend/src/views/Project/MembersPage/components/ServiceTokenTab/components/ServiceTokenSection/AddServiceTokenModal.tsx index dccae48d15..eaad8b320d 100644 --- a/frontend/src/views/Project/MembersPage/components/ServiceTokenTab/components/ServiceTokenSection/AddServiceTokenModal.tsx +++ b/frontend/src/views/Project/MembersPage/components/ServiceTokenTab/components/ServiceTokenSection/AddServiceTokenModal.tsx @@ -9,7 +9,7 @@ import { yupResolver } from "@hookform/resolvers/yup"; import { AxiosError } from "axios"; import * as yup from "yup"; -import { useNotificationContext } from "@app/components/context/Notifications/NotificationProvider"; +import { createNotification } from "@app/components/notifications"; import { decryptAssymmetric, encryptSymmetric @@ -79,7 +79,7 @@ type Props = { export const AddServiceTokenModal = ({ popUp, handlePopUpToggle }: Props) => { const { t } = useTranslation(); - const { createNotification } = useNotificationContext(); + const { currentWorkspace } = useWorkspace(); const { control, diff --git a/frontend/src/views/Project/MembersPage/components/ServiceTokenTab/components/ServiceTokenSection/ServiceTokenSection.tsx b/frontend/src/views/Project/MembersPage/components/ServiceTokenTab/components/ServiceTokenSection/ServiceTokenSection.tsx index 1f2280f413..46e9e2ceb8 100644 --- a/frontend/src/views/Project/MembersPage/components/ServiceTokenTab/components/ServiceTokenSection/ServiceTokenSection.tsx +++ b/frontend/src/views/Project/MembersPage/components/ServiceTokenTab/components/ServiceTokenSection/ServiceTokenSection.tsx @@ -2,7 +2,7 @@ import { useTranslation } from "react-i18next"; import { faPlus } from "@fortawesome/free-solid-svg-icons"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; -import { useNotificationContext } from "@app/components/context/Notifications/NotificationProvider"; +import { createNotification } from "@app/components/notifications"; import { ProjectPermissionCan } from "@app/components/permissions"; import { Button, DeleteActionModal } from "@app/components/v2"; import { ProjectPermissionActions, ProjectPermissionSub } from "@app/context"; @@ -18,7 +18,7 @@ type DeleteModalData = { name: string; id: string }; export const ServiceTokenSection = withProjectPermission( () => { const { t } = useTranslation(); - const { createNotification } = useNotificationContext(); + const deleteServiceToken = useDeleteServiceToken(); const { popUp, handlePopUpToggle, handlePopUpClose, handlePopUpOpen } = usePopUp([ diff --git a/frontend/src/views/SecretApprovalPage/components/SecretApprovalPolicyList/SecretApprovalPolicyList.tsx b/frontend/src/views/SecretApprovalPage/components/SecretApprovalPolicyList/SecretApprovalPolicyList.tsx index 11927a2b1a..345ff7d52e 100644 --- a/frontend/src/views/SecretApprovalPage/components/SecretApprovalPolicyList/SecretApprovalPolicyList.tsx +++ b/frontend/src/views/SecretApprovalPage/components/SecretApprovalPolicyList/SecretApprovalPolicyList.tsx @@ -1,7 +1,7 @@ import { faFileShield, faPlus } from "@fortawesome/free-solid-svg-icons"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; -import { useNotificationContext } from "@app/components/context/Notifications/NotificationProvider"; +import { createNotification } from "@app/components/notifications"; import { ProjectPermissionCan } from "@app/components/permissions"; import { Button, @@ -46,7 +46,7 @@ export const SecretApprovalPolicyList = ({ workspaceId }: Props) => { ] as const); const { permission } = useProjectPermission(); const { subscription } = useSubscription(); - const { createNotification } = useNotificationContext(); + const { data: members } = useGetWorkspaceUsers(workspaceId); const { data: policies, isLoading: isPoliciesLoading } = useGetSecretApprovalPolicies({ diff --git a/frontend/src/views/SecretApprovalPage/components/SecretApprovalPolicyList/components/SecretPolicyForm.tsx b/frontend/src/views/SecretApprovalPage/components/SecretApprovalPolicyList/components/SecretPolicyForm.tsx index b439a54b40..eb9d5303ad 100644 --- a/frontend/src/views/SecretApprovalPage/components/SecretApprovalPolicyList/components/SecretPolicyForm.tsx +++ b/frontend/src/views/SecretApprovalPage/components/SecretApprovalPolicyList/components/SecretPolicyForm.tsx @@ -5,7 +5,7 @@ import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { zodResolver } from "@hookform/resolvers/zod"; import { z } from "zod"; -import { useNotificationContext } from "@app/components/context/Notifications/NotificationProvider"; +import { createNotification } from "@app/components/notifications"; import { Button, DropdownMenu, @@ -65,7 +65,7 @@ export const SecretPolicyForm = ({ values: editValues ? { ...editValues, environment: editValues.environment.slug } : undefined }); const { currentWorkspace } = useWorkspace(); - const { createNotification } = useNotificationContext(); + const environments = currentWorkspace?.environments || []; useEffect(() => { diff --git a/frontend/src/views/SecretApprovalPage/components/SecretApprovalRequest/components/SecretApprovalRequestAction.tsx b/frontend/src/views/SecretApprovalPage/components/SecretApprovalRequest/components/SecretApprovalRequestAction.tsx index 9ccd76e77a..51f26a5493 100644 --- a/frontend/src/views/SecretApprovalPage/components/SecretApprovalRequest/components/SecretApprovalRequestAction.tsx +++ b/frontend/src/views/SecretApprovalPage/components/SecretApprovalRequest/components/SecretApprovalRequestAction.tsx @@ -9,7 +9,7 @@ import { import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { twMerge } from "tailwind-merge"; -import { useNotificationContext } from "@app/components/context/Notifications/NotificationProvider"; +import { createNotification } from "@app/components/notifications"; import { Button } from "@app/components/v2"; import { usePerformSecretApprovalRequestMerge, @@ -37,7 +37,7 @@ export const SecretApprovalRequestAction = ({ workspaceId, canApprove }: Props) => { - const { createNotification } = useNotificationContext(); + const { mutateAsync: performSecretApprovalMerge, isLoading: isMerging } = usePerformSecretApprovalRequestMerge(); diff --git a/frontend/src/views/SecretApprovalPage/components/SecretApprovalRequest/components/SecretApprovalRequestChanges.tsx b/frontend/src/views/SecretApprovalPage/components/SecretApprovalRequest/components/SecretApprovalRequestChanges.tsx index 142a68050d..e1437b5637 100644 --- a/frontend/src/views/SecretApprovalPage/components/SecretApprovalRequest/components/SecretApprovalRequestChanges.tsx +++ b/frontend/src/views/SecretApprovalPage/components/SecretApprovalRequest/components/SecretApprovalRequestChanges.tsx @@ -11,7 +11,7 @@ import { import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { twMerge } from "tailwind-merge"; -import { useNotificationContext } from "@app/components/context/Notifications/NotificationProvider"; +import { createNotification } from "@app/components/notifications"; import { Button, ContentLoader, EmptyState, IconButton, Tooltip } from "@app/components/v2"; import { useUser } from "@app/context"; import { @@ -83,7 +83,7 @@ export const SecretApprovalRequestChanges = ({ workspaceId, members = {} }: Props) => { - const { createNotification } = useNotificationContext(); + const { user } = useUser(); const { data: decryptFileKey } = useGetUserWsKey(workspaceId); const { diff --git a/frontend/src/views/SecretMainPage/SecretMainPage.tsx b/frontend/src/views/SecretMainPage/SecretMainPage.tsx index fcb0775122..270fd8c650 100644 --- a/frontend/src/views/SecretMainPage/SecretMainPage.tsx +++ b/frontend/src/views/SecretMainPage/SecretMainPage.tsx @@ -5,8 +5,8 @@ import { subject } from "@casl/ability"; import { faArrowDown, faArrowUp } from "@fortawesome/free-solid-svg-icons"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; -import { useNotificationContext } from "@app/components/context/Notifications/NotificationProvider"; import NavHeader from "@app/components/navigation/NavHeader"; +import { createNotification } from "@app/components/notifications"; import { PermissionDeniedBanner } from "@app/components/permissions"; import { ContentLoader } from "@app/components/v2"; import { @@ -53,7 +53,7 @@ export const SecretMainPage = () => { const { currentWorkspace, isLoading: isWorkspaceLoading } = useWorkspace(); const router = useRouter(); const { permission } = useProjectPermission(); - const { createNotification } = useNotificationContext(); + const [isVisible, setIsVisible] = useState(false); const [sortDir, setSortDir] = useState(SortDir.ASC); diff --git a/frontend/src/views/SecretMainPage/components/ActionBar/ActionBar.tsx b/frontend/src/views/SecretMainPage/components/ActionBar/ActionBar.tsx index 701d649cf0..13869b3f2d 100644 --- a/frontend/src/views/SecretMainPage/components/ActionBar/ActionBar.tsx +++ b/frontend/src/views/SecretMainPage/components/ActionBar/ActionBar.tsx @@ -20,7 +20,7 @@ import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import FileSaver from "file-saver"; import { twMerge } from "tailwind-merge"; -import { useNotificationContext } from "@app/components/context/Notifications/NotificationProvider"; +import { createNotification } from "@app/components/notifications"; import { ProjectPermissionCan } from "@app/components/permissions"; import { Button, @@ -105,7 +105,6 @@ export const ActionBar = ({ "upgradePlan" ] as const); const { subscription } = useSubscription(); - const { createNotification } = useNotificationContext(); const { openPopUp } = usePopUpAction(); const { mutateAsync: createFolder } = useCreateFolder(); diff --git a/frontend/src/views/SecretMainPage/components/ActionBar/CreateDynamicSecretForm/SqlDatabaseInputForm.tsx b/frontend/src/views/SecretMainPage/components/ActionBar/CreateDynamicSecretForm/SqlDatabaseInputForm.tsx index ace717bd37..c0dff20f5f 100644 --- a/frontend/src/views/SecretMainPage/components/ActionBar/CreateDynamicSecretForm/SqlDatabaseInputForm.tsx +++ b/frontend/src/views/SecretMainPage/components/ActionBar/CreateDynamicSecretForm/SqlDatabaseInputForm.tsx @@ -3,8 +3,8 @@ import { zodResolver } from "@hookform/resolvers/zod"; import ms from "ms"; import { z } from "zod"; -import { useNotificationContext } from "@app/components/context/Notifications/NotificationProvider"; import { TtlFormLabel } from "@app/components/features"; +import { createNotification } from "@app/components/notifications"; import { Accordion, AccordionContent, @@ -91,7 +91,7 @@ export const SqlDatabaseInputForm = ({ } } }); - const { createNotification } = useNotificationContext(); + const createDynamicSecret = useCreateDynamicSecret(); const handleCreateDynamicSecret = async ({ name, maxTTL, provider, defaultTTL }: TForm) => { diff --git a/frontend/src/views/SecretMainPage/components/ActionBar/CreateSecretImportForm.tsx b/frontend/src/views/SecretMainPage/components/ActionBar/CreateSecretImportForm.tsx index c178e75143..fa8340465e 100644 --- a/frontend/src/views/SecretMainPage/components/ActionBar/CreateSecretImportForm.tsx +++ b/frontend/src/views/SecretMainPage/components/ActionBar/CreateSecretImportForm.tsx @@ -3,7 +3,7 @@ import { zodResolver } from "@hookform/resolvers/zod"; import { AxiosError } from "axios"; import { z } from "zod"; -import { useNotificationContext } from "@app/components/context/Notifications/NotificationProvider"; +import { createNotification } from "@app/components/notifications"; import { Button, FormControl, @@ -55,7 +55,7 @@ export const CreateSecretImportForm = ({ const { currentWorkspace } = useWorkspace(); const environments = currentWorkspace?.environments || []; - const { createNotification } = useNotificationContext(); + const { mutateAsync: createSecretImport } = useCreateSecretImport(); diff --git a/frontend/src/views/SecretMainPage/components/CreateSecretForm/CreateSecretForm.tsx b/frontend/src/views/SecretMainPage/components/CreateSecretForm/CreateSecretForm.tsx index a8e1fb3363..23f8089d1d 100644 --- a/frontend/src/views/SecretMainPage/components/CreateSecretForm/CreateSecretForm.tsx +++ b/frontend/src/views/SecretMainPage/components/CreateSecretForm/CreateSecretForm.tsx @@ -2,7 +2,7 @@ import { Controller, useForm } from "react-hook-form"; import { zodResolver } from "@hookform/resolvers/zod"; import { z } from "zod"; -import { useNotificationContext } from "@app/components/context/Notifications/NotificationProvider"; +import { createNotification } from "@app/components/notifications"; import { Button, FormControl, Input, Modal, ModalContent, SecretInput } from "@app/components/v2"; import { useCreateSecretV3 } from "@app/hooks/api"; import { UserWsKeyPair } from "@app/hooks/api/types"; @@ -44,7 +44,7 @@ export const CreateSecretForm = ({ const { isOpen } = usePopUpState(PopUpNames.CreateSecretForm); const { closePopUp, togglePopUp } = usePopUpAction(); - const { createNotification } = useNotificationContext(); + const { mutateAsync: createSecretV3 } = useCreateSecretV3(); diff --git a/frontend/src/views/SecretMainPage/components/DynamicSecretListView/CreateDynamicSecretLease.tsx b/frontend/src/views/SecretMainPage/components/DynamicSecretListView/CreateDynamicSecretLease.tsx index 552b2fb1f8..3eb80c9b44 100644 --- a/frontend/src/views/SecretMainPage/components/DynamicSecretListView/CreateDynamicSecretLease.tsx +++ b/frontend/src/views/SecretMainPage/components/DynamicSecretListView/CreateDynamicSecretLease.tsx @@ -6,8 +6,8 @@ import { AnimatePresence, motion } from "framer-motion"; import ms from "ms"; import { z } from "zod"; -import { useNotificationContext } from "@app/components/context/Notifications/NotificationProvider"; import { TtlFormLabel } from "@app/components/features"; +import { createNotification } from "@app/components/notifications"; import { Button, FormControl, IconButton, Input, SecretInput, Tooltip } from "@app/components/v2"; import { useTimedReset } from "@app/hooks"; import { useCreateDynamicSecretLease } from "@app/hooks/api"; @@ -102,7 +102,7 @@ export const CreateDynamicSecretLease = ({ ttl: "1h" } }); - const { createNotification } = useNotificationContext(); + const createDynamicSecretLease = useCreateDynamicSecretLease(); diff --git a/frontend/src/views/SecretMainPage/components/DynamicSecretListView/DynamicSecretLease.tsx b/frontend/src/views/SecretMainPage/components/DynamicSecretListView/DynamicSecretLease.tsx index ae17e48518..49110c3bb5 100644 --- a/frontend/src/views/SecretMainPage/components/DynamicSecretListView/DynamicSecretLease.tsx +++ b/frontend/src/views/SecretMainPage/components/DynamicSecretListView/DynamicSecretLease.tsx @@ -9,7 +9,7 @@ import { import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { format, formatDistance } from "date-fns"; -import { useNotificationContext } from "@app/components/context/Notifications/NotificationProvider"; +import { createNotification } from "@app/components/notifications"; import { ProjectPermissionCan } from "@app/components/permissions"; import { Button, @@ -60,7 +60,7 @@ export const DynamicSecretLease = ({ path: secretPath, dynamicSecretName }); - const { createNotification } = useNotificationContext(); + const deleteDynamicSecretLease = useRevokeDynamicSecretLease(); diff --git a/frontend/src/views/SecretMainPage/components/DynamicSecretListView/DynamicSecretListView.tsx b/frontend/src/views/SecretMainPage/components/DynamicSecretListView/DynamicSecretListView.tsx index cfab8bfc2b..6b133d9459 100644 --- a/frontend/src/views/SecretMainPage/components/DynamicSecretListView/DynamicSecretListView.tsx +++ b/frontend/src/views/SecretMainPage/components/DynamicSecretListView/DynamicSecretListView.tsx @@ -7,7 +7,7 @@ import { } from "@fortawesome/free-solid-svg-icons"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; -import { useNotificationContext } from "@app/components/context/Notifications/NotificationProvider"; +import { createNotification } from "@app/components/notifications"; import { ProjectPermissionCan } from "@app/components/permissions"; import { Button, @@ -59,7 +59,7 @@ export const DynamicSecretListView = ({ "deleteDynamicSecret" ] as const); - const { createNotification } = useNotificationContext(); + const deleteDynamicSecret = useDeleteDynamicSecret(); const handleDynamicSecretDelete = async () => { diff --git a/frontend/src/views/SecretMainPage/components/DynamicSecretListView/EditDynamicSecretForm/EditDynamicSecretSqlProviderForm.tsx b/frontend/src/views/SecretMainPage/components/DynamicSecretListView/EditDynamicSecretForm/EditDynamicSecretSqlProviderForm.tsx index 7a91e0d3e0..8207b18924 100644 --- a/frontend/src/views/SecretMainPage/components/DynamicSecretListView/EditDynamicSecretForm/EditDynamicSecretSqlProviderForm.tsx +++ b/frontend/src/views/SecretMainPage/components/DynamicSecretListView/EditDynamicSecretForm/EditDynamicSecretSqlProviderForm.tsx @@ -3,8 +3,8 @@ import { zodResolver } from "@hookform/resolvers/zod"; import ms from "ms"; import { z } from "zod"; -import { useNotificationContext } from "@app/components/context/Notifications/NotificationProvider"; import { TtlFormLabel } from "@app/components/features"; +import { createNotification } from "@app/components/notifications"; import { Accordion, AccordionContent, @@ -94,7 +94,7 @@ export const EditDynamicSecretSqlProviderForm = ({ } } }); - const { createNotification } = useNotificationContext(); + const updateDynamicSecret = useUpdateDynamicSecret(); const handleUpdateDynamicSecret = async ({ inputs, maxTTL, defaultTTL, newName }: TForm) => { diff --git a/frontend/src/views/SecretMainPage/components/DynamicSecretListView/RenewDynamicSecretLease.tsx b/frontend/src/views/SecretMainPage/components/DynamicSecretListView/RenewDynamicSecretLease.tsx index b307c181c8..673c24a3cb 100644 --- a/frontend/src/views/SecretMainPage/components/DynamicSecretListView/RenewDynamicSecretLease.tsx +++ b/frontend/src/views/SecretMainPage/components/DynamicSecretListView/RenewDynamicSecretLease.tsx @@ -3,8 +3,8 @@ import { zodResolver } from "@hookform/resolvers/zod"; import ms from "ms"; import { z } from "zod"; -import { useNotificationContext } from "@app/components/context/Notifications/NotificationProvider"; import { TtlFormLabel } from "@app/components/features"; +import { createNotification } from "@app/components/notifications"; import { Button, FormControl, Input } from "@app/components/v2"; import { useRenewDynamicSecretLease } from "@app/hooks/api"; @@ -48,7 +48,7 @@ export const RenewDynamicSecretLease = ({ ttl: "1h" } }); - const { createNotification } = useNotificationContext(); + const renewDynamicSecretLease = useRenewDynamicSecretLease(); diff --git a/frontend/src/views/SecretMainPage/components/FolderListView/FolderListView.tsx b/frontend/src/views/SecretMainPage/components/FolderListView/FolderListView.tsx index 6fa9132f6d..55108535b1 100644 --- a/frontend/src/views/SecretMainPage/components/FolderListView/FolderListView.tsx +++ b/frontend/src/views/SecretMainPage/components/FolderListView/FolderListView.tsx @@ -3,7 +3,7 @@ import { subject } from "@casl/ability"; import { faClose, faFolder, faPencilSquare } from "@fortawesome/free-solid-svg-icons"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; -import { useNotificationContext } from "@app/components/context/Notifications/NotificationProvider"; +import { createNotification } from "@app/components/notifications"; import { ProjectPermissionCan } from "@app/components/permissions"; import { DeleteActionModal, IconButton, Modal, ModalContent } from "@app/components/v2"; import { ProjectPermissionActions, ProjectPermissionSub } from "@app/context"; @@ -35,7 +35,7 @@ export const FolderListView = ({ ] as const); const router = useRouter(); - const { createNotification } = useNotificationContext(); + const { mutateAsync: updateFolder } = useUpdateFolder(); const { mutateAsync: deleteFolder } = useDeleteFolder(); diff --git a/frontend/src/views/SecretMainPage/components/SecretDropzone/SecretDropzone.tsx b/frontend/src/views/SecretMainPage/components/SecretDropzone/SecretDropzone.tsx index a4f362a920..0155e5b312 100644 --- a/frontend/src/views/SecretMainPage/components/SecretDropzone/SecretDropzone.tsx +++ b/frontend/src/views/SecretMainPage/components/SecretDropzone/SecretDropzone.tsx @@ -6,7 +6,7 @@ import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { useQueryClient } from "@tanstack/react-query"; import { twMerge } from "tailwind-merge"; -import { useNotificationContext } from "@app/components/context/Notifications/NotificationProvider"; +import { createNotification } from "@app/components/notifications"; import { ProjectPermissionCan } from "@app/components/permissions"; // TODO:(akhilmhdh) convert all the util functions like this into a lib folder grouped by functionality import { parseDotEnv } from "@app/components/utilities/parseDotEnv"; @@ -60,7 +60,7 @@ export const SecretDropzone = ({ const { t } = useTranslation(); const [isDragActive, setDragActive] = useToggle(); const [isLoading, setIsLoading] = useToggle(); - const { createNotification } = useNotificationContext(); + const { popUp, handlePopUpToggle, handlePopUpOpen, handlePopUpClose } = usePopUp([ "importSecEnv", "overlapKeyWarning" @@ -119,8 +119,7 @@ export const SecretDropzone = ({ if (!file) { createNotification({ text: "You can't inject files from VS Code. Click 'Reveal in finder', and drag your file directly from the directory where it's located.", - type: "error", - timeoutMs: 10000 + type: "error" }); return; } diff --git a/frontend/src/views/SecretMainPage/components/SecretImportListView/SecretImportListView.tsx b/frontend/src/views/SecretMainPage/components/SecretImportListView/SecretImportListView.tsx index 39705fbb74..52a0673402 100644 --- a/frontend/src/views/SecretMainPage/components/SecretImportListView/SecretImportListView.tsx +++ b/frontend/src/views/SecretMainPage/components/SecretImportListView/SecretImportListView.tsx @@ -12,7 +12,7 @@ import { import { restrictToVerticalAxis } from "@dnd-kit/modifiers"; import { arrayMove, SortableContext, verticalListSortingStrategy } from "@dnd-kit/sortable"; -import { useNotificationContext } from "@app/components/context/Notifications/NotificationProvider"; +import { createNotification } from "@app/components/notifications"; import { DeleteActionModal } from "@app/components/v2"; import { usePopUp } from "@app/hooks"; import { useDeleteSecretImport, useUpdateSecretImport } from "@app/hooks/api"; @@ -90,7 +90,7 @@ export const SecretImportListView = ({ const { popUp, handlePopUpOpen, handlePopUpClose, handlePopUpToggle } = usePopUp([ "deleteSecretImport" ] as const); - const { createNotification } = useNotificationContext(); + const sensors = useSensors( useSensor(MouseSensor, {}), useSensor(TouchSensor, {}), diff --git a/frontend/src/views/SecretMainPage/components/SecretListView/SecretDetaiSidebar.tsx b/frontend/src/views/SecretMainPage/components/SecretListView/SecretDetaiSidebar.tsx index 092495597c..8f23a6ae75 100644 --- a/frontend/src/views/SecretMainPage/components/SecretListView/SecretDetaiSidebar.tsx +++ b/frontend/src/views/SecretMainPage/components/SecretListView/SecretDetaiSidebar.tsx @@ -13,7 +13,7 @@ import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { zodResolver } from "@hookform/resolvers/zod"; import { format } from "date-fns"; -import { useNotificationContext } from "@app/components/context/Notifications/NotificationProvider"; +import { createNotification } from "@app/components/notifications"; import { ProjectPermissionCan } from "@app/components/permissions"; import { Button, @@ -71,7 +71,7 @@ export const SecretDetailSidebar = ({ environment, secretPath }: Props) => { - const { createNotification } = useNotificationContext(); + const { register, control, diff --git a/frontend/src/views/SecretMainPage/components/SecretListView/SecretListView.tsx b/frontend/src/views/SecretMainPage/components/SecretListView/SecretListView.tsx index db57cb1449..6469351ea8 100644 --- a/frontend/src/views/SecretMainPage/components/SecretListView/SecretListView.tsx +++ b/frontend/src/views/SecretMainPage/components/SecretListView/SecretListView.tsx @@ -2,7 +2,7 @@ import { useCallback } from "react"; import { useQueryClient } from "@tanstack/react-query"; import { twMerge } from "tailwind-merge"; -import { useNotificationContext } from "@app/components/context/Notifications/NotificationProvider"; +import { createNotification } from "@app/components/notifications"; import { CreateTagModal } from "@app/components/tags/CreateTagModal"; import { DeleteActionModal } from "@app/components/v2"; import { usePopUp } from "@app/hooks"; @@ -89,7 +89,7 @@ export const SecretListView = ({ isVisible, isProtectedBranch = false }: Props) => { - const { createNotification } = useNotificationContext(); + const queryClient = useQueryClient(); const { popUp, handlePopUpToggle, handlePopUpOpen, handlePopUpClose } = usePopUp([ "deleteSecret", diff --git a/frontend/src/views/SecretMainPage/components/SnapshotView/SnapshotView.tsx b/frontend/src/views/SecretMainPage/components/SnapshotView/SnapshotView.tsx index d204ca7696..ff95f321b0 100644 --- a/frontend/src/views/SecretMainPage/components/SnapshotView/SnapshotView.tsx +++ b/frontend/src/views/SecretMainPage/components/SnapshotView/SnapshotView.tsx @@ -9,7 +9,7 @@ import { } from "@fortawesome/free-solid-svg-icons"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; -import { useNotificationContext } from "@app/components/context/Notifications/NotificationProvider"; +import { createNotification } from "@app/components/notifications"; import { ProjectPermissionCan } from "@app/components/permissions"; import { Button, ContentLoader, Input, Tag, Tooltip } from "@app/components/v2"; import { ProjectPermissionActions, ProjectPermissionSub } from "@app/context"; @@ -52,7 +52,7 @@ export const SnapshotView = ({ snapshotCount, onClickListSnapshot }: Props) => { - const { createNotification } = useNotificationContext(); + const [search, setSearch] = useState(""); const { mutateAsync: performRollback, isLoading: isRollingBack } = usePerformSecretRollback(); diff --git a/frontend/src/views/SecretOverviewPage/SecretOverviewPage.tsx b/frontend/src/views/SecretOverviewPage/SecretOverviewPage.tsx index 4b78411a92..c9680ad7bd 100644 --- a/frontend/src/views/SecretOverviewPage/SecretOverviewPage.tsx +++ b/frontend/src/views/SecretOverviewPage/SecretOverviewPage.tsx @@ -16,8 +16,8 @@ import { } from "@fortawesome/free-solid-svg-icons"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; -import { useNotificationContext } from "@app/components/context/Notifications/NotificationProvider"; import NavHeader from "@app/components/navigation/NavHeader"; +import { createNotification } from "@app/components/notifications"; import { ProjectPermissionCan } from "@app/components/permissions"; import { Button, @@ -71,7 +71,7 @@ import { SecretOverviewTableRow } from "./components/SecretOverviewTableRow"; export const SecretOverviewPage = () => { const { t } = useTranslation(); - const { createNotification } = useNotificationContext(); + const router = useRouter(); // this is to set expandable table width diff --git a/frontend/src/views/SecretOverviewPage/components/CreateSecretForm/CreateSecretForm.tsx b/frontend/src/views/SecretOverviewPage/components/CreateSecretForm/CreateSecretForm.tsx index 8c305af1a5..f7605aa93b 100644 --- a/frontend/src/views/SecretOverviewPage/components/CreateSecretForm/CreateSecretForm.tsx +++ b/frontend/src/views/SecretOverviewPage/components/CreateSecretForm/CreateSecretForm.tsx @@ -4,7 +4,7 @@ import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { zodResolver } from "@hookform/resolvers/zod"; import { z } from "zod"; -import { useNotificationContext } from "@app/components/context/Notifications/NotificationProvider"; +import { createNotification } from "@app/components/notifications"; import { Button, Checkbox, @@ -64,7 +64,7 @@ export const CreateSecretForm = ({ const workspaceId = currentWorkspace?.id || ""; const environments = currentWorkspace?.environments || []; - const { createNotification } = useNotificationContext(); + const { mutateAsync: createSecretV3 } = useCreateSecretV3(); const { mutateAsync: updateSecretV3 } = useUpdateSecretV3(); diff --git a/frontend/src/views/SecretOverviewPage/components/SecretOverviewTableRow/SecretEditRow.tsx b/frontend/src/views/SecretOverviewPage/components/SecretOverviewTableRow/SecretEditRow.tsx index 628e3d0083..e06a6d5002 100644 --- a/frontend/src/views/SecretOverviewPage/components/SecretOverviewTableRow/SecretEditRow.tsx +++ b/frontend/src/views/SecretOverviewPage/components/SecretOverviewTableRow/SecretEditRow.tsx @@ -4,7 +4,7 @@ import { faCheck, faCopy, faTrash, faXmark } from "@fortawesome/free-solid-svg-i import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { twMerge } from "tailwind-merge"; -import { useNotificationContext } from "@app/components/context/Notifications/NotificationProvider"; +import { createNotification } from "@app/components/notifications"; import { ProjectPermissionCan } from "@app/components/permissions"; import { IconButton, SecretInput, Tooltip } from "@app/components/v2"; import { ProjectPermissionActions, ProjectPermissionSub } from "@app/context"; @@ -49,7 +49,7 @@ export const SecretEditRow = ({ } }); const [isDeleting, setIsDeleting] = useToggle(); - const { createNotification } = useNotificationContext(); + const handleFormReset = () => { reset(); diff --git a/frontend/src/views/SecretOverviewPage/components/SecretOverviewTableRow/SecretRenameRow.tsx b/frontend/src/views/SecretOverviewPage/components/SecretOverviewTableRow/SecretRenameRow.tsx index 993997f4ad..8059f5e7b1 100644 --- a/frontend/src/views/SecretOverviewPage/components/SecretOverviewTableRow/SecretRenameRow.tsx +++ b/frontend/src/views/SecretOverviewPage/components/SecretOverviewTableRow/SecretRenameRow.tsx @@ -8,7 +8,7 @@ import { AnimatePresence, motion } from "framer-motion"; import { twMerge } from "tailwind-merge"; import { z } from "zod"; -import { useNotificationContext } from "@app/components/context/Notifications/NotificationProvider"; +import { createNotification } from "@app/components/notifications"; import { IconButton, Input, Spinner, Tooltip } from "@app/components/v2"; import { ProjectPermissionActions, @@ -37,7 +37,7 @@ type TFormSchema = z.infer; function SecretRenameRow({ environments, getSecretByKey, secretKey, secretPath }: Props) { const { currentWorkspace } = useWorkspace(); const { permission } = useProjectPermission(); - const { createNotification } = useNotificationContext(); + const secrets = environments.map((env) => getSecretByKey(env.slug, secretKey)); diff --git a/frontend/src/views/SecretRotationPage/SecretRotationPage.tsx b/frontend/src/views/SecretRotationPage/SecretRotationPage.tsx index 196304c70d..405cf004a8 100644 --- a/frontend/src/views/SecretRotationPage/SecretRotationPage.tsx +++ b/frontend/src/views/SecretRotationPage/SecretRotationPage.tsx @@ -13,7 +13,7 @@ import { import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { formatDistance } from "date-fns"; -import { useNotificationContext } from "@app/components/context/Notifications/NotificationProvider"; +import { createNotification } from "@app/components/notifications"; import { ProjectPermissionCan } from "@app/components/permissions"; import { Button, @@ -63,7 +63,7 @@ export const SecretRotationPage = withProjectPermission( const { currentWorkspace } = useWorkspace(); const { t } = useTranslation(); const { permission } = useProjectPermission(); - const { createNotification } = useNotificationContext(); + const { popUp, handlePopUpOpen, handlePopUpToggle, handlePopUpClose } = usePopUp([ "createRotation", "activeBot", diff --git a/frontend/src/views/SecretRotationPage/components/CreateRotationForm/CreateRotationForm.tsx b/frontend/src/views/SecretRotationPage/components/CreateRotationForm/CreateRotationForm.tsx index 37fae9389e..cdaeb32c40 100644 --- a/frontend/src/views/SecretRotationPage/components/CreateRotationForm/CreateRotationForm.tsx +++ b/frontend/src/views/SecretRotationPage/components/CreateRotationForm/CreateRotationForm.tsx @@ -1,7 +1,7 @@ import { useRef, useState } from "react"; import { AnimatePresence, motion } from "framer-motion"; -import { useNotificationContext } from "@app/components/context/Notifications/NotificationProvider"; +import { createNotification } from "@app/components/notifications"; import { Modal, ModalContent, Step, Stepper } from "@app/components/v2"; import { useCreateSecretRotation } from "@app/hooks/api"; import { TSecretRotationProviderTemplate } from "@app/hooks/api/types"; @@ -43,7 +43,7 @@ export const CreateRotationForm = ({ input?: Record; output?: TRotationOutputSchema; }>({}); - const { createNotification } = useNotificationContext(); + const { mutateAsync: createSecretRotation } = useCreateSecretRotation(); diff --git a/frontend/src/views/Settings/BillingSettingsPage/components/BillingDetailsTab/CompanyNameSection.tsx b/frontend/src/views/Settings/BillingSettingsPage/components/BillingDetailsTab/CompanyNameSection.tsx index 68360cc706..bf0b5c56ae 100644 --- a/frontend/src/views/Settings/BillingSettingsPage/components/BillingDetailsTab/CompanyNameSection.tsx +++ b/frontend/src/views/Settings/BillingSettingsPage/components/BillingDetailsTab/CompanyNameSection.tsx @@ -3,7 +3,7 @@ import { Controller, useForm } from "react-hook-form"; import { yupResolver } from "@hookform/resolvers/yup"; import * as yup from "yup"; -import { useNotificationContext } from "@app/components/context/Notifications/NotificationProvider"; +import { createNotification } from "@app/components/notifications"; import { OrgPermissionCan } from "@app/components/permissions"; import { Button, FormControl, Input } from "@app/components/v2"; import { OrgPermissionActions, OrgPermissionSubjects, useOrganization } from "@app/context"; @@ -16,7 +16,7 @@ const schema = yup .required(); export const CompanyNameSection = () => { - const { createNotification } = useNotificationContext(); + const { currentOrg } = useOrganization(); const { reset, control, handleSubmit } = useForm({ defaultValues: { diff --git a/frontend/src/views/Settings/BillingSettingsPage/components/BillingDetailsTab/InvoiceEmailSection.tsx b/frontend/src/views/Settings/BillingSettingsPage/components/BillingDetailsTab/InvoiceEmailSection.tsx index 47d4444641..d1fcf11804 100644 --- a/frontend/src/views/Settings/BillingSettingsPage/components/BillingDetailsTab/InvoiceEmailSection.tsx +++ b/frontend/src/views/Settings/BillingSettingsPage/components/BillingDetailsTab/InvoiceEmailSection.tsx @@ -3,7 +3,7 @@ import { Controller, useForm } from "react-hook-form"; import { yupResolver } from "@hookform/resolvers/yup"; import * as yup from "yup"; -import { useNotificationContext } from "@app/components/context/Notifications/NotificationProvider"; +import { createNotification } from "@app/components/notifications"; import { OrgPermissionCan } from "@app/components/permissions"; import { Button, FormControl, Input } from "@app/components/v2"; import { OrgPermissionActions, OrgPermissionSubjects, useOrganization } from "@app/context"; @@ -16,7 +16,7 @@ const schema = yup .required(); export const InvoiceEmailSection = () => { - const { createNotification } = useNotificationContext(); + const { currentOrg } = useOrganization(); const { reset, control, handleSubmit } = useForm({ defaultValues: { diff --git a/frontend/src/views/Settings/BillingSettingsPage/components/BillingDetailsTab/TaxIDModal.tsx b/frontend/src/views/Settings/BillingSettingsPage/components/BillingDetailsTab/TaxIDModal.tsx index 78810e0a05..15bfdf35b4 100644 --- a/frontend/src/views/Settings/BillingSettingsPage/components/BillingDetailsTab/TaxIDModal.tsx +++ b/frontend/src/views/Settings/BillingSettingsPage/components/BillingDetailsTab/TaxIDModal.tsx @@ -2,7 +2,7 @@ import { Controller, useForm } from "react-hook-form"; import { yupResolver } from "@hookform/resolvers/yup"; import * as yup from "yup"; -import { useNotificationContext } from "@app/components/context/Notifications/NotificationProvider"; +import { createNotification } from "@app/components/notifications"; import { Button, FormControl, @@ -85,7 +85,7 @@ type Props = { }; export const TaxIDModal = ({ popUp, handlePopUpClose, handlePopUpToggle }: Props) => { - const { createNotification } = useNotificationContext(); + const { currentOrg } = useOrganization(); const addOrgTaxId = useAddOrgTaxId(); diff --git a/frontend/src/views/Settings/OrgSettingsPage/components/OrgAuthTab/LDAPModal.tsx b/frontend/src/views/Settings/OrgSettingsPage/components/OrgAuthTab/LDAPModal.tsx index 8ecc595cbe..3734d685d6 100644 --- a/frontend/src/views/Settings/OrgSettingsPage/components/OrgAuthTab/LDAPModal.tsx +++ b/frontend/src/views/Settings/OrgSettingsPage/components/OrgAuthTab/LDAPModal.tsx @@ -3,7 +3,7 @@ import { Controller, useForm } from "react-hook-form"; import { zodResolver } from "@hookform/resolvers/zod"; import { z } from "zod"; -import { useNotificationContext } from "@app/components/context/Notifications/NotificationProvider"; +import { createNotification } from "@app/components/notifications"; import { Button, FormControl, Input, Modal, ModalContent, TextArea } from "@app/components/v2"; import { useOrganization } from "@app/context"; import { useCreateLDAPConfig, useGetLDAPConfig, useUpdateLDAPConfig } from "@app/hooks/api"; @@ -27,7 +27,7 @@ type Props = { export const LDAPModal = ({ popUp, handlePopUpClose, handlePopUpToggle }: Props) => { const { currentOrg } = useOrganization(); - const { createNotification } = useNotificationContext(); + const { mutateAsync: createMutateAsync, isLoading: createIsLoading } = useCreateLDAPConfig(); const { mutateAsync: updateMutateAsync, isLoading: updateIsLoading } = useUpdateLDAPConfig(); const { data } = useGetLDAPConfig(currentOrg?.id ?? ""); diff --git a/frontend/src/views/Settings/OrgSettingsPage/components/OrgAuthTab/OrgGeneralAuthSection.tsx b/frontend/src/views/Settings/OrgSettingsPage/components/OrgAuthTab/OrgGeneralAuthSection.tsx index 6de61c97f1..7c3af9493f 100644 --- a/frontend/src/views/Settings/OrgSettingsPage/components/OrgAuthTab/OrgGeneralAuthSection.tsx +++ b/frontend/src/views/Settings/OrgSettingsPage/components/OrgAuthTab/OrgGeneralAuthSection.tsx @@ -1,4 +1,4 @@ -import { useNotificationContext } from "@app/components/context/Notifications/NotificationProvider"; +import { createNotification } from "@app/components/notifications"; import { OrgPermissionCan } from "@app/components/permissions"; import { Switch, UpgradePlanModal } from "@app/components/v2"; import { @@ -11,7 +11,7 @@ import { useLogoutUser, useUpdateOrg } from "@app/hooks/api"; import { usePopUp } from "@app/hooks/usePopUp"; export const OrgGeneralAuthSection = () => { - const { createNotification } = useNotificationContext(); + const { currentOrg } = useOrganization(); const { subscription } = useSubscription(); const { popUp, handlePopUpOpen, handlePopUpToggle } = usePopUp(["upgradePlan"] as const); diff --git a/frontend/src/views/Settings/OrgSettingsPage/components/OrgAuthTab/OrgLDAPSection.tsx b/frontend/src/views/Settings/OrgSettingsPage/components/OrgAuthTab/OrgLDAPSection.tsx index 771737d698..159f2eb382 100644 --- a/frontend/src/views/Settings/OrgSettingsPage/components/OrgAuthTab/OrgLDAPSection.tsx +++ b/frontend/src/views/Settings/OrgSettingsPage/components/OrgAuthTab/OrgLDAPSection.tsx @@ -1,4 +1,4 @@ -import { useNotificationContext } from "@app/components/context/Notifications/NotificationProvider"; +import { createNotification } from "@app/components/notifications"; import { OrgPermissionCan } from "@app/components/permissions"; import { Button, Switch, UpgradePlanModal } from "@app/components/v2"; import { @@ -15,7 +15,7 @@ import { LDAPModal } from "./LDAPModal"; export const OrgLDAPSection = (): JSX.Element => { const { currentOrg } = useOrganization(); const { subscription } = useSubscription(); - const { createNotification } = useNotificationContext(); + const { data } = useGetLDAPConfig(currentOrg?.id ?? ""); const { mutateAsync } = useUpdateLDAPConfig(); const { popUp, handlePopUpOpen, handlePopUpClose, handlePopUpToggle } = usePopUp([ diff --git a/frontend/src/views/Settings/OrgSettingsPage/components/OrgAuthTab/OrgSCIMSection.tsx b/frontend/src/views/Settings/OrgSettingsPage/components/OrgAuthTab/OrgSCIMSection.tsx index a606507a8b..601643db80 100644 --- a/frontend/src/views/Settings/OrgSettingsPage/components/OrgAuthTab/OrgSCIMSection.tsx +++ b/frontend/src/views/Settings/OrgSettingsPage/components/OrgAuthTab/OrgSCIMSection.tsx @@ -1,4 +1,4 @@ -import { useNotificationContext } from "@app/components/context/Notifications/NotificationProvider"; +import { createNotification } from "@app/components/notifications"; import { OrgPermissionCan } from "@app/components/permissions"; import { Button, Switch, UpgradePlanModal } from "@app/components/v2"; import { @@ -13,7 +13,7 @@ import { usePopUp } from "@app/hooks/usePopUp"; import { ScimTokenModal } from "./ScimTokenModal"; export const OrgScimSection = () => { - const { createNotification } = useNotificationContext(); + const { currentOrg } = useOrganization(); const { subscription } = useSubscription(); const { popUp, handlePopUpOpen, handlePopUpToggle } = usePopUp([ diff --git a/frontend/src/views/Settings/OrgSettingsPage/components/OrgAuthTab/OrgSSOSection.tsx b/frontend/src/views/Settings/OrgSettingsPage/components/OrgAuthTab/OrgSSOSection.tsx index 54c1b76c15..67daf0fca0 100644 --- a/frontend/src/views/Settings/OrgSettingsPage/components/OrgAuthTab/OrgSSOSection.tsx +++ b/frontend/src/views/Settings/OrgSettingsPage/components/OrgAuthTab/OrgSSOSection.tsx @@ -1,4 +1,4 @@ -import { useNotificationContext } from "@app/components/context/Notifications/NotificationProvider"; +import { createNotification } from "@app/components/notifications"; import { OrgPermissionCan } from "@app/components/permissions"; import { Button, Switch, UpgradePlanModal } from "@app/components/v2"; import { @@ -15,7 +15,7 @@ import { SSOModal } from "./SSOModal"; export const OrgSSOSection = (): JSX.Element => { const { currentOrg } = useOrganization(); const { subscription } = useSubscription(); - const { createNotification } = useNotificationContext(); + const { data, isLoading } = useGetSSOConfig(currentOrg?.id ?? ""); const { mutateAsync } = useUpdateSSOConfig(); const { popUp, handlePopUpOpen, handlePopUpClose, handlePopUpToggle } = usePopUp([ diff --git a/frontend/src/views/Settings/OrgSettingsPage/components/OrgAuthTab/SSOModal.tsx b/frontend/src/views/Settings/OrgSettingsPage/components/OrgAuthTab/SSOModal.tsx index 5864d1c66a..4cad75ebdd 100644 --- a/frontend/src/views/Settings/OrgSettingsPage/components/OrgAuthTab/SSOModal.tsx +++ b/frontend/src/views/Settings/OrgSettingsPage/components/OrgAuthTab/SSOModal.tsx @@ -3,7 +3,7 @@ import { Controller, useForm } from "react-hook-form"; import { zodResolver } from "@hookform/resolvers/zod"; import { z } from "zod"; -import { useNotificationContext } from "@app/components/context/Notifications/NotificationProvider"; +import { createNotification } from "@app/components/notifications"; import { Button, FormControl, @@ -51,7 +51,7 @@ type Props = { export const SSOModal = ({ popUp, handlePopUpClose, handlePopUpToggle }: Props) => { const { currentOrg } = useOrganization(); - const { createNotification } = useNotificationContext(); + const { mutateAsync: createMutateAsync, isLoading: createIsLoading } = useCreateSSOConfig(); const { mutateAsync: updateMutateAsync, isLoading: updateIsLoading } = useUpdateSSOConfig(); const { data } = useGetSSOConfig(currentOrg?.id ?? ""); diff --git a/frontend/src/views/Settings/OrgSettingsPage/components/OrgAuthTab/ScimTokenModal.tsx b/frontend/src/views/Settings/OrgSettingsPage/components/OrgAuthTab/ScimTokenModal.tsx index caa081d47b..0f92729c89 100644 --- a/frontend/src/views/Settings/OrgSettingsPage/components/OrgAuthTab/ScimTokenModal.tsx +++ b/frontend/src/views/Settings/OrgSettingsPage/components/OrgAuthTab/ScimTokenModal.tsx @@ -7,7 +7,7 @@ import { yupResolver } from "@hookform/resolvers/yup"; import { format } from "date-fns"; import * as yup from "yup"; -import { useNotificationContext } from "@app/components/context/Notifications/NotificationProvider"; +import { createNotification } from "@app/components/notifications"; import { Button, DeleteActionModal, @@ -55,7 +55,7 @@ type Props = { export const ScimTokenModal = ({ popUp, handlePopUpOpen, handlePopUpToggle }: Props) => { const { currentOrg } = useOrganization(); const { t } = useTranslation(); - const { createNotification } = useNotificationContext(); + const [token, setToken] = useState(""); const [isScimUrlCopied, setIsScimUrlCopied] = useToggle(false); diff --git a/frontend/src/views/Settings/OrgSettingsPage/components/OrgDeleteSection/OrgDeleteSection.tsx b/frontend/src/views/Settings/OrgSettingsPage/components/OrgDeleteSection/OrgDeleteSection.tsx index e2598413c9..e76b39aa32 100644 --- a/frontend/src/views/Settings/OrgSettingsPage/components/OrgDeleteSection/OrgDeleteSection.tsx +++ b/frontend/src/views/Settings/OrgSettingsPage/components/OrgDeleteSection/OrgDeleteSection.tsx @@ -1,6 +1,6 @@ import { useRouter } from "next/router"; -import { useNotificationContext } from "@app/components/context/Notifications/NotificationProvider"; +import { createNotification } from "@app/components/notifications"; import { Button, DeleteActionModal } from "@app/components/v2"; import { useOrganization, useOrgPermission } from "@app/context"; import { useDeleteOrgById } from "@app/hooks/api"; @@ -10,7 +10,7 @@ import { navigateUserToOrg } from "@app/views/Login/Login.utils"; export const OrgDeleteSection = () => { const router = useRouter(); const { currentOrg } = useOrganization(); - const { createNotification } = useNotificationContext(); + const { membership } = useOrgPermission(); const { popUp, handlePopUpOpen, handlePopUpClose, handlePopUpToggle } = usePopUp([ diff --git a/frontend/src/views/Settings/OrgSettingsPage/components/OrgIncidentContactsSection/AddOrgIncidentContactModal.tsx b/frontend/src/views/Settings/OrgSettingsPage/components/OrgIncidentContactsSection/AddOrgIncidentContactModal.tsx index 6aef9ffc7a..c45e47a5f2 100644 --- a/frontend/src/views/Settings/OrgSettingsPage/components/OrgIncidentContactsSection/AddOrgIncidentContactModal.tsx +++ b/frontend/src/views/Settings/OrgSettingsPage/components/OrgIncidentContactsSection/AddOrgIncidentContactModal.tsx @@ -2,7 +2,7 @@ import { Controller, useForm } from "react-hook-form"; import { yupResolver } from "@hookform/resolvers/yup"; import * as yup from "yup"; -import { useNotificationContext } from "@app/components/context/Notifications/NotificationProvider"; +import { createNotification } from "@app/components/notifications"; import { Button, FormControl, Input, Modal, ModalContent } from "@app/components/v2"; import { useOrganization } from "@app/context"; import { useAddIncidentContact } from "@app/hooks/api"; @@ -26,7 +26,7 @@ export const AddOrgIncidentContactModal = ({ handlePopUpClose, handlePopUpToggle }: Props) => { - const { createNotification } = useNotificationContext(); + const { currentOrg } = useOrganization(); const { data: serverDetails } = useFetchServerStatus(); const { control, handleSubmit, reset } = useForm({ diff --git a/frontend/src/views/Settings/OrgSettingsPage/components/OrgIncidentContactsSection/OrgIncidentContactsTable.tsx b/frontend/src/views/Settings/OrgSettingsPage/components/OrgIncidentContactsSection/OrgIncidentContactsTable.tsx index 05465fe4bf..b9091b1ab6 100644 --- a/frontend/src/views/Settings/OrgSettingsPage/components/OrgIncidentContactsSection/OrgIncidentContactsTable.tsx +++ b/frontend/src/views/Settings/OrgSettingsPage/components/OrgIncidentContactsSection/OrgIncidentContactsTable.tsx @@ -2,7 +2,7 @@ import { useState } from "react"; import { faContactBook, faMagnifyingGlass, faTrash } from "@fortawesome/free-solid-svg-icons"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; -import { useNotificationContext } from "@app/components/context/Notifications/NotificationProvider"; +import { createNotification } from "@app/components/notifications"; import { OrgPermissionCan } from "@app/components/permissions"; import { DeleteActionModal, @@ -23,7 +23,7 @@ import { usePopUp } from "@app/hooks"; import { useDeleteIncidentContact, useGetOrgIncidentContact } from "@app/hooks/api"; export const OrgIncidentContactsTable = () => { - const { createNotification } = useNotificationContext(); + const { currentOrg } = useOrganization(); const { data: contacts, isLoading } = useGetOrgIncidentContact(currentOrg?.id ?? ""); const [searchContact, setSearchContact] = useState(""); diff --git a/frontend/src/views/Settings/OrgSettingsPage/components/OrgNameChangeSection/OrgNameChangeSection.tsx b/frontend/src/views/Settings/OrgSettingsPage/components/OrgNameChangeSection/OrgNameChangeSection.tsx index 1c4db741fd..eb87d59b5d 100644 --- a/frontend/src/views/Settings/OrgSettingsPage/components/OrgNameChangeSection/OrgNameChangeSection.tsx +++ b/frontend/src/views/Settings/OrgSettingsPage/components/OrgNameChangeSection/OrgNameChangeSection.tsx @@ -3,7 +3,7 @@ import { Controller, useForm } from "react-hook-form"; import { yupResolver } from "@hookform/resolvers/yup"; import * as yup from "yup"; -import { useNotificationContext } from "@app/components/context/Notifications/NotificationProvider"; +import { createNotification } from "@app/components/notifications"; import { OrgPermissionCan } from "@app/components/permissions"; import { Button, FormControl, Input } from "@app/components/v2"; import { OrgPermissionActions, OrgPermissionSubjects, useOrganization } from "@app/context"; @@ -26,7 +26,7 @@ type FormData = yup.InferType; export const OrgNameChangeSection = (): JSX.Element => { const { currentOrg } = useOrganization(); - const { createNotification } = useNotificationContext(); + const { handleSubmit, control, reset } = useForm({ resolver: yupResolver(formSchema) }); diff --git a/frontend/src/views/Settings/PersonalSettingsPage/APIKeySection/APIKeyTable.tsx b/frontend/src/views/Settings/PersonalSettingsPage/APIKeySection/APIKeyTable.tsx index 346d917223..1eb5abad2c 100644 --- a/frontend/src/views/Settings/PersonalSettingsPage/APIKeySection/APIKeyTable.tsx +++ b/frontend/src/views/Settings/PersonalSettingsPage/APIKeySection/APIKeyTable.tsx @@ -2,7 +2,7 @@ import { faKey, faXmark } from "@fortawesome/free-solid-svg-icons"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { format } from "date-fns"; -import { useNotificationContext } from "@app/components/context/Notifications/NotificationProvider"; +import { createNotification } from "@app/components/notifications"; import { EmptyState, IconButton, @@ -18,7 +18,7 @@ import { import { useDeleteAPIKey, useGetMyAPIKeys } from "@app/hooks/api"; export const APIKeyTable = () => { - const { createNotification } = useNotificationContext(); + const { data, isLoading } = useGetMyAPIKeys(); const { mutateAsync } = useDeleteAPIKey(); diff --git a/frontend/src/views/Settings/PersonalSettingsPage/APIKeySection/AddAPIKeyModal.tsx b/frontend/src/views/Settings/PersonalSettingsPage/APIKeySection/AddAPIKeyModal.tsx index d3814f636c..f65e708e97 100644 --- a/frontend/src/views/Settings/PersonalSettingsPage/APIKeySection/AddAPIKeyModal.tsx +++ b/frontend/src/views/Settings/PersonalSettingsPage/APIKeySection/AddAPIKeyModal.tsx @@ -5,7 +5,7 @@ import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { yupResolver } from "@hookform/resolvers/yup"; import * as yup from "yup"; -import { useNotificationContext } from "@app/components/context/Notifications/NotificationProvider"; +import { createNotification } from "@app/components/notifications"; import { Button, FormControl, @@ -53,7 +53,7 @@ type Props = { export const AddAPIKeyModal = ({ popUp, handlePopUpToggle }: Props) => { const [newAPIKey, setNewAPIKey] = useState(""); const [isAPIKeyCopied, setIsAPIKeyCopied] = useToggle(false); - const { createNotification } = useNotificationContext(); + const { mutateAsync, isLoading } = useCreateAPIKey(); const { control, handleSubmit, reset } = useForm({ diff --git a/frontend/src/views/Settings/PersonalSettingsPage/AuthMethodSection/AuthMethodSection.tsx b/frontend/src/views/Settings/PersonalSettingsPage/AuthMethodSection/AuthMethodSection.tsx index 5167bef17c..423d073429 100644 --- a/frontend/src/views/Settings/PersonalSettingsPage/AuthMethodSection/AuthMethodSection.tsx +++ b/frontend/src/views/Settings/PersonalSettingsPage/AuthMethodSection/AuthMethodSection.tsx @@ -6,7 +6,7 @@ import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { yupResolver } from "@hookform/resolvers/yup"; import * as yup from "yup"; -import { useNotificationContext } from "@app/components/context/Notifications/NotificationProvider"; +import { createNotification } from "@app/components/notifications"; import { Switch } from "@app/components/v2"; import { useUser } from "@app/context"; import { useUpdateUserAuthMethods } from "@app/hooks/api"; @@ -32,7 +32,7 @@ const schema = yup.object({ export type FormData = yup.InferType; export const AuthMethodSection = () => { - const { createNotification } = useNotificationContext(); + const { user } = useUser(); const { mutateAsync } = useUpdateUserAuthMethods(); diff --git a/frontend/src/views/Settings/PersonalSettingsPage/ChangePasswordSection/ChangePasswordSection.tsx b/frontend/src/views/Settings/PersonalSettingsPage/ChangePasswordSection/ChangePasswordSection.tsx index d74acef0f2..8ffaca1e1a 100644 --- a/frontend/src/views/Settings/PersonalSettingsPage/ChangePasswordSection/ChangePasswordSection.tsx +++ b/frontend/src/views/Settings/PersonalSettingsPage/ChangePasswordSection/ChangePasswordSection.tsx @@ -6,7 +6,7 @@ import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { yupResolver } from "@hookform/resolvers/yup"; import * as yup from "yup"; -import { useNotificationContext } from "@app/components/context/Notifications/NotificationProvider"; +import { createNotification } from "@app/components/notifications"; import attemptChangePassword from "@app/components/utilities/attemptChangePassword"; import checkPassword from "@app/components/utilities/checks/password/checkPassword"; import { Button, FormControl, Input } from "@app/components/v2"; @@ -34,7 +34,7 @@ export type FormData = yup.InferType; export const ChangePasswordSection = () => { const { t } = useTranslation(); - const { createNotification } = useNotificationContext(); + const { user } = useUser(); const { reset, control, handleSubmit } = useForm({ defaultValues: { diff --git a/frontend/src/views/Settings/PersonalSettingsPage/DeleteAccountSection/DeleteAccountSection.tsx b/frontend/src/views/Settings/PersonalSettingsPage/DeleteAccountSection/DeleteAccountSection.tsx index 3a2e947ae5..49908eabc8 100644 --- a/frontend/src/views/Settings/PersonalSettingsPage/DeleteAccountSection/DeleteAccountSection.tsx +++ b/frontend/src/views/Settings/PersonalSettingsPage/DeleteAccountSection/DeleteAccountSection.tsx @@ -1,13 +1,13 @@ import { useRouter } from "next/router"; -import { useNotificationContext } from "@app/components/context/Notifications/NotificationProvider"; +import { createNotification } from "@app/components/notifications"; import { Button, DeleteActionModal } from "@app/components/v2"; import { useDeleteUser } from "@app/hooks/api"; import { usePopUp } from "@app/hooks/usePopUp"; export const DeleteAccountSection = () => { const router = useRouter(); - const { createNotification } = useNotificationContext(); + const { popUp, handlePopUpOpen, handlePopUpClose, handlePopUpToggle } = usePopUp([ "deleteAccount" ] as const); diff --git a/frontend/src/views/Settings/PersonalSettingsPage/EmergencyKitSection/EmergencyKitSection.tsx b/frontend/src/views/Settings/PersonalSettingsPage/EmergencyKitSection/EmergencyKitSection.tsx index ebe3880ece..405b0e3e0e 100644 --- a/frontend/src/views/Settings/PersonalSettingsPage/EmergencyKitSection/EmergencyKitSection.tsx +++ b/frontend/src/views/Settings/PersonalSettingsPage/EmergencyKitSection/EmergencyKitSection.tsx @@ -2,7 +2,7 @@ import { Controller, useForm } from "react-hook-form"; import { yupResolver } from "@hookform/resolvers/yup"; import * as yup from "yup"; -import { useNotificationContext } from "@app/components/context/Notifications/NotificationProvider"; +import { createNotification } from "@app/components/notifications"; import issueBackupKey from "@app/components/utilities/cryptography/issueBackupKey"; import { Button, FormControl, Input } from "@app/components/v2"; import { useUser } from "@app/context"; @@ -16,7 +16,7 @@ const schema = yup export type FormData = yup.InferType; export const EmergencyKitSection = () => { - const { createNotification } = useNotificationContext(); + const { user } = useUser(); const { reset, control, handleSubmit } = useForm({ defaultValues: { diff --git a/frontend/src/views/Settings/PersonalSettingsPage/SecuritySection/MFASection.tsx b/frontend/src/views/Settings/PersonalSettingsPage/SecuritySection/MFASection.tsx index 696c2d78ed..96706af8e5 100644 --- a/frontend/src/views/Settings/PersonalSettingsPage/SecuritySection/MFASection.tsx +++ b/frontend/src/views/Settings/PersonalSettingsPage/SecuritySection/MFASection.tsx @@ -1,4 +1,4 @@ -import { useNotificationContext } from "@app/components/context/Notifications/NotificationProvider"; +import { createNotification } from "@app/components/notifications"; import { Checkbox, EmailServiceSetupModal } from "@app/components/v2"; import { useGetUser, useUpdateMfaEnabled } from "@app/hooks/api"; import { useFetchServerStatus } from "@app/hooks/api/serverDetails"; @@ -8,7 +8,7 @@ import { usePopUp } from "@app/hooks/usePopUp"; export const MFASection = () => { const { data: user } = useGetUser(); const { mutateAsync } = useUpdateMfaEnabled(); - const { createNotification } = useNotificationContext(); + const { handlePopUpToggle, popUp, handlePopUpOpen } = usePopUp(["setUpEmail"] as const); const { data: serverDetails } = useFetchServerStatus(); diff --git a/frontend/src/views/Settings/PersonalSettingsPage/UserNameSection/UserNameSection.tsx b/frontend/src/views/Settings/PersonalSettingsPage/UserNameSection/UserNameSection.tsx index 04f40f48ca..f5ebe03e6e 100644 --- a/frontend/src/views/Settings/PersonalSettingsPage/UserNameSection/UserNameSection.tsx +++ b/frontend/src/views/Settings/PersonalSettingsPage/UserNameSection/UserNameSection.tsx @@ -3,7 +3,7 @@ import { Controller, useForm } from "react-hook-form"; import { yupResolver } from "@hookform/resolvers/yup"; import * as yup from "yup"; -import { useNotificationContext } from "@app/components/context/Notifications/NotificationProvider"; +import { createNotification } from "@app/components/notifications"; import { Button, FormControl, Input } from "@app/components/v2"; import { useUser } from "@app/context"; import { useRenameUser } from "@app/hooks/api/users/queries"; @@ -16,7 +16,7 @@ type FormData = yup.InferType; export const UserNameSection = (): JSX.Element => { const { user } = useUser(); - const { createNotification } = useNotificationContext(); + const { handleSubmit, control, reset } = useForm({ resolver: yupResolver(formSchema) }); const { mutateAsync, isLoading } = useRenameUser(); diff --git a/frontend/src/views/Settings/ProjectSettingsPage/components/AutoCapitalizationSection/AutoCapitalizationSection.tsx b/frontend/src/views/Settings/ProjectSettingsPage/components/AutoCapitalizationSection/AutoCapitalizationSection.tsx index b0eda82045..b842a32fdd 100644 --- a/frontend/src/views/Settings/ProjectSettingsPage/components/AutoCapitalizationSection/AutoCapitalizationSection.tsx +++ b/frontend/src/views/Settings/ProjectSettingsPage/components/AutoCapitalizationSection/AutoCapitalizationSection.tsx @@ -1,6 +1,6 @@ import { useTranslation } from "react-i18next"; -import { useNotificationContext } from "@app/components/context/Notifications/NotificationProvider"; +import { createNotification } from "@app/components/notifications"; import { ProjectPermissionCan } from "@app/components/permissions"; import { Checkbox } from "@app/components/v2"; import { ProjectPermissionActions, ProjectPermissionSub, useWorkspace } from "@app/context"; @@ -8,7 +8,7 @@ import { useToggleAutoCapitalization } from "@app/hooks/api"; export const AutoCapitalizationSection = () => { const { t } = useTranslation(); - const { createNotification } = useNotificationContext(); + const { currentWorkspace } = useWorkspace(); const { mutateAsync } = useToggleAutoCapitalization(); diff --git a/frontend/src/views/Settings/ProjectSettingsPage/components/DeleteProjectSection/DeleteProjectSection.tsx b/frontend/src/views/Settings/ProjectSettingsPage/components/DeleteProjectSection/DeleteProjectSection.tsx index 3b3af1d49c..12d7359521 100644 --- a/frontend/src/views/Settings/ProjectSettingsPage/components/DeleteProjectSection/DeleteProjectSection.tsx +++ b/frontend/src/views/Settings/ProjectSettingsPage/components/DeleteProjectSection/DeleteProjectSection.tsx @@ -1,6 +1,6 @@ import { useRouter } from "next/router"; -import { useNotificationContext } from "@app/components/context/Notifications/NotificationProvider"; +import { createNotification } from "@app/components/notifications"; import { ProjectPermissionCan } from "@app/components/permissions"; import { Button, DeleteActionModal } from "@app/components/v2"; import { @@ -15,7 +15,7 @@ import { usePopUp } from "@app/hooks/usePopUp"; export const DeleteProjectSection = () => { const router = useRouter(); - const { createNotification } = useNotificationContext(); + const { popUp, handlePopUpOpen, handlePopUpClose, handlePopUpToggle } = usePopUp([ "deleteWorkspace" ] as const); diff --git a/frontend/src/views/Settings/ProjectSettingsPage/components/EnvironmentSection/AddEnvironmentModal.tsx b/frontend/src/views/Settings/ProjectSettingsPage/components/EnvironmentSection/AddEnvironmentModal.tsx index 51fee1ecd1..658faea0e3 100644 --- a/frontend/src/views/Settings/ProjectSettingsPage/components/EnvironmentSection/AddEnvironmentModal.tsx +++ b/frontend/src/views/Settings/ProjectSettingsPage/components/EnvironmentSection/AddEnvironmentModal.tsx @@ -2,7 +2,7 @@ import { Controller, useForm } from "react-hook-form"; import { yupResolver } from "@hookform/resolvers/yup"; import * as yup from "yup"; -import { useNotificationContext } from "@app/components/context/Notifications/NotificationProvider"; +import { createNotification } from "@app/components/notifications"; import { Button, FormControl, Input, Modal, ModalContent } from "@app/components/v2"; import { useWorkspace } from "@app/context"; import { useCreateWsEnvironment } from "@app/hooks/api"; @@ -22,7 +22,7 @@ const schema = yup.object({ export type FormData = yup.InferType; export const AddEnvironmentModal = ({ popUp, handlePopUpClose, handlePopUpToggle }: Props) => { - const { createNotification } = useNotificationContext(); + const { currentWorkspace } = useWorkspace(); const { mutateAsync, isLoading } = useCreateWsEnvironment(); const { control, handleSubmit, reset } = useForm({ diff --git a/frontend/src/views/Settings/ProjectSettingsPage/components/EnvironmentSection/EnvironmentSection.tsx b/frontend/src/views/Settings/ProjectSettingsPage/components/EnvironmentSection/EnvironmentSection.tsx index 92ba623a28..7981c8714f 100644 --- a/frontend/src/views/Settings/ProjectSettingsPage/components/EnvironmentSection/EnvironmentSection.tsx +++ b/frontend/src/views/Settings/ProjectSettingsPage/components/EnvironmentSection/EnvironmentSection.tsx @@ -1,7 +1,7 @@ import { faPlus } from "@fortawesome/free-solid-svg-icons"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; -import { useNotificationContext } from "@app/components/context/Notifications/NotificationProvider"; +import { createNotification } from "@app/components/notifications"; import { PermissionDeniedBanner, ProjectPermissionCan } from "@app/components/permissions"; import { Button, DeleteActionModal, UpgradePlanModal } from "@app/components/v2"; import { @@ -19,7 +19,7 @@ import { EnvironmentTable } from "./EnvironmentTable"; import { UpdateEnvironmentModal } from "./UpdateEnvironmentModal"; export const EnvironmentSection = () => { - const { createNotification } = useNotificationContext(); + const { subscription } = useSubscription(); const { currentWorkspace } = useWorkspace(); const { permission } = useProjectPermission(); diff --git a/frontend/src/views/Settings/ProjectSettingsPage/components/EnvironmentSection/EnvironmentTable.tsx b/frontend/src/views/Settings/ProjectSettingsPage/components/EnvironmentSection/EnvironmentTable.tsx index 6f7802d2f3..9bd23b6b1c 100644 --- a/frontend/src/views/Settings/ProjectSettingsPage/components/EnvironmentSection/EnvironmentTable.tsx +++ b/frontend/src/views/Settings/ProjectSettingsPage/components/EnvironmentSection/EnvironmentTable.tsx @@ -1,7 +1,7 @@ import { faArrowDown, faArrowUp, faPencil, faXmark } from "@fortawesome/free-solid-svg-icons"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; -import { useNotificationContext } from "@app/components/context/Notifications/NotificationProvider"; +import { createNotification } from "@app/components/notifications"; import { ProjectPermissionCan } from "@app/components/permissions"; import { EmptyState, @@ -36,7 +36,7 @@ type Props = { export const EnvironmentTable = ({ handlePopUpOpen }: Props) => { const { currentWorkspace, isLoading } = useWorkspace(); - const { createNotification } = useNotificationContext(); + const updateEnvironment = useUpdateWsEnvironment(); const handleReorderEnv = async (id: string, position: number) => { diff --git a/frontend/src/views/Settings/ProjectSettingsPage/components/EnvironmentSection/UpdateEnvironmentModal.tsx b/frontend/src/views/Settings/ProjectSettingsPage/components/EnvironmentSection/UpdateEnvironmentModal.tsx index 3f875677ea..0acd9fbe12 100644 --- a/frontend/src/views/Settings/ProjectSettingsPage/components/EnvironmentSection/UpdateEnvironmentModal.tsx +++ b/frontend/src/views/Settings/ProjectSettingsPage/components/EnvironmentSection/UpdateEnvironmentModal.tsx @@ -2,7 +2,7 @@ import { Controller, useForm } from "react-hook-form"; import { yupResolver } from "@hookform/resolvers/yup"; import * as yup from "yup"; -import { useNotificationContext } from "@app/components/context/Notifications/NotificationProvider"; +import { createNotification } from "@app/components/notifications"; import { Button, FormControl, Input, Modal, ModalContent } from "@app/components/v2"; import { useWorkspace } from "@app/context"; import { useUpdateWsEnvironment } from "@app/hooks/api"; @@ -22,7 +22,7 @@ const schema = yup.object({ export type FormData = yup.InferType; export const UpdateEnvironmentModal = ({ popUp, handlePopUpClose, handlePopUpToggle }: Props) => { - const { createNotification } = useNotificationContext(); + const { currentWorkspace } = useWorkspace(); const { mutateAsync, isLoading } = useUpdateWsEnvironment(); const { control, handleSubmit, reset } = useForm({ diff --git a/frontend/src/views/Settings/ProjectSettingsPage/components/ProjectNameChangeSection/CopyButton.tsx b/frontend/src/views/Settings/ProjectSettingsPage/components/ProjectNameChangeSection/CopyButton.tsx index 8337d1c4d2..c17629e0cb 100644 --- a/frontend/src/views/Settings/ProjectSettingsPage/components/ProjectNameChangeSection/CopyButton.tsx +++ b/frontend/src/views/Settings/ProjectSettingsPage/components/ProjectNameChangeSection/CopyButton.tsx @@ -2,7 +2,7 @@ import { useCallback } from "react"; import { faCheck, faCopy } from "@fortawesome/free-solid-svg-icons"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; -import { useNotificationContext } from "@app/components/context/Notifications/NotificationProvider"; +import { createNotification } from "@app/components/notifications"; import { Button } from "@app/components/v2"; import { useToggle } from "@app/hooks"; @@ -15,7 +15,7 @@ type Props = { export const CopyButton = ({ value, children, hoverText, notificationText }: Props) => { const [isProjectIdCopied, setIsProjectIdCopied] = useToggle(false); - const { createNotification } = useNotificationContext(); + const copyToClipboard = useCallback(() => { if (isProjectIdCopied) { diff --git a/frontend/src/views/Settings/ProjectSettingsPage/components/ProjectNameChangeSection/ProjectNameChangeSection.tsx b/frontend/src/views/Settings/ProjectSettingsPage/components/ProjectNameChangeSection/ProjectNameChangeSection.tsx index 5857acc0fd..2667a55d16 100644 --- a/frontend/src/views/Settings/ProjectSettingsPage/components/ProjectNameChangeSection/ProjectNameChangeSection.tsx +++ b/frontend/src/views/Settings/ProjectSettingsPage/components/ProjectNameChangeSection/ProjectNameChangeSection.tsx @@ -3,7 +3,7 @@ import { Controller, useForm } from "react-hook-form"; import { yupResolver } from "@hookform/resolvers/yup"; import * as yup from "yup"; -import { useNotificationContext } from "@app/components/context/Notifications/NotificationProvider"; +import { createNotification } from "@app/components/notifications"; import { ProjectPermissionCan } from "@app/components/permissions"; import { Button, FormControl, Input } from "@app/components/v2"; import { ProjectPermissionActions, ProjectPermissionSub, useWorkspace } from "@app/context"; @@ -22,7 +22,7 @@ const formSchema = yup.object({ type FormData = yup.InferType; export const ProjectNameChangeSection = () => { - const { createNotification } = useNotificationContext(); + const { currentWorkspace } = useWorkspace(); const { mutateAsync, isLoading } = useRenameWorkspace(); diff --git a/frontend/src/views/Settings/ProjectSettingsPage/components/SecretTagsSection/AddSecretTagModal.tsx b/frontend/src/views/Settings/ProjectSettingsPage/components/SecretTagsSection/AddSecretTagModal.tsx index 9218af1291..7cc1a926eb 100644 --- a/frontend/src/views/Settings/ProjectSettingsPage/components/SecretTagsSection/AddSecretTagModal.tsx +++ b/frontend/src/views/Settings/ProjectSettingsPage/components/SecretTagsSection/AddSecretTagModal.tsx @@ -2,7 +2,7 @@ import { Controller, useForm } from "react-hook-form"; import { yupResolver } from "@hookform/resolvers/yup"; import * as yup from "yup"; -import { useNotificationContext } from "@app/components/context/Notifications/NotificationProvider"; +import { createNotification } from "@app/components/notifications"; import { Button, FormControl, Input, Modal, ModalClose, ModalContent } from "@app/components/v2"; import { useWorkspace } from "@app/context"; import { useCreateWsTag } from "@app/hooks/api"; @@ -26,7 +26,7 @@ type Props = { }; export const AddSecretTagModal = ({ popUp, handlePopUpClose, handlePopUpToggle }: Props) => { - const { createNotification } = useNotificationContext(); + const { currentWorkspace } = useWorkspace(); const createWsTag = useCreateWsTag(); const { diff --git a/frontend/src/views/Settings/ProjectSettingsPage/components/SecretTagsSection/SecretTagsSection.tsx b/frontend/src/views/Settings/ProjectSettingsPage/components/SecretTagsSection/SecretTagsSection.tsx index 414f1f6fed..d1ba06835c 100644 --- a/frontend/src/views/Settings/ProjectSettingsPage/components/SecretTagsSection/SecretTagsSection.tsx +++ b/frontend/src/views/Settings/ProjectSettingsPage/components/SecretTagsSection/SecretTagsSection.tsx @@ -1,7 +1,7 @@ import { faPlus } from "@fortawesome/free-solid-svg-icons"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; -import { useNotificationContext } from "@app/components/context/Notifications/NotificationProvider"; +import { createNotification } from "@app/components/notifications"; import { PermissionDeniedBanner, ProjectPermissionCan } from "@app/components/permissions"; import { Button, DeleteActionModal } from "@app/components/v2"; import { @@ -19,7 +19,7 @@ import { SecretTagsTable } from "./SecretTagsTable"; type DeleteModalData = { name: string; id: string }; export const SecretTagsSection = (): JSX.Element => { - const { createNotification } = useNotificationContext(); + const { popUp, handlePopUpToggle, handlePopUpClose, handlePopUpOpen } = usePopUp([ "CreateSecretTag", "deleteTagConfirmation" diff --git a/frontend/src/views/Settings/ProjectSettingsPage/components/WebhooksTab/WebhooksTab.tsx b/frontend/src/views/Settings/ProjectSettingsPage/components/WebhooksTab/WebhooksTab.tsx index 71221226cc..93ba21dfba 100644 --- a/frontend/src/views/Settings/ProjectSettingsPage/components/WebhooksTab/WebhooksTab.tsx +++ b/frontend/src/views/Settings/ProjectSettingsPage/components/WebhooksTab/WebhooksTab.tsx @@ -3,7 +3,7 @@ import { faInfoCircle, faPlug, faPlus } from "@fortawesome/free-solid-svg-icons" import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { format } from "date-fns"; -import { useNotificationContext } from "@app/components/context/Notifications/NotificationProvider"; +import { createNotification } from "@app/components/notifications"; import { ProjectPermissionCan } from "@app/components/permissions"; import { Button, @@ -34,7 +34,7 @@ import { AddWebhookForm, TFormSchema } from "./AddWebhookForm"; export const WebhooksTab = withProjectPermission( () => { const { t } = useTranslation(); - const { createNotification } = useNotificationContext(); + const { currentWorkspace } = useWorkspace(); const workspaceId = currentWorkspace?.id || ""; const { popUp, handlePopUpOpen, handlePopUpToggle, handlePopUpClose } = usePopUp([ diff --git a/frontend/src/views/admin/DashboardPage/DashboardPage.tsx b/frontend/src/views/admin/DashboardPage/DashboardPage.tsx index 8231d29242..98ea827fd4 100644 --- a/frontend/src/views/admin/DashboardPage/DashboardPage.tsx +++ b/frontend/src/views/admin/DashboardPage/DashboardPage.tsx @@ -6,7 +6,7 @@ import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { zodResolver } from "@hookform/resolvers/zod"; import { z } from "zod"; -import { useNotificationContext } from "@app/components/context/Notifications/NotificationProvider"; +import { createNotification } from "@app/components/notifications"; import { Button, ContentLoader, @@ -62,7 +62,7 @@ export const AdminDashboardPage = () => { const { orgs } = useOrganization(); const { mutateAsync: updateServerConfig } = useUpdateServerConfig(); - const { createNotification } = useNotificationContext(); + const isNotAllowed = !user?.superAdmin; diff --git a/frontend/src/views/admin/SignUpPage/SignUpPage.tsx b/frontend/src/views/admin/SignUpPage/SignUpPage.tsx index 29134e50e3..bdbc8ac866 100644 --- a/frontend/src/views/admin/SignUpPage/SignUpPage.tsx +++ b/frontend/src/views/admin/SignUpPage/SignUpPage.tsx @@ -5,7 +5,7 @@ import { zodResolver } from "@hookform/resolvers/zod"; import { AnimatePresence, motion } from "framer-motion"; import { z } from "zod"; -import { useNotificationContext } from "@app/components/context/Notifications/NotificationProvider"; +import { createNotification } from "@app/components/notifications"; import { generateBackupPDFAsync } from "@app/components/utilities/generateBackupPDF"; // TODO(akhilmhdh): rewrite this into module functions in lib import { saveTokenToLocalStorage } from "@app/components/utilities/saveTokenToLocalStorage"; @@ -48,7 +48,7 @@ export const SignUpPage = () => { } = useForm({ resolver: zodResolver(formSchema) }); - const { createNotification } = useNotificationContext(); + const [step, setStep] = useState(SignupSteps.DetailsForm); const { config } = useServerConfig();