Skip to content

Commit 5232192

Browse files
committed
fix: various small fixes
1 parent e6db5e1 commit 5232192

File tree

10 files changed

+58
-27
lines changed

10 files changed

+58
-27
lines changed

src/components/file/DashboardFile/FileModal.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ import {
4848
IconUpload,
4949
} from '@tabler/icons-react';
5050
import { useEffect, useState } from 'react';
51-
import useSWR from 'swr';
51+
import useSWR, { mutate } from 'swr';
5252
import DashboardFileType from '../DashboardFileType';
5353
import {
5454
addToFolder,
@@ -157,6 +157,7 @@ export default function FileModal({
157157
}
158158

159159
mutateFiles();
160+
mutate('/api/user/tags');
160161
};
161162

162163
const triggerSave = async () => {

src/components/pages/files/PendingFilesButton.tsx

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,19 @@
11
import { Response } from '@/lib/api/response';
22
import { IncompleteFile } from '@/lib/db/models/incompleteFile';
33
import { fetchApi } from '@/lib/fetchApi';
4-
import { ActionIcon, Badge, Button, Card, Group, Modal, Stack, Text, Title, Tooltip } from '@mantine/core';
4+
import {
5+
ActionIcon,
6+
Badge,
7+
Button,
8+
Card,
9+
Group,
10+
Modal,
11+
Paper,
12+
Stack,
13+
Text,
14+
Title,
15+
Tooltip,
16+
} from '@mantine/core';
517
import { showNotification } from '@mantine/notifications';
618
import { IncompleteFileStatus } from '@prisma/client';
719
import { IconFileDots, IconTrashFilled } from '@tabler/icons-react';
@@ -118,7 +130,11 @@ export default function PendingFilesButton() {
118130
</Card>
119131
))}
120132

121-
{incompleteFiles?.length === 0 && <Text>Nothing here!</Text>}
133+
{incompleteFiles?.length === 0 && (
134+
<Paper withBorder px='sm' py='xs'>
135+
No pending files
136+
</Paper>
137+
)}
122138
</Stack>
123139
</Modal>
124140

src/components/pages/files/tags/CreateTagModal.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Response } from '@/lib/api/response';
22
import { Tag } from '@/lib/db/models/tag';
33
import { fetchApi } from '@/lib/fetchApi';
44
import { colorHash } from '@/lib/theme/color';
5-
import { ActionIcon, Button, ColorInput, Modal, Stack, Text, TextInput, Title, Tooltip } from '@mantine/core';
5+
import { ActionIcon, Button, ColorInput, Modal, Stack, TextInput, Title, Tooltip } from '@mantine/core';
66
import { hasLength, useForm } from '@mantine/form';
77
import { showNotification } from '@mantine/notifications';
88
import { IconTag, IconTagOff, IconTextRecognition } from '@tabler/icons-react';
@@ -61,10 +61,6 @@ export default function CreateTagModal({ open, onClose }: { open: boolean; onClo
6161

6262
return (
6363
<Modal opened={open} onClose={onClose} title={<Title>Create new tag</Title>} zIndex={3000}>
64-
<Text size='sm' c='dimmed'>
65-
Create a new tag that can be applied to files
66-
</Text>
67-
6864
<form onSubmit={form.onSubmit(onSubmit)}>
6965
<Stack gap='sm'>
7066
<TextInput label='Name' placeholder='Enter a name...' {...form.getInputProps('name')} />

src/components/pages/files/tags/TagsButton.tsx

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Response } from '@/lib/api/response';
22
import { Tag } from '@/lib/db/models/tag';
3-
import { ActionIcon, Group, Modal, Stack, Text, Title, Tooltip } from '@mantine/core';
3+
import { ActionIcon, Group, Modal, Paper, Stack, Text, Title, Tooltip } from '@mantine/core';
44
import { IconPencil, IconPlus, IconTagOff, IconTags, IconTrashFilled } from '@tabler/icons-react';
55
import { useRouter } from 'next/router';
66
import { useEffect, useState } from 'react';
@@ -10,6 +10,7 @@ import { fetchApi } from '@/lib/fetchApi';
1010
import { showNotification } from '@mantine/notifications';
1111
import CreateTagModal from './CreateTagModal';
1212
import EditTagModal from './EditTagModal';
13+
import { mutateFiles } from '@/components/file/actions';
1314

1415
export default function TagsButton() {
1516
const router = useRouter();
@@ -40,6 +41,7 @@ export default function TagsButton() {
4041
}
4142

4243
mutate();
44+
mutateFiles();
4345
};
4446

4547
useEffect(() => {
@@ -77,21 +79,31 @@ export default function TagsButton() {
7779
<TagPill tag={tag} />
7880

7981
<Text size='sm' c='dimmed'>
80-
{tag.files!.length} files
82+
{tag.files!.length} file{tag.files!.length === 1 ? '' : 's'}
8183
</Text>
8284
</Group>
8385

8486
<Group>
85-
<ActionIcon variant='outline' onClick={() => setSelectedTag(tag)}>
86-
<IconPencil size='1rem' />
87-
</ActionIcon>
87+
<Tooltip label='Edit tag'>
88+
<ActionIcon variant='outline' onClick={() => setSelectedTag(tag)}>
89+
<IconPencil size='1rem' />
90+
</ActionIcon>
91+
</Tooltip>
8892

89-
<ActionIcon variant='outline' color='red' onClick={() => handleDelete(tag)}>
90-
<IconTrashFilled size='1rem' />
91-
</ActionIcon>
93+
<Tooltip label='Delete tag'>
94+
<ActionIcon variant='outline' color='red' onClick={() => handleDelete(tag)}>
95+
<IconTrashFilled size='1rem' />
96+
</ActionIcon>
97+
</Tooltip>
9298
</Group>
9399
</Group>
94100
))}
101+
102+
{tags?.length === 0 && (
103+
<Paper withBorder px='sm' py='xs'>
104+
No tags. Create one by clicking the plus icon.
105+
</Paper>
106+
)}
95107
</Stack>
96108
</Modal>
97109

src/components/pages/files/views/FileTable.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -430,9 +430,8 @@ export default function FileTable({ id }: { id?: string }) {
430430
{
431431
accessor: 'actions',
432432
textAlign: 'right',
433-
width: 45 * 4,
434433
render: (file) => (
435-
<Group gap='sm'>
434+
<Group gap='sm' justify='right' wrap='nowrap'>
436435
<Tooltip label='More details'>
437436
<ActionIcon>
438437
<IconFile size='1rem' />
@@ -491,6 +490,7 @@ export default function FileTable({ id }: { id?: string }) {
491490
onCellClick={({ record }) => setSelectedFile(record)}
492491
selectedRecords={selectedFiles}
493492
onSelectedRecordsChange={setSelectedFiles}
493+
paginationText={({ from, to, totalRecords }) => `${from} - ${to} / ${totalRecords} files`}
494494
/>
495495
</Box>
496496
</>

src/components/pages/folders/views/FolderTableView.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,9 @@ export default function FolderTableView() {
8686
},
8787
{
8888
accessor: 'actions',
89-
width: 45 * 4,
89+
textAlign: 'right',
9090
render: (folder) => (
91-
<Group gap='sm'>
91+
<Group gap='sm' justify='right' wrap='nowrap'>
9292
<Tooltip label='View files'>
9393
<ActionIcon
9494
onClick={(e) => {

src/components/pages/invites/views/InviteTableView.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,9 @@ export default function InviteTableView() {
8787
},
8888
{
8989
accessor: 'actions',
90-
width: 45 * 2,
90+
textAlign: 'right',
9191
render: (invite) => (
92-
<Group gap='sm'>
92+
<Group gap='sm' justify='right' wrap='nowrap'>
9393
<Tooltip label='Copy invite link'>
9494
<ActionIcon
9595
onClick={(e) => {

src/components/pages/settings/parts/SettingsDashboard.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@ export default function SettingsDashboard() {
2222
const [settings, update] = useSettingsStore((state) => [state.settings, state.update]);
2323
const themes = useThemes();
2424

25+
const sortedThemes = themes.sort((a, b) => {
26+
if (a.colorScheme === 'light' && b.colorScheme === 'dark') return -1;
27+
if (a.colorScheme === 'dark' && b.colorScheme === 'light') return 1;
28+
return 0;
29+
});
30+
2531
return (
2632
<Paper withBorder p='sm'>
2733
<Title order={2}>Dashboard Settings</Title>
@@ -62,7 +68,7 @@ export default function SettingsDashboard() {
6268
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.'
6369
data={[
6470
{ value: 'system', label: 'System' },
65-
...themes.map((theme) => ({ value: theme.id, label: theme.name })),
71+
...sortedThemes.map((theme) => ({ value: theme.id, label: theme.name })),
6672
]}
6773
value={settings.theme}
6874
onChange={(value) => update('theme', value ?? 'builtin:dark_gray')}

src/components/pages/urls/views/UrlTableView.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,9 +255,9 @@ export default function UrlTableView() {
255255
},
256256
{
257257
accessor: 'actions',
258-
width: 45 * 3,
258+
textAlign: 'right',
259259
render: (url) => (
260-
<Group gap='sm'>
260+
<Group gap='sm' justify='right' wrap='nowrap'>
261261
<Tooltip label='Copy URL'>
262262
<ActionIcon
263263
onClick={(e) => {

src/components/pages/users/views/UserTableView.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,9 @@ export default function UserTableView() {
8181
},
8282
{
8383
accessor: 'actions',
84-
width: 45 * 3,
84+
textAlign: 'right',
8585
render: (user) => (
86-
<Group gap='sm'>
86+
<Group gap='sm' justify='right' wrap='nowrap'>
8787
<Tooltip label="View user's files">
8888
<ActionIcon
8989
component={Link}

0 commit comments

Comments
 (0)