Cleaning up sheet abstraction to use Ant/flipper-plugin dialogs instead
Summary: This diff cleans up order remaining dialogs, the ones involved in exporting to file or url. Includes some legacy component cleanup boyscouting, but not too much. This removes a lot of code where state of the wizard was stored globally, and makes it locally instead. Other code that was removed involves interaction with the old UI, which allowed import / export to be running in the background as well. (which is no longer needed since we optimised the process) Reviewed By: timur-valiev Differential Revision: D30192000 fbshipit-source-id: 13be883c5bf217a3d58b610b78516359e9bd0ebc
This commit is contained in:
committed by
Facebook GitHub Bot
parent
9e5575cf69
commit
d56375970d
@@ -9,42 +9,22 @@
|
||||
|
||||
import {connect} from 'react-redux';
|
||||
import React, {Component} from 'react';
|
||||
import {ShareType} from '../reducers/application';
|
||||
import {State as Store} from '../reducers';
|
||||
import {ActiveSheet} from '../reducers/application';
|
||||
import {selectedPlugins as actionForSelectedPlugins} from '../reducers/plugins';
|
||||
import {
|
||||
ACTIVE_SHEET_SHARE_DATA,
|
||||
setActiveSheet as getActiveSheetAction,
|
||||
setExportDataToFileActiveSheet as getExportDataToFileActiveSheetAction,
|
||||
} from '../reducers/application';
|
||||
import ListView from './ListView';
|
||||
import {Dispatch, Action} from 'redux';
|
||||
import {unsetShare} from '../reducers/application';
|
||||
import {FlexColumn, styled} from '../ui';
|
||||
import {getExportablePlugins} from '../selectors/connections';
|
||||
|
||||
type OwnProps = {
|
||||
onHide: () => void;
|
||||
selectedPlugins: Array<string>;
|
||||
setSelectedPlugins: (plugins: string[]) => void;
|
||||
};
|
||||
|
||||
type StateFromProps = {
|
||||
share: ShareType | null;
|
||||
selectedPlugins: Array<string>;
|
||||
availablePluginsToExport: Array<{id: string; label: string}>;
|
||||
};
|
||||
|
||||
type DispatchFromProps = {
|
||||
setSelectedPlugins: (payload: Array<string>) => void;
|
||||
setActiveSheet: (payload: ActiveSheet) => void;
|
||||
setExportDataToFileActiveSheet: (payload: {
|
||||
file: string;
|
||||
closeOnFinish: boolean;
|
||||
}) => void;
|
||||
unsetShare: () => void;
|
||||
};
|
||||
|
||||
type Props = OwnProps & StateFromProps & DispatchFromProps;
|
||||
type Props = OwnProps & StateFromProps;
|
||||
|
||||
const Container = styled(FlexColumn)({
|
||||
maxHeight: 700,
|
||||
@@ -53,78 +33,27 @@ const Container = styled(FlexColumn)({
|
||||
|
||||
class ExportDataPluginSheet extends Component<Props, {}> {
|
||||
render() {
|
||||
const {onHide} = this.props;
|
||||
const onHideWithUnsettingShare = () => {
|
||||
this.props.unsetShare();
|
||||
onHide();
|
||||
};
|
||||
return (
|
||||
<Container>
|
||||
<ListView
|
||||
type="multiple"
|
||||
title="Select the plugins for which you want to export the data"
|
||||
leftPadding={8}
|
||||
onSubmit={() => {
|
||||
const {share} = this.props;
|
||||
if (!share) {
|
||||
console.error(
|
||||
'applications.share is undefined, whereas it was expected to be defined',
|
||||
);
|
||||
} else {
|
||||
switch (share.type) {
|
||||
case 'link':
|
||||
this.props.setActiveSheet(ACTIVE_SHEET_SHARE_DATA);
|
||||
break;
|
||||
case 'file': {
|
||||
const file = share.file;
|
||||
if (file) {
|
||||
this.props.setExportDataToFileActiveSheet({
|
||||
file,
|
||||
closeOnFinish: true,
|
||||
});
|
||||
} else {
|
||||
console.error('share.file is undefined');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}}
|
||||
onChange={(selectedArray) => {
|
||||
this.props.setSelectedPlugins(selectedArray);
|
||||
}}
|
||||
elements={this.props.availablePluginsToExport}
|
||||
selectedElements={new Set(this.props.selectedPlugins)}
|
||||
onHide={onHideWithUnsettingShare}
|
||||
onHide={() => {}}
|
||||
/>
|
||||
</Container>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default connect<StateFromProps, DispatchFromProps, OwnProps, Store>(
|
||||
(state) => {
|
||||
const availablePluginsToExport = getExportablePlugins(state);
|
||||
return {
|
||||
share: state.application.share,
|
||||
selectedPlugins: state.plugins.selectedPlugins,
|
||||
availablePluginsToExport,
|
||||
};
|
||||
},
|
||||
(dispatch: Dispatch<Action<any>>) => ({
|
||||
setSelectedPlugins: (plugins: Array<string>) => {
|
||||
dispatch(actionForSelectedPlugins(plugins));
|
||||
},
|
||||
setActiveSheet: (payload: ActiveSheet) => {
|
||||
dispatch(getActiveSheetAction(payload));
|
||||
},
|
||||
setExportDataToFileActiveSheet: (payload: {
|
||||
file: string;
|
||||
closeOnFinish: boolean;
|
||||
}) => {
|
||||
dispatch(getExportDataToFileActiveSheetAction(payload));
|
||||
},
|
||||
unsetShare: () => {
|
||||
dispatch(unsetShare());
|
||||
},
|
||||
}),
|
||||
)(ExportDataPluginSheet);
|
||||
export default connect<StateFromProps, {}, OwnProps, Store>((state) => {
|
||||
const availablePluginsToExport = getExportablePlugins(state);
|
||||
return {
|
||||
availablePluginsToExport,
|
||||
};
|
||||
})(ExportDataPluginSheet);
|
||||
|
||||
Reference in New Issue
Block a user