refac
This commit is contained in:
1 parent
6cb2449ab7
commit
7a533d0d5b
2 files changed
+44
-16
No files matched your search
@@ -773,6 +773,14 @@
|
||||
'terminal',
|
||||
modelCapabilitiesById
|
||||
);
|
||||
$: hasDirectToolServerAccess =
|
||||
$_user?.role === 'admin' || ($_user?.permissions?.features?.direct_tool_servers ?? true);
|
||||
$: showTerminalSelector =
|
||||
terminalCapableModels.length > 0 &&
|
||||
(($terminalServers ?? []).some((t) => t.id) ||
|
||||
(hasDirectToolServerAccess &&
|
||||
(($terminalServers ?? []).some((t) => !t.id) ||
|
||||
($settings?.terminalServers ?? []).some((s) => s.url))));
|
||||
|
||||
let toggleFilters = [];
|
||||
$: toggleFilters = (atSelectedModel?.id ? [atSelectedModel.id] : selectedModels)
|
||||
@@ -2482,14 +2490,14 @@
|
||||
</Tooltip>
|
||||
{/each}
|
||||
|
||||
{#if !history?.currentId || history.messages[history.currentId]?.done == true}
|
||||
<!-- Terminal Server Selector -->
|
||||
{@const hasDirectToolServerAccess =
|
||||
$_user?.role === 'admin' ||
|
||||
($_user?.permissions?.features?.direct_tool_servers ?? true)}
|
||||
{#if terminalCapableModels.length > 0 && (($terminalServers ?? []).some((t) => t.id) || (hasDirectToolServerAccess && (($terminalServers ?? []).some((t) => !t.id) || ($settings?.terminalServers ?? []).some((s) => s.url))))}
|
||||
<TerminalMenu bind:show={showTerminalMenu} />
|
||||
{/if}
|
||||
{#if showTerminalSelector}
|
||||
<TerminalMenu
|
||||
bind:show={showTerminalMenu}
|
||||
disabled={generating ||
|
||||
(!!history?.currentId &&
|
||||
history.messages[history.currentId]?.done != true)}
|
||||
/>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
const i18n = getContext('i18n');
|
||||
|
||||
export let show = false;
|
||||
export let disabled = false;
|
||||
|
||||
const chatContext = (terminal: any) => terminal?.contexts?.chat ?? {};
|
||||
|
||||
@@ -117,22 +118,40 @@
|
||||
selectedDirectTerminal?.name ||
|
||||
selectedDirectTerminal?.url?.replace(/^https?:\/\//, '') ||
|
||||
$i18n.t('Terminal');
|
||||
$: if (disabled && show) show = false;
|
||||
|
||||
$: triggerClass = `flex items-center gap-1.5 translate-y-[1px] text-[0.8125rem] transition rounded-lg ${
|
||||
disabled
|
||||
? 'p-1 cursor-not-allowed opacity-40 text-gray-400 dark:text-gray-600'
|
||||
: `text-gray-600 hover:bg-gray-50/40 hover:text-gray-700 dark:text-gray-300 dark:hover:bg-gray-800/40 dark:hover:text-gray-200 cursor-pointer ${
|
||||
$selectedTerminalId && selectedLabel ? ' p-1 ' : ' p-1 opacity-50'
|
||||
}`
|
||||
}`;
|
||||
</script>
|
||||
|
||||
<div class="flex items-center translate-x-0.5">
|
||||
<Dropdown bind:show align="start">
|
||||
{#if disabled}
|
||||
<Tooltip content={$i18n.t('Terminal')} placement="top">
|
||||
<button
|
||||
type="button"
|
||||
class="flex items-center gap-1.5 translate-y-[1px] text-[0.8125rem] text-gray-600 hover:bg-gray-50/40 hover:text-gray-700 dark:text-gray-300 dark:hover:bg-gray-800/40 dark:hover:text-gray-200 transition rounded-lg cursor-pointer {$selectedTerminalId &&
|
||||
selectedLabel
|
||||
? ' p-1 '
|
||||
: ' p-1 opacity-50'}"
|
||||
>
|
||||
<button type="button" disabled aria-disabled="true" class={triggerClass}>
|
||||
<Cloud className="size-3.5" strokeWidth="2" />
|
||||
|
||||
{#if $selectedTerminalId && selectedLabel}
|
||||
<span class="truncate text-[0.8125rem] max-w-[6.25rem] sm:max-w-[9.375rem]">{selectedLabel}</span>
|
||||
<span class="truncate text-[0.8125rem] max-w-[6.25rem] sm:max-w-[9.375rem]"
|
||||
>{selectedLabel}</span
|
||||
>
|
||||
{/if}
|
||||
</button>
|
||||
</Tooltip>
|
||||
{:else}
|
||||
<Dropdown bind:show align="start">
|
||||
<Tooltip content={$i18n.t('Terminal')} placement="top">
|
||||
<button type="button" class={triggerClass}>
|
||||
<Cloud className="size-3.5" strokeWidth="2" />
|
||||
|
||||
{#if $selectedTerminalId && selectedLabel}
|
||||
<span class="truncate text-[0.8125rem] max-w-[6.25rem] sm:max-w-[9.375rem]"
|
||||
>{selectedLabel}</span
|
||||
>
|
||||
{/if}
|
||||
</button>
|
||||
</Tooltip>
|
||||
@@ -277,4 +296,5 @@
|
||||
</DropdownMenu>
|
||||
</div>
|
||||
</Dropdown>
|
||||
{/if}
|
||||
</div>
|
||||
Reference in new issue
Block a user