refac
This commit is contained in:
1 parent
e5e2cd7876
commit
3316ba76aa
2 files changed
+96
-102
No files matched your search
@@ -570,7 +570,7 @@
|
|||||||
</Tooltip>
|
</Tooltip>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="ml-2 flex shrink-0 flex-row items-center self-center">
|
<div class="ml-2 flex shrink-0 flex-row items-center gap-1.5 self-center">
|
||||||
{#if shiftKey}
|
{#if shiftKey}
|
||||||
<Tooltip content={$i18n.t('Delete')}>
|
<Tooltip content={$i18n.t('Delete')}>
|
||||||
<button
|
<button
|
||||||
@@ -639,78 +639,74 @@
|
|||||||
</button>
|
</button>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
|
|
||||||
<div class="ml-0.5 flex shrink-0 flex-row items-center gap-1.5 self-center">
|
<FunctionMenu
|
||||||
<FunctionMenu
|
{func}
|
||||||
{func}
|
show={openFunctionMenuId === func.id}
|
||||||
show={openFunctionMenuId === func.id}
|
editHandler={() => {
|
||||||
editHandler={() => {
|
goto(`/admin/functions/edit?id=${encodeURIComponent(func.id)}`);
|
||||||
goto(`/admin/functions/edit?id=${encodeURIComponent(func.id)}`);
|
}}
|
||||||
}}
|
shareHandler={() => {
|
||||||
shareHandler={() => {
|
shareHandler(func);
|
||||||
shareHandler(func);
|
}}
|
||||||
}}
|
cloneHandler={() => {
|
||||||
cloneHandler={() => {
|
cloneHandler(func);
|
||||||
cloneHandler(func);
|
}}
|
||||||
}}
|
exportHandler={() => {
|
||||||
exportHandler={() => {
|
exportHandler(func);
|
||||||
exportHandler(func);
|
}}
|
||||||
}}
|
deleteHandler={async () => {
|
||||||
deleteHandler={async () => {
|
selectedFunction = func;
|
||||||
selectedFunction = func;
|
showDeleteConfirm = true;
|
||||||
showDeleteConfirm = true;
|
}}
|
||||||
}}
|
toggleGlobalHandler={() => {
|
||||||
toggleGlobalHandler={() => {
|
if (['filter', 'action'].includes(func.type)) {
|
||||||
if (['filter', 'action'].includes(func.type)) {
|
toggleGlobalHandler(func);
|
||||||
toggleGlobalHandler(func);
|
}
|
||||||
}
|
}}
|
||||||
}}
|
onClose={() => {
|
||||||
onClose={() => {
|
openFunctionMenuId = null;
|
||||||
openFunctionMenuId = null;
|
}}
|
||||||
}}
|
>
|
||||||
>
|
|
||||||
<button
|
|
||||||
class="flex size-6 items-center justify-center rounded-lg text-gray-400 transition dark:text-gray-500"
|
|
||||||
type="button"
|
|
||||||
aria-label={$i18n.t('Function Menu')}
|
|
||||||
on:click={(e) => {
|
|
||||||
e.preventDefault();
|
|
||||||
e.stopPropagation();
|
|
||||||
openFunctionMenuId = openFunctionMenuId === func.id ? null : func.id;
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<EllipsisHorizontal className="size-4" />
|
|
||||||
</button>
|
|
||||||
</FunctionMenu>
|
|
||||||
|
|
||||||
<button
|
<button
|
||||||
class="flex h-6 items-center"
|
class="flex size-6 items-center justify-center rounded-lg text-gray-400 transition dark:text-gray-500"
|
||||||
type="button"
|
type="button"
|
||||||
|
aria-label={$i18n.t('Function Menu')}
|
||||||
on:click={(e) => {
|
on:click={(e) => {
|
||||||
e.stopPropagation();
|
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
e.stopPropagation();
|
||||||
|
openFunctionMenuId = openFunctionMenuId === func.id ? null : func.id;
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Tooltip
|
<EllipsisHorizontal className="size-4" />
|
||||||
content={func.is_active ? $i18n.t('Enabled') : $i18n.t('Disabled')}
|
|
||||||
>
|
|
||||||
<Switch
|
|
||||||
bind:state={func.is_active}
|
|
||||||
on:change={async () => {
|
|
||||||
toggleFunctionById(localStorage.token, func.id);
|
|
||||||
models.set(
|
|
||||||
await getModels(
|
|
||||||
localStorage.token,
|
|
||||||
$config?.features?.enable_direct_connections &&
|
|
||||||
($settings?.directConnections ?? null),
|
|
||||||
false,
|
|
||||||
true
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</Tooltip>
|
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</FunctionMenu>
|
||||||
|
|
||||||
|
<button
|
||||||
|
class="flex h-6 items-center"
|
||||||
|
type="button"
|
||||||
|
on:click={(e) => {
|
||||||
|
e.stopPropagation();
|
||||||
|
e.preventDefault();
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Tooltip content={func.is_active ? $i18n.t('Enabled') : $i18n.t('Disabled')}>
|
||||||
|
<Switch
|
||||||
|
bind:state={func.is_active}
|
||||||
|
on:change={async () => {
|
||||||
|
toggleFunctionById(localStorage.token, func.id);
|
||||||
|
models.set(
|
||||||
|
await getModels(
|
||||||
|
localStorage.token,
|
||||||
|
$config?.features?.enable_direct_connections &&
|
||||||
|
($settings?.directConnections ?? null),
|
||||||
|
false,
|
||||||
|
true
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</Tooltip>
|
||||||
|
</button>
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -494,7 +494,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
{#if tool.write_access}
|
{#if tool.write_access}
|
||||||
<div class="ml-2 flex shrink-0 flex-row items-center self-center">
|
<div class="ml-2 flex shrink-0 flex-row items-center gap-1.5 self-center">
|
||||||
{#if shiftKey}
|
{#if shiftKey}
|
||||||
<Tooltip content={$i18n.t('Delete')}>
|
<Tooltip content={$i18n.t('Delete')}>
|
||||||
<button
|
<button
|
||||||
@@ -563,43 +563,41 @@
|
|||||||
</button>
|
</button>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
|
|
||||||
<div class="ml-0.5 flex shrink-0 flex-row items-center self-center">
|
<ToolMenu
|
||||||
<ToolMenu
|
show={openToolMenuId === tool.id}
|
||||||
show={openToolMenuId === tool.id}
|
editHandler={() => {
|
||||||
editHandler={() => {
|
goto(`/workspace/tools/edit?id=${encodeURIComponent(tool.id)}`);
|
||||||
goto(`/workspace/tools/edit?id=${encodeURIComponent(tool.id)}`);
|
}}
|
||||||
}}
|
shareHandler={() => {
|
||||||
shareHandler={() => {
|
shareHandler(tool);
|
||||||
shareHandler(tool);
|
}}
|
||||||
}}
|
cloneHandler={() => {
|
||||||
cloneHandler={() => {
|
cloneHandler(tool);
|
||||||
cloneHandler(tool);
|
}}
|
||||||
}}
|
exportHandler={() => {
|
||||||
exportHandler={() => {
|
exportHandler(tool);
|
||||||
exportHandler(tool);
|
}}
|
||||||
}}
|
deleteHandler={async () => {
|
||||||
deleteHandler={async () => {
|
selectedTool = tool;
|
||||||
selectedTool = tool;
|
showDeleteConfirm = true;
|
||||||
showDeleteConfirm = true;
|
}}
|
||||||
}}
|
onClose={() => {
|
||||||
onClose={() => {
|
openToolMenuId = null;
|
||||||
openToolMenuId = null;
|
}}
|
||||||
|
>
|
||||||
|
<button
|
||||||
|
class="flex size-6 items-center justify-center rounded-lg text-gray-400 transition dark:text-gray-500"
|
||||||
|
type="button"
|
||||||
|
aria-label={$i18n.t('Tool Menu')}
|
||||||
|
on:click={(e) => {
|
||||||
|
e.preventDefault();
|
||||||
|
e.stopPropagation();
|
||||||
|
openToolMenuId = openToolMenuId === tool.id ? null : tool.id;
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<button
|
<EllipsisHorizontal className="size-4" />
|
||||||
class="flex size-6 items-center justify-center rounded-lg text-gray-400 transition dark:text-gray-500"
|
</button>
|
||||||
type="button"
|
</ToolMenu>
|
||||||
aria-label={$i18n.t('Tool Menu')}
|
|
||||||
on:click={(e) => {
|
|
||||||
e.preventDefault();
|
|
||||||
e.stopPropagation();
|
|
||||||
openToolMenuId = openToolMenuId === tool.id ? null : tool.id;
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<EllipsisHorizontal className="size-4" />
|
|
||||||
</button>
|
|
||||||
</ToolMenu>
|
|
||||||
</div>
|
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
|||||||
Reference in new issue
Block a user