<template>
<div class="admin-tools-panel">
<div class="admin-tools-header">
<h2 class="admin-tools-title">{{ t('settings.adminToolsTitle') }}</h2>
<GnButton
variant="primary"
size="sm"
:loading="running"
@click="onReload"
>
{{ t(running ? 'settings.adminToolsReloading' : 'settings.adminToolsReload') }}
</GnButton>
</div>
<p class="admin-tools-description">
{{ t('settings.adminToolsDescriptionBefore') }} <code>tools/</code>
{{ t('settings.adminToolsDescriptionAfter') }}
</p>
<div v-if="report" class="admin-tools-report" :class="{ 'has-problems': !report.ok }">
<div class="admin-tools-line">
<i class="ph ph-check-circle" aria-hidden="true"></i>
<span>
{{ t('settings.adminToolsLoaded', { n: report.tools.length }) }}
<template v-if="report.tools.length"> — {{ report.tools.join(', ') }}</template>
<span class="admin-tools-total">
{{ t('settings.adminToolsRegistry', { n: report.total_tools }) }}
</span>
</span>
</div>
<div v-if="report.missing_enabled.length" class="admin-tools-line is-warning">
<i class="ph ph-warning" aria-hidden="true"></i>
<span>
<code>enabled.json</code>
{{ t('settings.adminToolsMissing', { names: report.missing_enabled.join(', ') }) }}
</span>
</div>
<div v-for="(error, file) in report.tool_errors" :key="file" class="admin-tools-line is-error">
<i class="ph ph-x-circle" aria-hidden="true"></i>
<span><code>{{ file }}</code>: {{ error }}</span>
</div>
<div v-if="report.mcp_error" class="admin-tools-line is-error">
<i class="ph ph-x-circle" aria-hidden="true"></i>
<span>{{ t('settings.adminToolsMcpFailed', { error: report.mcp_error }) }}</span>
</div>
<div v-else class="admin-tools-line">
<i class="ph ph-plugs-connected" aria-hidden="true"></i>
<span>
{{ t('settings.adminToolsMcpTools', { n: report.mcp_tools.length }) }} —
{{ t('settings.adminToolsProviders', { n: report.providers.length }) }}
</span>
</div>
</div>
</div>
</template>
<script setup>
import { ref } from 'vue'
import { t } from '@/i18n/index.js'
import { useToast } from 'gnexus-ui-kit/vue'
import { GnButton } from 'gnexus-ui-kit/vue'
import * as api from '@/api/index.js'
const toast = useToast()
const running = ref(false)
const report = ref(null)
async function onReload() {
running.value = true
try {
report.value = await api.reloadTools()
if (report.value.ok) {
toast.success({
title: t('toast.toolsReloaded', { n: report.value.tools.length }),
})
} else {
toast.error({ title: t('toast.toolsReloadErrors') })
}
} catch (err) {
toast.error({ title: t('toast.toolsReloadFailed'), text: err.message })
} finally {
running.value = false
}
}
</script>
<style scoped lang="scss">
@use 'kit-deps' as *;
.admin-tools-panel {
margin-bottom: 24px;
}
.admin-tools-header {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
margin-bottom: 12px;
}
.admin-tools-title {
font-size: 1.1rem;
font-weight: 600;
margin: 0;
color: var(--gn-color-text-medium);
}
.admin-tools-description {
margin: 0 0 16px;
font-size: 0.875rem;
color: var(--gn-color-text-medium);
code {
font-size: 0.8rem;
}
}
.admin-tools-report {
display: flex;
flex-direction: column;
gap: 6px;
padding: 12px;
border: 1px solid var(--gn-color-border);
border-radius: var(--gn-radius-md);
font-size: 0.85rem;
color: var(--gn-color-text-medium);
&.has-problems {
border-color: var(--gn-color-danger, var(--gn-color-border));
}
}
.admin-tools-line {
display: flex;
align-items: flex-start;
gap: 8px;
i {
flex-shrink: 0;
margin-top: 2px;
}
&.is-warning i {
color: var(--gn-color-warning, inherit);
}
&.is-error i {
color: var(--gn-color-danger, inherit);
}
code {
font-size: 0.8rem;
}
}
.admin-tools-total {
color: var(--gn-color-text-dimmed);
}
</style>