Skip to content

Commit

Permalink
Add links to the manifest while saving wizard as editor (#2058)
Browse files Browse the repository at this point in the history
  • Loading branch information
kuzmadom authored Jan 27, 2025
1 parent 8ab0972 commit d49805a
Showing 1 changed file with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type {Request} from '@gravity-ui/expresskit';
import type {AppContext} from '@gravity-ui/nodekit';

import type {StringParams} from '../../../../shared';
import {type StringParams, isEnabledServerFeature} from '../../../../shared';

const commonTemplateGraph = `
const {buildHighchartsConfig, buildLibraryConfig} = require('#module');
Expand Down Expand Up @@ -149,8 +149,17 @@ type Chart = {
statface_metric?: string;
graph?: string;
statface_graph?: string;
meta?: string;
};

function createChartManifect(args: {links?: Record<string, string>}) {
const manifest = {
links: Object.values(args.links ?? {}),
};

return JSON.stringify(manifest, null, 4);
}

export const chartGenerator = {
generateChart: ({
data,
Expand Down Expand Up @@ -224,6 +233,10 @@ export const chartGenerator = {
chart.js = chart.js.replace('#apiVersion', apiVersion);
chart.url = chart.url.replace('#apiVersion', apiVersion);

if (isEnabledServerFeature(ctx, 'EnableChartEditorMetaTab')) {
chart.meta = createChartManifect({links});
}

const {config: _, ...chartWithoutCOnfig} = chart;

return {chart: isD3Graph ? chart : chartWithoutCOnfig, links, type};
Expand Down

0 comments on commit d49805a

Please sign in to comment.