From dc8ce7b8dc2c8b44660949d7438450463f9b1fa2 Mon Sep 17 00:00:00 2001 From: shatfield4 Date: Thu, 21 Dec 2023 16:41:55 -0800 Subject: [PATCH] system settings ui redesign complete --- backend/storage/settings.json | 1076 ++++++++++------- .../pages/SystemSettings/Settings/index.tsx | 254 ++-- 2 files changed, 742 insertions(+), 588 deletions(-) diff --git a/backend/storage/settings.json b/backend/storage/settings.json index 98f127d..afc8999 100644 --- a/backend/storage/settings.json +++ b/backend/storage/settings.json @@ -1,4 +1,468 @@ { + "_prisma_migrations": { + "slug": "_prisma_migrations", + "table": { + "name": "_prisma_migrations", + "pk": "id", + "verbose": "_prisma_migrations" + }, + "columns": [ + { + "name": "id", + "verbose": "id", + "control": { + "text": true + }, + "type": "varchar(36)", + "allowNull": false, + "defaultValue": null, + "listview": { + "show": true + }, + "editview": { + "show": true + } + }, + { + "name": "checksum", + "verbose": "checksum", + "control": { + "text": true + }, + "type": "varchar(64)", + "allowNull": false, + "defaultValue": null, + "listview": { + "show": true + }, + "editview": { + "show": true + } + }, + { + "name": "finished_at", + "verbose": "finished_at", + "control": { + "text": true + }, + "type": "timestamp", + "allowNull": true, + "defaultValue": null, + "listview": { + "show": true + }, + "editview": { + "show": true + } + }, + { + "name": "migration_name", + "verbose": "migration_name", + "control": { + "text": true + }, + "type": "varchar(255)", + "allowNull": false, + "defaultValue": null, + "listview": { + "show": true + }, + "editview": { + "show": true + } + }, + { + "name": "logs", + "verbose": "logs", + "control": { + "text": true + }, + "type": "text", + "allowNull": true, + "defaultValue": null, + "listview": { + "show": true + }, + "editview": { + "show": true + } + }, + { + "name": "rolled_back_at", + "verbose": "rolled_back_at", + "control": { + "text": true + }, + "type": "timestamp", + "allowNull": true, + "defaultValue": null, + "listview": { + "show": true + }, + "editview": { + "show": true + } + }, + { + "name": "started_at", + "verbose": "started_at", + "control": { + "text": true + }, + "type": "timestamp", + "allowNull": false, + "defaultValue": "now()", + "listview": { + "show": true + }, + "editview": { + "show": true + } + }, + { + "name": "applied_steps_count", + "verbose": "applied_steps_count", + "control": { + "text": true + }, + "type": "integer", + "allowNull": false, + "defaultValue": "0", + "listview": { + "show": true + }, + "editview": { + "show": true + } + } + ], + "mainview": { + "show": true + }, + "listview": { + "order": {}, + "page": 25 + }, + "editview": { + "readonly": false + } + }, + "system_settings": { + "slug": "system_settings", + "table": { + "name": "system_settings", + "pk": "id", + "verbose": "system_settings" + }, + "columns": [ + { + "name": "id", + "verbose": "id", + "control": { + "text": true + }, + "type": "integer", + "allowNull": false, + "defaultValue": null, + "listview": { + "show": true + }, + "editview": { + "show": true + } + }, + { + "name": "label", + "verbose": "label", + "control": { + "text": true + }, + "type": "text", + "allowNull": false, + "defaultValue": null, + "listview": { + "show": true + }, + "editview": { + "show": true + } + }, + { + "name": "value", + "verbose": "value", + "control": { + "text": true + }, + "type": "text", + "allowNull": false, + "defaultValue": null, + "listview": { + "show": true + }, + "editview": { + "show": true + } + }, + { + "name": "createdAt", + "verbose": "createdAt", + "control": { + "text": true + }, + "type": "timestamp", + "allowNull": false, + "defaultValue": "CURRENT_TIMESTAMP", + "listview": { + "show": true + }, + "editview": { + "show": true + } + }, + { + "name": "lastUpdatedAt", + "verbose": "lastUpdatedAt", + "control": { + "text": true + }, + "type": "timestamp", + "allowNull": false, + "defaultValue": "CURRENT_TIMESTAMP", + "listview": { + "show": true + }, + "editview": { + "show": true + } + } + ], + "mainview": { + "show": true + }, + "listview": { + "order": {}, + "page": 25 + }, + "editview": { + "readonly": false + } + }, + "users": { + "slug": "users", + "table": { + "name": "users", + "pk": "id", + "verbose": "users" + }, + "columns": [ + { + "name": "id", + "verbose": "id", + "control": { + "text": true + }, + "type": "integer", + "allowNull": false, + "defaultValue": null, + "listview": { + "show": true + }, + "editview": { + "show": true + } + }, + { + "name": "email", + "verbose": "email", + "control": { + "text": true + }, + "type": "text", + "allowNull": false, + "defaultValue": null, + "listview": { + "show": true + }, + "editview": { + "show": true + } + }, + { + "name": "password", + "verbose": "password", + "control": { + "text": true + }, + "type": "text", + "allowNull": false, + "defaultValue": null, + "listview": { + "show": true + }, + "editview": { + "show": true + } + }, + { + "name": "role", + "verbose": "role", + "control": { + "text": true + }, + "type": "text", + "allowNull": false, + "defaultValue": "'default'::text", + "listview": { + "show": true + }, + "editview": { + "show": true + } + }, + { + "name": "createdAt", + "verbose": "createdAt", + "control": { + "text": true + }, + "type": "timestamp", + "allowNull": false, + "defaultValue": "CURRENT_TIMESTAMP", + "listview": { + "show": true + }, + "editview": { + "show": true + } + }, + { + "name": "lastUpdatedAt", + "verbose": "lastUpdatedAt", + "control": { + "text": true + }, + "type": "timestamp", + "allowNull": false, + "defaultValue": "CURRENT_TIMESTAMP", + "listview": { + "show": true + }, + "editview": { + "show": true + } + } + ], + "mainview": { + "show": true + }, + "listview": { + "order": {}, + "page": 25 + }, + "editview": { + "readonly": false + } + }, + "organization_users": { + "slug": "organization_users", + "table": { + "name": "organization_users", + "pk": "id", + "verbose": "organization_users" + }, + "columns": [ + { + "name": "id", + "verbose": "id", + "control": { + "text": true + }, + "type": "integer", + "allowNull": false, + "defaultValue": null, + "listview": { + "show": true + }, + "editview": { + "show": true + } + }, + { + "name": "user_id", + "verbose": "user_id", + "control": { + "text": true + }, + "type": "integer", + "allowNull": false, + "defaultValue": null, + "listview": { + "show": true + }, + "editview": { + "show": true + } + }, + { + "name": "organization_id", + "verbose": "organization_id", + "control": { + "text": true + }, + "type": "integer", + "allowNull": false, + "defaultValue": null, + "listview": { + "show": true + }, + "editview": { + "show": true + } + }, + { + "name": "createdAt", + "verbose": "createdAt", + "control": { + "text": true + }, + "type": "timestamp", + "allowNull": false, + "defaultValue": "CURRENT_TIMESTAMP", + "listview": { + "show": true + }, + "editview": { + "show": true + } + }, + { + "name": "lastUpdatedAt", + "verbose": "lastUpdatedAt", + "control": { + "text": true + }, + "type": "timestamp", + "allowNull": false, + "defaultValue": "CURRENT_TIMESTAMP", + "listview": { + "show": true + }, + "editview": { + "show": true + } + } + ], + "mainview": { + "show": true + }, + "listview": { + "order": {}, + "page": 25 + }, + "editview": { + "readonly": false + } + }, "organizations": { "slug": "organizations", "table": { @@ -331,154 +795,6 @@ "readonly": false } }, - "organization_workspaces": { - "slug": "organization_workspaces", - "table": { - "name": "organization_workspaces", - "pk": "id", - "verbose": "organization_workspaces" - }, - "columns": [ - { - "name": "id", - "verbose": "id", - "control": { - "text": true - }, - "type": "integer", - "allowNull": false, - "defaultValue": null, - "listview": { - "show": true - }, - "editview": { - "show": true - } - }, - { - "name": "name", - "verbose": "name", - "control": { - "text": true - }, - "type": "text", - "allowNull": false, - "defaultValue": null, - "listview": { - "show": true - }, - "editview": { - "show": true - } - }, - { - "name": "slug", - "verbose": "slug", - "control": { - "text": true - }, - "type": "text", - "allowNull": false, - "defaultValue": null, - "listview": { - "show": true - }, - "editview": { - "show": true - } - }, - { - "name": "uuid", - "verbose": "uuid", - "control": { - "text": true - }, - "type": "text", - "allowNull": false, - "defaultValue": null, - "listview": { - "show": true - }, - "editview": { - "show": true - } - }, - { - "name": "fname", - "verbose": "fname", - "control": { - "text": true - }, - "type": "text", - "allowNull": false, - "defaultValue": null, - "listview": { - "show": true - }, - "editview": { - "show": true - } - }, - { - "name": "organization_id", - "verbose": "organization_id", - "control": { - "text": true - }, - "type": "integer", - "allowNull": false, - "defaultValue": null, - "listview": { - "show": true - }, - "editview": { - "show": true - } - }, - { - "name": "createdAt", - "verbose": "createdAt", - "control": { - "text": true - }, - "type": "timestamp", - "allowNull": false, - "defaultValue": "CURRENT_TIMESTAMP", - "listview": { - "show": true - }, - "editview": { - "show": true - } - }, - { - "name": "lastUpdatedAt", - "verbose": "lastUpdatedAt", - "control": { - "text": true - }, - "type": "timestamp", - "allowNull": false, - "defaultValue": "CURRENT_TIMESTAMP", - "listview": { - "show": true - }, - "editview": { - "show": true - } - } - ], - "mainview": { - "show": true - }, - "listview": { - "order": {}, - "page": 25 - }, - "editview": { - "readonly": false - } - }, "workspace_documents": { "slug": "workspace_documents", "table": { @@ -759,222 +1075,6 @@ "readonly": false } }, - "users": { - "slug": "users", - "table": { - "name": "users", - "pk": "id", - "verbose": "users" - }, - "columns": [ - { - "name": "id", - "verbose": "id", - "control": { - "text": true - }, - "type": "integer", - "allowNull": false, - "defaultValue": null, - "listview": { - "show": true - }, - "editview": { - "show": true - } - }, - { - "name": "email", - "verbose": "email", - "control": { - "text": true - }, - "type": "text", - "allowNull": false, - "defaultValue": null, - "listview": { - "show": true - }, - "editview": { - "show": true - } - }, - { - "name": "password", - "verbose": "password", - "control": { - "text": true - }, - "type": "text", - "allowNull": false, - "defaultValue": null, - "listview": { - "show": true - }, - "editview": { - "show": true - } - }, - { - "name": "role", - "verbose": "role", - "control": { - "text": true - }, - "type": "text", - "allowNull": false, - "defaultValue": "'default'::text", - "listview": { - "show": true - }, - "editview": { - "show": true - } - }, - { - "name": "createdAt", - "verbose": "createdAt", - "control": { - "text": true - }, - "type": "timestamp", - "allowNull": false, - "defaultValue": "CURRENT_TIMESTAMP", - "listview": { - "show": true - }, - "editview": { - "show": true - } - }, - { - "name": "lastUpdatedAt", - "verbose": "lastUpdatedAt", - "control": { - "text": true - }, - "type": "timestamp", - "allowNull": false, - "defaultValue": "CURRENT_TIMESTAMP", - "listview": { - "show": true - }, - "editview": { - "show": true - } - } - ], - "mainview": { - "show": true - }, - "listview": { - "order": {}, - "page": 25 - }, - "editview": { - "readonly": false - } - }, - "system_settings": { - "slug": "system_settings", - "table": { - "name": "system_settings", - "pk": "id", - "verbose": "system_settings" - }, - "columns": [ - { - "name": "id", - "verbose": "id", - "control": { - "text": true - }, - "type": "integer", - "allowNull": false, - "defaultValue": null, - "listview": { - "show": true - }, - "editview": { - "show": true - } - }, - { - "name": "label", - "verbose": "label", - "control": { - "text": true - }, - "type": "text", - "allowNull": false, - "defaultValue": null, - "listview": { - "show": true - }, - "editview": { - "show": true - } - }, - { - "name": "value", - "verbose": "value", - "control": { - "text": true - }, - "type": "text", - "allowNull": false, - "defaultValue": null, - "listview": { - "show": true - }, - "editview": { - "show": true - } - }, - { - "name": "createdAt", - "verbose": "createdAt", - "control": { - "text": true - }, - "type": "timestamp", - "allowNull": false, - "defaultValue": "CURRENT_TIMESTAMP", - "listview": { - "show": true - }, - "editview": { - "show": true - } - }, - { - "name": "lastUpdatedAt", - "verbose": "lastUpdatedAt", - "control": { - "text": true - }, - "type": "timestamp", - "allowNull": false, - "defaultValue": "CURRENT_TIMESTAMP", - "listview": { - "show": true - }, - "editview": { - "show": true - } - } - ], - "mainview": { - "show": true - }, - "listview": { - "order": {}, - "page": 25 - }, - "editview": { - "readonly": false - } - }, "jobs": { "slug": "jobs", "table": { @@ -1139,6 +1239,154 @@ "readonly": false } }, + "organization_workspaces": { + "slug": "organization_workspaces", + "table": { + "name": "organization_workspaces", + "pk": "id", + "verbose": "organization_workspaces" + }, + "columns": [ + { + "name": "id", + "verbose": "id", + "control": { + "text": true + }, + "type": "integer", + "allowNull": false, + "defaultValue": null, + "listview": { + "show": true + }, + "editview": { + "show": true + } + }, + { + "name": "name", + "verbose": "name", + "control": { + "text": true + }, + "type": "text", + "allowNull": false, + "defaultValue": null, + "listview": { + "show": true + }, + "editview": { + "show": true + } + }, + { + "name": "slug", + "verbose": "slug", + "control": { + "text": true + }, + "type": "text", + "allowNull": false, + "defaultValue": null, + "listview": { + "show": true + }, + "editview": { + "show": true + } + }, + { + "name": "uuid", + "verbose": "uuid", + "control": { + "text": true + }, + "type": "text", + "allowNull": false, + "defaultValue": null, + "listview": { + "show": true + }, + "editview": { + "show": true + } + }, + { + "name": "organization_id", + "verbose": "organization_id", + "control": { + "text": true + }, + "type": "integer", + "allowNull": false, + "defaultValue": null, + "listview": { + "show": true + }, + "editview": { + "show": true + } + }, + { + "name": "createdAt", + "verbose": "createdAt", + "control": { + "text": true + }, + "type": "timestamp", + "allowNull": false, + "defaultValue": "CURRENT_TIMESTAMP", + "listview": { + "show": true + }, + "editview": { + "show": true + } + }, + { + "name": "lastUpdatedAt", + "verbose": "lastUpdatedAt", + "control": { + "text": true + }, + "type": "timestamp", + "allowNull": false, + "defaultValue": "CURRENT_TIMESTAMP", + "listview": { + "show": true + }, + "editview": { + "show": true + } + }, + { + "name": "fname", + "verbose": "fname", + "control": { + "text": true + }, + "type": "text", + "allowNull": false, + "defaultValue": null, + "listview": { + "show": true + }, + "editview": { + "show": true + } + } + ], + "mainview": { + "show": true + }, + "listview": { + "order": {}, + "page": 25 + }, + "editview": { + "readonly": false + } + }, "organization_notifications": { "slug": "organization_notifications", "table": { @@ -1303,106 +1551,6 @@ "readonly": false } }, - "organization_users": { - "slug": "organization_users", - "table": { - "name": "organization_users", - "pk": "id", - "verbose": "organization_users" - }, - "columns": [ - { - "name": "id", - "verbose": "id", - "control": { - "text": true - }, - "type": "integer", - "allowNull": false, - "defaultValue": null, - "listview": { - "show": true - }, - "editview": { - "show": true - } - }, - { - "name": "user_id", - "verbose": "user_id", - "control": { - "text": true - }, - "type": "integer", - "allowNull": false, - "defaultValue": null, - "listview": { - "show": true - }, - "editview": { - "show": true - } - }, - { - "name": "organization_id", - "verbose": "organization_id", - "control": { - "text": true - }, - "type": "integer", - "allowNull": false, - "defaultValue": null, - "listview": { - "show": true - }, - "editview": { - "show": true - } - }, - { - "name": "createdAt", - "verbose": "createdAt", - "control": { - "text": true - }, - "type": "timestamp", - "allowNull": false, - "defaultValue": "CURRENT_TIMESTAMP", - "listview": { - "show": true - }, - "editview": { - "show": true - } - }, - { - "name": "lastUpdatedAt", - "verbose": "lastUpdatedAt", - "control": { - "text": true - }, - "type": "timestamp", - "allowNull": false, - "defaultValue": "CURRENT_TIMESTAMP", - "listview": { - "show": true - }, - "editview": { - "show": true - } - } - ], - "mainview": { - "show": true - }, - "listview": { - "order": {}, - "page": 25 - }, - "editview": { - "readonly": false - } - }, "organization_rag_tests": { "slug": "organization_rag_tests", "table": { diff --git a/frontend/src/pages/SystemSettings/Settings/index.tsx b/frontend/src/pages/SystemSettings/Settings/index.tsx index 1997eaa..eac978f 100644 --- a/frontend/src/pages/SystemSettings/Settings/index.tsx +++ b/frontend/src/pages/SystemSettings/Settings/index.tsx @@ -1,21 +1,23 @@ import { useState } from 'react'; import { APP_NAME } from '../../../utils/constants'; import System from '../../../models/system'; -import { ExternalLink, Eye, EyeOff } from 'react-feather'; import paths from '../../../utils/paths'; +import { + CaretDown, + EyeSlash, + Eye, + ArrowSquareOut, +} from '@phosphor-icons/react'; +import showToast from '../../../utils/toast'; export default function Settings({ settings }: { settings: any[] }) { - const [result, setResult] = useState<{ - show: boolean; - success: boolean; - error: null | string; - }>({ show: false, success: false, error: null }); + const [hasChanges, setHasChanges] = useState(false); + const getSetting = (label: string) => { return settings.find((setting) => setting.label === label); }; const handleSubmit = async (e: any) => { e.preventDefault(); - setResult({ show: false, success: false, error: null }); const form = new FormData(e.target); const data = { allow_account_creation: form.get('allow_account_creation') === 'yes', @@ -26,111 +28,119 @@ export default function Settings({ settings }: { settings: any[] }) { data.open_ai_api_key = form.get('open_ai_api_key') || null; const { success, error } = await System.updateSettings(data); - setResult({ show: true, success, error }); + + if (success) { + showToast('Settings updated successfully', 'success'); + setHasChanges(false); + } else { + showToast(`Error updating settings: ${error}`, 'error'); + } }; return ( -
-
-
-

- System Settings -

+ <> +
+
+
+
+
+ +
+ System Settings +
+
+
+
+
+ +
+
+
+ + + Allow anyone to create an account from the new account sign up + page. If disabled only an admin can create new accounts. + + + +
+ +
+ +

+ Force all accounts created to have emails ending in + @yourdomain.com +

+
+ setHasChanges(true)} + type="text" + name="account_creation_domain_scope" + placeholder="yourdomain.xyz" + defaultValue={ + getSetting('account_creation_domain_scope')?.value + } + className="mt-2 inline-flex h-11 w-[210px] items-center justify-start gap-2.5 rounded-lg bg-white bg-opacity-10 p-2.5 text-sm font-medium leading-tight text-white placeholder:text-opacity-60" + /> +
+
+ +
+ +

+ Required only if you will be updating or uploading new documents + or embeddings via {APP_NAME}. +

+
+ setHasChanges(true)} + type="password" + name="open_ai_api_key" + placeholder="sk-xxxxxxxx" + defaultValue={getSetting('open_ai_api_key')?.value} + className="max-w-1/2 mt-2 inline-flex h-11 min-w-[350px] items-center justify-start gap-2.5 rounded-lg bg-white bg-opacity-10 p-2.5 text-sm font-medium leading-tight text-white placeholder:text-opacity-60" + /> +
+
+ +
+ +
+
+
- -
- {result.show && ( - <> - {result.success ? ( -

- Settings updated successfully. -

- ) : ( -

- {result.error} -

- )} - - )} - -
-
- -

- Allow anyone to create an account from the new account sign up - page. If disabled only an admin can create new accounts. -

- - -
- -
- -

- force all accounts created to have emails ending in - @yourdomain.com -

-
- -
-
- -
- -

- Required only if you will be updating or uploading new documents - or embeddings via {APP_NAME}. -

-
- -
-
- -
- -
-
- -
-
+ ); } @@ -142,13 +152,12 @@ function DebugCredentials({ settings }: { settings: {} }) { return ( <> -
-
+
-

+

Database Debug Credentials

-

+

Use these credentials to for direct application database access.
Changes done via the database admin UI will not impact @@ -160,36 +169,33 @@ function DebugCredentials({ settings }: { settings: {} }) {

-
+
-
+
@@ -198,10 +204,10 @@ function DebugCredentials({ settings }: { settings: {} }) { Go to {APP_NAME} database manager - +