Skip to content

Commit d8a17b7

Browse files
author
Serge Pavlyuk
committed
Wizard update and create
1 parent d6a4680 commit d8a17b7

File tree

3 files changed

+51
-7
lines changed

3 files changed

+51
-7
lines changed

src/server/components/charts-engine/components/storage/united-storage/provider.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ export type ProviderCreateParams = {
216216
recursion?: boolean;
217217
meta?: Record<string, string>;
218218
includePermissionsInfo?: boolean | string;
219-
workbookId: string;
219+
workbookId: string | null;
220220
name: string;
221221
mode?: EntryUpdateMode;
222222
};
@@ -360,7 +360,7 @@ export class USProvider {
360360
) {
361361
const result = await USProvider.retrieveById(ctx, props);
362362

363-
result.data.shared = mapChartsConfigToLatestVersion(JSON.parse(result.data.shared));
363+
result.data = mapChartsConfigToLatestVersion(JSON.parse(result.data.shared));
364364

365365
return result;
366366
}

src/server/controllers/public-api.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,14 @@ const proxyMap: PublicApiRpcMap = {
5959
},
6060
},
6161
updateWizardChart: {
62-
resolve: (api) => api.bi.updateDataset,
62+
resolve: (api) => api.mix.updateWizardChartApi,
6363
openApi: {
6464
summary: 'Delete wizard chart',
6565
tags: ['wizard'],
6666
},
6767
},
6868
createWizardChart: {
69-
resolve: (api) => api.bi.createDataset,
69+
resolve: (api) => api.mix.createWizardChartApi,
7070
openApi: {
7171
summary: 'Create wizard chart',
7272
tags: ['wizard'],

src/shared/schema/mix/actions/wizard.ts

Lines changed: 47 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@ import {createTypedAction} from '../../gateway-utils';
77
import {getTypedApi} from '../../simple-schema';
88

99
const wizardUsSchema = z.object({
10-
data: z.object({
11-
shared: v12ChartsConfigSchema,
12-
}),
10+
data: v12ChartsConfigSchema,
1311
entryId: z.string(),
1412
scope: z.literal(EntryScope.Widget),
1513
type: z.enum(WizardType),
@@ -52,6 +50,52 @@ export const wizardActions = {
5250

5351
return result as any;
5452
}),
53+
createWizardChartApi: createTypedAction({
54+
argsSchema: z.object({
55+
entryId: z.string(),
56+
data: v12ChartsConfigSchema,
57+
key: z.string(),
58+
workbookId: z.union([z.string(), z.null()]).optional(),
59+
type: z.enum(WizardType).optional(),
60+
name: z.string(),
61+
}),
62+
bodySchema: wizardUsSchema,
63+
}).withValidationSchema(async (_, args, {ctx, headers}) => {
64+
const {data, type, key, workbookId, name} = args;
65+
66+
const result = await USProvider.create(ctx, {
67+
type,
68+
data,
69+
key,
70+
name,
71+
scope: EntryScope.Widget,
72+
...(workbookId ? {workbookId} : {workbookId: null}),
73+
headers,
74+
});
75+
76+
return result as any;
77+
}),
78+
updateWizardChartApi: createTypedAction({
79+
argsSchema: z.object({
80+
entryId: z.string(),
81+
revId: z.string().optional(),
82+
data: v12ChartsConfigSchema,
83+
type: z.enum(WizardType).optional(),
84+
}),
85+
bodySchema: wizardUsSchema,
86+
}).withValidationSchema(async (_, args, {ctx, headers}) => {
87+
const {entryId, revId, data, type} = args;
88+
89+
const result = await USProvider.update(ctx, {
90+
entryId,
91+
...(revId ? {revId} : {}),
92+
...(type ? {type} : {}),
93+
data,
94+
headers,
95+
});
96+
97+
return result as any;
98+
}),
5599
deleteWizardChartApi: createTypedAction({
56100
argsSchema: z.object({
57101
chartId: z.string(),

0 commit comments

Comments
 (0)