diff --git a/src/ui/components/Widgets/Chart/Chart.tsx b/src/ui/components/Widgets/Chart/Chart.tsx index 8f0880f675..e980edcbaa 100644 --- a/src/ui/components/Widgets/Chart/Chart.tsx +++ b/src/ui/components/Widgets/Chart/Chart.tsx @@ -65,6 +65,7 @@ export const Chart = (props: ChartNoWidgetProps) => { ignoreUsedParams, onInnerParamsChanged, disableChartLoader, + actionParamsEnabled, } = props; const innerParamsRef = React.useRef(null); @@ -170,7 +171,7 @@ export const Chart = (props: ChartNoWidgetProps) => { ignoreUsedParams, clearedOuterParams, onInnerParamsChanged, - enableActionParams: false, + enableActionParams: actionParamsEnabled, }); /** diff --git a/src/ui/components/Widgets/Chart/types.ts b/src/ui/components/Widgets/Chart/types.ts index ab5e2ea623..4e103606ef 100644 --- a/src/ui/components/Widgets/Chart/types.ts +++ b/src/ui/components/Widgets/Chart/types.ts @@ -103,6 +103,7 @@ type ChartKitBaseWrapperProps = ChartsProps & { skipReload?: boolean; renderPluginLoader?: () => React.ReactNode; + actionParamsEnabled?: boolean; }; export type ChartWidgetProviderPropsWithRefProps = Omit< diff --git a/src/ui/constants/common.ts b/src/ui/constants/common.ts index c896be90f8..a9667b48df 100644 --- a/src/ui/constants/common.ts +++ b/src/ui/constants/common.ts @@ -255,6 +255,7 @@ export const URL_OPTIONS = { EMBEDDED: '_embedded', NO_CONTROLS: '_no_controls', LANGUAGE: '_lang', + ACTION_PARAMS_ENABLED: '_ap_enabled', }; export const DLS_SUBJECT = { diff --git a/src/ui/libs/DatalensChartkit/ChartKit/helpers/apply-hc-handlers.ts b/src/ui/libs/DatalensChartkit/ChartKit/helpers/apply-hc-handlers.ts index 2f7d024695..1f6a7e6c83 100644 --- a/src/ui/libs/DatalensChartkit/ChartKit/helpers/apply-hc-handlers.ts +++ b/src/ui/libs/DatalensChartkit/ChartKit/helpers/apply-hc-handlers.ts @@ -1,11 +1,12 @@ import type {Highcharts} from '@gravity-ui/chartkit/highcharts'; +import {pickActionParamsFromParams} from '@gravity-ui/dashkit'; import {wrap} from 'highcharts'; import get from 'lodash/get'; import has from 'lodash/has'; import merge from 'lodash/merge'; import set from 'lodash/set'; -import {GraphWidgetEventScope, URL_ACTION_PARAMS_PREFIX} from 'shared'; +import type {GraphWidgetEventScope} from '../../../../../shared'; import type {GraphWidget} from '../../types'; import type {ChartKitAdapterProps} from '../types'; @@ -30,19 +31,6 @@ export const fixPieTotals = (args: {data: GraphWidget}) => { }); }; -function getActionParams(params: Record = {}) { - const actionParams: Record = {}; - Object.entries(params).forEach(([key, value]) => { - if (key.startsWith(URL_ACTION_PARAMS_PREFIX)) { - actionParams[key.slice(URL_ACTION_PARAMS_PREFIX.length)] = Array.isArray(value) - ? value - : [value]; - } - }); - - return actionParams; -} - export const applySetActionParamsEvents = (args: { action: ShapedAction; data: GraphWidget; @@ -72,7 +60,7 @@ export const applySetActionParamsEvents = (args: { set(data, pathToScatterMarkerStates, {}); } - const actionParams = getActionParams(get(data, 'unresolvedParams', {})); + const actionParams = pickActionParamsFromParams(get(data, 'unresolvedParams', {})); wrap( get(data, pathToChartEvents), diff --git a/src/ui/units/preview/components/Preview/Preview.tsx b/src/ui/units/preview/components/Preview/Preview.tsx index 3f2ef02d28..d6c35bc223 100644 --- a/src/ui/units/preview/components/Preview/Preview.tsx +++ b/src/ui/units/preview/components/Preview/Preview.tsx @@ -65,7 +65,7 @@ const Preview: React.FC = (props) => { isEmbedded, } = props; - const {noControls} = Utils.getOptionsFromSearch(search); + const {noControls, actionParamsEnabled} = Utils.getOptionsFromSearch(search); const possibleEntryId = React.useMemo(() => extractEntryId(idOrSource), [idOrSource]); @@ -197,6 +197,7 @@ const Preview: React.FC = (props) => { onChartLoad={onChartLoad} onChartRender={onChartRender} noControls={noControls} + actionParamsEnabled={actionParamsEnabled} forwardedRef={chartKitRef as unknown as React.RefObject} splitTooltip={hasSplitTooltip} menuType="preview" diff --git a/src/ui/utils/utils.ts b/src/ui/utils/utils.ts index 9c17b907b6..25cc8d5ef7 100644 --- a/src/ui/utils/utils.ts +++ b/src/ui/utils/utils.ts @@ -237,6 +237,7 @@ export default class Utils { noControls: searchParams.get(URL_OPTIONS.NO_CONTROLS) === '1' || searchParams.get(URL_OPTIONS.NO_CONTROLS) === 'true', // deprecated + actionParamsEnabled: searchParams.get(URL_OPTIONS.ACTION_PARAMS_ENABLED) === '1', }; }