fix: derive integrations toggle state from the selected ids (#28807)
This commit is contained in:
1 file changed
+9
-17
@@ -34,7 +34,6 @@
|
|||||||
id: string;
|
id: string;
|
||||||
name: string;
|
name: string;
|
||||||
description?: string;
|
description?: string;
|
||||||
enabled: boolean;
|
|
||||||
meta?: { description?: string };
|
meta?: { description?: string };
|
||||||
is_active?: boolean;
|
is_active?: boolean;
|
||||||
authenticated?: boolean;
|
authenticated?: boolean;
|
||||||
@@ -113,8 +112,7 @@
|
|||||||
a[tool.id] = {
|
a[tool.id] = {
|
||||||
...tool,
|
...tool,
|
||||||
name: tool.name,
|
name: tool.name,
|
||||||
description: tool.meta?.description,
|
description: tool.meta?.description
|
||||||
enabled: selectedToolIds.includes(tool.id)
|
|
||||||
};
|
};
|
||||||
return a;
|
return a;
|
||||||
}, {});
|
}, {});
|
||||||
@@ -130,8 +128,7 @@
|
|||||||
items[`direct_server:${serverIdx}`] = {
|
items[`direct_server:${serverIdx}`] = {
|
||||||
id: `direct_server:${serverIdx}`,
|
id: `direct_server:${serverIdx}`,
|
||||||
name,
|
name,
|
||||||
description: server.info.description ?? '',
|
description: server.info.description ?? ''
|
||||||
enabled: selectedToolIds.includes(`direct_server:${serverIdx}`)
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -150,8 +147,7 @@
|
|||||||
a[skill.id] = {
|
a[skill.id] = {
|
||||||
...skill,
|
...skill,
|
||||||
name: skill.name,
|
name: skill.name,
|
||||||
description: skill.description,
|
description: skill.description
|
||||||
enabled: selectedSkillIds.includes(skill.id)
|
|
||||||
};
|
};
|
||||||
return a;
|
return a;
|
||||||
}, {});
|
}, {});
|
||||||
@@ -229,9 +225,7 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
tool.enabled = !tool.enabled;
|
const state = !selectedToolIds.includes(toolId);
|
||||||
|
|
||||||
const state = tool.enabled;
|
|
||||||
await tick();
|
await tick();
|
||||||
|
|
||||||
if (state) {
|
if (state) {
|
||||||
@@ -245,9 +239,7 @@
|
|||||||
const skill = skills?.[skillId];
|
const skill = skills?.[skillId];
|
||||||
if (!skill) return;
|
if (!skill) return;
|
||||||
|
|
||||||
skill.enabled = !skill.enabled;
|
const state = !selectedSkillIds.includes(skillId);
|
||||||
|
|
||||||
const state = skill.enabled;
|
|
||||||
await tick();
|
await tick();
|
||||||
|
|
||||||
if (state) {
|
if (state) {
|
||||||
@@ -506,7 +498,7 @@
|
|||||||
<button
|
<button
|
||||||
class="relative flex w-full justify-between gap-2 items-center h-[1.6875rem] px-2 text-[0.8125rem] font-normal cursor-pointer rounded-xl hover:bg-gray-50/40 dark:hover:bg-gray-800/40"
|
class="relative flex w-full justify-between gap-2 items-center h-[1.6875rem] px-2 text-[0.8125rem] font-normal cursor-pointer rounded-xl hover:bg-gray-50/40 dark:hover:bg-gray-800/40"
|
||||||
aria-pressed={(tools?.[toolId]?.authenticated ?? true)
|
aria-pressed={(tools?.[toolId]?.authenticated ?? true)
|
||||||
? tools?.[toolId]?.enabled
|
? selectedToolIds.includes(toolId)
|
||||||
: undefined}
|
: undefined}
|
||||||
on:click={async (e) => {
|
on:click={async (e) => {
|
||||||
await toggleTool(toolId, e);
|
await toggleTool(toolId, e);
|
||||||
@@ -584,7 +576,7 @@
|
|||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
<div class=" shrink-0" inert>
|
<div class=" shrink-0" inert>
|
||||||
<Switch state={tools?.[toolId]?.enabled} />
|
<Switch state={selectedToolIds.includes(toolId)} />
|
||||||
</div>
|
</div>
|
||||||
</button>
|
</button>
|
||||||
{/each}
|
{/each}
|
||||||
@@ -620,7 +612,7 @@
|
|||||||
{#each skillIds as skillId}
|
{#each skillIds as skillId}
|
||||||
<button
|
<button
|
||||||
class="relative flex w-full justify-between gap-2 items-center h-[1.6875rem] px-2 text-[0.8125rem] font-normal cursor-pointer rounded-xl hover:bg-gray-50/40 dark:hover:bg-gray-800/40"
|
class="relative flex w-full justify-between gap-2 items-center h-[1.6875rem] px-2 text-[0.8125rem] font-normal cursor-pointer rounded-xl hover:bg-gray-50/40 dark:hover:bg-gray-800/40"
|
||||||
aria-pressed={skills?.[skillId]?.enabled}
|
aria-pressed={selectedSkillIds.includes(skillId)}
|
||||||
on:click={async () => {
|
on:click={async () => {
|
||||||
await toggleSkill(skillId);
|
await toggleSkill(skillId);
|
||||||
}}
|
}}
|
||||||
@@ -642,7 +634,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class=" shrink-0" inert>
|
<div class=" shrink-0" inert>
|
||||||
<Switch state={skills?.[skillId]?.enabled} />
|
<Switch state={selectedSkillIds.includes(skillId)} />
|
||||||
</div>
|
</div>
|
||||||
</button>
|
</button>
|
||||||
{/each}
|
{/each}
|
||||||
|
|||||||
Reference in new issue
Block a user