diff --git a/package.json b/package.json index d6a677d5..9b6a09e5 100644 --- a/package.json +++ b/package.json @@ -84,7 +84,7 @@ "startWithEmulators": "VITE_APP_FIREBASE_EMULATORS=true vite --port 7699", "emulators": "firebase emulators:start --only firestore,auth --import ./emulators/ --export-on-exit", "test": "vitest", - "build": "tsc && vite build", + "build": "tsc && cross-env NODE_OPTIONS=--max-old-space-size=8192 vite build", "preview": "vite preview --port 7699", "analyze": "source-map-explorer ./build/static/js/*.js", "prepare": "husky install", diff --git a/src/components/Function/Function.tsx b/src/components/Function/Function.tsx deleted file mode 100644 index 74503e55..00000000 --- a/src/components/Function/Function.tsx +++ /dev/null @@ -1,55 +0,0 @@ -import { AutoTypings, LocalStorageCache } from "monaco-editor-auto-typings"; -import Editor, { OnMount } from "@monaco-editor/react"; - -const defaultCode = `import React from "react"; -function App() { - return ( -
-

Hello World!

-
- ); -} -`; -const handleEditorMount: OnMount = (monacoEditor, monaco) => { - console.log("handleEditorMount"); - monaco.languages.typescript.typescriptDefaults.setCompilerOptions({ - target: monaco.languages.typescript.ScriptTarget.ES2016, - allowNonTsExtensions: true, - moduleResolution: monaco.languages.typescript.ModuleResolutionKind.NodeJs, - module: monaco.languages.typescript.ModuleKind.CommonJS, - noEmit: true, - typeRoots: ["node_modules/@types"], - }); - - monaco.languages.typescript.typescriptDefaults.setDiagnosticsOptions({ - noSemanticValidation: false, - noSyntaxValidation: false, - }); - - const autoTypings = AutoTypings.create(monacoEditor, { - sourceCache: new LocalStorageCache(), // Cache loaded sources in localStorage. May be omitted - monaco: monaco, - onError: (error) => { - console.log(error); - }, - onUpdate: (update, textual) => { - console.log(textual); - }, - }); -}; -export default function Function() { - const onChange = (value: string | undefined, ev: any) => { - //console.log(value) - }; - return ( - - ); -} diff --git a/src/components/Function/index.ts b/src/components/Function/index.ts deleted file mode 100644 index b6263050..00000000 --- a/src/components/Function/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -//export * from "./Function"; -export { default } from "./Function"; diff --git a/src/components/Functions/FunctionGrid/TableCard.tsx b/src/components/Functions/FunctionGrid/TableCard.tsx deleted file mode 100644 index 21be4ece..00000000 --- a/src/components/Functions/FunctionGrid/TableCard.tsx +++ /dev/null @@ -1,79 +0,0 @@ -import { Link } from "react-router-dom"; - -import { - Card, - CardActionArea, - CardContent, - Typography, - CardActions, - Button, -} from "@mui/material"; -import { Go as GoIcon } from "@src/assets/icons"; - -import RenderedMarkdown from "@src/components/RenderedMarkdown"; -import { TableSettings } from "@src/types/table"; - -export interface ITableCardProps extends TableSettings { - link: string; - actions?: React.ReactNode; -} - -export default function TableCard({ - section, - name, - description, - link, - actions, -}: ITableCardProps) { - return ( - - - - - {section} - - - {name} - - - - - - - (theme.typography.body2.lineHeight as number) * 2 + "em", - display: "flex", - flexDirection: "column", - gap: 1, - }} - component="div" - > - {description && ( - - )} - - - - - - -
- - {actions} - - - ); -} diff --git a/src/components/Functions/FunctionGrid/TableCardSkeleton.tsx b/src/components/Functions/FunctionGrid/TableCardSkeleton.tsx deleted file mode 100644 index c6611bde..00000000 --- a/src/components/Functions/FunctionGrid/TableCardSkeleton.tsx +++ /dev/null @@ -1,42 +0,0 @@ -import { - Card, - CardContent, - Typography, - CardActions, - Skeleton, -} from "@mui/material"; - -export default function TableCardSkeleton() { - return ( - - - - - - - - - - (theme.typography.body2.lineHeight as number) * 2 + "em", - }} - > - - - - - - - - - - - ); -} diff --git a/src/components/Functions/FunctionGrid/TableGrid.tsx b/src/components/Functions/FunctionGrid/TableGrid.tsx deleted file mode 100644 index 20d3b774..00000000 --- a/src/components/Functions/FunctionGrid/TableGrid.tsx +++ /dev/null @@ -1,73 +0,0 @@ -import { TransitionGroup } from "react-transition-group"; - -import { Box, Grid, Collapse } from "@mui/material"; - -import SectionHeading from "@src/components/SectionHeading"; -import TableCard from "./TableCard"; -import SlideTransition from "@src/components/Modal/SlideTransition"; - -import { TableSettings } from "@src/types/table"; - -export interface ITableGridProps { - sections: Record; - getLink: (table: TableSettings) => string; - getActions?: (table: TableSettings) => React.ReactNode; -} - -export default function TableGrid({ - sections, - getLink, - getActions, -}: ITableGridProps) { - return ( - - {Object.entries(sections).map( - ([sectionName, sectionTables], sectionIndex) => { - const tableItems = sectionTables - .map((table, tableIndex) => { - if (!table) return null; - - return ( - - - - - - ); - }) - .filter((item) => item !== null); - - if (tableItems.length === 0) return null; - - return ( - - - - - {sectionName} - - - - - {tableItems} - - - - ); - } - )} - - ); -} diff --git a/src/components/Functions/FunctionGrid/index.ts b/src/components/Functions/FunctionGrid/index.ts deleted file mode 100644 index 0397ca90..00000000 --- a/src/components/Functions/FunctionGrid/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from "./TableGrid"; -export { default } from "./TableGrid"; diff --git a/src/components/Functions/FunctionList/TableList.tsx b/src/components/Functions/FunctionList/TableList.tsx deleted file mode 100644 index 62911137..00000000 --- a/src/components/Functions/FunctionList/TableList.tsx +++ /dev/null @@ -1,71 +0,0 @@ -import { TransitionGroup } from "react-transition-group"; - -import { Box, Paper, Collapse, List } from "@mui/material"; - -import SectionHeading from "@src/components/SectionHeading"; -import TableListItem from "./TableListItem"; -import SlideTransition from "@src/components/Modal/SlideTransition"; - -import { TableSettings } from "@src/types/table"; - -export interface ITableListProps { - sections: Record; - getLink: (table: TableSettings) => string; - getActions?: (table: TableSettings) => React.ReactNode; -} - -export default function TableList({ - sections, - getLink, - getActions, -}: ITableListProps) { - return ( - - {Object.entries(sections).map( - ([sectionName, sectionTables], sectionIndex) => { - const tableItems = sectionTables - .map((table) => { - if (!table) return null; - - return ( - - - - ); - }) - .filter((item) => item !== null); - - if (tableItems.length === 0) return null; - - return ( - - - - - {sectionName} - - - - - - - {tableItems} - - - - - - ); - } - )} - - ); -} diff --git a/src/components/Functions/FunctionList/TableListItem.tsx b/src/components/Functions/FunctionList/TableListItem.tsx deleted file mode 100644 index e54c56a5..00000000 --- a/src/components/Functions/FunctionList/TableListItem.tsx +++ /dev/null @@ -1,81 +0,0 @@ -import { Link } from "react-router-dom"; - -import { - ListItem, - ListItemButton, - Typography, - IconButton, -} from "@mui/material"; -import GoIcon from "@mui/icons-material/ArrowForward"; - -import RenderedMarkdown from "@src/components/RenderedMarkdown"; -import { TableSettings } from "@src/types/table"; - -export interface ITableListItemProps extends TableSettings { - link: string; - actions?: React.ReactNode; -} - -export default function TableListItem({ - // section, - name, - description, - link, - actions, -}: ITableListItemProps) { - return ( - - *": { lineHeight: "48px !important" }, - flexWrap: "nowrap", - overflow: "hidden", - - flexBasis: 160 + 16, - flexGrow: 0, - flexShrink: 0, - mr: 2, - }} - > - - {name} - - - - - {description && ( - - )} - - -
- {actions} - - - - -
-
- ); -} diff --git a/src/components/Functions/FunctionList/TableListItemSkeleton.tsx b/src/components/Functions/FunctionList/TableListItemSkeleton.tsx deleted file mode 100644 index a2854ee8..00000000 --- a/src/components/Functions/FunctionList/TableListItemSkeleton.tsx +++ /dev/null @@ -1,23 +0,0 @@ -import { ListItem, Skeleton } from "@mui/material"; - -export default function TableListItemSkeleton() { - return ( - - - - - - - - ); -} diff --git a/src/components/Functions/FunctionList/index.ts b/src/components/Functions/FunctionList/index.ts deleted file mode 100644 index 20165432..00000000 --- a/src/components/Functions/FunctionList/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from "./TableList"; -export { default } from "./TableList"; diff --git a/src/components/Functions/HomeWelcomePrompt.tsx b/src/components/Functions/HomeWelcomePrompt.tsx deleted file mode 100644 index 1f2e10af..00000000 --- a/src/components/Functions/HomeWelcomePrompt.tsx +++ /dev/null @@ -1,33 +0,0 @@ -import { Zoom, Stack, Typography } from "@mui/material"; - -export default function HomeWelcomePrompt() { - return ( - - - - Get started - - - - Create a function - - - - ); -} diff --git a/src/pages/FunctionPage.tsx b/src/pages/FunctionPage.tsx deleted file mode 100644 index 721eefb1..00000000 --- a/src/pages/FunctionPage.tsx +++ /dev/null @@ -1,67 +0,0 @@ -import { Suspense } from "react"; -import { useAtom, Provider } from "jotai"; -import { useParams } from "react-router-dom"; -import { isEmpty } from "lodash-es"; - -import { Fade } from "@mui/material"; - -//import TableHeaderSkeleton from "@src/components/Table/Skeleton/TableHeaderSkeleton"; -//import TableSkeleton from "@src/components/Table/Skeleton/TableSkeleton"; -//import EmptyTable from "@src/components/Table/EmptyTable"; -import Function from "@src/components/Function"; - -import { currentUserAtom, projectScope } from "@src/atoms/projectScope"; -// import TableSourceFirestore from "@src/sources/TableSourceFirestore"; -// import { -// tableScope, -// tableIdAtom, -// tableSettingsAtom, -// tableSchemaAtom, -// } from "@src/atoms/tableScope"; - -export default function FunctionPage() { - // const [tableId] = useAtom(tableIdAtom, tableScope); - // const [tableSettings] = useAtom(tableSettingsAtom, tableScope); - // const [tableSchema] = useAtom(tableSchemaAtom, tableScope); - - // console.log(tableSchema); - - // if (isEmpty(tableSchema.columns)) - // return ( - // - //
- // - //
- //
- // ); - - return ; -} - -function ProvidedFunctionPage() { - const { id } = useParams(); - const [currentUser] = useAtom(currentUserAtom, projectScope); - - return ( - - {/* - */} - - } - > - {/* */} - {/* */} - - {/* */} - - ); -} diff --git a/src/pages/FunctionsPage.tsx b/src/pages/FunctionsPage.tsx deleted file mode 100644 index dd1dcd93..00000000 --- a/src/pages/FunctionsPage.tsx +++ /dev/null @@ -1,226 +0,0 @@ -import { useAtom, useSetAtom } from "jotai"; -import { find, groupBy } from "lodash-es"; - -import { - Container, - Stack, - Typography, - ToggleButtonGroup, - ToggleButton, - Tooltip, - Fab, - Checkbox, - IconButton, - Zoom, -} from "@mui/material"; -import ViewListIcon from "@mui/icons-material/ViewListOutlined"; -import ViewGridIcon from "@mui/icons-material/ViewModuleOutlined"; -import FavoriteBorderIcon from "@mui/icons-material/FavoriteBorder"; -import FavoriteIcon from "@mui/icons-material/Favorite"; -import EditIcon from "@mui/icons-material/EditOutlined"; -import AddIcon from "@mui/icons-material/Add"; - -import FloatingSearch from "@src/components/FloatingSearch"; -import SlideTransition from "@src/components/Modal/SlideTransition"; -import FunctionGrid from "@src/components/Functions/FunctionGrid"; -import FunctionList from "@src/components/Functions/FunctionList"; -import HomeWelcomePrompt from "@src/components/Functions/HomeWelcomePrompt"; -import EmptyState from "@src/components/EmptyState"; - -import { - projectScope, - userRolesAtom, - userSettingsAtom, - updateUserSettingsAtom, - tablesAtom, - tablesViewAtom, - tableSettingsDialogAtom, -} from "@src/atoms/projectScope"; -import { TableSettings } from "@src/types/table"; -import { ROUTES } from "@src/constants/routes"; -import useBasicSearch from "@src/hooks/useBasicSearch"; -import { TOP_BAR_HEIGHT } from "@src/layouts/Navigation/TopBar"; - -const SEARCH_KEYS = ["id", "name", "section", "description"]; - -export default function HomePage() { - const [userRoles] = useAtom(userRolesAtom, projectScope); - const [userSettings] = useAtom(userSettingsAtom, projectScope); - const [updateUserSettings] = useAtom(updateUserSettingsAtom, projectScope); - const [tables] = useAtom(tablesAtom, projectScope); - const [view, setView] = useAtom(tablesViewAtom, projectScope); - const openTableSettingsDialog = useSetAtom( - tableSettingsDialogAtom, - projectScope - ); - - const [results, query, handleQuery] = useBasicSearch( - tables ?? [], - SEARCH_KEYS - ); - - const favorites = Array.isArray(userSettings.favoriteTables) - ? userSettings.favoriteTables - : []; - const sections: Record = { - Favorites: favorites.map((id) => find(results, { id })) as TableSettings[], - ...groupBy(results, "section"), - }; - - if (!Array.isArray(tables)) - throw new Error( - "Project settings are not configured correctly. `tables` is not an array." - ); - - const createFunctionFab = ( - - - openTableSettingsDialog({ mode: "create" })} - sx={{ - zIndex: "speedDial", - position: "fixed", - bottom: (theme) => ({ - xs: `max(${theme.spacing(2)}, env(safe-area-inset-bottom))`, - sm: `max(${theme.spacing(3)}, env(safe-area-inset-bottom))`, - }), - right: (theme) => ({ - xs: `max(${theme.spacing(2)}, env(safe-area-inset-right))`, - sm: `max(${theme.spacing(3)}, env(safe-area-inset-right))`, - }), - }} - > - - - - - ); - - if (tables.length === 0) { - if (userRoles.includes("ADMIN")) - return ( - <> - - {createFunctionFab} - - ); - - return ( - - ); - } - - const getLink = (table: TableSettings) => - `${ROUTES.table}/${table.id.replace(/\//g, "~2F")}`; - - const handleFavorite = - (id: string) => (e: React.ChangeEvent) => { - const favoriteTables = e.target.checked - ? [...favorites, id] - : favorites.filter((f) => f !== id); - - if (updateUserSettings) updateUserSettings({ favoriteTables }); - }; - - const getActions = (table: TableSettings) => ( - <> - {userRoles.includes("ADMIN") && ( - - openTableSettingsDialog({ mode: "update", data: table }) - } - size={view === "list" ? "large" : undefined} - > - - - )} - } - checkedIcon={ - - - - } - name={`favorite-${table.id}`} - inputProps={{ "aria-label": "Favorite" }} - sx={view === "list" ? { p: 1.5 } : undefined} - color="secondary" - /> - - ); - - return ( - - handleQuery(e.target.value)} - paperSx={{ - maxWidth: (theme) => ({ md: theme.breakpoints.values.sm - 48 }), - mb: { xs: 2, md: -6 }, - }} - /> - - - - - {query ? `${results.length} of ${tables.length}` : tables.length}{" "} - tables - - - { - if (v !== null) setView(v); - }} - aria-label="Table view" - sx={{ "& .MuiToggleButton-root": { borderRadius: 2 } }} - > - - - - - - - - - - - {view === "list" ? ( - - ) : ( - - )} - - {userRoles.includes("ADMIN") && createFunctionFab} - - ); -}