Skip to content

Commit 6baf15c

Browse files
feat: shareable workspaces MVP (frontend) (#379)
* fix: handle breaking changes to "workspaces by provider" endpoint * feat: shareable workspaces mvp * fix integration bugs * fix cache invalidation bugs * Merge branch 'main' of github.com:stacklok/codegate-ui into feat/shareable-workspaces * fix: cache invalidation bug when updating mux config --------- Co-authored-by: Luke Hinds <[email protected]>
1 parent a46703b commit 6baf15c

31 files changed

+505
-284
lines changed

src/Page.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export default function Page() {
2929
<Route path="providers">
3030
<Route index element={<RouteProvider />} />
3131
<Route element={<RouteProvider />}>
32-
<Route path=":id" element={<RouteProviderUpdate />} />
32+
<Route path=":name" element={<RouteProviderUpdate />} />
3333
<Route path="new" element={<RouteProviderCreate />} />
3434
</Route>
3535
</Route>

src/api/generated/@tanstack/react-query.gen.ts

+30-27
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import {
2424
v1ActivateWorkspace,
2525
v1UpdateWorkspace,
2626
v1DeleteWorkspace,
27+
v1GetWorkspaceByName,
2728
v1ListArchivedWorkspaces,
2829
v1RecoverWorkspace,
2930
v1HardDeleteWorkspace,
@@ -36,7 +37,6 @@ import {
3637
v1DeleteWorkspaceCustomInstructions,
3738
v1GetWorkspaceMuxes,
3839
v1SetWorkspaceMuxes,
39-
v1ListWorkspacesByProvider,
4040
v1StreamSse,
4141
v1VersionCheck,
4242
v1GetWorkspaceTokenUsage,
@@ -62,6 +62,7 @@ import type {
6262
V1ConfigureAuthMaterialData,
6363
V1ConfigureAuthMaterialError,
6464
V1ConfigureAuthMaterialResponse,
65+
V1ListWorkspacesData,
6566
V1CreateWorkspaceData,
6667
V1CreateWorkspaceError,
6768
V1CreateWorkspaceResponse,
@@ -74,6 +75,7 @@ import type {
7475
V1DeleteWorkspaceData,
7576
V1DeleteWorkspaceError,
7677
V1DeleteWorkspaceResponse,
78+
V1GetWorkspaceByNameData,
7779
V1RecoverWorkspaceData,
7880
V1RecoverWorkspaceError,
7981
V1RecoverWorkspaceResponse,
@@ -97,7 +99,6 @@ import type {
9799
V1SetWorkspaceMuxesData,
98100
V1SetWorkspaceMuxesError,
99101
V1SetWorkspaceMuxesResponse,
100-
V1ListWorkspacesByProviderData,
101102
V1GetWorkspaceTokenUsageData,
102103
V1CreatePersonaData,
103104
V1CreatePersonaError,
@@ -349,11 +350,13 @@ export const v1ConfigureAuthMaterialMutation = (
349350
return mutationOptions
350351
}
351352

352-
export const v1ListWorkspacesQueryKey = (options?: OptionsLegacyParser) => [
353-
createQueryKey('v1ListWorkspaces', options),
354-
]
353+
export const v1ListWorkspacesQueryKey = (
354+
options?: OptionsLegacyParser<V1ListWorkspacesData>
355+
) => [createQueryKey('v1ListWorkspaces', options)]
355356

356-
export const v1ListWorkspacesOptions = (options?: OptionsLegacyParser) => {
357+
export const v1ListWorkspacesOptions = (
358+
options?: OptionsLegacyParser<V1ListWorkspacesData>
359+
) => {
357360
return queryOptions({
358361
queryFn: async ({ queryKey, signal }) => {
359362
const { data } = await v1ListWorkspaces({
@@ -511,6 +514,27 @@ export const v1DeleteWorkspaceMutation = (
511514
return mutationOptions
512515
}
513516

517+
export const v1GetWorkspaceByNameQueryKey = (
518+
options: OptionsLegacyParser<V1GetWorkspaceByNameData>
519+
) => [createQueryKey('v1GetWorkspaceByName', options)]
520+
521+
export const v1GetWorkspaceByNameOptions = (
522+
options: OptionsLegacyParser<V1GetWorkspaceByNameData>
523+
) => {
524+
return queryOptions({
525+
queryFn: async ({ queryKey, signal }) => {
526+
const { data } = await v1GetWorkspaceByName({
527+
...options,
528+
...queryKey[0],
529+
signal,
530+
throwOnError: true,
531+
})
532+
return data
533+
},
534+
queryKey: v1GetWorkspaceByNameQueryKey(options),
535+
})
536+
}
537+
514538
export const v1ListArchivedWorkspacesQueryKey = (
515539
options?: OptionsLegacyParser
516540
) => [createQueryKey('v1ListArchivedWorkspaces', options)]
@@ -867,27 +891,6 @@ export const v1SetWorkspaceMuxesMutation = (
867891
return mutationOptions
868892
}
869893

870-
export const v1ListWorkspacesByProviderQueryKey = (
871-
options: OptionsLegacyParser<V1ListWorkspacesByProviderData>
872-
) => [createQueryKey('v1ListWorkspacesByProvider', options)]
873-
874-
export const v1ListWorkspacesByProviderOptions = (
875-
options: OptionsLegacyParser<V1ListWorkspacesByProviderData>
876-
) => {
877-
return queryOptions({
878-
queryFn: async ({ queryKey, signal }) => {
879-
const { data } = await v1ListWorkspacesByProvider({
880-
...options,
881-
...queryKey[0],
882-
signal,
883-
throwOnError: true,
884-
})
885-
return data
886-
},
887-
queryKey: v1ListWorkspacesByProviderQueryKey(options),
888-
})
889-
}
890-
891894
export const v1StreamSseQueryKey = (options?: OptionsLegacyParser) => [
892895
createQueryKey('v1StreamSse', options),
893896
]

src/api/generated/sdk.gen.ts

+38-31
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import type {
3131
V1ConfigureAuthMaterialData,
3232
V1ConfigureAuthMaterialError,
3333
V1ConfigureAuthMaterialResponse,
34+
V1ListWorkspacesData,
3435
V1ListWorkspacesError,
3536
V1ListWorkspacesResponse,
3637
V1CreateWorkspaceData,
@@ -47,6 +48,9 @@ import type {
4748
V1DeleteWorkspaceData,
4849
V1DeleteWorkspaceError,
4950
V1DeleteWorkspaceResponse,
51+
V1GetWorkspaceByNameData,
52+
V1GetWorkspaceByNameError,
53+
V1GetWorkspaceByNameResponse,
5054
V1ListArchivedWorkspacesError,
5155
V1ListArchivedWorkspacesResponse,
5256
V1RecoverWorkspaceData,
@@ -82,9 +86,6 @@ import type {
8286
V1SetWorkspaceMuxesData,
8387
V1SetWorkspaceMuxesError,
8488
V1SetWorkspaceMuxesResponse,
85-
V1ListWorkspacesByProviderData,
86-
V1ListWorkspacesByProviderError,
87-
V1ListWorkspacesByProviderResponse,
8889
V1StreamSseError,
8990
V1StreamSseResponse,
9091
V1VersionCheckError,
@@ -192,13 +193,13 @@ export const v1ListModelsByProvider = <ThrowOnError extends boolean = false>(
192193
ThrowOnError
193194
>({
194195
...options,
195-
url: '/api/v1/provider-endpoints/{provider_id}/models',
196+
url: '/api/v1/provider-endpoints/{provider_name}/models',
196197
})
197198
}
198199

199200
/**
200201
* Get Provider Endpoint
201-
* Get a provider endpoint by ID.
202+
* Get a provider endpoint by name.
202203
*/
203204
export const v1GetProviderEndpoint = <ThrowOnError extends boolean = false>(
204205
options: OptionsLegacyParser<V1GetProviderEndpointData, ThrowOnError>
@@ -209,13 +210,13 @@ export const v1GetProviderEndpoint = <ThrowOnError extends boolean = false>(
209210
ThrowOnError
210211
>({
211212
...options,
212-
url: '/api/v1/provider-endpoints/{provider_id}',
213+
url: '/api/v1/provider-endpoints/{provider_name}',
213214
})
214215
}
215216

216217
/**
217218
* Update Provider Endpoint
218-
* Update a provider endpoint by ID.
219+
* Update a provider endpoint by name.
219220
*/
220221
export const v1UpdateProviderEndpoint = <ThrowOnError extends boolean = false>(
221222
options: OptionsLegacyParser<V1UpdateProviderEndpointData, ThrowOnError>
@@ -226,13 +227,13 @@ export const v1UpdateProviderEndpoint = <ThrowOnError extends boolean = false>(
226227
ThrowOnError
227228
>({
228229
...options,
229-
url: '/api/v1/provider-endpoints/{provider_id}',
230+
url: '/api/v1/provider-endpoints/{provider_name}',
230231
})
231232
}
232233

233234
/**
234235
* Delete Provider Endpoint
235-
* Delete a provider endpoint by id.
236+
* Delete a provider endpoint by name.
236237
*/
237238
export const v1DeleteProviderEndpoint = <ThrowOnError extends boolean = false>(
238239
options: OptionsLegacyParser<V1DeleteProviderEndpointData, ThrowOnError>
@@ -243,7 +244,7 @@ export const v1DeleteProviderEndpoint = <ThrowOnError extends boolean = false>(
243244
ThrowOnError
244245
>({
245246
...options,
246-
url: '/api/v1/provider-endpoints/{provider_id}',
247+
url: '/api/v1/provider-endpoints/{provider_name}',
247248
})
248249
}
249250

@@ -260,16 +261,24 @@ export const v1ConfigureAuthMaterial = <ThrowOnError extends boolean = false>(
260261
ThrowOnError
261262
>({
262263
...options,
263-
url: '/api/v1/provider-endpoints/{provider_id}/auth-material',
264+
url: '/api/v1/provider-endpoints/{provider_name}/auth-material',
264265
})
265266
}
266267

267268
/**
268269
* List Workspaces
269270
* List all workspaces.
271+
*
272+
* Args:
273+
* provider_name (Optional[str]): Filter workspaces by provider name. If provided,
274+
* will return workspaces where models from the specified provider (e.g., OpenAI,
275+
* Anthropic) have been used in workspace muxing rules.
276+
*
277+
* Returns:
278+
* ListWorkspacesResponse: A response object containing the list of workspaces.
270279
*/
271280
export const v1ListWorkspaces = <ThrowOnError extends boolean = false>(
272-
options?: OptionsLegacyParser<unknown, ThrowOnError>
281+
options?: OptionsLegacyParser<V1ListWorkspacesData, ThrowOnError>
273282
) => {
274283
return (options?.client ?? client).get<
275284
V1ListWorkspacesResponse,
@@ -369,6 +378,23 @@ export const v1DeleteWorkspace = <ThrowOnError extends boolean = false>(
369378
})
370379
}
371380

381+
/**
382+
* Get Workspace By Name
383+
* List workspaces by provider ID.
384+
*/
385+
export const v1GetWorkspaceByName = <ThrowOnError extends boolean = false>(
386+
options: OptionsLegacyParser<V1GetWorkspaceByNameData, ThrowOnError>
387+
) => {
388+
return (options?.client ?? client).get<
389+
V1GetWorkspaceByNameResponse,
390+
V1GetWorkspaceByNameError,
391+
ThrowOnError
392+
>({
393+
...options,
394+
url: '/api/v1/workspaces/{workspace_name}',
395+
})
396+
}
397+
372398
/**
373399
* List Archived Workspaces
374400
* List all archived workspaces.
@@ -591,25 +617,6 @@ export const v1SetWorkspaceMuxes = <ThrowOnError extends boolean = false>(
591617
})
592618
}
593619

594-
/**
595-
* List Workspaces By Provider
596-
* List workspaces by provider ID.
597-
*/
598-
export const v1ListWorkspacesByProvider = <
599-
ThrowOnError extends boolean = false,
600-
>(
601-
options: OptionsLegacyParser<V1ListWorkspacesByProviderData, ThrowOnError>
602-
) => {
603-
return (options?.client ?? client).get<
604-
V1ListWorkspacesByProviderResponse,
605-
V1ListWorkspacesByProviderError,
606-
ThrowOnError
607-
>({
608-
...options,
609-
url: '/api/v1/workspaces/{provider_id}',
610-
})
611-
}
612-
613620
/**
614621
* Stream Sse
615622
* Send alerts event

0 commit comments

Comments
 (0)