From f1b1ec59ecda603d8a34d72fc5fa4f1daacac20d Mon Sep 17 00:00:00 2001 From: Thomas Camlong Date: Sun, 19 May 2024 22:38:39 +0200 Subject: [PATCH] chore: update prettier configuration for print width (#519) * feat: update prettier configuration for print width * chore: apply code formatting to entire repository * fix: remove build files * fix: format issue --------- Co-authored-by: Meier Lukas --- .gitignore | 5 +- .vscode/settings.json | 3 +- apps/nextjs/next.config.mjs | 14 +- .../_client-providers/next-international.tsx | 5 +- .../[locale]/_client-providers/session.tsx | 5 +- .../app/[locale]/_client-providers/trpc.tsx | 14 +- .../auth/invite/[id]/_registration-form.tsx | 15 +- .../app/[locale]/auth/invite/[id]/page.tsx | 10 +- .../app/[locale]/auth/login/_login-form.tsx | 32 +- .../app/[locale]/boards/(content)/_client.tsx | 26 +- .../[locale]/boards/(content)/_context.tsx | 18 +- .../[locale]/boards/(content)/_creator.tsx | 16 +- .../boards/(content)/_header-actions.tsx | 63 +- .../app/[locale]/boards/(content)/_theme.tsx | 4 +- .../boards/[name]/settings/_access.tsx | 6 +- .../_access/board-access-table-rows.tsx | 44 +- .../boards/[name]/settings/_access/form.ts | 3 +- .../[name]/settings/_access/group-access.tsx | 59 +- .../settings/_access/group-select-modal.tsx | 97 ++- .../settings/_access/inherit-access.tsx | 13 +- .../[name]/settings/_access/user-access.tsx | 57 +- .../settings/_access/user-select-modal.tsx | 123 ++-- .../boards/[name]/settings/_background.tsx | 31 +- .../boards/[name]/settings/_colors.tsx | 14 +- .../boards/[name]/settings/_danger.tsx | 34 +- .../boards/[name]/settings/_general.tsx | 40 +- .../boards/[name]/settings/_layout.tsx | 22 +- .../[locale]/boards/[name]/settings/page.tsx | 48 +- .../app/[locale]/boards/_layout-creator.tsx | 5 +- apps/nextjs/src/app/[locale]/boards/_types.ts | 5 +- apps/nextjs/src/app/[locale]/compose.tsx | 18 +- .../[locale]/init/user/_init-user-form.tsx | 23 +- apps/nextjs/src/app/[locale]/layout.tsx | 9 +- .../manage/_components/hero-banner.tsx | 24 +- .../[locale]/manage/about/about.module.css | 5 +- .../src/app/[locale]/manage/about/page.tsx | 18 +- .../manage/apps/_app-delete-button.tsx | 13 +- .../src/app/[locale]/manage/apps/_form.tsx | 8 +- .../manage/apps/edit/[id]/_app-edit-form.tsx | 10 +- .../manage/apps/new/_app-new-form.tsx | 16 +- .../src/app/[locale]/manage/apps/page.tsx | 4 +- .../_components/board-card-menu-dropdown.tsx | 16 +- .../_components/create-board-button.tsx | 6 +- .../src/app/[locale]/manage/boards/page.tsx | 24 +- .../integrations/_integration-buttons.tsx | 10 +- .../integrations/_integration-secret-card.tsx | 25 +- .../_integration-secret-inputs.tsx | 5 +- .../_integration-test-connection.tsx | 39 +- .../edit/[id]/_integration-edit-form.tsx | 55 +- .../manage/integrations/edit/[id]/page.tsx | 8 +- .../new/_integration-new-dropdown.tsx | 10 +- .../new/_integration-new-form.tsx | 71 +- .../[locale]/manage/integrations/new/page.tsx | 8 +- .../app/[locale]/manage/integrations/page.tsx | 39 +- apps/nextjs/src/app/[locale]/manage/page.tsx | 7 +- .../_components/analytics.settings.tsx | 47 +- .../app/[locale]/manage/tools/logs/page.tsx | 7 +- .../[locale]/manage/tools/logs/terminal.tsx | 13 +- .../[locale]/manage/users/[userId]/access.ts | 5 +- .../_components/_delete-user-button.tsx | 13 +- .../_components/_profile-avatar-form.tsx | 49 +- .../general/_components/_profile-form.tsx | 16 +- .../manage/users/[userId]/general/page.tsx | 5 +- .../[locale]/manage/users/[userId]/layout.tsx | 27 +- .../_components/_change-password-form.tsx | 11 +- .../manage/users/[userId]/security/page.tsx | 4 +- .../users/_components/user-list.component.tsx | 8 +- .../_components/create-user-stepper.tsx | 53 +- .../stepper-navigation.component.tsx | 19 +- .../users/groups/[id]/_delete-group.tsx | 15 +- .../manage/users/groups/[id]/_navigation.tsx | 10 +- .../users/groups/[id]/_rename-group-form.tsx | 10 +- .../groups/[id]/_transfer-group-ownership.tsx | 20 +- .../manage/users/groups/[id]/layout.tsx | 23 +- .../groups/[id]/members/_add-group-member.tsx | 9 +- .../[id]/members/_remove-group-member.tsx | 25 +- .../manage/users/groups/[id]/members/page.tsx | 29 +- .../manage/users/groups/[id]/page.tsx | 9 +- .../permissions/_group-permission-form.tsx | 14 +- .../users/groups/[id]/permissions/page.tsx | 25 +- .../manage/users/groups/_add-group.tsx | 11 +- .../app/[locale]/manage/users/groups/page.tsx | 19 +- .../invites/_components/invite-copy-modal.tsx | 12 +- .../users/invites/_components/invite-list.tsx | 21 +- .../app/[locale]/widgets/[kind]/_content.tsx | 64 +- .../widgets/[kind]/_dimension-modal.tsx | 68 +- apps/nextjs/src/app/api/trpc/[trpc]/route.ts | 7 +- .../src/components/active-tab-accordion.tsx | 20 +- .../components/board/items/item-actions.tsx | 26 +- .../board/items/item-select-modal.tsx | 17 +- .../board/modals/board-rename-modal.tsx | 97 ++- .../components/board/permissions/server.ts | 4 +- .../board/sections/category-section.tsx | 22 +- .../sections/category/category-actions.ts | 58 +- .../sections/category/category-edit-modal.tsx | 68 +- .../category/category-menu-actions.tsx | 3 +- .../board/sections/category/category-menu.tsx | 10 +- .../src/components/board/sections/content.tsx | 52 +- .../board/sections/empty-section.tsx | 6 +- .../sections/gridstack/init-gridstack.ts | 10 +- .../board/sections/gridstack/use-gridstack.ts | 31 +- .../components/icons/picker/icon-picker.tsx | 33 +- .../components/language/language-combobox.tsx | 14 +- .../src/components/layout/background.tsx | 5 +- apps/nextjs/src/components/layout/header.tsx | 8 +- .../src/components/layout/header/burger.tsx | 9 +- .../src/components/layout/header/button.tsx | 32 +- .../src/components/layout/logo/board-logo.tsx | 5 +- .../components/layout/logo/homarr-logo.tsx | 8 +- .../src/components/layout/logo/logo.tsx | 20 +- .../src/components/layout/navigation-link.tsx | 6 +- .../src/components/layout/navigation.tsx | 6 +- .../manage/boards/add-board-modal.tsx | 75 +- .../src/components/manage/danger-zone.tsx | 16 +- .../src/components/user-avatar-menu.tsx | 81 +-- apps/nextjs/src/components/user-avatar.tsx | 14 +- apps/nextjs/src/env.mjs | 12 +- apps/nextjs/src/versions/package-reader.ts | 9 +- apps/tasks/src/jobs/icons-updater.ts | 14 +- apps/tasks/src/lib/cron-job/creator.ts | 5 +- apps/tasks/src/lib/cron-job/group.ts | 5 +- apps/tasks/src/lib/queue/client.ts | 15 +- apps/tasks/src/seed-server-settings.ts | 9 +- apps/websocket/src/main.ts | 14 +- packages/api/src/router/app.ts | 90 ++- packages/api/src/router/board.ts | 651 +++++++----------- packages/api/src/router/board/board-access.ts | 14 +- packages/api/src/router/group.ts | 324 ++++----- packages/api/src/router/home.ts | 28 +- packages/api/src/router/icons.ts | 38 +- packages/api/src/router/integration.ts | 366 +++++----- packages/api/src/router/location.ts | 8 +- packages/api/src/router/serverSettings.ts | 4 +- packages/api/src/router/test/board.spec.ts | 313 +++------ .../router/test/board/board-access.spec.ts | 212 +++--- packages/api/src/router/test/group.spec.ts | 162 ++--- .../api/src/router/test/integration.spec.ts | 61 +- .../src/router/test/serverSettings.spec.ts | 5 +- packages/api/src/router/test/user.spec.ts | 10 +- packages/api/src/router/user.ts | 256 ++++--- packages/api/src/trpc.ts | 10 +- packages/auth/callbacks.ts | 33 +- packages/auth/configuration.ts | 5 +- packages/auth/env.mjs | 8 +- packages/auth/index.ts | 8 +- .../auth/permissions/board-permissions.ts | 17 +- packages/auth/providers/credentials.ts | 9 +- .../auth/providers/test/credentials.spec.ts | 8 +- packages/auth/session.ts | 5 +- packages/auth/test/callbacks.spec.ts | 48 +- packages/auth/test/session.spec.ts | 13 +- packages/common/src/object.ts | 3 +- packages/common/src/test/object.spec.ts | 7 +- packages/db/schema/mysql.ts | 144 ++-- packages/db/schema/sqlite.ts | 126 ++-- packages/db/test/schema.spec.ts | 92 +-- packages/definitions/src/_definition.ts | 5 +- packages/definitions/src/board.ts | 24 +- packages/definitions/src/integration.ts | 62 +- packages/definitions/src/permissions.ts | 43 +- .../definitions/src/test/permissions.spec.ts | 71 +- packages/definitions/src/widget.ts | 9 +- packages/form/src/index.ts | 11 +- packages/form/src/messages.ts | 12 +- packages/icons/src/icons-fetcher.ts | 16 +- .../repositories/github.icon-repository.ts | 20 +- .../icons/src/repositories/icon-repository.ts | 4 +- .../repositories/jsdelivr.icon-repository.ts | 20 +- packages/log/src/index.mjs | 6 +- packages/modals/src/confirm-modal.tsx | 105 ++- packages/modals/src/creator.ts | 4 +- packages/modals/src/index.tsx | 36 +- packages/modals/src/reducer.tsx | 13 +- packages/redis/src/index.ts | 4 +- packages/redis/src/lib/channel.ts | 4 +- packages/spotlight/ReadMe.md | 3 +- packages/spotlight/src/chip-group.tsx | 21 +- packages/spotlight/src/component.tsx | 44 +- packages/spotlight/src/data-store.ts | 7 +- packages/spotlight/src/spotlight-store.ts | 13 +- packages/spotlight/src/type.ts | 8 +- packages/translation/src/client.ts | 15 +- packages/translation/src/index.ts | 5 +- packages/translation/src/lang.ts | 8 +- packages/translation/src/lang/de.ts | 9 +- packages/translation/src/lang/en.ts | 60 +- packages/translation/src/server.ts | 9 +- packages/ui/src/components/search-input.tsx | 5 +- .../components/select-with-custom-items.tsx | 29 +- .../select-with-description-and-badge.tsx | 13 +- .../components/select-with-description.tsx | 7 +- .../ui/src/components/table-pagination.tsx | 17 +- .../ui/src/components/user-avatar-group.tsx | 6 +- packages/ui/src/components/user-avatar.tsx | 4 +- packages/validation/src/enums.ts | 10 +- packages/validation/src/form/i18n.ts | 10 +- packages/validation/src/index.ts | 6 +- packages/validation/src/shared.ts | 13 +- packages/validation/src/user.ts | 7 +- packages/widgets/src/_inputs/common.tsx | 9 +- packages/widgets/src/_inputs/form.ts | 3 +- packages/widgets/src/_inputs/index.ts | 4 +- .../widgets/src/_inputs/widget-app-input.tsx | 28 +- .../src/_inputs/widget-location-input.tsx | 133 ++-- .../src/_inputs/widget-multiselect-input.tsx | 6 +- .../src/_inputs/widget-number-input.tsx | 6 +- .../src/_inputs/widget-select-input.tsx | 17 +- .../src/_inputs/widget-slider-input.tsx | 6 +- .../src/_inputs/widget-switch-input.tsx | 6 +- .../widgets/src/_inputs/widget-text-input.tsx | 6 +- packages/widgets/src/app/component.tsx | 45 +- packages/widgets/src/app/index.ts | 21 +- packages/widgets/src/app/serverData.ts | 4 +- packages/widgets/src/clock/component.tsx | 38 +- packages/widgets/src/definition.ts | 85 +-- packages/widgets/src/iframe/component.tsx | 20 +- packages/widgets/src/iframe/index.ts | 35 +- packages/widgets/src/index.tsx | 5 +- .../widgets/src/modals/widget-edit-modal.tsx | 102 ++- packages/widgets/src/notebook/component.tsx | 13 +- packages/widgets/src/notebook/index.ts | 41 +- packages/widgets/src/notebook/notebook.tsx | 156 +---- packages/widgets/src/options.ts | 33 +- packages/widgets/src/server/provider.tsx | 27 +- packages/widgets/src/server/runner.tsx | 11 +- packages/widgets/src/video/component.tsx | 13 +- packages/widgets/src/weather/component.tsx | 116 +--- packages/widgets/src/weather/icon.tsx | 3 +- packages/widgets/src/weather/index.ts | 57 +- .../src/widget-integration-select.module.css | 8 +- .../widgets/src/widget-integration-select.tsx | 39 +- tooling/eslint/base.js | 31 +- tooling/eslint/react.js | 6 +- tooling/prettier/index.mjs | 1 + 234 files changed, 2444 insertions(+), 5375 deletions(-) diff --git a/.gitignore b/.gitignore index 6b4c33b50..8327c8b84 100644 --- a/.gitignore +++ b/.gitignore @@ -51,4 +51,7 @@ yarn-error.log* db.sqlite # logs -*.log \ No newline at end of file +*.log + +apps/tasks/tasks.cjs +apps/websocket/wssServer.cjs \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json index b59ae4f97..53c760db0 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -6,9 +6,10 @@ ], "typescript.tsdk": "node_modules\\typescript\\lib", "js/ts.implicitProjectConfig.experimentalDecorators": true, + "prettier.configPath": "./tooling/prettier/index.mjs", "cSpell.words": [ "superjson", "homarr", "trpc" ] -} +} \ No newline at end of file diff --git a/apps/nextjs/next.config.mjs b/apps/nextjs/next.config.mjs index 26bb9d9c1..fcf1321a4 100644 --- a/apps/nextjs/next.config.mjs +++ b/apps/nextjs/next.config.mjs @@ -10,19 +10,9 @@ const config = { eslint: { ignoreDuringBuilds: true }, typescript: { ignoreBuildErrors: true }, experimental: { - optimizePackageImports: [ - "@mantine/core", - "@mantine/hooks", - "@tabler/icons-react", - ], + optimizePackageImports: ["@mantine/core", "@mantine/hooks", "@tabler/icons-react"], }, - transpilePackages: [ - "@homarr/ui", - "@homarr/notifications", - "@homarr/modals", - "@homarr/spotlight", - "@homarr/widgets", - ], + transpilePackages: ["@homarr/ui", "@homarr/notifications", "@homarr/modals", "@homarr/spotlight", "@homarr/widgets"], images: { domains: ["cdn.jsdelivr.net"], }, diff --git a/apps/nextjs/src/app/[locale]/_client-providers/next-international.tsx b/apps/nextjs/src/app/[locale]/_client-providers/next-international.tsx index 626296d69..8297a73bb 100644 --- a/apps/nextjs/src/app/[locale]/_client-providers/next-international.tsx +++ b/apps/nextjs/src/app/[locale]/_client-providers/next-international.tsx @@ -3,10 +3,7 @@ import type { PropsWithChildren } from "react"; import { defaultLocale } from "@homarr/translation"; import { I18nProviderClient } from "@homarr/translation/client"; -export const NextInternationalProvider = ({ - children, - locale, -}: PropsWithChildren<{ locale: string }>) => { +export const NextInternationalProvider = ({ children, locale }: PropsWithChildren<{ locale: string }>) => { return ( {children} diff --git a/apps/nextjs/src/app/[locale]/_client-providers/session.tsx b/apps/nextjs/src/app/[locale]/_client-providers/session.tsx index 5ed469e1c..d4e0538db 100644 --- a/apps/nextjs/src/app/[locale]/_client-providers/session.tsx +++ b/apps/nextjs/src/app/[locale]/_client-providers/session.tsx @@ -9,9 +9,6 @@ interface AuthProviderProps { session: Session | null; } -export const AuthProvider = ({ - children, - session, -}: PropsWithChildren) => { +export const AuthProvider = ({ children, session }: PropsWithChildren) => { return {children}; }; diff --git a/apps/nextjs/src/app/[locale]/_client-providers/trpc.tsx b/apps/nextjs/src/app/[locale]/_client-providers/trpc.tsx index 00a923407..db34ced95 100644 --- a/apps/nextjs/src/app/[locale]/_client-providers/trpc.tsx +++ b/apps/nextjs/src/app/[locale]/_client-providers/trpc.tsx @@ -5,12 +5,7 @@ import { useState } from "react"; import { QueryClient, QueryClientProvider } from "@tanstack/react-query"; import { ReactQueryDevtools } from "@tanstack/react-query-devtools"; import { ReactQueryStreamedHydration } from "@tanstack/react-query-next-experimental"; -import { - createWSClient, - loggerLink, - unstable_httpBatchStreamLink, - wsLink, -} from "@trpc/client"; +import { createWSClient, loggerLink, unstable_httpBatchStreamLink, wsLink } from "@trpc/client"; import superjson from "superjson"; import type { AppRouter } from "@homarr/api"; @@ -37,8 +32,7 @@ export function TRPCReactProvider(props: PropsWithChildren) { links: [ loggerLink({ enabled: (opts) => - process.env.NODE_ENV === "development" || - (opts.direction === "down" && opts.result instanceof Error), + process.env.NODE_ENV === "development" || (opts.direction === "down" && opts.result instanceof Error), }), (args) => { return ({ op, next }) => { @@ -69,9 +63,7 @@ export function TRPCReactProvider(props: PropsWithChildren) { return ( - - {props.children} - + {props.children} diff --git a/apps/nextjs/src/app/[locale]/auth/invite/[id]/_registration-form.tsx b/apps/nextjs/src/app/[locale]/auth/invite/[id]/_registration-form.tsx index 9baf60958..e91e78de0 100644 --- a/apps/nextjs/src/app/[locale]/auth/invite/[id]/_registration-form.tsx +++ b/apps/nextjs/src/app/[locale]/auth/invite/[id]/_registration-form.tsx @@ -5,10 +5,7 @@ import { Button, PasswordInput, Stack, TextInput } from "@mantine/core"; import { clientApi } from "@homarr/api/client"; import { useZodForm } from "@homarr/form"; -import { - showErrorNotification, - showSuccessNotification, -} from "@homarr/notifications"; +import { showErrorNotification, showSuccessNotification } from "@homarr/notifications"; import { useScopedI18n } from "@homarr/translation/client"; import type { z } from "@homarr/validation"; import { validation } from "@homarr/validation"; @@ -32,9 +29,7 @@ export const RegistrationForm = ({ invite }: RegistrationFormProps) => { }, }); - const handleSubmit = ( - values: z.infer, - ) => { + const handleSubmit = (values: z.infer) => { mutate( { ...values, @@ -63,11 +58,7 @@ export const RegistrationForm = ({ invite }: RegistrationFormProps) => {
- + { }, }); - const handleSubmitAsync = async ( - values: z.infer, - ) => { + const handleSubmitAsync = async (values: z.infer) => { setIsLoading(true); setError(undefined); await signIn("credentials", { @@ -67,18 +55,10 @@ export const LoginForm = () => { return ( - void handleSubmitAsync(values))} - > + void handleSubmitAsync(values))}> - - + + diff --git a/apps/nextjs/src/app/[locale]/boards/(content)/_client.tsx b/apps/nextjs/src/app/[locale]/boards/(content)/_client.tsx index 1a7fe0cc1..ea80dc68b 100644 --- a/apps/nextjs/src/app/[locale]/boards/(content)/_client.tsx +++ b/apps/nextjs/src/app/[locale]/boards/(content)/_client.tsx @@ -18,9 +18,7 @@ export const updateBoardName = (name: string | null) => { boardName = name; }; -type UpdateCallback = ( - prev: RouterOutputs["board"]["getHomeBoard"], -) => RouterOutputs["board"]["getHomeBoard"]; +type UpdateCallback = (prev: RouterOutputs["board"]["getHomeBoard"]) => RouterOutputs["board"]["getHomeBoard"]; export const useUpdateBoard = () => { const utils = clientApi.useUtils(); @@ -46,9 +44,7 @@ export const ClientBoard = () => { const board = useRequiredBoard(); const isReady = useIsBoardReady(); - const sortedSections = board.sections.sort( - (sectionA, sectionB) => sectionA.position - sectionB.position, - ); + const sortedSections = board.sections.sort((sectionA, sectionB) => sectionA.position - sectionB.position); const ref = useRef(null); @@ -61,24 +57,12 @@ export const ClientBoard = () => { loaderProps={{ size: "lg" }} h={fullHeightWithoutHeaderAndFooter} /> - + {sortedSections.map((section) => section.kind === "empty" ? ( - + ) : ( - + ), )} diff --git a/apps/nextjs/src/app/[locale]/boards/(content)/_context.tsx b/apps/nextjs/src/app/[locale]/boards/(content)/_context.tsx index ae12b472f..a5ab76c03 100644 --- a/apps/nextjs/src/app/[locale]/boards/(content)/_context.tsx +++ b/apps/nextjs/src/app/[locale]/boards/(content)/_context.tsx @@ -1,13 +1,7 @@ "use client"; import type { PropsWithChildren } from "react"; -import { - createContext, - useCallback, - useContext, - useEffect, - useState, -} from "react"; +import { createContext, useCallback, useContext, useEffect, useState } from "react"; import { usePathname } from "next/navigation"; import type { RouterOutputs } from "@homarr/api"; @@ -52,18 +46,12 @@ export const BoardProvider = ({ }, [pathname, utils, initialBoard.name]); useEffect(() => { - setReadySections((previous) => - previous.filter((id) => - data.sections.some((section) => section.id === id), - ), - ); + setReadySections((previous) => previous.filter((id) => data.sections.some((section) => section.id === id))); // eslint-disable-next-line react-hooks/exhaustive-deps }, [data.sections.length, setReadySections]); const markAsReady = useCallback((id: string) => { - setReadySections((previous) => - previous.includes(id) ? previous : [...previous, id], - ); + setReadySections((previous) => (previous.includes(id) ? previous : [...previous, id])); }, []); return ( diff --git a/apps/nextjs/src/app/[locale]/boards/(content)/_creator.tsx b/apps/nextjs/src/app/[locale]/boards/(content)/_creator.tsx index 55eada4b2..fe56c11ea 100644 --- a/apps/nextjs/src/app/[locale]/boards/(content)/_creator.tsx +++ b/apps/nextjs/src/app/[locale]/boards/(content)/_creator.tsx @@ -18,9 +18,7 @@ interface Props { getInitialBoardAsync: (params: TParams) => Promise; } -export const createBoardContentPage = < - TParams extends Record, ->({ +export const createBoardContentPage = >({ getInitialBoardAsync: getInitialBoard, }: Props) => { return { @@ -32,21 +30,13 @@ export const createBoardContentPage = < page: () => { return ; }, - generateMetadataAsync: async ({ - params, - }: { - params: TParams; - }): Promise => { + generateMetadataAsync: async ({ params }: { params: TParams }): Promise => { try { const board = await getInitialBoard(params); const t = await getI18n(); return { - title: - board.metaTitle ?? - createMetaTitle( - t("board.content.metaTitle", { boardName: board.name }), - ), + title: board.metaTitle ?? createMetaTitle(t("board.content.metaTitle", { boardName: board.name })), icons: { icon: board.faviconImageUrl ? board.faviconImageUrl : undefined, }, diff --git a/apps/nextjs/src/app/[locale]/boards/(content)/_header-actions.tsx b/apps/nextjs/src/app/[locale]/boards/(content)/_header-actions.tsx index 33abb0661..79c019dad 100644 --- a/apps/nextjs/src/app/[locale]/boards/(content)/_header-actions.tsx +++ b/apps/nextjs/src/app/[locale]/boards/(content)/_header-actions.tsx @@ -16,10 +16,7 @@ import { useAtom, useAtomValue } from "jotai"; import { clientApi } from "@homarr/api/client"; import { useModalAction } from "@homarr/modals"; -import { - showErrorNotification, - showSuccessNotification, -} from "@homarr/notifications"; +import { showErrorNotification, showSuccessNotification } from "@homarr/notifications"; import { useI18n, useScopedI18n } from "@homarr/translation/client"; import { revalidatePathActionAsync } from "~/app/revalidatePathAction"; @@ -54,8 +51,7 @@ export const BoardContentHeaderActions = () => { }; const AddMenu = () => { - const { openModal: openCategoryEditModal } = - useModalAction(CategoryEditModal); + const { openModal: openCategoryEditModal } = useModalAction(CategoryEditModal); const { openModal: openItemSelectModal } = useModalAction(ItemSelectModal); const { addCategoryToEnd } = useCategoryActions(); const t = useI18n(); @@ -95,22 +91,14 @@ const AddMenu = () => { - } - onClick={handleSelectItem} - > + } onClick={handleSelectItem}> {t("item.action.create")} - }> - {t("item.action.import")} - + }>{t("item.action.import")} - } - onClick={handleAddCategory} - > + } onClick={handleAddCategory}> {t("section.category.action.create")} @@ -123,24 +111,23 @@ const EditModeMenu = () => { const board = useRequiredBoard(); const utils = clientApi.useUtils(); const t = useScopedI18n("board.action.edit"); - const { mutate: saveBoard, isPending } = - clientApi.board.saveBoard.useMutation({ - onSuccess() { - showSuccessNotification({ - title: t("notification.success.title"), - message: t("notification.success.message"), - }); - void utils.board.getBoardByName.invalidate({ name: board.name }); - void revalidatePathActionAsync(`/boards/${board.name}`); - setEditMode(false); - }, - onError() { - showErrorNotification({ - title: t("notification.error.title"), - message: t("notification.error.message"), - }); - }, - }); + const { mutate: saveBoard, isPending } = clientApi.board.saveBoard.useMutation({ + onSuccess() { + showSuccessNotification({ + title: t("notification.success.title"), + message: t("notification.success.message"), + }); + void utils.board.getBoardByName.invalidate({ name: board.name }); + void revalidatePathActionAsync(`/boards/${board.name}`); + setEditMode(false); + }, + onError() { + showErrorNotification({ + title: t("notification.error.title"), + message: t("notification.error.message"), + }); + }, + }); const toggle = useCallback(() => { if (isEditMode) return saveBoard(board); @@ -149,11 +136,7 @@ const EditModeMenu = () => { return ( - {isEditMode ? ( - - ) : ( - - )} + {isEditMode ? : } ); }; diff --git a/apps/nextjs/src/app/[locale]/boards/(content)/_theme.tsx b/apps/nextjs/src/app/[locale]/boards/(content)/_theme.tsx index 48c8a829d..bf68bb902 100644 --- a/apps/nextjs/src/app/[locale]/boards/(content)/_theme.tsx +++ b/apps/nextjs/src/app/[locale]/boards/(content)/_theme.tsx @@ -22,9 +22,7 @@ export const BoardMantineProvider = ({ children }: PropsWithChildren) => { }; export const generateColors = (hex: string) => { - const lightnessForColors = [ - -0.25, -0.2, -0.15, -0.1, -0.05, 0, 0.05, 0.1, 0.15, 0.2, - ] as const; + const lightnessForColors = [-0.25, -0.2, -0.15, -0.1, -0.05, 0, 0.05, 0.1, 0.15, 0.2] as const; const rgbaColors = lightnessForColors.map((lightness) => { if (lightness < 0) { return lighten(hex, -lightness); diff --git a/apps/nextjs/src/app/[locale]/boards/[name]/settings/_access.tsx b/apps/nextjs/src/app/[locale]/boards/[name]/settings/_access.tsx index c90192bfa..5739e98b6 100644 --- a/apps/nextjs/src/app/[locale]/boards/[name]/settings/_access.tsx +++ b/apps/nextjs/src/app/[locale]/boards/[name]/settings/_access.tsx @@ -44,11 +44,7 @@ export const AccessSettingsContent = ({ board, initialPermissions }: Props) => { - + diff --git a/apps/nextjs/src/app/[locale]/boards/[name]/settings/_access/board-access-table-rows.tsx b/apps/nextjs/src/app/[locale]/boards/[name]/settings/_access/board-access-table-rows.tsx index 392e5a36d..4a370051a 100644 --- a/apps/nextjs/src/app/[locale]/boards/[name]/settings/_access/board-access-table-rows.tsx +++ b/apps/nextjs/src/app/[locale]/boards/[name]/settings/_access/board-access-table-rows.tsx @@ -1,21 +1,8 @@ import { useCallback } from "react"; import type { ReactNode } from "react"; import type { SelectProps } from "@mantine/core"; -import { - Button, - Flex, - Group, - Select, - TableTd, - TableTr, - Text, -} from "@mantine/core"; -import { - IconCheck, - IconEye, - IconPencil, - IconSettings, -} from "@tabler/icons-react"; +import { Button, Flex, Group, Select, TableTd, TableTr, Text } from "@mantine/core"; +import { IconCheck, IconEye, IconPencil, IconSettings } from "@tabler/icons-react"; import type { BoardPermission } from "@homarr/definitions"; import { boardPermissions } from "@homarr/definitions"; @@ -38,12 +25,7 @@ interface BoardAccessSelectRowProps { onCountChange: OnCountChange; } -export const BoardAccessSelectRow = ({ - itemContent, - permission, - index, - onCountChange, -}: BoardAccessSelectRowProps) => { +export const BoardAccessSelectRow = ({ itemContent, permission, index, onCountChange }: BoardAccessSelectRowProps) => { const tRoot = useI18n(); const tPermissions = useScopedI18n("board.setting.section.access.permission"); const form = useFormContext(); @@ -61,11 +43,7 @@ export const BoardAccessSelectRow = ({ {itemContent} - + : undefined} - nothingFoundMessage={t("group.action.select.notFound")} - limit={5} - data={groups - ?.filter( - (group) => !innerProps.presentGroupIds.includes(group.id), - ) - .map((group) => ({ value: group.id, label: group.name }))} - /> - - - - - - - ); - }, -).withOptions({ - defaultTitle: (t) => - t("board.setting.section.access.permission.groupSelect.title"), + return ( +
void handleSubmitAsync(values))}> + + - ) : currentUser ? ( - - ) : undefined - } - nothingFoundMessage={t("user.action.select.notFound")} - renderOption={createRenderOption(users ?? [])} - limit={5} - data={users - ?.filter((user) => !innerProps.presentUserIds.includes(user.id)) - .map((user) => ({ value: user.id, label: user.name ?? "" }))} - /> - - - - - -
- ); - }, -).withOptions({ - defaultTitle: (t) => - t("board.setting.section.access.permission.userSelect.title"), + return ( +
void handleSubmitAsync(values))}> + +