diff --git a/app/src/data/fields/Field.ts b/app/src/data/fields/Field.ts index 5260d61..ffa7f08 100644 --- a/app/src/data/fields/Field.ts +++ b/app/src/data/fields/Field.ts @@ -157,8 +157,12 @@ export abstract class Field< return this.config.virtual ?? false; } - getLabel(): string { - return this.config.label ?? snakeToPascalWithSpaces(this.name); + getLabel(options?: { fallback?: boolean }): string | undefined { + return this.config.label + ? this.config.label + : options?.fallback !== false + ? snakeToPascalWithSpaces(this.name) + : undefined; } getDescription(): string | undefined { diff --git a/app/src/ui/client/BkndProvider.tsx b/app/src/ui/client/BkndProvider.tsx index 4f5293f..cc32221 100644 --- a/app/src/ui/client/BkndProvider.tsx +++ b/app/src/ui/client/BkndProvider.tsx @@ -33,6 +33,7 @@ export function BkndProvider({ useState>(); const [fetched, setFetched] = useState(false); const errorShown = useRef(); + const [local_version, set_local_version] = useState(0); const api = useApi(); async function reloadSchema() { @@ -80,6 +81,7 @@ export function BkndProvider({ setSchema(schema); setWithSecrets(_includeSecrets); setFetched(true); + set_local_version((v) => v + 1); }); } @@ -98,7 +100,10 @@ export function BkndProvider({ const actions = getSchemaActions({ api, setSchema, reloadSchema }); return ( - + {children} ); diff --git a/app/src/ui/client/schema/data/use-bknd-data.ts b/app/src/ui/client/schema/data/use-bknd-data.ts index 36db148..e5342c6 100644 --- a/app/src/ui/client/schema/data/use-bknd-data.ts +++ b/app/src/ui/client/schema/data/use-bknd-data.ts @@ -12,6 +12,7 @@ import { } from "data/data-schema"; import { useBknd } from "ui/client/bknd"; import type { TSchemaActions } from "ui/client/schema/actions"; +import { bkndModals } from "ui/modals"; export function useBkndData() { const { config, app, schema, actions: bkndActions } = useBknd(); @@ -62,7 +63,8 @@ export function useBkndData() { } }; const $data = { - entity: (name: string) => entities[name] + entity: (name: string) => entities[name], + modals }; return { @@ -75,6 +77,35 @@ export function useBkndData() { }; } +const modals = { + createAny: () => bkndModals.open(bkndModals.ids.dataCreate, {}), + createEntity: () => + bkndModals.open(bkndModals.ids.dataCreate, { + initialPath: ["entities", "entity"], + initialState: { action: "entity" } + }), + createRelation: (rel: { source?: string; target?: string; type?: string }) => + bkndModals.open(bkndModals.ids.dataCreate, { + initialPath: ["entities", "relation"], + initialState: { + action: "relation", + relations: { + create: [rel as any] + } + } + }), + createMedia: (entity?: string) => + bkndModals.open(bkndModals.ids.dataCreate, { + initialPath: ["entities", "template-media"], + initialState: { + action: "template-media", + initial: { + entity + } + } + }) +}; + function entityFieldActions(bkndActions: TSchemaActions, entityName: string) { return { add: async (name: string, field: TAppDataField) => { diff --git a/app/src/ui/components/buttons/Button.tsx b/app/src/ui/components/buttons/Button.tsx index c9df2b6..a9a55e2 100644 --- a/app/src/ui/components/buttons/Button.tsx +++ b/app/src/ui/components/buttons/Button.tsx @@ -4,15 +4,15 @@ import { twMerge } from "tailwind-merge"; import { Link } from "ui/components/wouter/Link"; const sizes = { - small: "px-2 py-1.5 rounded-md gap-1.5 text-sm", - default: "px-3 py-2.5 rounded-md gap-2.5", - large: "px-4 py-3 rounded-md gap-3 text-lg" + small: "px-2 py-1.5 rounded-md gap-1 text-sm", + default: "px-3 py-2.5 rounded-md gap-1.5", + large: "px-4 py-3 rounded-md gap-2.5 text-lg" }; const iconSizes = { - small: 15, - default: 18, - large: 22 + small: 12, + default: 16, + large: 20 }; const styles = { diff --git a/app/src/ui/components/buttons/IconButton.tsx b/app/src/ui/components/buttons/IconButton.tsx index 30d0263..145b2f8 100644 --- a/app/src/ui/components/buttons/IconButton.tsx +++ b/app/src/ui/components/buttons/IconButton.tsx @@ -10,9 +10,9 @@ export type IconType = const styles = { xs: { className: "p-0.5", size: 13 }, - sm: { className: "p-0.5", size: 16 }, - md: { className: "p-1", size: 20 }, - lg: { className: "p-1.5", size: 24 } + sm: { className: "p-0.5", size: 15 }, + md: { className: "p-1", size: 18 }, + lg: { className: "p-1.5", size: 22 } } as const; interface IconButtonProps extends ComponentPropsWithoutRef<"button"> { diff --git a/app/src/ui/components/display/Empty.tsx b/app/src/ui/components/display/Empty.tsx index 717b781..9f1291c 100644 --- a/app/src/ui/components/display/Empty.tsx +++ b/app/src/ui/components/display/Empty.tsx @@ -1,33 +1,33 @@ -import { Button } from "../buttons/Button"; +import { twMerge } from "tailwind-merge"; +import { Button, type ButtonProps } from "../buttons/Button"; export type EmptyProps = { Icon?: any; title?: string; description?: string; - buttonText?: string; - buttonOnClick?: () => void; + primary?: ButtonProps; + secondary?: ButtonProps; + className?: string; }; export const Empty: React.FC = ({ Icon = undefined, title = undefined, description = "Check back later my friend.", - buttonText, - buttonOnClick + primary, + secondary, + className }) => ( -
+
{Icon && }
{title &&

{title}

}

{description}

- {buttonText && ( -
- -
- )} +
+ {secondary &&
); diff --git a/app/src/ui/components/steps/Steps.tsx b/app/src/ui/components/steps/Steps.tsx index 0dc02f2..d0ccc47 100644 --- a/app/src/ui/components/steps/Steps.tsx +++ b/app/src/ui/components/steps/Steps.tsx @@ -10,6 +10,7 @@ import { export type TStepsProps = { children: any; initialPath?: string[]; + initialState?: any; lastBack?: () => void; [key: string]: any; }; @@ -19,13 +20,14 @@ type TStepContext = { stepBack: () => void; close: () => void; state: T; + path: string[]; setState: Dispatch>; }; const StepContext = createContext(undefined as any); -export function Steps({ children, initialPath = [], lastBack }: TStepsProps) { - const [state, setState] = useState({}); +export function Steps({ children, initialPath = [], initialState = {}, lastBack }: TStepsProps) { + const [state, setState] = useState(initialState); const [path, setPath] = useState(initialPath); const steps: any[] = Children.toArray(children).filter( (child: any) => child.props.disabled !== true @@ -46,7 +48,7 @@ export function Steps({ children, initialPath = [], lastBack }: TStepsProps) { const current = steps.find((step) => step.props.id === path[path.length - 1]) || steps[0]; return ( - + {current} ); diff --git a/app/src/ui/hooks/use-effect.ts b/app/src/ui/hooks/use-effect.ts new file mode 100644 index 0000000..539bc7b --- /dev/null +++ b/app/src/ui/hooks/use-effect.ts @@ -0,0 +1,32 @@ +import { useEffect, useRef } from "react"; + +export function useEffectOnce(effect: () => void | (() => void | undefined), deps: any[]): void { + const hasRunRef = useRef(false); + const savedDepsRef = useRef(deps); + + useEffect(() => { + const depsChanged = !hasRunRef.current || !areDepsEqual(savedDepsRef.current, deps); + + if (depsChanged) { + hasRunRef.current = true; + savedDepsRef.current = deps; + return effect(); + } + }, [deps]); +} + +function areDepsEqual(prevDeps: any[] | undefined, nextDeps: any[]): boolean { + if (prevDeps && prevDeps.length === 0 && nextDeps.length === 0) { + return true; + } + + if (!prevDeps && nextDeps.length === 0) { + return true; + } + + if (!prevDeps || !nextDeps || prevDeps.length !== nextDeps.length) { + return false; + } + + return prevDeps.every((dep, index) => Object.is(dep, nextDeps[index])); +} diff --git a/app/src/ui/modals/index.tsx b/app/src/ui/modals/index.tsx index 3ea2143..9869158 100644 --- a/app/src/ui/modals/index.tsx +++ b/app/src/ui/modals/index.tsx @@ -1,8 +1,8 @@ import type { ModalProps } from "@mantine/core"; import { modals as $modals, ModalsProvider, closeModal, openContextModal } from "@mantine/modals"; -import { transformObject } from "core/utils"; import type { ComponentProps } from "react"; import { OverlayModal } from "ui/modals/debug/OverlayModal"; +import { CreateModal } from "ui/modules/data/components/schema/create-modal/CreateModal"; import { DebugModal } from "./debug/DebugModal"; import { SchemaFormModal } from "./debug/SchemaFormModal"; import { TestModal } from "./debug/TestModal"; @@ -11,7 +11,8 @@ const modals = { test: TestModal, debug: DebugModal, form: SchemaFormModal, - overlay: OverlayModal + overlay: OverlayModal, + dataCreate: CreateModal }; declare module "@mantine/modals" { @@ -54,10 +55,9 @@ function close(modal: Modal) { } export const bkndModals = { - ids: transformObject(modals, (key) => key) as unknown as Record< - keyof typeof modals, - keyof typeof modals - >, + ids: Object.fromEntries(Object.keys(modals).map((key) => [key, key])) as { + [K in keyof typeof modals]: K; + }, open, close, closeAll: $modals.closeAll diff --git a/app/src/ui/modules/data/components/fields/EntityRelationalFormField.tsx b/app/src/ui/modules/data/components/fields/EntityRelationalFormField.tsx index 861bc24..1d3788c 100644 --- a/app/src/ui/modules/data/components/fields/EntityRelationalFormField.tsx +++ b/app/src/ui/modules/data/components/fields/EntityRelationalFormField.tsx @@ -9,6 +9,7 @@ import { useBknd } from "ui/client/bknd"; import { Button } from "ui/components/buttons/Button"; import * as Formy from "ui/components/form/Formy"; import { Popover } from "ui/components/overlay/Popover"; +import { Link } from "ui/components/wouter/Link"; import { routes } from "ui/lib/routes"; import { useLocation } from "wouter"; import { EntityTable } from "../EntityTable"; @@ -82,7 +83,9 @@ export function EntityRelationalFormField({ return ( - {field.getLabel()} + + {field.getLabel({ fallback: false }) ?? entity.label} +
- + + + ) : (
- Select -
diff --git a/app/src/ui/modules/data/components/schema/create-modal/CreateModal.tsx b/app/src/ui/modules/data/components/schema/create-modal/CreateModal.tsx index 1863d83..e44d04e 100644 --- a/app/src/ui/modules/data/components/schema/create-modal/CreateModal.tsx +++ b/app/src/ui/modules/data/components/schema/create-modal/CreateModal.tsx @@ -1,15 +1,9 @@ -import { type Static, StringEnum, StringIdentifier, Type, transformObject } from "core/utils"; -import { FieldClassMap } from "data"; +import type { ModalProps } from "@mantine/core"; +import type { ContextModalProps } from "@mantine/modals"; +import { type Static, StringEnum, StringIdentifier, Type } from "core/utils"; import { entitiesSchema, fieldsSchema, relationsSchema } from "data/data-schema"; -import { omit } from "lodash-es"; -import { forwardRef, useState } from "react"; -import { - Modal2, - type Modal2Ref, - ModalBody, - ModalFooter, - ModalTitle -} from "ui/components/modal/Modal2"; +import { useState } from "react"; +import { type Modal2Ref, ModalBody, ModalFooter, ModalTitle } from "ui/components/modal/Modal2"; import { Step, Steps, useStepContext } from "ui/components/steps/Steps"; import { StepCreate } from "ui/modules/data/components/schema/create-modal/step.create"; import { StepEntity } from "./step.entity"; @@ -45,6 +39,7 @@ export type TFieldCreate = Static; const createModalSchema = Type.Object( { action: schemaAction, + initial: Type.Optional(Type.Any()), entities: Type.Optional( Type.Object({ create: Type.Optional(Type.Array(entitySchema)) @@ -67,48 +62,59 @@ const createModalSchema = Type.Object( ); export type TCreateModalSchema = Static; -export const CreateModal = forwardRef(function CreateModal(props, ref) { - const [path, setPath] = useState([]); +export function CreateModal({ + context, + id, + innerProps: { initialPath = [], initialState } +}: ContextModalProps<{ initialPath?: string[]; initialState?: TCreateModalSchema }>) { + const [path, setPath] = useState(initialPath); + console.log("...", initialPath, initialState); function close() { - // @ts-ignore - ref?.current?.close(); + context.closeModal(id); } return ( - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + - {/* Templates */} - {Templates.map(([Component, meta]) => ( - - - - - ))} - - + {/* Templates */} + {Templates.map(([Component, meta]) => ( + + + + + ))} + ); -}); +} +CreateModal.defaultTitle = undefined; +CreateModal.modalProps = { + withCloseButton: false, + size: "xl", + padding: 0, + classNames: { + root: "bknd-admin" + } +} satisfies Partial; export { ModalBody, ModalFooter, ModalTitle, useStepContext, relationsSchema }; diff --git a/app/src/ui/modules/data/components/schema/create-modal/step.create.tsx b/app/src/ui/modules/data/components/schema/create-modal/step.create.tsx index 16cad49..371646e 100644 --- a/app/src/ui/modules/data/components/schema/create-modal/step.create.tsx +++ b/app/src/ui/modules/data/components/schema/create-modal/step.create.tsx @@ -10,6 +10,7 @@ import { ucFirst } from "core/utils"; import { useEffect, useState } from "react"; import { TbCirclesRelation, TbSettings } from "react-icons/tb"; import { twMerge } from "tailwind-merge"; +import { useBknd } from "ui/client/bknd"; import { useBkndData } from "ui/client/schema/data/use-bknd-data"; import { IconButton, type IconType } from "ui/components/buttons/IconButton"; import { JsonViewer } from "ui/components/code/JsonViewer"; @@ -26,6 +27,7 @@ export function StepCreate() { const [states, setStates] = useState<(boolean | string)[]>([]); const [submitting, setSubmitting] = useState(false); const $data = useBkndData(); + const b = useBknd(); const items: ActionItem[] = []; if (state.entities?.create) { @@ -90,7 +92,8 @@ export function StepCreate() { states.every((s) => s === true) ); if (items.length === states.length && states.every((s) => s === true)) { - close(); + b.actions.reload().then(close); + //close(); } else { setSubmitting(false); } diff --git a/app/src/ui/modules/data/components/schema/create-modal/step.relation.tsx b/app/src/ui/modules/data/components/schema/create-modal/step.relation.tsx index 05066a1..f32e4a1 100644 --- a/app/src/ui/modules/data/components/schema/create-modal/step.relation.tsx +++ b/app/src/ui/modules/data/components/schema/create-modal/step.relation.tsx @@ -9,12 +9,15 @@ import { registerCustomTypeboxKinds } from "core/utils"; import { ManyToOneRelation, type RelationType, RelationTypes } from "data"; -import { type ReactNode, useEffect } from "react"; +import { type ReactNode, startTransition, useEffect } from "react"; import { type Control, type FieldValues, type UseFormRegister, useForm } from "react-hook-form"; +import { TbRefresh } from "react-icons/tb"; import { useBknd } from "ui/client/bknd"; +import { Button } from "ui/components/buttons/Button"; import { MantineNumberInput } from "ui/components/form/hook-form-mantine/MantineNumberInput"; import { MantineSelect } from "ui/components/form/hook-form-mantine/MantineSelect"; import { useStepContext } from "ui/components/steps/Steps"; +import { useEvent } from "ui/hooks/use-event"; import { ModalBody, ModalFooter, type TCreateModalSchema } from "./CreateModal"; // @todo: check if this could become an issue @@ -63,7 +66,7 @@ type ComponentCtx = { export function StepRelation() { const { config } = useBknd(); const entities = config.data.entities; - const { nextStep, stepBack, state, setState } = useStepContext(); + const { nextStep, stepBack, state, path, setState } = useStepContext(); const { register, handleSubmit, @@ -93,6 +96,22 @@ export function StepRelation() { } } + const flip = useEvent(() => { + const { source, target } = data; + if (source && target) { + setValue("source", target); + setValue("target", source); + } else { + if (source) { + setValue("target", source); + setValue("source", null as any); + } else { + setValue("source", target); + setValue("target", null as any); + } + } + }); + return ( <>
@@ -109,14 +128,23 @@ export function StepRelation() { disabled: data.target === name }))} /> - setValue("config", {})} - label="Relation Type" - data={Relations.map((r) => ({ value: r.type, label: r.label }))} - allowDeselect={false} - /> +
+ setValue("config", {})} + label="Relation Type" + data={Relations.map((r) => ({ value: r.type, label: r.label }))} + allowDeselect={false} + /> + {data.type && ( +
+ +
+ )} +
diff --git a/app/src/ui/modules/data/components/schema/create-modal/step.select.tsx b/app/src/ui/modules/data/components/schema/create-modal/step.select.tsx index 30bb3a2..a26c62d 100644 --- a/app/src/ui/modules/data/components/schema/create-modal/step.select.tsx +++ b/app/src/ui/modules/data/components/schema/create-modal/step.select.tsx @@ -12,7 +12,7 @@ import { import Templates from "./templates/register"; export function StepSelect() { - const { nextStep, stepBack, state, setState } = useStepContext(); + const { nextStep, stepBack, state, path, setState } = useStepContext(); const selected = state.action ?? null; function handleSelect(action: TSchemaAction) { @@ -74,6 +74,7 @@ export function StepSelect() { }} prev={{ onClick: stepBack }} prevLabel="Cancel" + debug={{ state, path }} /> ); diff --git a/app/src/ui/modules/data/components/schema/create-modal/templates/media/template.media.component.tsx b/app/src/ui/modules/data/components/schema/create-modal/templates/media/template.media.component.tsx index 3f5474b..ea4d149 100644 --- a/app/src/ui/modules/data/components/schema/create-modal/templates/media/template.media.component.tsx +++ b/app/src/ui/modules/data/components/schema/create-modal/templates/media/template.media.component.tsx @@ -31,7 +31,7 @@ const schema = Type.Object({ type TCreateModalMediaSchema = Static; export function TemplateMediaComponent() { - const { stepBack, setState, state, nextStep } = useStepContext(); + const { stepBack, setState, state, path, nextStep } = useStepContext(); const { register, handleSubmit, @@ -41,7 +41,7 @@ export function TemplateMediaComponent() { control } = useForm({ resolver: typeboxResolver(schema), - defaultValues: Default(schema, {}) as TCreateModalMediaSchema + defaultValues: Default(schema, state.initial ?? {}) as TCreateModalMediaSchema }); const { config } = useBknd(); @@ -134,7 +134,7 @@ export function TemplateMediaComponent() { prev={{ onClick: stepBack }} - debug={{ state, data }} + debug={{ state, path, data }} /> diff --git a/app/src/ui/routes/data/_data.root.tsx b/app/src/ui/routes/data/_data.root.tsx index d021c54..1ad24fa 100644 --- a/app/src/ui/routes/data/_data.root.tsx +++ b/app/src/ui/routes/data/_data.root.tsx @@ -1,8 +1,10 @@ -import { SegmentedControl } from "@mantine/core"; +import { SegmentedControl, Tooltip } from "@mantine/core"; import { IconDatabase } from "@tabler/icons-react"; import type { Entity, TEntityType } from "data"; +import { TbDatabasePlus } from "react-icons/tb"; import { twMerge } from "tailwind-merge"; -import { useBknd } from "ui/client/bknd"; +import { useBkndData } from "ui/client/schema/data/use-bknd-data"; +import { IconButton } from "ui/components/buttons/IconButton"; import { Empty } from "ui/components/display/Empty"; import { Link } from "ui/components/wouter/Link"; import { useBrowserTitle } from "ui/hooks/use-browser-title"; @@ -11,9 +13,7 @@ import { routes, useNavigate } from "ui/lib/routes"; export function DataRoot({ children }) { // @todo: settings routes should be centralized - const { - app: { entities } - } = useBknd(); + const { entities, $data } = useBkndData(); const entityList: Record = { regular: [], generated: [], @@ -22,7 +22,7 @@ export function DataRoot({ children }) { const [navigate] = useNavigate(); const context = window.location.href.match(/\/schema/) ? "schema" : "data"; - for (const entity of entities) { + for (const entity of Object.values(entities)) { entityList[entity.getType()].push(entity); } @@ -52,14 +52,19 @@ export function DataRoot({ children }) { + <> + + + + + } > Entities @@ -70,7 +75,7 @@ export function DataRoot({ children }) {
*/} - + { - if (entities.length === 0) return null; + context, + suggestCreate = false +}: { entities: Entity[]; title?: string; context: "data" | "schema"; suggestCreate?: boolean }) => { + const { $data } = useBkndData(); + if (entities.length === 0) { + return suggestCreate ? ( + $data.modals.createEntity() + }} + /> + ) : null; + } return (
diff --git a/app/src/ui/routes/data/data.schema.index.tsx b/app/src/ui/routes/data/data.schema.index.tsx index a9cbe18..8635650 100644 --- a/app/src/ui/routes/data/data.schema.index.tsx +++ b/app/src/ui/routes/data/data.schema.index.tsx @@ -1,10 +1,7 @@ -import { Suspense, lazy, useRef } from "react"; -import { - CreateModal, - type CreateModalRef -} from "ui/modules/data/components/schema/create-modal/CreateModal"; -import { Button } from "../../components/buttons/Button"; -import * as AppShell from "../../layouts/AppShell/AppShell"; +import { Suspense, lazy } from "react"; +import { useBkndData } from "ui/client/schema/data/use-bknd-data"; +import { Button } from "ui/components/buttons/Button"; +import * as AppShell from "ui/layouts/AppShell/AppShell"; const DataSchemaCanvas = lazy(() => import("ui/modules/data/components/canvas/DataSchemaCanvas").then((m) => ({ @@ -13,18 +10,12 @@ const DataSchemaCanvas = lazy(() => ); export function DataSchemaIndex() { - const createModalRef = useRef(null); - + const { $data } = useBkndData(); return ( <> - createModalRef.current?.open()} - > + } diff --git a/app/src/ui/routes/flows_old/_flows.root.tsx b/app/src/ui/routes/flows_old/_flows.root.tsx index e7bb1c6..15d1e09 100644 --- a/app/src/ui/routes/flows_old/_flows.root.tsx +++ b/app/src/ui/routes/flows_old/_flows.root.tsx @@ -55,8 +55,10 @@ export function FlowsEmpty() { title="No flow selected" description="Please select a flow from the left sidebar or create a new one to continue." - buttonText="Create Flow" - buttonOnClick={() => navigate(app.getSettingsPath(["flows"]))} + primary={{ + children: "Create Flow", + onClick: () => navigate(app.getSettingsPath(["flows"])) + }} /> diff --git a/app/src/ui/routes/media/_media.root.tsx b/app/src/ui/routes/media/_media.root.tsx index 4b34188..959a636 100644 --- a/app/src/ui/routes/media/_media.root.tsx +++ b/app/src/ui/routes/media/_media.root.tsx @@ -20,8 +20,10 @@ export function MediaRoot({ children }) { Icon={IconPhoto} title="Media not enabled" description="Please enable media in the settings to continue." - buttonText="Manage Settings" - buttonOnClick={() => navigate(app.getSettingsPath(["media"]))} + primary={{ + children: "Manage Settings", + onClick: () => navigate(app.getSettingsPath(["media"])) + }} /> ); } diff --git a/app/src/ui/routes/root.tsx b/app/src/ui/routes/root.tsx index a0b2ed8..184c903 100644 --- a/app/src/ui/routes/root.tsx +++ b/app/src/ui/routes/root.tsx @@ -1,17 +1,18 @@ import { IconHome } from "@tabler/icons-react"; import { useEffect } from "react"; import { useAuth } from "ui/client"; +import { useEffectOnce } from "ui/hooks/use-effect"; import { Empty } from "../components/display/Empty"; import { useBrowserTitle } from "../hooks/use-browser-title"; import * as AppShell from "../layouts/AppShell/AppShell"; import { useNavigate } from "../lib/routes"; export const Root = ({ children }) => { - const { verify } = useAuth(); + const { verify, user } = useAuth(); - useEffect(() => { + useEffectOnce(() => { verify(); - }, []); + }, [user?.id]); return ( diff --git a/app/src/ui/routes/settings/components/Setting.tsx b/app/src/ui/routes/settings/components/Setting.tsx index 20a852b..d26a877 100644 --- a/app/src/ui/routes/settings/components/Setting.tsx +++ b/app/src/ui/routes/settings/components/Setting.tsx @@ -175,7 +175,10 @@ export function Setting({ goBack() + }} /> ); } diff --git a/app/vite.dev.ts b/app/vite.dev.ts index 244b84d..0d27e5a 100644 --- a/app/vite.dev.ts +++ b/app/vite.dev.ts @@ -7,12 +7,11 @@ import { StorageLocalAdapter } from "./src/media/storage/adapters/StorageLocalAd registries.media.register("local", StorageLocalAdapter); -const run_example: string | boolean = false; -//run_example = "ex-admin-rich"; +const example = import.meta.env.VITE_EXAMPLE; -const credentials = run_example +const credentials = example ? { - url: `file:.configs/${run_example}.db` + url: `file:.configs/${example}.db` //url: ":memory:" } : { @@ -26,10 +25,8 @@ if (!credentials.url) { const connection = new LibsqlConnection(createClient(credentials)); let initialConfig: any = undefined; -if (run_example) { - const { version, ...config } = JSON.parse( - await readFile(`.configs/${run_example}.json`, "utf-8") - ); +if (example) { + const { version, ...config } = JSON.parse(await readFile(`.configs/${example}.json`, "utf-8")); initialConfig = config; } diff --git a/biome.json b/biome.json index 37a8584..34a1fb1 100644 --- a/biome.json +++ b/biome.json @@ -52,6 +52,7 @@ "noSwitchDeclarations": "warn" }, "complexity": { + "noUselessFragments": "warn", "noStaticOnlyClass": "off", "noForEach": "off", "useLiteralKeys": "warn",