From 6a1477c60728f505918cf0819667c29ebf45602c Mon Sep 17 00:00:00 2001 From: "Irina V. Kuzmina" Date: Wed, 18 Sep 2024 13:25:27 +0300 Subject: [PATCH 1/3] Enable markup and markdown in fields without using the flag --- .../datalens/preparers/bar-x/prepare-bar-x.ts | 10 +++------- .../preparers/bar-y/prepare-bar-y-data.ts | 10 +++------- .../preparers/line/prepare-line-data.ts | 10 +++------- .../datalens/preparers/pie/prepare-pie-data.ts | 8 ++------ .../preparers/scatter/prepareScatter.ts | 17 ++++++++--------- .../plugins/datalens/preparers/treemap.ts | 8 ++------ src/ui/constants/visualizations/pie.ts | 11 ++--------- .../Dialogs/DialogField/DialogField.tsx | 10 +--------- src/ui/utils/visualizations/line.ts | 7 ------- 9 files changed, 24 insertions(+), 67 deletions(-) diff --git a/src/server/modes/charts/plugins/datalens/preparers/bar-x/prepare-bar-x.ts b/src/server/modes/charts/plugins/datalens/preparers/bar-x/prepare-bar-x.ts index 88fafb2ff2..e80a0a8096 100644 --- a/src/server/modes/charts/plugins/datalens/preparers/bar-x/prepare-bar-x.ts +++ b/src/server/modes/charts/plugins/datalens/preparers/bar-x/prepare-bar-x.ts @@ -10,7 +10,6 @@ import type { import { AxisMode, AxisNullsMode, - Feature, PlaceholderId, getActualAxisModeForField, getFakeTitleOrTitle, @@ -68,13 +67,10 @@ export function prepareBarX(args: PrepareFunctionArgs) { usedColors, ChartEditor, disableDefaultSorting = false, - features, } = args; const {data, order} = resultData; const widgetConfig = ChartEditor.getWidgetConfig(); const isActionParamsEnable = widgetConfig?.actionParams?.enable; - const isMarkdownFieldsEnabled = features[Feature.WizardMarkdownFields]; - const isMarkupLabelsEnabled = features[Feature.MarkupInLabels]; const xPlaceholder = placeholders.find((p) => p.id === PlaceholderId.X); const x: ServerField | undefined = xPlaceholder?.items[0]; @@ -124,8 +120,8 @@ export function prepareBarX(args: PrepareFunctionArgs) { const labelItem = labels?.[0]; const labelsLength = labels && labels.length; - const isMarkdownLabel = isMarkdownFieldsEnabled && isMarkdownField(labelItem); - const isMarkupLabel = isMarkupLabelsEnabled && isMarkupField(labelItem); + const isMarkdownLabel = isMarkdownField(labelItem); + const isMarkupLabel = isMarkupField(labelItem); const segmentField = segments[0]; const segmentIndexInOrder = getSegmentsIndexInOrder(order, segmentField, idToTitle); @@ -257,7 +253,7 @@ export function prepareBarX(args: PrepareFunctionArgs) { segmentIndexInOrder, layers: shared.visualization?.layers, colorMode, - convertMarkupToString: !isMarkupLabelsEnabled, + convertMarkupToString: false, }); }); diff --git a/src/server/modes/charts/plugins/datalens/preparers/bar-y/prepare-bar-y-data.ts b/src/server/modes/charts/plugins/datalens/preparers/bar-y/prepare-bar-y-data.ts index e05be8b422..f45e1e82f9 100644 --- a/src/server/modes/charts/plugins/datalens/preparers/bar-y/prepare-bar-y-data.ts +++ b/src/server/modes/charts/plugins/datalens/preparers/bar-y/prepare-bar-y-data.ts @@ -8,7 +8,6 @@ import type { import { AxisMode, AxisNullsMode, - Feature, getActualAxisModeForField, getFakeTitleOrTitle, isDateField, @@ -57,13 +56,10 @@ export function prepareBarYData({ layerChartMeta, usedColors, disableDefaultSorting = false, - features, }: PrepareFunctionArgs) { const {data, order} = resultData; const widgetConfig = ChartEditor.getWidgetConfig(); const isActionParamsEnable = widgetConfig?.actionParams?.enable; - const isMarkdownFieldsEnabled = features[Feature.WizardMarkdownFields]; - const isMarkupLabelsEnabled = features[Feature.MarkupInLabels]; const xPlaceholder = placeholders[0]; const x: ServerField | undefined = placeholders[0].items[0]; @@ -111,8 +107,8 @@ export function prepareBarYData({ isGradientMode({colorField: colorItem, colorFieldDataType, colorsConfig}); const labelItem = labels?.[0]; - const isMarkdownLabel = isMarkdownFieldsEnabled && isMarkdownField(labelItem); - const isMarkupLabel = isMarkupLabelsEnabled && isMarkupField(labelItem); + const isMarkdownLabel = isMarkdownField(labelItem); + const isMarkupLabel = isMarkupField(labelItem); const isColorItemExist = Boolean(colorItem && colorItem.type !== 'PSEUDO'); const isColorizeByMeasure = isMeasureField(colorItem); @@ -239,7 +235,7 @@ export function prepareBarYData({ segmentIndexInOrder: -1, layers: shared.visualization?.layers, colorMode, - convertMarkupToString: !isMarkupLabelsEnabled, + convertMarkupToString: false, }); }); diff --git a/src/server/modes/charts/plugins/datalens/preparers/line/prepare-line-data.ts b/src/server/modes/charts/plugins/datalens/preparers/line/prepare-line-data.ts index 2edd206502..09cefe89cd 100644 --- a/src/server/modes/charts/plugins/datalens/preparers/line/prepare-line-data.ts +++ b/src/server/modes/charts/plugins/datalens/preparers/line/prepare-line-data.ts @@ -4,7 +4,6 @@ import type {Field, HighchartsSeriesCustomObject} from '../../../../../../../sha import { AxisMode, AxisNullsMode, - Feature, PlaceholderId, WizardVisualizationId, getActualAxisModeForField, @@ -62,12 +61,9 @@ export function prepareLineData(args: PrepareFunctionArgs) { layerChartMeta, usedColors, disableDefaultSorting = false, - features, } = args; const widgetConfig = ChartEditor.getWidgetConfig(); const isActionParamsEnable = widgetConfig?.actionParams?.enable; - const isMarkdownFieldsEnabled = features[Feature.WizardMarkdownFields]; - const isMarkupLabelsEnabled = features[Feature.MarkupInLabels]; const xPlaceholder = placeholders.find((p) => p.id === PlaceholderId.X); const xField = xPlaceholder?.items[0]; @@ -116,8 +112,8 @@ export function prepareLineData(args: PrepareFunctionArgs) { const labelItem = labels?.[0]; const labelsLength = labels && labels.length; - const isMarkdownLabel = isMarkdownFieldsEnabled && isMarkdownField(labelItem); - const isMarkupLabel = isMarkupLabelsEnabled && isMarkupField(labelItem); + const isMarkdownLabel = isMarkdownField(labelItem); + const isMarkupLabel = isMarkupField(labelItem); const segmentField = segments[0]; const segmentIndexInOrder = getSegmentsIndexInOrder(order, segmentField, idToTitle); @@ -263,7 +259,7 @@ export function prepareLineData(args: PrepareFunctionArgs) { segmentIndexInOrder, layers: shared.visualization?.layers, colorMode, - convertMarkupToString: !isMarkupLabelsEnabled, + convertMarkupToString: false, }); }); diff --git a/src/server/modes/charts/plugins/datalens/preparers/pie/prepare-pie-data.ts b/src/server/modes/charts/plugins/datalens/preparers/pie/prepare-pie-data.ts index ab697d17e5..1108f8d43f 100644 --- a/src/server/modes/charts/plugins/datalens/preparers/pie/prepare-pie-data.ts +++ b/src/server/modes/charts/plugins/datalens/preparers/pie/prepare-pie-data.ts @@ -1,7 +1,6 @@ import type {ExtendedSeriesLineOptions} from '../../../../../../../shared'; import { DATASET_FIELD_TYPES, - Feature, MINIMUM_FRACTION_DIGITS, PlaceholderId, getDistinctValue, @@ -97,12 +96,9 @@ export function preparePieData(args: PrepareFunctionArgs) { ChartEditor, disableDefaultSorting = false, shared, - features, } = args; const {data, order, totals} = resultData; const widgetConfig = ChartEditor.getWidgetConfig(); - const isMarkdownFieldsEnabled = features[Feature.WizardMarkdownFields]; - const isMarkupLabelsEnabled = features[Feature.MarkupInLabels]; const measure = placeholders.find((p) => p.id === PlaceholderId.Measures)?.items[0]; let colorField = placeholders.find((p) => p.id === PlaceholderId.Colors)?.items[0]; @@ -131,8 +127,8 @@ export function preparePieData(args: PrepareFunctionArgs) { const labelIndex = labelField ? findIndexInOrder(order, labelField, idToTitle[labelField.guid]) : -1; - const isMarkdownLabel = isMarkdownFieldsEnabled && isMarkdownField(labelItem); - const isMarkupLabel = isMarkupLabelsEnabled && isMarkupField(labelItem); + const isMarkdownLabel = isMarkdownField(labelItem); + const isMarkupLabel = isMarkupField(labelItem); const measureIndex = findIndexInOrder(order, measure, idToTitle[measure.guid]); const measureDataType = idToDataType[measure.guid] || measure.data_type; diff --git a/src/server/modes/charts/plugins/datalens/preparers/scatter/prepareScatter.ts b/src/server/modes/charts/plugins/datalens/preparers/scatter/prepareScatter.ts index 8a37210adf..d942733f6e 100644 --- a/src/server/modes/charts/plugins/datalens/preparers/scatter/prepareScatter.ts +++ b/src/server/modes/charts/plugins/datalens/preparers/scatter/prepareScatter.ts @@ -76,7 +76,6 @@ export function prepareScatter(options: PrepareFunctionArgs): PrepareScatterResu features, shared, } = options; - const isMarkdownFieldsEnabled = features[Feature.WizardMarkdownFields]; const widgetConfig = ChartEditor.getWidgetConfig(); const isActionParamsEnable = widgetConfig?.actionParams?.enable; const {data, order} = resultData; @@ -183,7 +182,7 @@ export function prepareScatter(options: PrepareFunctionArgs): PrepareScatterResu }); } else { let value: string | WrappedMarkdown = xValue as string; - if (isMarkdownField(x) && isMarkdownFieldsEnabled) { + if (isMarkdownField(x)) { value = wrapMarkdownValue(value); } else if (shouldEscapeUserValue) { value = escape(value); @@ -237,7 +236,7 @@ export function prepareScatter(options: PrepareFunctionArgs): PrepareScatterResu } else { let yLabel: string | WrappedMarkdown = yValue && shouldEscapeUserValue ? escape(yValue as string) : (yValue as string); - if (isMarkdownField(x) && isMarkdownFieldsEnabled) { + if (isMarkdownField(x)) { yLabel = wrapMarkdownValue(String(yLabel)); } @@ -272,7 +271,7 @@ export function prepareScatter(options: PrepareFunctionArgs): PrepareScatterResu } if (isStringField(z)) { - if (isMarkdownField(z) && isMarkdownFieldsEnabled) { + if (isMarkdownField(z)) { formattedZValue = wrapMarkdownValue(zValueRaw as string); } else if (shouldEscapeUserValue) { formattedZValue = escape(formattedZValue as string); @@ -315,7 +314,7 @@ export function prepareScatter(options: PrepareFunctionArgs): PrepareScatterResu const colorValue = values[i] && shouldEscapeUserValue ? escape(String(values[i])) : values[i]; let colorLabel: string | null | WrappedMarkdown = colorValue; - if (isMarkdownField(color) && isMarkdownFieldsEnabled) { + if (isMarkdownField(color)) { colorLabel = wrapMarkdownValue(String(colorValue)); } @@ -352,7 +351,7 @@ export function prepareScatter(options: PrepareFunctionArgs): PrepareScatterResu const i = findIndexInOrder(order, shape, cTitle); const shapeValue = escape(values[i] as string) || ''; let shapeLabel: WrappedMarkdown | string = shapeValue; - if (isMarkdownField(shape) && isMarkdownFieldsEnabled) { + if (isMarkdownField(shape)) { shapeLabel = wrapMarkdownValue(String(shapeValue)); } @@ -410,7 +409,7 @@ export function prepareScatter(options: PrepareFunctionArgs): PrepareScatterResu }); } - if ((isMarkdownField(color) || isMarkdownField(shape)) && isMarkdownFieldsEnabled) { + if (isMarkdownField(color) || isMarkdownField(shape)) { graphs.forEach((g) => { g.name = wrapMarkdownValue(g.name as string); }); @@ -421,13 +420,13 @@ export function prepareScatter(options: PrepareFunctionArgs): PrepareScatterResu if (!xIsNumber && !xIsDate) { categories = xCategories; - if (isMarkdownField(x) && isMarkdownFieldsEnabled) { + if (isMarkdownField(x)) { categories = categories?.map((c) => wrapMarkdownValue(c as string)); } } const hasMarkdown = [x, y, z, size, color, shape].some((field) => isMarkdownField(field)); - if (isMarkdownFieldsEnabled && hasMarkdown) { + if (hasMarkdown) { ChartEditor.updateConfig({useMarkdown: true}); } diff --git a/src/server/modes/charts/plugins/datalens/preparers/treemap.ts b/src/server/modes/charts/plugins/datalens/preparers/treemap.ts index 8717e26138..5f950aa31f 100644 --- a/src/server/modes/charts/plugins/datalens/preparers/treemap.ts +++ b/src/server/modes/charts/plugins/datalens/preparers/treemap.ts @@ -45,11 +45,10 @@ function prepareTreemap({ features, ChartEditor, }: PrepareFunctionArgs) { - const isMarkdownFieldsEnabled = features[Feature.WizardMarkdownFields]; // Dimensions const d = placeholders[0].items; const dTypes = d.map((item) => item.data_type); - const useMarkdown = isMarkdownFieldsEnabled && d?.some(isMarkdownField); + const useMarkdown = d?.some(isMarkdownField); // Measures const m = placeholders[1].items; @@ -141,10 +140,7 @@ function prepareTreemap({ const treemapId = dPath.length >= 1 ? `id_${dPath[0]}/${value}` : `id_${dPath.join()}${value}`; - const name = - isMarkdownField(item) && isMarkdownFieldsEnabled - ? wrapMarkdownValue(value as string) - : value; + const name = isMarkdownField(item) ? wrapMarkdownValue(value as string) : value; const treemapItem: TreemapItem = { id: treemapId, diff --git a/src/ui/constants/visualizations/pie.ts b/src/ui/constants/visualizations/pie.ts index 683cb608e5..6a925a3caf 100644 --- a/src/ui/constants/visualizations/pie.ts +++ b/src/ui/constants/visualizations/pie.ts @@ -1,9 +1,8 @@ import {BucketPaint, ChartPie, LayoutColumns3} from '@gravity-ui/icons'; import type {Field, GraphShared, Placeholder} from 'shared'; -import {Feature, PlaceholderId, WizardVisualizationId, isMarkupField} from 'shared'; +import {PlaceholderId, WizardVisualizationId} from 'shared'; import {prepareFieldToMeasureTransformation} from 'units/wizard/utils/visualization'; -import Utils from '../../utils/utils'; import {ITEM_TYPES, PRIMITIVE_DATA_TYPES, PRIMITIVE_DATA_TYPES_AND_HIERARCHY} from '../misc'; import {prepareFieldToDimensionTransformation} from './utils'; @@ -28,13 +27,7 @@ export const PIE_VISUALIZATION: GraphShared['visualization'] = { return selectedItems.some((selectedItem) => selectedItem.guid === item.guid); }, - checkAllowedLabels: (item: Field) => { - if (isMarkupField(item)) { - return Utils.isEnabledFeature(Feature.MarkupInLabels); - } - - return ITEM_TYPES.ALL.has(item.type); - }, + checkAllowedLabels: (item: Field) => ITEM_TYPES.ALL.has(item.type), availableLabelModes: ['absolute', 'percent'], placeholders: [ { diff --git a/src/ui/units/wizard/components/Dialogs/DialogField/DialogField.tsx b/src/ui/units/wizard/components/Dialogs/DialogField/DialogField.tsx index 1498650e9a..a09c23bbd5 100644 --- a/src/ui/units/wizard/components/Dialogs/DialogField/DialogField.tsx +++ b/src/ui/units/wizard/components/Dialogs/DialogField/DialogField.tsx @@ -14,20 +14,13 @@ import type { Placeholder, TableFieldBackgroundSettings, } from 'shared'; -import { - Feature, - PlaceholderId, - WizardVisualizationId, - getDefaultFormatting, - isPseudoField, -} from 'shared'; +import {PlaceholderId, WizardVisualizationId, getDefaultFormatting, isPseudoField} from 'shared'; import type {TableSubTotalsSettings} from 'shared/types/wizard/sub-totals'; import {setExtraSettings} from 'ui/units/wizard/actions/widget'; import { getDefaultSubTotalsSettings, isSubTotalsAvailableInDialogField, } from 'ui/units/wizard/components/Dialogs/DialogField/utils/subTotals'; -import Utils from 'ui/utils'; import type {Optional} from 'utility-types'; import type { @@ -468,7 +461,6 @@ class DialogField extends React.PureComponent Date: Wed, 18 Sep 2024 13:31:12 +0300 Subject: [PATCH 2/3] remove from Feature --- .../features/features-list/MarkupInLabels.ts | 10 ---------- .../features/features-list/WizardMarkdownFields.ts | 10 ---------- src/shared/types/feature.ts | 4 ---- 3 files changed, 24 deletions(-) delete mode 100644 src/server/components/features/features-list/MarkupInLabels.ts delete mode 100644 src/server/components/features/features-list/WizardMarkdownFields.ts diff --git a/src/server/components/features/features-list/MarkupInLabels.ts b/src/server/components/features/features-list/MarkupInLabels.ts deleted file mode 100644 index 2b631bdb79..0000000000 --- a/src/server/components/features/features-list/MarkupInLabels.ts +++ /dev/null @@ -1,10 +0,0 @@ -import {Feature} from '../../../../shared'; -import {createFeatureConfig} from '../utils'; - -export default createFeatureConfig({ - name: Feature.MarkupInLabels, - state: { - development: false, - production: false, - }, -}); diff --git a/src/server/components/features/features-list/WizardMarkdownFields.ts b/src/server/components/features/features-list/WizardMarkdownFields.ts deleted file mode 100644 index 7652e30d53..0000000000 --- a/src/server/components/features/features-list/WizardMarkdownFields.ts +++ /dev/null @@ -1,10 +0,0 @@ -import {Feature} from '../../../../shared'; -import {createFeatureConfig} from '../utils'; - -export default createFeatureConfig({ - name: Feature.WizardMarkdownFields, - state: { - development: true, - production: false, - }, -}); diff --git a/src/shared/types/feature.ts b/src/shared/types/feature.ts index 239065f3b6..440e129385 100644 --- a/src/shared/types/feature.ts +++ b/src/shared/types/feature.ts @@ -87,12 +87,8 @@ export enum Feature { NewSandbox_75p = 'NewSandbox_75p', NewSandbox_100p = 'NewSandbox_100p', SandboxEngineSelectSwitch = 'SandboxEngineSelectSwitch', - /** Allow markdown in chart fields. */ - WizardMarkdownFields = 'WizardMarkdownFields', EnableEmbedsInDialogShare = 'EnableEmbedsInDialogShare', EnableEntryMenuItemShare = 'EnableEntryMenuItemShare', - /** Render markup in chart dataLabels. */ - MarkupInLabels = 'MarkupInLabels', } export type FeatureConfig = Record; From 6d46c8032ad3e6b9dee43717cd543a88112794a5 Mon Sep 17 00:00:00 2001 From: "Irina V. Kuzmina" Date: Wed, 18 Sep 2024 13:47:19 +0300 Subject: [PATCH 3/3] fix test --- .../datalens/preparers/line/__tests__/mocks/line.mock.ts | 8 ++++---- .../datalens/preparers/pie/__tests__/mocks/pie.mock.ts | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/server/modes/charts/plugins/datalens/preparers/line/__tests__/mocks/line.mock.ts b/src/server/modes/charts/plugins/datalens/preparers/line/__tests__/mocks/line.mock.ts index 817e7ddf51..786e5d1734 100644 --- a/src/server/modes/charts/plugins/datalens/preparers/line/__tests__/mocks/line.mock.ts +++ b/src/server/modes/charts/plugins/datalens/preparers/line/__tests__/mocks/line.mock.ts @@ -392,7 +392,7 @@ export const linesColoredByFieldWithPostfixResult = { {x: 1, y: 844, dataLabels: {enabled: false}, label: ''}, {x: 2, y: 429, dataLabels: {enabled: false}, label: ''}, ], - dataLabels: {enabled: false}, + dataLabels: {enabled: false, useHTML: false}, legendTitle: '2 014 г. в.', drillDownFilterValue: '2014', colorGuid: 'd0ab8220-16e9-4320-b6da-1ca12163d956', @@ -415,7 +415,7 @@ export const linesColoredByFieldWithPostfixResult = { {x: 1, y: 2789, dataLabels: {enabled: false}, label: ''}, {x: 2, y: 9667, dataLabels: {enabled: false}, label: ''}, ], - dataLabels: {enabled: false}, + dataLabels: {enabled: false, useHTML: false}, legendTitle: '2 015 г. в.', drillDownFilterValue: '2015', colorGuid: 'd0ab8220-16e9-4320-b6da-1ca12163d956', @@ -438,7 +438,7 @@ export const linesColoredByFieldWithPostfixResult = { {x: 1, y: 4969, dataLabels: {enabled: false}, label: ''}, {x: 2, y: 3535, dataLabels: {enabled: false}, label: ''}, ], - dataLabels: {enabled: false}, + dataLabels: {enabled: false, useHTML: false}, legendTitle: '2 016 г. в.', drillDownFilterValue: '2016', colorGuid: 'd0ab8220-16e9-4320-b6da-1ca12163d956', @@ -461,7 +461,7 @@ export const linesColoredByFieldWithPostfixResult = { {x: 1, y: 1564, dataLabels: {enabled: false}, label: ''}, {x: 2, y: 14646, dataLabels: {enabled: false}, label: ''}, ], - dataLabels: {enabled: false}, + dataLabels: {enabled: false, useHTML: false}, legendTitle: '2 017 г. в.', drillDownFilterValue: '2017', colorGuid: 'd0ab8220-16e9-4320-b6da-1ca12163d956', diff --git a/src/server/modes/charts/plugins/datalens/preparers/pie/__tests__/mocks/pie.mock.ts b/src/server/modes/charts/plugins/datalens/preparers/pie/__tests__/mocks/pie.mock.ts index e4181dafda..359dc80e69 100644 --- a/src/server/modes/charts/plugins/datalens/preparers/pie/__tests__/mocks/pie.mock.ts +++ b/src/server/modes/charts/plugins/datalens/preparers/pie/__tests__/mocks/pie.mock.ts @@ -357,7 +357,7 @@ export const piePrepareForQLResult = { name: 'iznos', pointConflict: true, tooltip: {chartKitFormatting: true, chartKitPrecision: 2}, - dataLabels: {chartKitFormatting: true, chartKitPrecision: 0}, + dataLabels: {chartKitFormatting: true, chartKitPrecision: 0, useHTML: false}, data: [ { name: 'Кирпич',