Skip to content

Commit 0e13f36

Browse files
author
Lasim
committed
feat(frontend): add ConfigurationHeaders and ConfigurationQueryParams components for managing installation headers and query parameters
- Implemented ConfigurationHeaders.vue to allow team admins to manage team and user headers. - Implemented ConfigurationQueryParams.vue for managing team and user query parameters. - Updated index.ts to export new components. - Enhanced config.vue to integrate new configuration components and handle updates.
1 parent 110d52d commit 0e13f36

File tree

13 files changed

+1879
-1603
lines changed

13 files changed

+1879
-1603
lines changed
Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
<script setup lang="ts">
2+
import { ref, computed, onMounted } from 'vue'
3+
import { McpCatalogService } from '@/services/mcpCatalogService'
4+
import { McpInstallationService } from '@/services/mcpInstallationService'
5+
import { Spinner } from '@/components/ui/spinner'
6+
import {
7+
ConfigurationArgs,
8+
ConfigurationEnv,
9+
ConfigurationHeaders,
10+
ConfigurationQueryParams
11+
} from './config'
12+
import type { McpInstallation, UserConfiguration } from '@/types/mcp-installations'
13+
14+
interface Props {
15+
installation: McpInstallation
16+
teamId: string
17+
canEdit?: boolean
18+
userRole?: 'team_admin' | 'team_user' | null
19+
}
20+
21+
const props = withDefaults(defineProps<Props>(), {
22+
canEdit: true,
23+
userRole: null
24+
})
25+
26+
const emit = defineEmits<{
27+
'installation-updated': [installation: McpInstallation]
28+
'configuration-updated': [config: UserConfiguration]
29+
}>()
30+
31+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
32+
const serverData = ref<any>(null)
33+
const isLoadingServer = ref(true)
34+
const userConfigurations = ref<UserConfiguration[]>([])
35+
const currentUserConfig = ref<UserConfiguration | null>(null)
36+
const isLoadingUserConfig = ref(true)
37+
38+
const isTeamAdmin = computed(() => props.userRole === 'team_admin')
39+
40+
const isStdio = computed(() => {
41+
const transport = props.installation.server?.transport_type || serverData.value?.transport_type
42+
return transport === 'stdio'
43+
})
44+
45+
const isRemote = computed(() => {
46+
const transport = props.installation.server?.transport_type || serverData.value?.transport_type
47+
return transport === 'http' || transport === 'sse'
48+
})
49+
50+
onMounted(async () => {
51+
try {
52+
isLoadingServer.value = true
53+
isLoadingUserConfig.value = true
54+
55+
if (props.installation.server_id) {
56+
serverData.value = await McpCatalogService.getServerById(props.installation.server_id)
57+
}
58+
59+
await loadUserConfigurations()
60+
} catch (error) {
61+
console.error('Error loading data:', error)
62+
} finally {
63+
isLoadingServer.value = false
64+
isLoadingUserConfig.value = false
65+
}
66+
})
67+
68+
const loadUserConfigurations = async () => {
69+
try {
70+
const configs: UserConfiguration[] = await McpInstallationService.getUserConfigurations(
71+
props.teamId,
72+
props.installation.id
73+
)
74+
userConfigurations.value = configs
75+
76+
if (configs.length > 0 && configs[0]) {
77+
currentUserConfig.value = configs[0]
78+
} else {
79+
currentUserConfig.value = null
80+
}
81+
} catch (error) {
82+
console.error('Error loading user configurations:', error)
83+
userConfigurations.value = []
84+
currentUserConfig.value = null
85+
}
86+
}
87+
88+
const handleInstallationUpdated = (updatedInstallation: McpInstallation) => {
89+
emit('installation-updated', updatedInstallation)
90+
}
91+
92+
const handleConfigurationUpdated = async (config: UserConfiguration) => {
93+
await loadUserConfigurations()
94+
emit('configuration-updated', config)
95+
}
96+
</script>
97+
98+
<template>
99+
<div v-if="isLoadingServer || isLoadingUserConfig" class="flex items-center justify-center py-12">
100+
<Spinner class="h-8 w-8" />
101+
</div>
102+
103+
<div v-else class="space-y-0">
104+
<!-- STDIO TRANSPORT: Arguments + Environment Variables -->
105+
<ConfigurationArgs
106+
v-if="isStdio"
107+
:installation="installation"
108+
:server-data="serverData"
109+
:current-user-config="currentUserConfig"
110+
:team-id="teamId"
111+
:can-edit="canEdit"
112+
:is-team-admin="isTeamAdmin"
113+
@installation-updated="handleInstallationUpdated"
114+
@configuration-updated="handleConfigurationUpdated"
115+
/>
116+
117+
<ConfigurationEnv
118+
v-if="isStdio"
119+
:installation="installation"
120+
:server-data="serverData"
121+
:current-user-config="currentUserConfig"
122+
:team-id="teamId"
123+
:can-edit="canEdit"
124+
:is-team-admin="isTeamAdmin"
125+
@installation-updated="handleInstallationUpdated"
126+
@configuration-updated="handleConfigurationUpdated"
127+
/>
128+
129+
<!-- HTTP/SSE TRANSPORT: Headers + URL Query Parameters -->
130+
<ConfigurationHeaders
131+
v-if="isRemote"
132+
:installation="installation"
133+
:server-data="serverData"
134+
:current-user-config="currentUserConfig"
135+
:team-id="teamId"
136+
:can-edit="canEdit"
137+
:is-team-admin="isTeamAdmin"
138+
@installation-updated="handleInstallationUpdated"
139+
@configuration-updated="handleConfigurationUpdated"
140+
/>
141+
142+
<ConfigurationQueryParams
143+
v-if="isRemote"
144+
:installation="installation"
145+
:server-data="serverData"
146+
:current-user-config="currentUserConfig"
147+
:team-id="teamId"
148+
:can-edit="canEdit"
149+
:is-team-admin="isTeamAdmin"
150+
@installation-updated="handleInstallationUpdated"
151+
@configuration-updated="handleConfigurationUpdated"
152+
/>
153+
</div>
154+
</template>

services/frontend/src/components/mcp-server/installation/InstallationTabs.vue

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,29 +15,21 @@ const route = useRoute()
1515
const router = useRouter()
1616
const { t } = useI18n()
1717
18-
// Get environment variables count for badge
19-
const environmentVariablesCount = computed(() => {
20-
if (!props.installation?.user_environment_variables) return 0
21-
return Object.keys(props.installation.user_environment_variables).length
22-
})
23-
2418
// Map route names to tab values
2519
const routeToTabMap: Record<string, string> = {
2620
'McpServerInstallationGeneral': 'general',
2721
'McpServerInstallationTools': 'tools',
28-
'McpServerInstallationUserConfig': 'user-config',
29-
'McpServerInstallationTeamConfig': 'team-config',
3022
'McpServerInstallationRequests': 'requests',
23+
'McpServerInstallationConfig': 'config',
3124
'McpServerInstallationDangerZone': 'danger-zone',
3225
}
3326
3427
// Map tab values to route names
3528
const tabToRouteMap: Record<string, string> = {
3629
'general': 'McpServerInstallationGeneral',
3730
'tools': 'McpServerInstallationTools',
38-
'user-config': 'McpServerInstallationUserConfig',
39-
'team-config': 'McpServerInstallationTeamConfig',
4031
'requests': 'McpServerInstallationRequests',
32+
'config': 'McpServerInstallationConfig',
4133
'danger-zone': 'McpServerInstallationDangerZone',
4234
}
4335
@@ -61,12 +53,7 @@ const activeTab = computed({
6153
<DsTabsItem value="general" label="General" />
6254
<DsTabsItem value="tools" :label="t('mcpInstallations.details.tools.title')" />
6355
<DsTabsItem value="requests" label="Requests" />
64-
<DsTabsItem value="user-config" label="User Configuration" />
65-
<DsTabsItem
66-
value="team-config"
67-
label="Team Configuration"
68-
:badge="environmentVariablesCount > 0 ? environmentVariablesCount : undefined"
69-
/>
56+
<DsTabsItem value="config" label="Configuration" />
7057
<DsTabsItem value="danger-zone" label="Danger Zone" />
7158
</DsTabs>
7259
</template>

0 commit comments

Comments
 (0)