mirror of
https://github.com/apache/superset.git
synced 2024-09-12 00:29:39 -04:00
fix: Removes Redux state mutations - iteration 1 (#23522)
This commit is contained in:
parent
ee9ef24509
commit
1ced7cdbbb
@ -18,6 +18,7 @@
|
|||||||
*/
|
*/
|
||||||
/* eslint camelcase: 0 */
|
/* eslint camelcase: 0 */
|
||||||
import { t } from '@superset-ui/core';
|
import { t } from '@superset-ui/core';
|
||||||
|
import { omit } from 'lodash';
|
||||||
import { HYDRATE_DASHBOARD } from 'src/dashboard/actions/hydrate';
|
import { HYDRATE_DASHBOARD } from 'src/dashboard/actions/hydrate';
|
||||||
import { DatasourcesAction } from 'src/dashboard/actions/datasources';
|
import { DatasourcesAction } from 'src/dashboard/actions/datasources';
|
||||||
import { ChartState } from 'src/explore/types';
|
import { ChartState } from 'src/explore/types';
|
||||||
@ -180,8 +181,7 @@ export default function chartReducer(
|
|||||||
|
|
||||||
/* eslint-disable no-param-reassign */
|
/* eslint-disable no-param-reassign */
|
||||||
if (action.type === actions.REMOVE_CHART) {
|
if (action.type === actions.REMOVE_CHART) {
|
||||||
delete charts[action.key];
|
return omit(charts, [action.key]);
|
||||||
return charts;
|
|
||||||
}
|
}
|
||||||
if (action.type === actions.UPDATE_CHART_ID) {
|
if (action.type === actions.UPDATE_CHART_ID) {
|
||||||
const { newId, key } = action;
|
const { newId, key } = action;
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
import { cloneDeep } from 'lodash';
|
||||||
import {
|
import {
|
||||||
Behavior,
|
Behavior,
|
||||||
FeatureFlag,
|
FeatureFlag,
|
||||||
@ -60,7 +60,8 @@ export const getCrossFiltersConfiguration = (
|
|||||||
|
|
||||||
if (behaviors.includes(Behavior.INTERACTIVE_CHART)) {
|
if (behaviors.includes(Behavior.INTERACTIVE_CHART)) {
|
||||||
if (initialConfig[chartId]) {
|
if (initialConfig[chartId]) {
|
||||||
chartConfiguration[chartId] = initialConfig[chartId];
|
// We need to clone to avoid mutating Redux state
|
||||||
|
chartConfiguration[chartId] = cloneDeep(initialConfig[chartId]);
|
||||||
}
|
}
|
||||||
if (!chartConfiguration[chartId]) {
|
if (!chartConfiguration[chartId]) {
|
||||||
chartConfiguration[chartId] = {
|
chartConfiguration[chartId] = {
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
import { logging } from '@superset-ui/core';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
* or more contributor license agreements. See the NOTICE file
|
* or more contributor license agreements. See the NOTICE file
|
||||||
@ -18,6 +16,8 @@ import { logging } from '@superset-ui/core';
|
|||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
import { logging } from '@superset-ui/core';
|
||||||
|
|
||||||
export default function updateComponentParentsList({
|
export default function updateComponentParentsList({
|
||||||
currentComponent,
|
currentComponent,
|
||||||
layout = {},
|
layout = {},
|
||||||
@ -32,11 +32,14 @@ export default function updateComponentParentsList({
|
|||||||
|
|
||||||
if (Array.isArray(currentComponent.children)) {
|
if (Array.isArray(currentComponent.children)) {
|
||||||
currentComponent.children.forEach(childId => {
|
currentComponent.children.forEach(childId => {
|
||||||
const child = layout[childId];
|
if (layout[childId]) {
|
||||||
if (child) {
|
// eslint-disable-next-line no-param-reassign
|
||||||
child.parents = parentsList; // eslint-disable-line no-param-reassign
|
layout[childId] = {
|
||||||
|
...layout[childId],
|
||||||
|
parents: parentsList,
|
||||||
|
};
|
||||||
updateComponentParentsList({
|
updateComponentParentsList({
|
||||||
currentComponent: child,
|
currentComponent: layout[childId],
|
||||||
layout,
|
layout,
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user