From cd655b128f49d0509de91405a61e2bc74d4f7047 Mon Sep 17 00:00:00 2001 From: Timothy Jaeryang Baek Date: Sat, 16 Nov 2024 01:38:20 -0800 Subject: [PATCH] refac --- .../workspace/Models/ModelEditor.svelte | 24 +++++++--- .../workspace/common/AccessControl.svelte | 44 ++++++++----------- 2 files changed, 35 insertions(+), 33 deletions(-) diff --git a/src/lib/components/workspace/Models/ModelEditor.svelte b/src/lib/components/workspace/Models/ModelEditor.svelte index 8e5fb2a02..0af526afd 100644 --- a/src/lib/components/workspace/Models/ModelEditor.svelte +++ b/src/lib/components/workspace/Models/ModelEditor.svelte @@ -14,6 +14,7 @@ import { getFunctions } from '$lib/apis/functions'; import { getKnowledgeItems } from '$lib/apis/knowledge'; import AccessControl from '../common/AccessControl.svelte'; + import { stringify } from 'postcss'; const i18n = getContext('i18n'); @@ -159,6 +160,7 @@ } if (model) { + console.log(model); name = model.name; await tick(); @@ -166,7 +168,7 @@ if (model.base_model_id) { const base_model = $models - .filter((m) => !m?.preset && m?.owned_by !== 'arena') + .filter((m) => !m?.preset && !(m?.arena ?? false)) .find((m) => [model.base_model_id, `${model.base_model_id}:latest`].includes(m.id)); console.log('base_model', base_model); @@ -213,6 +215,9 @@ accessControl = model?.access_control ?? null; + console.log(model?.access_control); + console.log(accessControl); + info = { ...info, ...JSON.parse( @@ -491,6 +496,17 @@ +
+
+ { + accessControl = _accessControl; + }} + /> +
+
+
@@ -670,12 +686,6 @@
-
-
- -
-
-
{$i18n.t('JSON Preview')}
diff --git a/src/lib/components/workspace/common/AccessControl.svelte b/src/lib/components/workspace/common/AccessControl.svelte index 8e6bf0f70..8ddbe2b47 100644 --- a/src/lib/components/workspace/common/AccessControl.svelte +++ b/src/lib/components/workspace/common/AccessControl.svelte @@ -11,30 +11,11 @@ export let accessControl = null; - let privateAccess = false; - let selectedGroupId = ''; - let groups = []; - $: if (privateAccess) { - accessControl = { - read: { - group_ids: [] - } - }; - } else { - accessControl = null; - } - onMount(async () => { groups = await getGroups(localStorage.token); - - if (accessControl === null) { - privateAccess = false; - } else { - privateAccess = true; - } }); @@ -45,7 +26,7 @@
- {#if privateAccess} + {#if accessControl !== null} { + if (e.target.value === 'public') { + accessControl = null; + } else { + accessControl = { + read: { + group_ids: [] + } + }; + } + }} > - - + +
- {#if privateAccess} + {#if accessControl !== null} {$i18n.t('Only select users and groups with permission can access')} {:else} {$i18n.t('Accessible to all users')} @@ -100,7 +92,7 @@
- {#if privateAccess} + {#if accessControl !== null} {@const accessGroups = groups.filter((group) => accessControl.read.group_ids.includes(group.id) )} @@ -151,7 +143,7 @@
-
+