diff --git a/package.json b/package.json
index a0af9271b..26020bf90 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "zip3",
- "version": "3.4.1",
+ "version": "3.4.2",
"license": "MIT",
"scripts": {
"dev": "node esbuild.config.js && REACT_EDITOR=code-insiders NODE_ENV=development node dist/server",
diff --git a/prisma/migrations/20220304004623_domains/migration.sql b/prisma/migrations/20220304004623_domains/migration.sql
new file mode 100644
index 000000000..7ba8191b2
--- /dev/null
+++ b/prisma/migrations/20220304004623_domains/migration.sql
@@ -0,0 +1,2 @@
+-- AlterTable
+ALTER TABLE "User" ADD COLUMN "domains" TEXT[];
diff --git a/prisma/schema.prisma b/prisma/schema.prisma
index 6a8f59f3c..1a991020e 100644
--- a/prisma/schema.prisma
+++ b/prisma/schema.prisma
@@ -8,16 +8,17 @@ generator client {
}
model User {
- id Int @id @default(autoincrement())
+ id Int @id @default(autoincrement())
username String
password String
token String
- administrator Boolean @default(false)
- systemTheme String @default("system")
+ administrator Boolean @default(false)
+ systemTheme String @default("system")
embedTitle String?
- embedColor String @default("#2f3136")
- embedSiteName String? @default("{image.file} • {user.name}")
- ratelimited Boolean @default(false)
+ embedColor String @default("#2f3136")
+ embedSiteName String? @default("{image.file} • {user.name}")
+ ratelimited Boolean @default(false)
+ domains String[]
images Image[]
urls Url[]
}
diff --git a/src/components/pages/Manage.tsx b/src/components/pages/Manage.tsx
index 418d9cd96..131b8b293 100644
--- a/src/components/pages/Manage.tsx
+++ b/src/components/pages/Manage.tsx
@@ -1,12 +1,13 @@
-import React from 'react';
+import React, { useState } from 'react';
import useFetch from 'hooks/useFetch';
import Link from 'components/Link';
import { useStoreDispatch, useStoreSelector } from 'lib/redux/store';
import { updateUser } from 'lib/redux/reducers/user';
-import { useForm } from '@mantine/hooks';
-import { Tooltip, TextInput, Button, Text, Title, Group, ColorInput } from '@mantine/core';
-import { DownloadIcon } from '@modulz/radix-icons';
+import { randomId, useForm } from '@mantine/hooks';
+import { Tooltip, TextInput, Button, Text, Title, Group, ColorInput, MultiSelect, Space } from '@mantine/core';
+import { DownloadIcon, Cross1Icon } from '@modulz/radix-icons';
+import { useNotifications } from '@mantine/notifications';
function VarsTooltip({ children }) {
return (
@@ -27,6 +28,9 @@ function VarsTooltip({ children }) {
export default function Manage() {
const user = useStoreSelector(state => state.user);
const dispatch = useStoreDispatch();
+ const notif = useNotifications();
+
+ const [domains, setDomains] = useState(user.domains ?? []);
const genShareX = (withEmbed: boolean = false, withZws: boolean = false) => {
const config = {
@@ -61,6 +65,7 @@ export default function Manage() {
embedTitle: user.embedTitle ?? '',
embedColor: user.embedColor,
embedSiteName: user.embedSiteName ?? '',
+ domains: user.domains ?? [],
},
});
@@ -73,19 +78,51 @@ export default function Manage() {
if (cleanUsername === '') return form.setFieldError('username', 'Username can\'t be nothing');
+ const id = notif.showNotification({
+ title: 'Updating user...',
+ message: '',
+ loading: true,
+ });
+
const data = {
username: cleanUsername,
password: cleanPassword === '' ? null : cleanPassword,
embedTitle: cleanEmbedTitle === '' ? null : cleanEmbedTitle,
embedColor: cleanEmbedColor === '' ? null : cleanEmbedColor,
embedSiteName: cleanEmbedSiteName === '' ? null : cleanEmbedSiteName,
+ domains,
};
const newUser = await useFetch('/api/user', 'PATCH', data);
if (newUser.error) {
+ if (newUser.invalidDomains) {
+ notif.updateNotification(id, {
+ message: <>
+