From 20e9834e66771acf43d4e1c663e520de7c04783d Mon Sep 17 00:00:00 2001 From: rikimaru0345 Date: Thu, 4 Jul 2024 15:26:08 +0200 Subject: [PATCH] frontend: use "console" api instead of "dataplane" api for wasm transforms --- frontend/src/components/RequireAuth.tsx | 3 +++ frontend/src/config.ts | 2 +- frontend/src/state/backendApi.ts | 22 ++++++++++++++++------ frontend/src/state/restInterfaces.ts | 4 ++++ 4 files changed, 24 insertions(+), 7 deletions(-) diff --git a/frontend/src/components/RequireAuth.tsx b/frontend/src/components/RequireAuth.tsx index bc4cdfe7c..34c91cd6c 100644 --- a/frontend/src/components/RequireAuth.tsx +++ b/frontend/src/components/RequireAuth.tsx @@ -72,6 +72,9 @@ export default class RequireAuth extends Component<{children: ReactNode}> { canDeleteSchemas: true, canManageSchemaRegistry: true, canViewSchemas: true, + canListTransforms: true, + canCreateTransforms: true, + canDeleteTransforms: true, seat: null as any, user: { providerID: -1, providerName: 'debug provider', id: 'debug', internalIdentifier: 'debug', meta: { avatarUrl: '', email: '', name: 'local fake user for debugging' } } }; diff --git a/frontend/src/config.ts b/frontend/src/config.ts index d5f9a3b3c..496e56c0a 100644 --- a/frontend/src/config.ts +++ b/frontend/src/config.ts @@ -21,7 +21,7 @@ import { createConnectTransport } from '@connectrpc/connect-web'; import { ConsoleService } from './protogen/redpanda/api/console/v1alpha1/console_service_connect'; import { SecurityService } from './protogen/redpanda/api/console/v1alpha1/security_connect'; import { RedpandaConnectService } from './protogen/redpanda/api/console/v1alpha1/rp_connect_connect'; -import { TransformService } from './protogen/redpanda/api/dataplane/v1alpha1/transform_connect'; +import { TransformService } from './protogen/redpanda/api/console/v1alpha1/transform_connect'; declare const __webpack_public_path__: string; diff --git a/frontend/src/state/backendApi.ts b/frontend/src/state/backendApi.ts index c6b734983..88a155a0b 100644 --- a/frontend/src/state/backendApi.ts +++ b/frontend/src/state/backendApi.ts @@ -366,6 +366,9 @@ const apiStore = { canDeleteSchemas: true, canManageSchemaRegistry: true, canViewSchemas: true, + canListTransforms: true, + canCreateTransforms: true, + canDeleteTransforms: true, seat: null as any, user: { providerID: -1, providerName: 'debug provider', id: 'debug', internalIdentifier: 'debug', meta: { avatarUrl: '', email: '', name: 'local fake user for debugging' } } }; @@ -1697,13 +1700,16 @@ export const transformsApi = observable({ const transforms: TransformMetadata[] = []; let nextPageToken = ''; while (true) { - const res = await client.listTransforms({ pageSize: 500, pageToken: nextPageToken }); + const res = await client.listTransforms({ request: { pageSize: 500, pageToken: nextPageToken } }); + const r = res.response; + if (!r) + break; - transforms.push(...res.transforms); + transforms.push(...r.transforms); - if (!res.nextPageToken || res.nextPageToken.length == 0) + if (!r.nextPageToken || r.nextPageToken.length == 0) break; - nextPageToken = res.nextPageToken; + nextPageToken = r.nextPageToken; } runInAction(() => { @@ -1718,7 +1724,11 @@ export const transformsApi = observable({ const client = appConfig.transformsClient; if (!client) throw new Error('transforms client is not initialized'); - const r = await client.getTransform({ name }); + const res = await client.getTransform({ request: { name } }); + const r = res.response; + if (!r) + throw new Error('got empty response from getTransform'); + if (!r.transform) return; this.transformDetails.set(r.transform.name, r.transform); @@ -1728,7 +1738,7 @@ export const transformsApi = observable({ const client = appConfig.transformsClient; if (!client) throw new Error('transforms client is not initialized'); - await client.deleteTransform({ name }); + await client.deleteTransform({ request: { name } }); }, }); diff --git a/frontend/src/state/restInterfaces.ts b/frontend/src/state/restInterfaces.ts index 4ba9cab36..7ccc3e7be 100644 --- a/frontend/src/state/restInterfaces.ts +++ b/frontend/src/state/restInterfaces.ts @@ -526,6 +526,10 @@ export interface UserData { canCreateSchemas: boolean; canDeleteSchemas: boolean; canManageSchemaRegistry: boolean; + + canListTransforms: boolean; + canCreateTransforms: boolean; + canDeleteTransforms: boolean; } export type UserPermissions = Exclude;