You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by mi...@apache.org on 2024/02/22 17:41:48 UTC
(superset) 09/14: fix: Duplicated toast messages (#27135)
This is an automated email from the ASF dual-hosted git repository.
michaelsmolina pushed a commit to branch 3.1
in repository https://gitbox.apache.org/repos/asf/superset.git
commit c839c5734a8fc0ad2e564ad625ee35adec2a4193
Author: Michael S. Molina <70...@users.noreply.github.com>
AuthorDate: Fri Feb 16 08:13:34 2024 -0500
fix: Duplicated toast messages (#27135)
---
.../src/SqlLab/reducers/getInitialState.ts | 4 --
.../MessageToasts/getToastsFromPyFlashMessages.js | 40 ------------------
.../getToastsFromPyFlashMessages.test.js | 48 ----------------------
.../src/dashboard/components/Dashboard.jsx | 2 -
.../src/dashboard/components/Dashboard.test.jsx | 1 -
.../FilterBarSettings/FilterBarSettings.test.tsx | 1 -
.../src/dashboard/containers/Dashboard.ts | 1 -
superset-frontend/src/dashboard/types.ts | 1 -
8 files changed, 98 deletions(-)
diff --git a/superset-frontend/src/SqlLab/reducers/getInitialState.ts b/superset-frontend/src/SqlLab/reducers/getInitialState.ts
index 8d72a313b2..02bb5b45fc 100644
--- a/superset-frontend/src/SqlLab/reducers/getInitialState.ts
+++ b/superset-frontend/src/SqlLab/reducers/getInitialState.ts
@@ -17,7 +17,6 @@
* under the License.
*/
import { t } from '@superset-ui/core';
-import getToastsFromPyFlashMessages from 'src/components/MessageToasts/getToastsFromPyFlashMessages';
import type { BootstrapData } from 'src/types/bootstrapTypes';
import type { InitialState } from 'src/hooks/apiResources/sqlLab';
import {
@@ -244,9 +243,6 @@ export default function getInitialState({
queryCostEstimates: {},
unsavedQueryEditor,
},
- messageToasts: getToastsFromPyFlashMessages(
- (common || {})?.flash_messages || [],
- ),
localStorageUsageInKilobytes: 0,
common,
...otherBootstrapData,
diff --git a/superset-frontend/src/components/MessageToasts/getToastsFromPyFlashMessages.js b/superset-frontend/src/components/MessageToasts/getToastsFromPyFlashMessages.js
deleted file mode 100644
index 982df17100..0000000000
--- a/superset-frontend/src/components/MessageToasts/getToastsFromPyFlashMessages.js
+++ /dev/null
@@ -1,40 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-import { addToast } from './actions';
-import { ToastType } from './types';
-
-export default function toastsFromPyFlashMessages(flashMessages = []) {
- const toasts = [];
-
- flashMessages.forEach(([messageType, message]) => {
- const toastType =
- messageType === 'danger'
- ? ToastType.DANGER
- : (messageType === 'success' && ToastType.SUCCESS) || ToastType.INFO;
-
- const toast = addToast({
- text: message,
- toastType,
- }).payload;
-
- toasts.push(toast);
- });
-
- return toasts;
-}
diff --git a/superset-frontend/src/components/MessageToasts/getToastsFromPyFlashMessages.test.js b/superset-frontend/src/components/MessageToasts/getToastsFromPyFlashMessages.test.js
deleted file mode 100644
index d19ac0c5d5..0000000000
--- a/superset-frontend/src/components/MessageToasts/getToastsFromPyFlashMessages.test.js
+++ /dev/null
@@ -1,48 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-import { ToastType } from 'src/components/MessageToasts/types';
-import getToastsFromPyFlashMessages from 'src/components/MessageToasts/getToastsFromPyFlashMessages';
-
-describe('getToastsFromPyFlashMessages', () => {
- it('should return an info toast', () => {
- const toast = getToastsFromPyFlashMessages([['info', 'info test']])[0];
- expect(toast).toMatchObject({
- toastType: ToastType.INFO,
- text: 'info test',
- });
- });
-
- it('should return a success toast', () => {
- const toast = getToastsFromPyFlashMessages([
- ['success', 'success test'],
- ])[0];
- expect(toast).toMatchObject({
- toastType: ToastType.SUCCESS,
- text: 'success test',
- });
- });
-
- it('should return a danger toast', () => {
- const toast = getToastsFromPyFlashMessages([['danger', 'danger test']])[0];
- expect(toast).toMatchObject({
- toastType: ToastType.DANGER,
- text: 'danger test',
- });
- });
-});
diff --git a/superset-frontend/src/dashboard/components/Dashboard.jsx b/superset-frontend/src/dashboard/components/Dashboard.jsx
index 6e909f3b15..45a1e3046f 100644
--- a/superset-frontend/src/dashboard/components/Dashboard.jsx
+++ b/superset-frontend/src/dashboard/components/Dashboard.jsx
@@ -59,13 +59,11 @@ const propTypes = {
ownDataCharts: PropTypes.object.isRequired,
layout: PropTypes.object.isRequired,
impressionId: PropTypes.string.isRequired,
- initMessages: PropTypes.array,
timeout: PropTypes.number,
userId: PropTypes.string,
};
const defaultProps = {
- initMessages: [],
timeout: 60,
userId: '',
};
diff --git a/superset-frontend/src/dashboard/components/Dashboard.test.jsx b/superset-frontend/src/dashboard/components/Dashboard.test.jsx
index a66eab37e3..d75bda27dc 100644
--- a/superset-frontend/src/dashboard/components/Dashboard.test.jsx
+++ b/superset-frontend/src/dashboard/components/Dashboard.test.jsx
@@ -47,7 +47,6 @@ describe('Dashboard', () => {
triggerQuery() {},
logEvent() {},
},
- initMessages: [],
dashboardState,
dashboardInfo,
charts: chartQueries,
diff --git a/superset-frontend/src/dashboard/components/nativeFilters/FilterBar/FilterBarSettings/FilterBarSettings.test.tsx b/superset-frontend/src/dashboard/components/nativeFilters/FilterBar/FilterBarSettings/FilterBarSettings.test.tsx
index 8c236c2714..e2d198c3e9 100644
--- a/superset-frontend/src/dashboard/components/nativeFilters/FilterBar/FilterBarSettings/FilterBarSettings.test.tsx
+++ b/superset-frontend/src/dashboard/components/nativeFilters/FilterBar/FilterBarSettings/FilterBarSettings.test.tsx
@@ -50,7 +50,6 @@ const initialState: { dashboardInfo: DashboardInfo } = {
filterBarOrientation: FilterBarOrientation.VERTICAL,
common: {
conf: {},
- flash_messages: [],
},
crossFiltersEnabled: true,
},
diff --git a/superset-frontend/src/dashboard/containers/Dashboard.ts b/superset-frontend/src/dashboard/containers/Dashboard.ts
index 5f9b29b95d..15de5c255c 100644
--- a/superset-frontend/src/dashboard/containers/Dashboard.ts
+++ b/superset-frontend/src/dashboard/containers/Dashboard.ts
@@ -48,7 +48,6 @@ function mapStateToProps(state: RootState) {
} = state;
return {
- initMessages: dashboardInfo.common?.flash_messages,
timeout: dashboardInfo.common?.conf?.SUPERSET_WEBSERVER_TIMEOUT,
userId: dashboardInfo.userId,
dashboardInfo,
diff --git a/superset-frontend/src/dashboard/types.ts b/superset-frontend/src/dashboard/types.ts
index 4f28e72186..604f264540 100644
--- a/superset-frontend/src/dashboard/types.ts
+++ b/superset-frontend/src/dashboard/types.ts
@@ -117,7 +117,6 @@ export type DashboardState = {
export type DashboardInfo = {
id: number;
common: {
- flash_messages: string[];
conf: JsonObject;
};
userId: string;