Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[D&D] Fixes time series for new chart types #2309

Merged
merged 2 commits into from
Sep 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,7 @@ export const getTopNavConfig = (
}),
testId: 'wizardSaveButton',
disableButton: !!saveDisabledReason,
tooltip() {
if (saveDisabledReason) {
return i18n.translate('wizard.topNavMenu.saveVisualizationDisabledButtonTooltip', {
defaultMessage: saveDisabledReason,
});
}
},
tooltip: saveDisabledReason,
run: (_anchorElement) => {
const onSave = async ({
newTitle,
Expand Down
15 changes: 12 additions & 3 deletions src/plugins/wizard/public/application/utils/use/use_can_save.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* SPDX-License-Identifier: Apache-2.0
*/

import { i18n } from '@osd/i18n';
import { useTypedSelector } from '../state_management';

export const useCanSave = () => {
Expand All @@ -20,12 +21,20 @@ export const useCanSave = () => {

// TODO: Need to finalize the error messages
const getErrorMsg = (isEmpty, hasNoChange, hasDraftAgg) => {
const i18nTranslate = (key: string, defaultMessage: string) =>
i18n.translate(`wizard.saveVisualizationTooltip.${key}`, {
defaultMessage,
});

if (isEmpty) {
return 'The canvas is empty. Add some aggregations before saving.';
return i18nTranslate('empty', 'The canvas is empty. Add some aggregations before saving.');
} else if (hasNoChange) {
return 'Add some changes before saving.';
return i18nTranslate('noChange', 'Add some changes before saving.');
} else if (hasDraftAgg) {
return 'Has unapplied aggregations changes, update them before saving.';
return i18nTranslate(
'hasDraftAgg',
'Has unapplied aggregations changes, update them before saving.'
);
} else {
return undefined;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,20 @@ import { Vis, buildVislibDimensions } from '../../../../../visualizations/public
import { buildExpression, buildExpressionFunction } from '../../../../../expressions/public';
import { AreaOptionsDefaults } from './area_vis_type';
import { getAggExpressionFunctions } from '../../common/expression_helpers';
import { VislibRootState } from '../common/types';
import { getValueAxes } from '../common/get_value_axes';
import { VislibRootState, getValueAxes, getPipelineParams } from '../common';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice


export const toExpression = async ({
style: styleState,
visualization,
}: VislibRootState<AreaOptionsDefaults>) => {
const { aggConfigs, expressionFns } = await getAggExpressionFunctions(visualization);
const { addLegend, addTooltip, legendPosition, type } = styleState;
const pipelineConfigs = {
// todo: this will blow up for time x dimensions
timefilter: null, // todo: get the time filter from elsewhere
};
const params = getPipelineParams();

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

const dimensions = await buildVislibDimensions(vis, pipelineConfigs as any);
const dimensions = await buildVislibDimensions(vis, params);
const valueAxes = getValueAxes(dimensions.y);

// TODO: what do we want to put in this "vis config"?
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

import { BuildPipelineParams } from '../../../../../visualizations/public';
import { getTimeFilter } from '../../../plugin_services';

export const getPipelineParams = (): BuildPipelineParams => {
const timeFilter = getTimeFilter();
return {
timefilter: timeFilter,
timeRange: timeFilter.getTime(),
};
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

export * from './basic_vis_options';
export * from './get_pipeline_params';
export * from './get_value_axes';
export * from './types';
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,20 @@ import { Vis, buildVislibDimensions } from '../../../../../visualizations/public
import { buildExpression, buildExpressionFunction } from '../../../../../expressions/public';
import { HistogramOptionsDefaults } from './histogram_vis_type';
import { getAggExpressionFunctions } from '../../common/expression_helpers';
import { VislibRootState } from '../common/types';
import { getValueAxes } from '../common/get_value_axes';
import { VislibRootState, getValueAxes, getPipelineParams } from '../common';

export const toExpression = async ({
style: styleState,
visualization,
}: VislibRootState<HistogramOptionsDefaults>) => {
const { aggConfigs, expressionFns } = await getAggExpressionFunctions(visualization);
const { addLegend, addTooltip, legendPosition, type } = styleState;
const pipelineConfigs = {
// todo: this will blow up for time x dimensions
timefilter: null, // todo: get the time filter from elsewhere
};
const params = getPipelineParams();

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

const dimensions = await buildVislibDimensions(vis, pipelineConfigs as any);
const dimensions = await buildVislibDimensions(vis, params);
const valueAxes = getValueAxes(dimensions.y);

// TODO: what do we want to put in this "vis config"?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,20 @@ import { Vis, buildVislibDimensions } from '../../../../../visualizations/public
import { buildExpression, buildExpressionFunction } from '../../../../../expressions/public';
import { LineOptionsDefaults } from './line_vis_type';
import { getAggExpressionFunctions } from '../../common/expression_helpers';
import { VislibRootState } from '../common/types';
import { getValueAxes } from '../common/get_value_axes';
import { VislibRootState, getValueAxes, getPipelineParams } from '../common';

export const toExpression = async ({
style: styleState,
visualization,
}: VislibRootState<LineOptionsDefaults>) => {
const { aggConfigs, expressionFns } = await getAggExpressionFunctions(visualization);
const { addLegend, addTooltip, legendPosition, type } = styleState;
const pipelineConfigs = {
// todo: this will blow up for time x dimensions
timefilter: null, // todo: get the time filter from elsewhere
};
const params = getPipelineParams();

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

const dimensions = await buildVislibDimensions(vis, pipelineConfigs as any);
const dimensions = await buildVislibDimensions(vis, params);
const valueAxes = getValueAxes(dimensions.y);

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