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

chore: Moves messageToasts to the components folder #14431

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
2 changes: 1 addition & 1 deletion superset-frontend/spec/fixtures/mockState.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/
import datasources from 'spec/fixtures/mockDatasource';
import messageToasts from 'spec/javascripts/messageToasts/mockMessageToasts';
import messageToasts from 'src/components/MessageToasts/mockMessageToasts';
import {
nativeFiltersInfo,
mockDataMaskInfo,
Expand Down
2 changes: 1 addition & 1 deletion superset-frontend/spec/fixtures/mockStateWithoutUser.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/
import datasources from 'spec/fixtures/mockDatasource';
import messageToasts from 'spec/javascripts/messageToasts/mockMessageToasts';
import messageToasts from 'src/components/MessageToasts/mockMessageToasts';
import {
nativeFiltersInfo,
mockDataMaskInfo,
Expand Down
2 changes: 1 addition & 1 deletion superset-frontend/spec/helpers/reducerIndex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import nativeFilters from 'src/dashboard/reducers/nativeFilters';
import datasources from 'src/dashboard/reducers/datasources';
import sliceEntities from 'src/dashboard/reducers/sliceEntities';
import dashboardLayout from 'src/dashboard/reducers/undoableDashboardLayout';
import messageToasts from 'src/messageToasts/reducers';
import messageToasts from 'src/components/MessageToasts/reducers';
import saveModal from 'src/explore/reducers/saveModalReducer';
import explore from 'src/explore/reducers/exploreReducer';
import sqlLab from 'src/SqlLab/reducers/sqlLab';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import {

import { setUnsavedChanges } from 'src/dashboard/actions/dashboardState';
import * as dashboardFilters from 'src/dashboard/actions/dashboardFilters';
import { ADD_TOAST } from 'src/messageToasts/actions';
import { ADD_TOAST } from 'src/components/MessageToasts/actions';

import {
DASHBOARD_GRID_TYPE,
Expand Down
30 changes: 0 additions & 30 deletions superset-frontend/spec/javascripts/messageToasts/.eslintrc

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import configureMockStore from 'redux-mock-store';
import thunk from 'redux-thunk';
import shortid from 'shortid';
import * as featureFlags from 'src/featureFlags';
import { ADD_TOAST } from 'src/messageToasts/actions';
import { ADD_TOAST } from 'src/components/MessageToasts/actions';
import * as actions from 'src/SqlLab/actions/sqlLab';
import { defaultQueryEditor, query } from '../fixtures';

Expand Down
8 changes: 4 additions & 4 deletions superset-frontend/src/SqlLab/actions/sqlLab.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ import invert from 'lodash/invert';
import mapKeys from 'lodash/mapKeys';
import { isFeatureEnabled, FeatureFlag } from 'src/featureFlags';

import { now } from '../../modules/dates';
import { now } from 'src/modules/dates';
import {
addDangerToast as addDangerToastAction,
addInfoToast as addInfoToastAction,
addSuccessToast as addSuccessToastAction,
addWarningToast as addWarningToastAction,
} from '../../messageToasts/actions/index';
import { getClientErrorObject } from '../../utils/getClientErrorObject';
import COMMON_ERR_MESSAGES from '../../utils/errorMessages';
} from 'src/components/MessageToasts/actions';
import { getClientErrorObject } from 'src/utils/getClientErrorObject';
import COMMON_ERR_MESSAGES from 'src/utils/errorMessages';

export const RESET_STATE = 'RESET_STATE';
export const ADD_QUERY_EDITOR = 'ADD_QUERY_EDITOR';
Expand Down
14 changes: 7 additions & 7 deletions superset-frontend/src/SqlLab/components/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,16 @@ import { connect } from 'react-redux';
import { t, supersetTheme, ThemeProvider } from '@superset-ui/core';
import { FeatureFlag, isFeatureEnabled } from 'src/featureFlags';
import throttle from 'lodash/throttle';
import TabbedSqlEditors from './TabbedSqlEditors';
import QueryAutoRefresh from './QueryAutoRefresh';
import QuerySearch from './QuerySearch';
import ToastPresenter from '../../messageToasts/containers/ToastPresenter';
import ToastContainer from 'src/components/MessageToasts/ToastContainer';
import {
LOCALSTORAGE_MAX_USAGE_KB,
LOCALSTORAGE_WARNING_THRESHOLD,
LOCALSTORAGE_WARNING_MESSAGE_THROTTLE_MS,
} from '../constants';
import * as Actions from '../actions/sqlLab';
} from 'src/SqlLab/constants';
import * as Actions from 'src/SqlLab/actions/sqlLab';
import TabbedSqlEditors from './TabbedSqlEditors';
import QueryAutoRefresh from './QueryAutoRefresh';
import QuerySearch from './QuerySearch';

class App extends React.PureComponent {
constructor(props) {
Expand Down Expand Up @@ -109,7 +109,7 @@ class App extends React.PureComponent {
<ThemeProvider theme={supersetTheme}>
<div className="App SqlLab">
{content}
<ToastPresenter />
<ToastContainer />
</div>
</ThemeProvider>
);
Expand Down
3 changes: 1 addition & 2 deletions superset-frontend/src/SqlLab/components/ShareSqlLabQuery.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,9 @@
*/
import React from 'react';
import { t, useTheme, styled } from '@superset-ui/core';

import Button from 'src/components/Button';
import withToasts from 'src/messageToasts/enhancers/withToasts';
import Icons from 'src/components/Icons';
import withToasts from 'src/components/MessageToasts/withToasts';
import CopyToClipboard from 'src/components/CopyToClipboard';
import { storeQuery } from 'src/utils/common';
import { getClientErrorObject } from 'src/utils/getClientErrorObject';
Expand Down
2 changes: 1 addition & 1 deletion superset-frontend/src/SqlLab/reducers/getInitialState.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/
import { t } from '@superset-ui/core';
import getToastsFromPyFlashMessages from '../../messageToasts/utils/getToastsFromPyFlashMessages';
import getToastsFromPyFlashMessages from 'src/components/MessageToasts/getToastsFromPyFlashMessages';

export default function getInitialState({
defaultDbId,
Expand Down
3 changes: 1 addition & 2 deletions superset-frontend/src/SqlLab/reducers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,9 @@
* under the License.
*/
import { combineReducers } from 'redux';

import messageToasts from 'src/components/MessageToasts/reducers';
import sqlLab from './sqlLab';
import localStorageUsageInKilobytes from './localStorageUsage';
import messageToasts from '../../messageToasts/reducers/index';
import common from './common';

export default combineReducers({
Expand Down
22 changes: 11 additions & 11 deletions superset-frontend/src/chart/chartAction.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import moment from 'moment';
import { t, SupersetClient } from '@superset-ui/core';
import { getControlsState } from 'src/explore/store';
import { isFeatureEnabled, FeatureFlag } from '../featureFlags';
import { isFeatureEnabled, FeatureFlag } from 'src/featureFlags';
import {
getAnnotationJsonUrl,
getExploreUrl,
Expand All @@ -30,19 +30,19 @@ import {
postForm,
shouldUseLegacyApi,
getChartDataUri,
} from '../explore/exploreUtils';
} from 'src/explore/exploreUtils';
import {
requiresQuery,
ANNOTATION_SOURCE_TYPES,
} from '../modules/AnnotationTypes';

import { addDangerToast } from '../messageToasts/actions';
import { logEvent } from '../logger/actions';
import { Logger, LOG_ACTIONS_LOAD_CHART } from '../logger/LogUtils';
import { getClientErrorObject } from '../utils/getClientErrorObject';
import { allowCrossDomain as domainShardingEnabled } from '../utils/hostNamesConfig';
import { updateDataMask } from '../dataMask/actions';
import { waitForAsyncData } from '../middleware/asyncEvent';
} from 'src/modules/AnnotationTypes';

import { addDangerToast } from 'src/components/MessageToasts/actions';
import { logEvent } from 'src/logger/actions';
import { Logger, LOG_ACTIONS_LOAD_CHART } from 'src/logger/LogUtils';
import { getClientErrorObject } from 'src/utils/getClientErrorObject';
import { allowCrossDomain as domainShardingEnabled } from 'src/utils/hostNamesConfig';
import { updateDataMask } from 'src/dataMask/actions';
import { waitForAsyncData } from 'src/middleware/asyncEvent';

export const CHART_UPDATE_STARTED = 'CHART_UPDATE_STARTED';
export function chartUpdateStarted(queryController, latestQueryFormData, key) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import React from 'react';
import { useTheme } from '@superset-ui/core';
import Button from 'src/components/Button';
import Icons from 'src/components/Icons';
import ToastPresenter from 'src/messageToasts/containers/ToastPresenter';
import ToastContainer from 'src/components/MessageToasts/ToastContainer';
import CopyToClipboard from '.';

export default {
Expand All @@ -39,7 +39,7 @@ export const InteractiveCopyToClipboard = ({ copyNode, ...rest }: any) => {
return (
<>
<CopyToClipboard copyNode={node} {...rest} />
<ToastPresenter />
<ToastContainer />
</>
);
};
Expand Down
2 changes: 1 addition & 1 deletion superset-frontend/src/components/CopyToClipboard/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import React from 'react';
import PropTypes from 'prop-types';
import { t } from '@superset-ui/core';
import { Tooltip } from 'src/components/Tooltip';
import withToasts from 'src/messageToasts/enhancers/withToasts';
import withToasts from 'src/components/MessageToasts/withToasts';
import copyTextToClipboard from 'src/utils/copy';

const propTypes = {
Expand Down
2 changes: 1 addition & 1 deletion superset-frontend/src/components/FlashProvider/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
import { useToasts } from 'src/messageToasts/enhancers/withToasts';
import { useToasts } from 'src/components/MessageToasts/withToasts';
import { useComponentDidMount } from 'src/common/hooks/useComponentDidMount';

type FlashMessageType = 'info' | 'alert' | 'danger' | 'warning' | 'success';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
import React from 'react';
import { mount } from 'enzyme';
import { ThemeProvider, supersetTheme } from '@superset-ui/core';
import Toast from 'src/messageToasts/components/Toast';
import Toast from 'src/components/MessageToasts/Toast';
import { act } from 'react-dom/test-utils';
import mockMessageToasts from '../mockMessageToasts';
import mockMessageToasts from './mockMessageToasts';

const props = {
toast: mockMessageToasts[0],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ import cx from 'classnames';
import Interweave from 'interweave';
import React, { useCallback, useEffect, useRef, useState } from 'react';
import Icons from 'src/components/Icons';
import { ToastType } from 'src/messageToasts/constants';
import { ToastMeta } from '../types';
import { ToastType, ToastMeta } from './types';

const ToastContainer = styled.div`
display: flex;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
*/
import { bindActionCreators } from 'redux';
import { connect } from 'react-redux';
import ToastPresenter from '../components/ToastPresenter';
import ToastPresenter from './ToastPresenter';

import { removeToast } from '../actions';
import { removeToast } from './actions';

export default connect(
({ messageToasts: toasts }) => ({ toasts }),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,9 @@
*/
import React from 'react';
import { shallow } from 'enzyme';
import Toast from 'src/messageToasts/components/Toast';
import ToastPresenter from 'src/messageToasts/components/ToastPresenter';

import mockMessageToasts from '../mockMessageToasts';
import Toast from 'src/components/MessageToasts/Toast';
import ToastPresenter from 'src/components/MessageToasts/ToastPresenter';
import mockMessageToasts from './mockMessageToasts';

describe('ToastPresenter', () => {
const props = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/
import React from 'react';
import { styled } from '@superset-ui/core';
import { ToastMeta } from 'src/messageToasts/types';
import { ToastMeta } from 'src/components/MessageToasts/types';
import Toast from './Toast';

const StyledToastPresenter = styled.div`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/
import shortid from 'shortid';
import { ToastType, ToastMeta } from '../types';
import { ToastType, ToastMeta } from './types';

type ToastOptions = Partial<Omit<ToastMeta, 'id' | 'toastType' | 'text'>>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
* specific language governing permissions and limitations
* under the License.
*/
import { addToast } from '../actions';
import { ToastType } from '../constants';
import { addToast } from './actions';
import { ToastType } from './types';

export default function toastsFromPyFlashMessages(flashMessages = []) {
const toasts = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@
* specific language governing permissions and limitations
* under the License.
*/
import { ToastType } from 'src/messageToasts/constants';

import getToastsFromPyFlashMessages from 'src/messageToasts/utils/getToastsFromPyFlashMessages';
import { ToastType } from 'src/components/MessageToasts/types';
import getToastsFromPyFlashMessages from 'src/components/MessageToasts/getToastsFromPyFlashMessages';

describe('getToastsFromPyFlashMessages', () => {
it('should return an info toast', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
import { ToastType } from 'src/messageToasts/constants';
import { ToastType } from 'src/components/MessageToasts/types';

export default [
{ id: 'info_id', toastType: ToastType.INFO, text: 'info toast' },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
import { ADD_TOAST, REMOVE_TOAST } from '../actions';
import { ADD_TOAST, REMOVE_TOAST } from './actions';

export default function messageToastsReducer(toasts = [], action) {
switch (action.type) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
* specific language governing permissions and limitations
* under the License.
*/
import { ADD_TOAST, REMOVE_TOAST } from 'src/messageToasts/actions';
import messageToastsReducer from 'src/messageToasts/reducers';
import { ADD_TOAST, REMOVE_TOAST } from 'src/components/MessageToasts/actions';
import messageToastsReducer from 'src/components/MessageToasts/reducers';

describe('messageToasts reducer', () => {
it('should return initial state', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import {
addInfoToast,
addSuccessToast,
addWarningToast,
} from '../actions';
} from './actions';

export interface ToastProps {
addDangerToast: typeof addDangerToast;
Expand Down
2 changes: 1 addition & 1 deletion superset-frontend/src/components/ReportModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import { AlertObject } from 'src/views/CRUD/alert/types';
import TimezoneSelector from 'src/components/TimezoneSelector';
import LabeledErrorBoundInput from 'src/components/Form/LabeledErrorBoundInput';
import Icons from 'src/components/Icons';
import withToasts from 'src/messageToasts/enhancers/withToasts';
import withToasts from 'src/components/MessageToasts/withToasts';
import { CronError } from 'src/components/CronPicker';
import { RadioChangeEvent } from 'src/common/components';
import {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { render, screen } from 'spec/helpers/testing-library';
import { Provider } from 'react-redux';
import fetchMock from 'fetch-mock';
import { storeWithState } from 'spec/fixtures/mockStore';
import ToastPresenter from 'src/messageToasts/containers/ToastPresenter';
import ToastContainer from 'src/components/MessageToasts/ToastContainer';
import TableLoader, { TableLoaderProps } from '.';

fetchMock.get('glob:*/api/v1/mock', [
Expand All @@ -38,7 +38,7 @@ function renderWithProps(props: TableLoaderProps = defaultProps) {
return render(
<Provider store={storeWithState({})}>
<TableLoader {...props} />
<ToastPresenter />
<ToastContainer />
</Provider>,
);
}
Expand Down
2 changes: 1 addition & 1 deletion superset-frontend/src/components/TableLoader/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import React, { useState, useEffect, useMemo } from 'react';
import { t, SupersetClient, JsonObject } from '@superset-ui/core';
import TableView, { EmptyWrapperType } from 'src/components/TableView';
import withToasts from 'src/messageToasts/enhancers/withToasts';
import withToasts from 'src/components/MessageToasts/withToasts';
import Loading from 'src/components/Loading';
import 'stylesheets/reactable-pagination.less';

Expand Down
Loading