From 1b5c36eab129681d70e373102456ebaebc975bdf Mon Sep 17 00:00:00 2001 From: Irina Kuzmina Date: Wed, 11 Dec 2024 10:06:24 +0300 Subject: [PATCH] Fix the serialization of the array in the ui-sandbox --- package-lock.json | 8 ++++---- package.json | 2 +- .../components/Widgets/Chart/components/Content.tsx | 2 +- .../modules/data-provider/charts/ui-sandbox.ts | 11 +++++++++-- 4 files changed, 15 insertions(+), 8 deletions(-) diff --git a/package-lock.json b/package-lock.json index 0e797d3f02..9a65927cae 100644 --- a/package-lock.json +++ b/package-lock.json @@ -65,7 +65,7 @@ "workerpool": "^9.1.1" }, "devDependencies": { - "@datalens-tech/ui-sandbox-modules": "^0.32.0", + "@datalens-tech/ui-sandbox-modules": "^0.33.0", "@gravity-ui/app-builder": "^0.13.1", "@gravity-ui/components": "^3.12.5", "@gravity-ui/date-components": "^2.11.0", @@ -4204,9 +4204,9 @@ } }, "node_modules/@datalens-tech/ui-sandbox-modules": { - "version": "0.32.0", - "resolved": "https://registry.npmjs.org/@datalens-tech/ui-sandbox-modules/-/ui-sandbox-modules-0.32.0.tgz", - "integrity": "sha512-syrgdOOFkJsMKLjjJSYqEYtZ9nrn5K8iJaa7NcWA1U5QAPDIosNkCAfKckc5iB4B28LYudH5CXxhNszGzXHHTw==", + "version": "0.33.0", + "resolved": "https://registry.npmjs.org/@datalens-tech/ui-sandbox-modules/-/ui-sandbox-modules-0.33.0.tgz", + "integrity": "sha512-gxj35QhnwGY//rcAm4XrackbTcQu5Qqf2YD4FRH1zkLX5jgc0018biTZhfepR9jwc0zQ7DF5sIR0CsGiYVuphQ==", "dev": true }, "node_modules/@datalens-tech/xlsx": { diff --git a/package.json b/package.json index c1c0c23d55..86d6860db2 100644 --- a/package.json +++ b/package.json @@ -109,7 +109,7 @@ "workerpool": "^9.1.1" }, "devDependencies": { - "@datalens-tech/ui-sandbox-modules": "^0.32.0", + "@datalens-tech/ui-sandbox-modules": "^0.33.0", "@gravity-ui/app-builder": "^0.13.1", "@gravity-ui/components": "^3.12.5", "@gravity-ui/date-components": "^2.11.0", diff --git a/src/ui/components/Widgets/Chart/components/Content.tsx b/src/ui/components/Widgets/Chart/components/Content.tsx index f47f88c452..9001dbba71 100644 --- a/src/ui/components/Widgets/Chart/components/Content.tsx +++ b/src/ui/components/Widgets/Chart/components/Content.tsx @@ -126,7 +126,7 @@ export const Content = (props: ChartContentProps) => { ); break; } - case 'setPatams': { + case 'setParams': { if (onChange) { onChange( {type: 'PARAMS_CHANGED', data: {params: args}}, diff --git a/src/ui/libs/DatalensChartkit/modules/data-provider/charts/ui-sandbox.ts b/src/ui/libs/DatalensChartkit/modules/data-provider/charts/ui-sandbox.ts index 2ca3e4abdd..0f37b50f89 100644 --- a/src/ui/libs/DatalensChartkit/modules/data-provider/charts/ui-sandbox.ts +++ b/src/ui/libs/DatalensChartkit/modules/data-provider/charts/ui-sandbox.ts @@ -101,8 +101,12 @@ function getChartProps(chart: unknown) { return pick(chart, 'chartHeight', 'chartWidth', 'index'); } -function clearVmProp(prop: unknown) { +function clearVmProp(prop: unknown): unknown { if (prop && typeof prop === 'object') { + if (Array.isArray(prop)) { + return prop.map(clearVmProp); + } + if ('angular' in prop) { // It looks like it's Highcharts.Chart - preparing a minimum of attributes for the entity return getChartProps(prop); @@ -201,7 +205,10 @@ async function getUnwrappedFunction(args: { if (wrappedFn.args) { preparedUserArgs = Array.isArray(wrappedFn.args) ? wrappedFn.args : [wrappedFn.args]; } - const fnArgs = [...restArgs, ...preparedUserArgs].map((a) => clearVmProp(a)); + let fnArgs: unknown[] = [...restArgs, ...preparedUserArgs]; + if (entryType === 'graph_node') { + fnArgs = fnArgs.map((a) => clearVmProp(a)); + } // prepare function context const fnContext = clearVmProp(this);