From 523219273a388f43bfa567ef1b43e1060de385c0 Mon Sep 17 00:00:00 2001 From: diced Date: Thu, 14 Nov 2024 15:34:32 -0800 Subject: [PATCH] fix: various small fixes --- .../file/DashboardFile/FileModal.tsx | 3 +- .../pages/files/PendingFilesButton.tsx | 20 +++++++++++-- .../pages/files/tags/CreateTagModal.tsx | 6 +--- .../pages/files/tags/TagsButton.tsx | 28 +++++++++++++------ .../pages/files/views/FileTable.tsx | 4 +-- .../pages/folders/views/FolderTableView.tsx | 4 +-- .../pages/invites/views/InviteTableView.tsx | 4 +-- .../settings/parts/SettingsDashboard.tsx | 8 +++++- .../pages/urls/views/UrlTableView.tsx | 4 +-- .../pages/users/views/UserTableView.tsx | 4 +-- 10 files changed, 58 insertions(+), 27 deletions(-) diff --git a/src/components/file/DashboardFile/FileModal.tsx b/src/components/file/DashboardFile/FileModal.tsx index 751d1ef1f..9a1cc0eb7 100755 --- a/src/components/file/DashboardFile/FileModal.tsx +++ b/src/components/file/DashboardFile/FileModal.tsx @@ -48,7 +48,7 @@ import { IconUpload, } from '@tabler/icons-react'; import { useEffect, useState } from 'react'; -import useSWR from 'swr'; +import useSWR, { mutate } from 'swr'; import DashboardFileType from '../DashboardFileType'; import { addToFolder, @@ -157,6 +157,7 @@ export default function FileModal({ } mutateFiles(); + mutate('/api/user/tags'); }; const triggerSave = async () => { diff --git a/src/components/pages/files/PendingFilesButton.tsx b/src/components/pages/files/PendingFilesButton.tsx index 27e750f8c..cef72910e 100755 --- a/src/components/pages/files/PendingFilesButton.tsx +++ b/src/components/pages/files/PendingFilesButton.tsx @@ -1,7 +1,19 @@ import { Response } from '@/lib/api/response'; import { IncompleteFile } from '@/lib/db/models/incompleteFile'; import { fetchApi } from '@/lib/fetchApi'; -import { ActionIcon, Badge, Button, Card, Group, Modal, Stack, Text, Title, Tooltip } from '@mantine/core'; +import { + ActionIcon, + Badge, + Button, + Card, + Group, + Modal, + Paper, + Stack, + Text, + Title, + Tooltip, +} from '@mantine/core'; import { showNotification } from '@mantine/notifications'; import { IncompleteFileStatus } from '@prisma/client'; import { IconFileDots, IconTrashFilled } from '@tabler/icons-react'; @@ -118,7 +130,11 @@ export default function PendingFilesButton() { ))} - {incompleteFiles?.length === 0 && Nothing here!} + {incompleteFiles?.length === 0 && ( + + No pending files + + )} diff --git a/src/components/pages/files/tags/CreateTagModal.tsx b/src/components/pages/files/tags/CreateTagModal.tsx index b7204e08d..f94cdc612 100755 --- a/src/components/pages/files/tags/CreateTagModal.tsx +++ b/src/components/pages/files/tags/CreateTagModal.tsx @@ -2,7 +2,7 @@ import { Response } from '@/lib/api/response'; import { Tag } from '@/lib/db/models/tag'; import { fetchApi } from '@/lib/fetchApi'; import { colorHash } from '@/lib/theme/color'; -import { ActionIcon, Button, ColorInput, Modal, Stack, Text, TextInput, Title, Tooltip } from '@mantine/core'; +import { ActionIcon, Button, ColorInput, Modal, Stack, TextInput, Title, Tooltip } from '@mantine/core'; import { hasLength, useForm } from '@mantine/form'; import { showNotification } from '@mantine/notifications'; import { IconTag, IconTagOff, IconTextRecognition } from '@tabler/icons-react'; @@ -61,10 +61,6 @@ export default function CreateTagModal({ open, onClose }: { open: boolean; onClo return ( Create new tag} zIndex={3000}> - - Create a new tag that can be applied to files - -
diff --git a/src/components/pages/files/tags/TagsButton.tsx b/src/components/pages/files/tags/TagsButton.tsx index 88229af37..48f68e1e6 100755 --- a/src/components/pages/files/tags/TagsButton.tsx +++ b/src/components/pages/files/tags/TagsButton.tsx @@ -1,6 +1,6 @@ import { Response } from '@/lib/api/response'; import { Tag } from '@/lib/db/models/tag'; -import { ActionIcon, Group, Modal, Stack, Text, Title, Tooltip } from '@mantine/core'; +import { ActionIcon, Group, Modal, Paper, Stack, Text, Title, Tooltip } from '@mantine/core'; import { IconPencil, IconPlus, IconTagOff, IconTags, IconTrashFilled } from '@tabler/icons-react'; import { useRouter } from 'next/router'; import { useEffect, useState } from 'react'; @@ -10,6 +10,7 @@ import { fetchApi } from '@/lib/fetchApi'; import { showNotification } from '@mantine/notifications'; import CreateTagModal from './CreateTagModal'; import EditTagModal from './EditTagModal'; +import { mutateFiles } from '@/components/file/actions'; export default function TagsButton() { const router = useRouter(); @@ -40,6 +41,7 @@ export default function TagsButton() { } mutate(); + mutateFiles(); }; useEffect(() => { @@ -77,21 +79,31 @@ export default function TagsButton() { - {tag.files!.length} files + {tag.files!.length} file{tag.files!.length === 1 ? '' : 's'} - setSelectedTag(tag)}> - - + + setSelectedTag(tag)}> + + + - handleDelete(tag)}> - - + + handleDelete(tag)}> + + + ))} + + {tags?.length === 0 && ( + + No tags. Create one by clicking the plus icon. + + )} diff --git a/src/components/pages/files/views/FileTable.tsx b/src/components/pages/files/views/FileTable.tsx index c5729de6b..988a47922 100755 --- a/src/components/pages/files/views/FileTable.tsx +++ b/src/components/pages/files/views/FileTable.tsx @@ -430,9 +430,8 @@ export default function FileTable({ id }: { id?: string }) { { accessor: 'actions', textAlign: 'right', - width: 45 * 4, render: (file) => ( - + @@ -491,6 +490,7 @@ export default function FileTable({ id }: { id?: string }) { onCellClick={({ record }) => setSelectedFile(record)} selectedRecords={selectedFiles} onSelectedRecordsChange={setSelectedFiles} + paginationText={({ from, to, totalRecords }) => `${from} - ${to} / ${totalRecords} files`} /> diff --git a/src/components/pages/folders/views/FolderTableView.tsx b/src/components/pages/folders/views/FolderTableView.tsx index 3de90882b..2fe9ba42f 100755 --- a/src/components/pages/folders/views/FolderTableView.tsx +++ b/src/components/pages/folders/views/FolderTableView.tsx @@ -86,9 +86,9 @@ export default function FolderTableView() { }, { accessor: 'actions', - width: 45 * 4, + textAlign: 'right', render: (folder) => ( - + { diff --git a/src/components/pages/invites/views/InviteTableView.tsx b/src/components/pages/invites/views/InviteTableView.tsx index 09e499f85..cab62a566 100755 --- a/src/components/pages/invites/views/InviteTableView.tsx +++ b/src/components/pages/invites/views/InviteTableView.tsx @@ -87,9 +87,9 @@ export default function InviteTableView() { }, { accessor: 'actions', - width: 45 * 2, + textAlign: 'right', render: (invite) => ( - + { diff --git a/src/components/pages/settings/parts/SettingsDashboard.tsx b/src/components/pages/settings/parts/SettingsDashboard.tsx index ca4028f48..9de8bda1d 100755 --- a/src/components/pages/settings/parts/SettingsDashboard.tsx +++ b/src/components/pages/settings/parts/SettingsDashboard.tsx @@ -22,6 +22,12 @@ export default function SettingsDashboard() { const [settings, update] = useSettingsStore((state) => [state.settings, state.update]); const themes = useThemes(); + const sortedThemes = themes.sort((a, b) => { + if (a.colorScheme === 'light' && b.colorScheme === 'dark') return -1; + if (a.colorScheme === 'dark' && b.colorScheme === 'light') return 1; + return 0; + }); + return ( Dashboard Settings @@ -62,7 +68,7 @@ export default function SettingsDashboard() { description='The theme to use for the dashboard. This is only a visual change on your browser and does not change the theme for other users.' data={[ { value: 'system', label: 'System' }, - ...themes.map((theme) => ({ value: theme.id, label: theme.name })), + ...sortedThemes.map((theme) => ({ value: theme.id, label: theme.name })), ]} value={settings.theme} onChange={(value) => update('theme', value ?? 'builtin:dark_gray')} diff --git a/src/components/pages/urls/views/UrlTableView.tsx b/src/components/pages/urls/views/UrlTableView.tsx index 012afb7c3..cab8a1131 100755 --- a/src/components/pages/urls/views/UrlTableView.tsx +++ b/src/components/pages/urls/views/UrlTableView.tsx @@ -255,9 +255,9 @@ export default function UrlTableView() { }, { accessor: 'actions', - width: 45 * 3, + textAlign: 'right', render: (url) => ( - + { diff --git a/src/components/pages/users/views/UserTableView.tsx b/src/components/pages/users/views/UserTableView.tsx index f69f08ea9..07dbc5630 100755 --- a/src/components/pages/users/views/UserTableView.tsx +++ b/src/components/pages/users/views/UserTableView.tsx @@ -81,9 +81,9 @@ export default function UserTableView() { }, { accessor: 'actions', - width: 45 * 3, + textAlign: 'right', render: (user) => ( - +