fix(frontend): move sandbox uninstall into the manage drawer header
The leftover danger-zone button sat under a wall of copy and opened a modal. Put a compact popconfirm on the title row instead.main
parent
56bf53a1fd
commit
d3a3cc888d
|
|
@ -13,11 +13,17 @@ test('focused skill management expands env vars and transcript without a mid-pag
|
|||
assert.match(manageBlock, /onEnvFieldBlur/)
|
||||
assert.match(source, /isBusy\(skill\) \|\| !hasEnvEdits\(skill\)/)
|
||||
assert.match(manageBlock, /SkillInstallTimeline/)
|
||||
assert.match(manageBlock, /Teleport/)
|
||||
assert.match(manageBlock, /settings\.skills\.manageUninstall/)
|
||||
assert.match(manageBlock, /skill-manage__section--danger/)
|
||||
assert.match(manageBlock, /managedSkill\.status !== 'installing'/)
|
||||
assert.match(manageBlock, /manageUninstallConfirm/)
|
||||
assert.match(manageBlock, /showHeaderUninstall/)
|
||||
assert.match(source, /SETTING_DRAWER_HEADER_ACTIONS_ID/)
|
||||
assert.match(source, /skill\.status === 'installing'/)
|
||||
assert.match(manageBlock, /skill-manage__section--remove/)
|
||||
assert.match(manageBlock, /askRemove/)
|
||||
assert.match(manageBlock, /t-popconfirm/)
|
||||
assert.doesNotMatch(manageBlock, /askRemove/)
|
||||
assert.doesNotMatch(manageBlock, /skill-manage__section--danger/)
|
||||
assert.doesNotMatch(source, /useConfirmDelete/)
|
||||
assert.match(manageBlock, /skillRemoveDone/)
|
||||
assert.match(manageBlock, /progressStageText/)
|
||||
assert.match(source, /overlayUninstallStatus/)
|
||||
|
|
|
|||
|
|
@ -76,6 +76,28 @@
|
|||
</section>
|
||||
|
||||
<section v-if="mode === 'list' && focusSkillId" class="skill-manage">
|
||||
<Teleport v-if="headerActionsTarget && showHeaderUninstall" :to="headerActionsTarget" defer>
|
||||
<t-popconfirm
|
||||
theme="warning"
|
||||
attach="body"
|
||||
:content="$t('settings.skills.manageUninstallConfirm', { name: managedSkill?.name || '' })"
|
||||
:confirm-btn="{ content: $t('settings.skills.manageUninstall'), theme: 'danger' }"
|
||||
:cancel-btn="{ content: $t('common.cancel') }"
|
||||
placement="bottom-right"
|
||||
@confirm="managedSkill && removeSkill(managedSkill)"
|
||||
>
|
||||
<t-button
|
||||
class="skill-header-uninstall"
|
||||
theme="danger"
|
||||
variant="outline"
|
||||
size="small"
|
||||
:disabled="!managedSkill || isBusy(managedSkill)"
|
||||
:loading="!!managedSkill && deletingId === managedSkill.id"
|
||||
>
|
||||
{{ $t('settings.skills.manageUninstall') }}
|
||||
</t-button>
|
||||
</t-popconfirm>
|
||||
</Teleport>
|
||||
<div v-if="uninstallDone" class="skill-manage__done">
|
||||
<t-icon name="check-circle-filled" size="22px" />
|
||||
<p>{{ $t('settings.sandbox.skillRemoveDone', { name: uninstallingName }) }}</p>
|
||||
|
|
@ -124,6 +146,9 @@
|
|||
<ul v-if="failedErrorLines(managedSkill).length" class="skill-card__error">
|
||||
<li v-for="(line, i) in failedErrorLines(managedSkill)" :key="i">{{ line }}</li>
|
||||
</ul>
|
||||
<ul v-if="removalErrorLines(managedSkill).length" class="skill-card__error">
|
||||
<li v-for="(line, i) in removalErrorLines(managedSkill)" :key="i">{{ line }}</li>
|
||||
</ul>
|
||||
<section v-if="skillHasDeclaredEnvs(managedSkill)" class="skill-manage__section">
|
||||
<h4>{{ $t('settings.sandbox.skillEnv.toggle') }}</h4>
|
||||
<p class="skill-envs__hint">{{ $t('settings.sandbox.skillEnv.workspaceHint') }}</p>
|
||||
|
|
@ -211,25 +236,6 @@
|
|||
:live="managedSkill.status === 'installing'"
|
||||
/>
|
||||
</section>
|
||||
<section
|
||||
v-if="managedSkill.status !== 'installing'"
|
||||
class="skill-manage__section skill-manage__section--danger"
|
||||
>
|
||||
<h4>{{ $t('settings.skills.manageUninstall') }}</h4>
|
||||
<p class="skill-envs__hint">{{ deleteHint }}</p>
|
||||
<ul v-if="removalErrorLines(managedSkill).length" class="skill-card__error">
|
||||
<li v-for="(line, i) in removalErrorLines(managedSkill)" :key="i">{{ line }}</li>
|
||||
</ul>
|
||||
<t-button
|
||||
theme="danger"
|
||||
variant="outline"
|
||||
:disabled="isBusy(managedSkill)"
|
||||
:loading="deletingId === managedSkill.id"
|
||||
@click="askRemove(managedSkill)"
|
||||
>
|
||||
{{ $t('settings.skills.manageUninstall') }}
|
||||
</t-button>
|
||||
</section>
|
||||
</template>
|
||||
</section>
|
||||
|
||||
|
|
@ -502,16 +508,25 @@
|
|||
<t-icon name="refresh" size="14px" />
|
||||
</button>
|
||||
</t-tooltip>
|
||||
<button
|
||||
<t-popconfirm
|
||||
v-if="!isBusy(skill)"
|
||||
type="button"
|
||||
class="skill-card__icon-btn skill-card__icon-btn--danger"
|
||||
:disabled="deletingId === skill.id"
|
||||
:aria-label="$t('settings.skills.manageUninstall')"
|
||||
@click="askRemove(skill)"
|
||||
theme="warning"
|
||||
attach="body"
|
||||
:content="deleteHint"
|
||||
:confirm-btn="{ content: $t('settings.skills.manageUninstall'), theme: 'danger' }"
|
||||
:cancel-btn="{ content: $t('common.cancel') }"
|
||||
placement="top-right"
|
||||
@confirm="removeSkill(skill)"
|
||||
>
|
||||
<t-icon name="delete" size="14px" />
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="skill-card__icon-btn skill-card__icon-btn--danger"
|
||||
:disabled="deletingId === skill.id"
|
||||
:aria-label="$t('settings.skills.manageUninstall')"
|
||||
>
|
||||
<t-icon name="delete" size="14px" />
|
||||
</button>
|
||||
</t-popconfirm>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="skill.version && !focusSkillId" class="skill-card__type">{{ skill.version }}</div>
|
||||
|
|
@ -548,14 +563,14 @@
|
|||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, nextTick, onUnmounted, reactive, ref, watch } from 'vue'
|
||||
import { computed, inject, nextTick, onUnmounted, reactive, ref, watch } from 'vue'
|
||||
import { MessagePlugin } from 'tdesign-vue-next'
|
||||
import { AddIcon } from 'tdesign-icons-vue-next'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { fetchEventSource } from '@microsoft/fetch-event-source'
|
||||
import ModelSelector from '@/components/ModelSelector.vue'
|
||||
import SkillInstallTimeline from '@/components/SkillInstallTimeline.vue'
|
||||
import { useConfirmDelete } from '@/components/settings/useConfirmDelete'
|
||||
import { SETTING_DRAWER_HEADER_ACTIONS_ID } from '@/components/settings/SettingDrawer.vue'
|
||||
import { SKILL_ICON } from '@/types/mention'
|
||||
import {
|
||||
getAgentById,
|
||||
|
|
@ -615,7 +630,7 @@ const emit = defineEmits<{
|
|||
}>()
|
||||
|
||||
const { t } = useI18n()
|
||||
const confirmDelete = useConfirmDelete()
|
||||
const headerActionsTarget = inject(SETTING_DRAWER_HEADER_ACTIONS_ID, '')
|
||||
|
||||
const loading = ref(false)
|
||||
const uploading = ref(false)
|
||||
|
|
@ -735,6 +750,13 @@ const managedSkill = computed(() =>
|
|||
props.focusSkillId ? (visibleSkills.value[0] || null) : null,
|
||||
)
|
||||
|
||||
const showHeaderUninstall = computed(() => {
|
||||
if (!props.focusSkillId || uninstallDone.value) return false
|
||||
const skill = managedSkill.value
|
||||
if (!skill || skill.status === 'installing') return false
|
||||
return !isRemoving(skill)
|
||||
})
|
||||
|
||||
watch(managedSkill, (skill) => {
|
||||
if (skill && skillHasDeclaredEnvs(skill)) ensureEnvDrafts(skill.id)
|
||||
}, { immediate: true })
|
||||
|
|
@ -1336,16 +1358,6 @@ async function retrySkill(skill: ConfigSkill) {
|
|||
}
|
||||
}
|
||||
|
||||
function askRemove(skill: ConfigSkill) {
|
||||
if (!props.record || isBusy(skill) || deletingId.value) return
|
||||
confirmDelete({
|
||||
title: t('settings.skills.manageUninstall'),
|
||||
body: deleteHint.value,
|
||||
confirmText: t('settings.skills.manageUninstall'),
|
||||
onConfirm: () => removeSkill(skill),
|
||||
})
|
||||
}
|
||||
|
||||
async function removeSkill(skill: ConfigSkill) {
|
||||
if (!props.record || isBusy(skill) || deletingId.value) return
|
||||
deletingId.value = skill.id
|
||||
|
|
@ -1585,6 +1597,10 @@ onUnmounted(() => {
|
|||
min-height: 0;
|
||||
}
|
||||
|
||||
.skill-header-uninstall {
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.skill-manage {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
|
@ -1632,10 +1648,6 @@ onUnmounted(() => {
|
|||
padding-top: 12px;
|
||||
border-top: 1px solid var(--td-component-stroke);
|
||||
|
||||
> .t-button {
|
||||
align-self: flex-start;
|
||||
}
|
||||
|
||||
h4 {
|
||||
margin: 0;
|
||||
font-size: 13px;
|
||||
|
|
@ -1664,10 +1676,6 @@ onUnmounted(() => {
|
|||
}
|
||||
}
|
||||
|
||||
&--danger h4 {
|
||||
color: var(--td-error-color);
|
||||
}
|
||||
|
||||
&--remove {
|
||||
border-top: 0;
|
||||
padding-top: 0;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,14 @@
|
|||
import assert from 'node:assert/strict'
|
||||
import { readFileSync } from 'node:fs'
|
||||
import test from 'node:test'
|
||||
|
||||
const source = readFileSync(new URL('./SettingDrawer.vue', import.meta.url), 'utf8')
|
||||
|
||||
test('the title row hosts compact header actions without replacing the step rail', () => {
|
||||
assert.match(source, /headerActionsId/)
|
||||
assert.match(source, /SETTING_DRAWER_HEADER_ACTIONS_ID/)
|
||||
assert.match(source, /header-actions/)
|
||||
assert.match(source, /header-extra/)
|
||||
assert.match(source, /setting-drawer__header-actions/)
|
||||
assert.match(source, /&:empty/)
|
||||
})
|
||||
|
|
@ -31,6 +31,7 @@
|
|||
<slot name="subtitle">{{ description }}</slot>
|
||||
</div>
|
||||
</div>
|
||||
<div :id="headerActionsId" class="setting-drawer__header-actions"><slot name="header-actions" /></div>
|
||||
</div>
|
||||
<div v-if="$slots['header-extra']" class="setting-drawer__header-extra">
|
||||
<slot name="header-extra" />
|
||||
|
|
@ -61,8 +62,16 @@
|
|||
</t-drawer>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import type { InjectionKey } from 'vue'
|
||||
|
||||
// Skill manage (and similar) panels teleport compact header actions here so
|
||||
// they sit on the title row without each drawer re-declaring the chrome.
|
||||
export const SETTING_DRAWER_HEADER_ACTIONS_ID: InjectionKey<string> = Symbol('settingDrawerHeaderActionsId')
|
||||
</script>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, computed, useAttrs, onMounted, onUnmounted } from 'vue'
|
||||
import { ref, computed, provide, useAttrs, useId, onMounted, onUnmounted } from 'vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
|
||||
interface Props {
|
||||
|
|
@ -122,6 +131,8 @@ const emit = defineEmits<{
|
|||
|
||||
const { t } = useI18n()
|
||||
const attrs = useAttrs()
|
||||
const headerActionsId = `sdha${useId().replace(/\W/g, '')}`
|
||||
provide(SETTING_DRAWER_HEADER_ACTIONS_ID, `#${headerActionsId}`)
|
||||
|
||||
const drawerPassthroughAttrs = computed(() => {
|
||||
const { class: _class, ...rest } = attrs
|
||||
|
|
@ -299,6 +310,27 @@ const handleCancel = () => {
|
|||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1px;
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.setting-drawer__header-actions {
|
||||
flex-shrink: 0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
margin-left: auto;
|
||||
|
||||
&:empty {
|
||||
display: none;
|
||||
}
|
||||
|
||||
:deep(.t-button) {
|
||||
white-space: nowrap;
|
||||
}
|
||||
}
|
||||
|
||||
.setting-drawer__header-extra {
|
||||
width: 100%;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1449,6 +1449,7 @@ export default {
|
|||
manageDrawerDesc: 'Manage enablement, variables, and uninstall on sandbox “{name}”.',
|
||||
manageEnable: 'Enable',
|
||||
manageUninstall: 'Uninstall from sandbox',
|
||||
manageUninstallConfirm: 'Uninstall “{name}” from this sandbox?',
|
||||
deleteCatalog: 'Remove from catalog',
|
||||
deleteCatalogConfirm: 'Remove “{name}” from the catalog? Uninstall it from every sandbox first.',
|
||||
deleteCatalogBlocked: 'Uninstall this skill from every sandbox first.',
|
||||
|
|
|
|||
|
|
@ -5369,6 +5369,7 @@ export default {
|
|||
manageDrawerDesc: '샌드박스 「{name}」에서 사용 여부, 변수, 제거를 관리합니다.',
|
||||
manageEnable: '사용',
|
||||
manageUninstall: '샌드박스에서 제거',
|
||||
manageUninstallConfirm: '샌드박스에서 「{name}」을(를) 제거할까요?',
|
||||
deleteCatalog: '카탈로그에서 삭제',
|
||||
deleteCatalogConfirm: '「{name}」을 카탈로그에서 삭제할까요? 모든 샌드박스에서 먼저 제거하세요.',
|
||||
deleteCatalogBlocked: '모든 샌드박스에서 이 스킬을 먼저 제거하세요.',
|
||||
|
|
|
|||
|
|
@ -5369,6 +5369,7 @@ export default {
|
|||
manageDrawerDesc: 'В песочнице «{name}» можно включать навык, править переменные и удалять установку.',
|
||||
manageEnable: 'Включить',
|
||||
manageUninstall: 'Удалить из песочницы',
|
||||
manageUninstallConfirm: 'Удалить «{name}» из этой песочницы?',
|
||||
deleteCatalog: 'Удалить из каталога',
|
||||
deleteCatalogConfirm: 'Удалить «{name}» из каталога? Сначала снимите установку со всех песочниц.',
|
||||
deleteCatalogBlocked: 'Сначала снимите этот навык со всех песочниц.',
|
||||
|
|
|
|||
|
|
@ -5371,6 +5371,7 @@ export default {
|
|||
manageDrawerDesc: '在沙箱「{name}」上管理启用、变量和卸载。',
|
||||
manageEnable: '启用',
|
||||
manageUninstall: '从沙箱卸载',
|
||||
manageUninstallConfirm: '确定从该沙箱卸载「{name}」?',
|
||||
deleteCatalog: '从目录删除',
|
||||
deleteCatalogConfirm: '确定从目录删除「{name}」?请先从所有沙箱卸载。',
|
||||
deleteCatalogBlocked: '请先从所有沙箱卸载此技能。',
|
||||
|
|
|
|||
Loading…
Reference in New Issue