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

[Vis Builder] Add metric to metric, bucket to bucket aggregation persistence #3495

Merged
Merged
Show file tree
Hide file tree
Changes from 6 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- Make build scripts find and use the latest version of Node.js that satisfies `engines.node` ([#3467](https://github.com/opensearch-project/OpenSearch-Dashboards/issues/3467))
- [Multiple DataSource] Refactor test connection to support SigV4 auth type ([#3456](https://github.com/opensearch-project/OpenSearch-Dashboards/issues/3456))
- [Darwin] Add support for Darwin for running OpenSearch snapshots with `yarn opensearch snapshot` ([#3537](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/3537))
- [Vis Builder] Add metric to metric, bucket to bucket aggregation persistence ([#3495](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/3495))
abbyhu2000 marked this conversation as resolved.
Show resolved Hide resolved

### 🐛 Bug Fixes

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@ import { useVisualizationType } from '../utils/use';
import './side_nav.scss';
import { useOpenSearchDashboards } from '../../../../opensearch_dashboards_react/public';
import { VisBuilderServices } from '../../types';
import { setActiveVisualization, useTypedDispatch } from '../utils/state_management';
import {
setActiveVisualization,
useTypedDispatch,
useTypedSelector,
} from '../utils/state_management';
import { usePersistedAggParams } from '../utils/use/use_persisted_agg_params';

export const RightNav = () => {
const [newVisType, setNewVisType] = useState<string>();
Expand All @@ -28,6 +33,15 @@ export const RightNav = () => {
const dispatch = useTypedDispatch();
const StyleSection = ui.containerConfig.style.render;

const { activeVisualization } = useTypedSelector((state) => state.visualization);
const aggConfigParams = activeVisualization?.aggConfigParams ?? [];
const persistedAggParams = usePersistedAggParams(
types,
aggConfigParams,
activeVisName,
newVisType
);

const options: Array<EuiSuperSelectOption<string>> = types.all().map(({ name, icon, title }) => ({
value: name,
inputDisplay: <OptionItem icon={icon} title={title} />,
Expand Down Expand Up @@ -68,6 +82,7 @@ export const RightNav = () => {
setActiveVisualization({
name: newVisType,
style: types.get(newVisType)?.ui.containerConfig.style.defaults,
aggConfigParams: persistedAggParams,
})
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export const createVisBuilderServicesMock = () => {
},
},
],
get: jest.fn(),
},
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@
*/

import { createAction } from '@reduxjs/toolkit';
import { CreateAggConfigParams } from '../../../../../data/common';
import { VisualizationType } from '../../../services/type_service/visualization_type';

interface ActiveVisPayload {
name: VisualizationType['name'];
style: VisualizationType['ui']['containerConfig']['style']['defaults'];
aggConfigParams: CreateAggConfigParams[];
}

export const setActiveVisualization = createAction<ActiveVisPayload>('setActiveVisualzation');
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export const slice = createSlice({
builder.addCase(setActiveVisualization, (state, action) => {
state.activeVisualization = {
name: action.payload.name,
aggConfigParams: [],
aggConfigParams: action.payload.aggConfigParams,
};
});
},
Expand Down
Loading