Open-source LLM knowledge platform: turn raw documents into a queryable RAG, an autonomous reasoning agent, and a self-maintaining Wiki.
Go agentagenticaichatbotdsh-pluginembeddingsevaluationgenerative-aigolangknowledge-basellmmulti-tenantollamaopenaiquestion-answeringragrerankingsemantic-searchvector-searchwiki
fix(frontend): hide API integration tab for non-owner tenants
wizardchenf8accb261022
diff --git a/frontend/src/components/menu.vue b/frontend/src/components/menu.vueindex 1f35a33e2..ababf30c7 100644--- a/frontend/src/components/menu.vue+++ b/frontend/src/components/menu.vue@@ -257,10 +257,17 @@ import UserMenu from '@/components/UserMenu.vue';import TenantSelector from '@/components/TenantSelector.vue';import { useI18n } from 'vue-i18n';import { getSystemInfo } from '@/api/system';-import { INTEGRATION_PREVIEW_ITEMS } from '@/config/integrations';+import { INTEGRATION_PREVIEW_ITEMS, INTEGRATION_TAB_MIN_ROLE } from '@/config/integrations';const chatResources = useChatResourcesStore();-const integrationPreviewItems = INTEGRATION_PREVIEW_ITEMS;+const integrationPreviewItems = computed(() =>+ INTEGRATION_PREVIEW_ITEMS.filter((item) => {+ const min = INTEGRATION_TAB_MIN_ROLE[item.key];+ if (!min) return true;+ if (authStore.canAccessAllTenants) return true;+ return authStore.hasRole(min);+ }),+);// Platform logos reused from IMChannelsOverviewPanel — keeps the session list// visually consistent with the channels admin view.import wecomLogo from '@/assets/img/im/wecom.svg';diff --git a/frontend/src/config/integrations.ts b/frontend/src/config/integrations.tsindex c9bb2b558..70d06e172 100644--- a/frontend/src/config/integrations.ts+++ b/frontend/src/config/integrations.ts@@ -7,6 +7,13 @@ export type IntegrationTab = 'im' | 'embed' | 'api' | 'chrome' | 'claw'export const INTEGRATION_TABS: IntegrationTab[] = ['im', 'embed', 'api', 'chrome', 'claw']+/** Aligns with Settings.vue SECTION_MIN_ROLE.api and router.go g.Owner() on /api-principal-config. */+export type IntegrationTabRole = 'viewer' | 'contributor' | 'admin' | 'owner'++export const INTEGRATION_TAB_MIN_ROLE: Partial<Record<IntegrationTab, IntegrationTabRole>> = {+ api: 'owner',+}+export type IntegrationPreviewIcon =| { type: 'icon'; name: string }| { type: 'emoji'; value: string }diff --git a/frontend/src/views/integrations/IntegrationsModal.vue b/frontend/src/views/integrations/IntegrationsModal.vueindex 5c2d55df8..27502a41f 100644--- a/frontend/src/views/integrations/IntegrationsModal.vue+++ b/frontend/src/views/integrations/IntegrationsModal.vue@@ -84,11 +84,18 @@ import AgentEmbedChannelPanel from '@/components/AgentEmbedChannelPanel.vue';import ApiIntegrationSettings from '@/views/integrations/ApiIntegrationSettings.vue';import ChromeExtensionLanding from '@/views/integrations/ChromeExtensionLanding.vue';import ClawSkillLanding from '@/views/integrations/ClawSkillLanding.vue';-import { INTEGRATION_PREVIEW_ITEMS, INTEGRATION_TABS, type IntegrationTab } from '@/config/integrations';+import {+ INTEGRATION_PREVIEW_ITEMS,+ INTEGRATION_TAB_MIN_ROLE,+ INTEGRATION_TABS,+ type IntegrationTab,+} from '@/config/integrations';+import { useAuthStore } from '@/stores/auth';const { t } = useI18n();const route = useRoute();const router = useRouter();+const authStore = useAuthStore();const currentSection = ref<IntegrationTab>('im');const filterAgentId = ref('');@@ -99,19 +106,34 @@ const isLandingSection = computed(() => currentSection.value === 'chrome' || currentSection.value === 'claw',);+function canSeeTab(tab: IntegrationTab): boolean {+ const min = INTEGRATION_TAB_MIN_ROLE[tab];+ if (!min) return true;+ if (authStore.canAccessAllTenants) return true;+ return authStore.hasRole(min);+}+const navItems = computed(() =>- INTEGRATION_PREVIEW_ITEMS.map((item) => ({- key: item.key,- icon: item.icon.type === 'icon' ? item.icon.name : '',- emoji: item.icon.type === 'emoji' ? item.icon.value : undefined,- label: t(`integrations.tabs.${item.key}`),- })),+ INTEGRATION_PREVIEW_ITEMS+ .filter((item) => canSeeTab(item.key))+ .map((item) => ({+ key: item.key,+ icon: item.icon.type === 'icon' ? item.icon.name : '',+ emoji: item.icon.type === 'emoji' ? item.icon.value : undefined,+ label: t(`integrations.tabs.${item.key}`),+ })),);function applyRouteQuery() {const tab = route.query.tab as string;- if (INTEGRATION_TABS.includes(tab as IntegrationTab)) {+ if (INTEGRATION_TABS.includes(tab as IntegrationTab) && canSeeTab(tab as IntegrationTab)) {currentSection.value = tab as IntegrationTab;+ } else if (INTEGRATION_TABS.includes(tab as IntegrationTab)) {+ currentSection.value = navItems.value[0]?.key ?? 'im';+ if (visible.value) syncRouteQuery();+ } else if (navItems.value.length > 0 && !canSeeTab(currentSection.value)) {+ currentSection.value = navItems.value[0].key;+ if (visible.value) syncRouteQuery();}filterAgentId.value = (route.query.agentId as string) || '';}