Skip to content

Commit

Permalink
chore: Move charts to src/pages folder (#22230)
Browse files Browse the repository at this point in the history
  • Loading branch information
EugeneTorap authored Jan 12, 2023
1 parent 5a422b3 commit 1a0de49
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 59 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ import { styledMount as mount } from 'spec/helpers/theming';
import Button from 'src/components/Button';
import { AsyncSelect } from 'src/components';
import {
AddSliceContainer,
AddSliceContainerProps,
AddSliceContainerState,
} from 'src/addSlice/AddSliceContainer';
ChartCreation,
ChartCreationProps,
ChartCreationState,
} from 'src/pages/ChartCreation';
import VizTypeGallery from 'src/explore/components/controls/VizTypeControl/VizTypeGallery';
import { act } from 'spec/helpers/testing-library';
import { UserWithPermissionsAndRoles } from 'src/types/bootstrapTypes';
Expand Down Expand Up @@ -70,15 +70,11 @@ const routeProps = {

async function getWrapper(user = mockUser) {
const wrapper = mount(
<AddSliceContainer
user={user}
addSuccessToast={() => null}
{...routeProps}
/>,
<ChartCreation user={user} addSuccessToast={() => null} {...routeProps} />,
) as unknown as ReactWrapper<
AddSliceContainerProps,
AddSliceContainerState,
AddSliceContainer
ChartCreationProps,
ChartCreationState,
ChartCreation
>;
await act(() => new Promise(resolve => setTimeout(resolve, 0)));
return wrapper;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,12 @@ type Dataset = {
datasource_type: string;
};

export interface AddSliceContainerProps extends RouteComponentProps {
export interface ChartCreationProps extends RouteComponentProps {
user: UserWithPermissionsAndRoles;
addSuccessToast: (arg: string) => void;
}

export type AddSliceContainerState = {
export type ChartCreationState = {
datasource?: { label: string; value: string };
datasetName?: string | string[] | null;
vizType: string | null;
Expand Down Expand Up @@ -215,11 +215,11 @@ const StyledStepDescription = styled.div`
`}
`;

export class AddSliceContainer extends React.PureComponent<
AddSliceContainerProps,
AddSliceContainerState
export class ChartCreation extends React.PureComponent<
ChartCreationProps,
ChartCreationState
> {
constructor(props: AddSliceContainerProps) {
constructor(props: ChartCreationProps) {
super(props);
this.state = {
vizType: null,
Expand Down Expand Up @@ -428,4 +428,4 @@ export class AddSliceContainer extends React.PureComponent<
}
}

export default withRouter(withToasts(AddSliceContainer));
export default withRouter(withToasts(ChartCreation));
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import { AntdDropdown } from 'src/components';
import { Menu } from 'src/components/Menu';
import FaveStar from 'src/components/FaveStar';
import FacePile from 'src/components/FacePile';
import { handleChartDelete, CardStyles } from '../utils';
import { handleChartDelete, CardStyles } from 'src/views/CRUD/utils';

interface ChartCardProps {
chart: Chart;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import userEvent from '@testing-library/user-event';
import { QueryParamProvider } from 'use-query-params';
import { act } from 'react-dom/test-utils';

import ChartList from 'src/views/CRUD/chart/ChartList';
import ChartList from 'src/pages/ChartList';
import ConfirmStatusChange from 'src/components/ConfirmStatusChange';
import ListView from 'src/components/ListView';
import PropertiesModal from 'src/explore/components/PropertiesModal';
Expand Down
28 changes: 0 additions & 28 deletions superset-frontend/src/views/CRUD/chart/types.ts

This file was deleted.

2 changes: 1 addition & 1 deletion superset-frontend/src/views/CRUD/welcome/ChartTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import {
PAGE_SIZE,
} from 'src/views/CRUD/utils';
import { LoadingCards } from 'src/views/CRUD/welcome/Welcome';
import ChartCard from 'src/views/CRUD/chart/ChartCard';
import ChartCard from 'src/pages/ChartList/ChartCard';
import Chart from 'src/types/Chart';
import handleResourceExport from 'src/utils/export';
import Loading from 'src/components/Loading';
Expand Down
13 changes: 4 additions & 9 deletions superset-frontend/src/views/routes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,9 @@ import React, { lazy } from 'react';
// not lazy loaded since this is the home page.
import Welcome from 'src/views/CRUD/welcome/Welcome';

const AddSliceContainer = lazy(
const ChartCreation = lazy(
() =>
import(
/* webpackChunkName: "AddSliceContainer" */ 'src/addSlice/AddSliceContainer'
),
import(/* webpackChunkName: "ChartCreation" */ 'src/pages/ChartCreation'),
);
const AnnotationLayersList = lazy(
() =>
Expand All @@ -46,10 +44,7 @@ const AnnotationList = lazy(
),
);
const ChartList = lazy(
() =>
import(
/* webpackChunkName: "ChartList" */ 'src/views/CRUD/chart/ChartList'
),
() => import(/* webpackChunkName: "ChartList" */ 'src/pages/ChartList'),
);
const CssTemplatesList = lazy(
() =>
Expand Down Expand Up @@ -139,7 +134,7 @@ export const routes: Routes = [
},
{
path: '/chart/add',
Component: AddSliceContainer,
Component: ChartCreation,
},
{
path: '/chart/list/',
Expand Down

0 comments on commit 1a0de49

Please sign in to comment.