Skip to content

Commit 3d67b47

Browse files
ashwin-pcgithub-actions[bot]
authored andcommitted
[D&D] Fixes time series for new chart types (#2309)
* fixes time series for new chart types Signed-off-by: Ashwin Pc <[email protected]> * moves translate to source string Signed-off-by: Ashwin Pc <[email protected]> Signed-off-by: Ashwin Pc <[email protected]> (cherry picked from commit 93f6872)
1 parent 966b411 commit 3d67b47

File tree

7 files changed

+46
-31
lines changed

7 files changed

+46
-31
lines changed

src/plugins/wizard/public/application/utils/get_top_nav_config.tsx

+1-7
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,7 @@ export const getTopNavConfig = (
8080
}),
8181
testId: 'wizardSaveButton',
8282
disableButton: !!saveDisabledReason,
83-
tooltip() {
84-
if (saveDisabledReason) {
85-
return i18n.translate('wizard.topNavMenu.saveVisualizationDisabledButtonTooltip', {
86-
defaultMessage: saveDisabledReason,
87-
});
88-
}
89-
},
83+
tooltip: saveDisabledReason,
9084
run: (_anchorElement) => {
9185
const onSave = async ({
9286
newTitle,

src/plugins/wizard/public/application/utils/use/use_can_save.ts

+12-3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* SPDX-License-Identifier: Apache-2.0
44
*/
55

6+
import { i18n } from '@osd/i18n';
67
import { useTypedSelector } from '../state_management';
78

89
export const useCanSave = () => {
@@ -20,12 +21,20 @@ export const useCanSave = () => {
2021

2122
// TODO: Need to finalize the error messages
2223
const getErrorMsg = (isEmpty, hasNoChange, hasDraftAgg) => {
24+
const i18nTranslate = (key: string, defaultMessage: string) =>
25+
i18n.translate(`wizard.saveVisualizationTooltip.${key}`, {
26+
defaultMessage,
27+
});
28+
2329
if (isEmpty) {
24-
return 'The canvas is empty. Add some aggregations before saving.';
30+
return i18nTranslate('empty', 'The canvas is empty. Add some aggregations before saving.');
2531
} else if (hasNoChange) {
26-
return 'Add some changes before saving.';
32+
return i18nTranslate('noChange', 'Add some changes before saving.');
2733
} else if (hasDraftAgg) {
28-
return 'Has unapplied aggregations changes, update them before saving.';
34+
return i18nTranslate(
35+
'hasDraftAgg',
36+
'Has unapplied aggregations changes, update them before saving.'
37+
);
2938
} else {
3039
return undefined;
3140
}

src/plugins/wizard/public/visualizations/vislib/area/to_expression.ts

+3-7
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,20 @@ import { Vis, buildVislibDimensions } from '../../../../../visualizations/public
77
import { buildExpression, buildExpressionFunction } from '../../../../../expressions/public';
88
import { AreaOptionsDefaults } from './area_vis_type';
99
import { getAggExpressionFunctions } from '../../common/expression_helpers';
10-
import { VislibRootState } from '../common/types';
11-
import { getValueAxes } from '../common/get_value_axes';
10+
import { VislibRootState, getValueAxes, getPipelineParams } from '../common';
1211

1312
export const toExpression = async ({
1413
style: styleState,
1514
visualization,
1615
}: VislibRootState<AreaOptionsDefaults>) => {
1716
const { aggConfigs, expressionFns } = await getAggExpressionFunctions(visualization);
1817
const { addLegend, addTooltip, legendPosition, type } = styleState;
19-
const pipelineConfigs = {
20-
// todo: this will blow up for time x dimensions
21-
timefilter: null, // todo: get the time filter from elsewhere
22-
};
18+
const params = getPipelineParams();
2319

2420
const vis = new Vis(type);
2521
vis.data.aggs = aggConfigs;
2622

27-
const dimensions = await buildVislibDimensions(vis, pipelineConfigs as any);
23+
const dimensions = await buildVislibDimensions(vis, params);
2824
const valueAxes = getValueAxes(dimensions.y);
2925

3026
// TODO: what do we want to put in this "vis config"?
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/*
2+
* Copyright OpenSearch Contributors
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
import { BuildPipelineParams } from '../../../../../visualizations/public';
7+
import { getTimeFilter } from '../../../plugin_services';
8+
9+
export const getPipelineParams = (): BuildPipelineParams => {
10+
const timeFilter = getTimeFilter();
11+
return {
12+
timefilter: timeFilter,
13+
timeRange: timeFilter.getTime(),
14+
};
15+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/*
2+
* Copyright OpenSearch Contributors
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
export * from './basic_vis_options';
7+
export * from './get_pipeline_params';
8+
export * from './get_value_axes';
9+
export * from './types';

src/plugins/wizard/public/visualizations/vislib/histogram/to_expression.ts

+3-7
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,20 @@ import { Vis, buildVislibDimensions } from '../../../../../visualizations/public
77
import { buildExpression, buildExpressionFunction } from '../../../../../expressions/public';
88
import { HistogramOptionsDefaults } from './histogram_vis_type';
99
import { getAggExpressionFunctions } from '../../common/expression_helpers';
10-
import { VislibRootState } from '../common/types';
11-
import { getValueAxes } from '../common/get_value_axes';
10+
import { VislibRootState, getValueAxes, getPipelineParams } from '../common';
1211

1312
export const toExpression = async ({
1413
style: styleState,
1514
visualization,
1615
}: VislibRootState<HistogramOptionsDefaults>) => {
1716
const { aggConfigs, expressionFns } = await getAggExpressionFunctions(visualization);
1817
const { addLegend, addTooltip, legendPosition, type } = styleState;
19-
const pipelineConfigs = {
20-
// todo: this will blow up for time x dimensions
21-
timefilter: null, // todo: get the time filter from elsewhere
22-
};
18+
const params = getPipelineParams();
2319

2420
const vis = new Vis(type);
2521
vis.data.aggs = aggConfigs;
2622

27-
const dimensions = await buildVislibDimensions(vis, pipelineConfigs as any);
23+
const dimensions = await buildVislibDimensions(vis, params);
2824
const valueAxes = getValueAxes(dimensions.y);
2925

3026
// TODO: what do we want to put in this "vis config"?

src/plugins/wizard/public/visualizations/vislib/line/to_expression.ts

+3-7
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,20 @@ import { Vis, buildVislibDimensions } from '../../../../../visualizations/public
77
import { buildExpression, buildExpressionFunction } from '../../../../../expressions/public';
88
import { LineOptionsDefaults } from './line_vis_type';
99
import { getAggExpressionFunctions } from '../../common/expression_helpers';
10-
import { VislibRootState } from '../common/types';
11-
import { getValueAxes } from '../common/get_value_axes';
10+
import { VislibRootState, getValueAxes, getPipelineParams } from '../common';
1211

1312
export const toExpression = async ({
1413
style: styleState,
1514
visualization,
1615
}: VislibRootState<LineOptionsDefaults>) => {
1716
const { aggConfigs, expressionFns } = await getAggExpressionFunctions(visualization);
1817
const { addLegend, addTooltip, legendPosition, type } = styleState;
19-
const pipelineConfigs = {
20-
// todo: this will blow up for time x dimensions
21-
timefilter: null, // todo: get the time filter from elsewhere
22-
};
18+
const params = getPipelineParams();
2319

2420
const vis = new Vis(type);
2521
vis.data.aggs = aggConfigs;
2622

27-
const dimensions = await buildVislibDimensions(vis, pipelineConfigs as any);
23+
const dimensions = await buildVislibDimensions(vis, params);
2824
const valueAxes = getValueAxes(dimensions.y);
2925

3026
// TODO: what do we want to put in this "vis config"?

0 commit comments

Comments
 (0)