From 5fcfb9956fa9dc9380954f06fbd61f3e93369661 Mon Sep 17 00:00:00 2001 From: Sidney Alcantara Date: Thu, 6 Oct 2022 16:12:02 +1100 Subject: [PATCH] move types in src/atoms/projectScope to src/types/settings --- src/atoms/projectScope/project.ts | 38 ++--------- src/atoms/projectScope/user.ts | 37 +---------- .../Settings/UserManagement/UserItem.tsx | 2 +- src/types/settings.d.ts | 64 +++++++++++++++++++ 4 files changed, 72 insertions(+), 69 deletions(-) create mode 100644 src/types/settings.d.ts diff --git a/src/atoms/projectScope/project.ts b/src/atoms/projectScope/project.ts index 4295a897..9a5810cb 100644 --- a/src/atoms/projectScope/project.ts +++ b/src/atoms/projectScope/project.ts @@ -1,9 +1,12 @@ import { atom } from "jotai"; import { sortBy } from "lodash-es"; -import { ThemeOptions } from "@mui/material"; import { userRolesAtom } from "./auth"; -import { UserSettings } from "./user"; +import { + PublicSettings, + ProjectSettings, + UserSettings, +} from "@src/types/settings"; import { UpdateDocFunction, UpdateCollectionDocFunction, @@ -15,22 +18,6 @@ import { FunctionSettings } from "@src/types/function"; export const projectIdAtom = atom(""); -/** Public settings are visible to unauthenticated users */ -export type PublicSettings = Partial<{ - signInOptions: Array< - | "google" - | "twitter" - | "facebook" - | "github" - | "microsoft" - | "apple" - | "yahoo" - | "email" - | "phone" - | "anonymous" - >; - theme: Record<"base" | "light" | "dark", ThemeOptions>; -}>; /** Public settings are visible to unauthenticated users */ export const publicSettingsAtom = atom({}); /** Stores a function that updates public settings */ @@ -38,21 +25,6 @@ export const updatePublicSettingsAtom = atom< UpdateDocFunction | undefined >(undefined); -/** Project settings are visible to authenticated users */ -export type ProjectSettings = Partial<{ - tables: TableSettings[]; - - setupCompleted: boolean; - - rowyRunUrl: string; - rowyRunRegion: string; - rowyRunDeployStatus: "BUILDING" | "COMPLETE"; - services: Partial<{ - hooks: string; - builder: string; - terminal: string; - }>; -}>; /** Project settings are visible to authenticated users */ export const projectSettingsAtom = atom({}); /** diff --git a/src/atoms/projectScope/user.ts b/src/atoms/projectScope/user.ts index 4f8aad75..62bcc175 100644 --- a/src/atoms/projectScope/user.ts +++ b/src/atoms/projectScope/user.ts @@ -1,45 +1,12 @@ import { atom } from "jotai"; import { atomWithStorage } from "jotai/utils"; import { merge } from "lodash-es"; -import { ThemeOptions } from "@mui/material"; import themes from "@src/theme"; import { publicSettingsAtom } from "./project"; -import { - UpdateDocFunction, - TableFilter, - TableRowRef, - TableSort, -} from "@src/types/table"; +import { UserSettings } from "@src/types/settings"; +import { UpdateDocFunction } from "@src/types/table"; -/** User info and settings */ -export type UserSettings = Partial<{ - _rowy_ref: TableRowRef; - /** Synced from user auth info */ - user: { - email: string; - displayName?: string; - photoURL?: string; - phoneNumber?: string; - }; - roles: string[]; - - theme: Record<"base" | "light" | "dark", ThemeOptions>; - - favoriteTables: string[]; - /** Stores user overrides */ - tables: Record< - string, - Partial<{ - filters: TableFilter[]; - hiddenFields: string[]; - sorts: TableSort[]; - }> - >; - - /** Stores table tutorial completion */ - tableTutorialComplete?: boolean; -}>; /** User info and settings */ export const userSettingsAtom = atom({}); /** Stores a function that updates user settings */ diff --git a/src/components/Settings/UserManagement/UserItem.tsx b/src/components/Settings/UserManagement/UserItem.tsx index 4aab15e5..3b9d2701 100644 --- a/src/components/Settings/UserManagement/UserItem.tsx +++ b/src/components/Settings/UserManagement/UserItem.tsx @@ -23,12 +23,12 @@ import { projectSettingsAtom, rowyRunAtom, rowyRunModalAtom, - UserSettings, updateUserAtom, confirmDialogAtom, } from "@src/atoms/projectScope"; import { runRoutes } from "@src/constants/runRoutes"; import { USERS } from "@src/config/dbPaths"; +import type { UserSettings } from "@src/types/settings"; export default function UserItem({ _rowy_ref, diff --git a/src/types/settings.d.ts b/src/types/settings.d.ts new file mode 100644 index 00000000..0f3b5761 --- /dev/null +++ b/src/types/settings.d.ts @@ -0,0 +1,64 @@ +import { ThemeOptions } from "@mui/material"; +import { TableSettings, TableFilter, TableRowRef, TableSort } from "./table"; + +/** Public settings are visible to unauthenticated users */ +export type PublicSettings = Partial<{ + signInOptions: Array< + | "google" + | "twitter" + | "facebook" + | "github" + | "microsoft" + | "apple" + | "yahoo" + | "email" + | "phone" + | "anonymous" + >; + theme: Record<"base" | "light" | "dark", ThemeOptions>; +}>; + +/** Project settings are visible to authenticated users */ +export type ProjectSettings = Partial<{ + tables: TableSettings[]; + + setupCompleted: boolean; + + rowyRunUrl: string; + rowyRunRegion: string; + rowyRunDeployStatus: "BUILDING" | "COMPLETE"; + services: Partial<{ + hooks: string; + builder: string; + terminal: string; + }>; +}>; + +/** User info and settings */ +export type UserSettings = Partial<{ + _rowy_ref: TableRowRef; + /** Synced from user auth info */ + user: { + email: string; + displayName?: string; + photoURL?: string; + phoneNumber?: string; + }; + roles: string[]; + + theme: Record<"base" | "light" | "dark", ThemeOptions>; + + favoriteTables: string[]; + /** Stores user overrides */ + tables: Record< + string, + Partial<{ + filters: TableFilter[]; + hiddenFields: string[]; + sorts: TableSort[]; + }> + >; + + /** Stores table tutorial completion */ + tableTutorialComplete?: boolean; +}>;