Close export dialog autmatically for support form
Summary: This diff adds the support to close the dialog automatically for the support form. Reviewed By: passy Differential Revision: D17899862 fbshipit-source-id: 9d9cd14556a4cebe60f8cc1d082be3e439998e9c
This commit is contained in:
committed by
Facebook Github Bot
parent
4a8a4aabb6
commit
de17f3905b
@@ -93,7 +93,13 @@ export class App extends React.Component<Props> {
|
||||
return <ExportDataPluginSheet onHide={onHide} />;
|
||||
case ACTIVE_SHEET_SHARE_DATA:
|
||||
return (
|
||||
<ShareSheetExportUrl onHide={onHide} logger={this.props.logger} />
|
||||
<ShareSheetExportUrl
|
||||
onHide={onHide}
|
||||
logger={this.props.logger}
|
||||
closeOnFinish={
|
||||
this.props.share != null && this.props.share.closeOnFinish
|
||||
}
|
||||
/>
|
||||
);
|
||||
case ACTIVE_SHEET_SHARE_DATA_IN_FILE:
|
||||
return this.props.share && this.props.share.type === 'file' ? (
|
||||
|
||||
@@ -196,7 +196,11 @@ function getTemplate(
|
||||
return;
|
||||
}
|
||||
store.dispatch(
|
||||
setSelectPluginsToExportActiveSheet({type: 'file', file: file}),
|
||||
setSelectPluginsToExportActiveSheet({
|
||||
type: 'file',
|
||||
file: file,
|
||||
closeOnFinish: false,
|
||||
}),
|
||||
);
|
||||
},
|
||||
);
|
||||
@@ -208,7 +212,12 @@ function getTemplate(
|
||||
label: 'Sharable Link',
|
||||
accelerator: 'CommandOrControl+Shift+E',
|
||||
click: function() {
|
||||
store.dispatch(setSelectPluginsToExportActiveSheet({type: 'link'}));
|
||||
store.dispatch(
|
||||
setSelectPluginsToExportActiveSheet({
|
||||
type: 'link',
|
||||
closeOnFinish: false,
|
||||
}),
|
||||
);
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
@@ -37,7 +37,10 @@ type StateFromProps = {
|
||||
type DispatchFromProps = {
|
||||
selectedPlugins: (payload: Array<string>) => void;
|
||||
setActiveSheet: (payload: ActiveSheet) => void;
|
||||
setExportDataToFileActiveSheet: (payload: string) => void;
|
||||
setExportDataToFileActiveSheet: (payload: {
|
||||
file: string;
|
||||
closeOnFinish: boolean;
|
||||
}) => void;
|
||||
};
|
||||
|
||||
type Props = OwnProps & StateFromProps & DispatchFromProps;
|
||||
@@ -61,7 +64,10 @@ class ExportDataPluginSheet extends Component<Props> {
|
||||
case 'file': {
|
||||
const file = share.file;
|
||||
if (file) {
|
||||
this.props.setExportDataToFileActiveSheet(file);
|
||||
this.props.setExportDataToFileActiveSheet({
|
||||
file,
|
||||
closeOnFinish: true,
|
||||
});
|
||||
} else {
|
||||
console.error('share.file is undefined');
|
||||
}
|
||||
@@ -100,7 +106,10 @@ export default connect<StateFromProps, DispatchFromProps, OwnProps, Store>(
|
||||
setActiveSheet: (payload: ActiveSheet) => {
|
||||
dispatch(getActiveSheetAction(payload));
|
||||
},
|
||||
setExportDataToFileActiveSheet: (payload: string) => {
|
||||
setExportDataToFileActiveSheet: (payload: {
|
||||
file: string;
|
||||
closeOnFinish: boolean;
|
||||
}) => {
|
||||
dispatch(getExportDataToFileActiveSheetAction(payload));
|
||||
},
|
||||
}),
|
||||
|
||||
@@ -69,6 +69,7 @@ const ErrorMessage = styled(Text)({
|
||||
type Props = {
|
||||
onHide: () => any;
|
||||
logger: Logger;
|
||||
closeOnFinish: boolean;
|
||||
};
|
||||
|
||||
type State = {
|
||||
@@ -162,6 +163,24 @@ export default class ShareSheetExportUrl extends Component<Props, State> {
|
||||
}
|
||||
}
|
||||
|
||||
sheetHidden: boolean = false;
|
||||
|
||||
hideSheet = () => {
|
||||
this.sheetHidden = true;
|
||||
this.props.onHide();
|
||||
this.idler.cancel();
|
||||
};
|
||||
|
||||
componentDidUpdate() {
|
||||
const {result} = this.state;
|
||||
if (!result || !(result as DataExportResult).flipperUrl) {
|
||||
return;
|
||||
}
|
||||
if (!this.sheetHidden && this.props.closeOnFinish) {
|
||||
this.hideSheet();
|
||||
}
|
||||
}
|
||||
|
||||
renderPending(cancelAndHide: () => void, statusUpdate: string | null) {
|
||||
return (
|
||||
<ShareSheetPendingDialog
|
||||
@@ -182,9 +201,9 @@ export default class ShareSheetExportUrl extends Component<Props, State> {
|
||||
render() {
|
||||
const cancelAndHide = () => {
|
||||
this.context.store.dispatch(unsetShare());
|
||||
this.props.onHide();
|
||||
this.idler.cancel();
|
||||
this.hideSheet();
|
||||
};
|
||||
|
||||
const {result, statusUpdate, errorArray} = this.state;
|
||||
if (!result || !(result as DataExportResult).flipperUrl) {
|
||||
return this.renderPending(cancelAndHide, statusUpdate);
|
||||
|
||||
@@ -63,6 +63,7 @@ type SubShareType =
|
||||
|
||||
export type ShareType = {
|
||||
statusComponent?: React.ReactNode;
|
||||
closeOnFinish: boolean;
|
||||
} & SubShareType;
|
||||
|
||||
export type State = {
|
||||
@@ -99,7 +100,7 @@ export type Action =
|
||||
}
|
||||
| {
|
||||
type: typeof ACTIVE_SHEET_SHARE_DATA_IN_FILE;
|
||||
payload: {file: string};
|
||||
payload: {file: string; closeOnFinish: boolean};
|
||||
}
|
||||
| {
|
||||
type: typeof ACTIVE_SHEET_SELECT_PLUGINS_TO_EXPORT;
|
||||
@@ -219,7 +220,11 @@ export default function reducer(
|
||||
return {
|
||||
...state,
|
||||
activeSheet: ACTIVE_SHEET_SHARE_DATA_IN_FILE,
|
||||
share: {type: 'file', file: action.payload.file},
|
||||
share: {
|
||||
type: 'file',
|
||||
file: action.payload.file,
|
||||
closeOnFinish: action.payload.closeOnFinish,
|
||||
},
|
||||
};
|
||||
} else if (action.type === ACTIVE_SHEET_SELECT_PLUGINS_TO_EXPORT) {
|
||||
return {
|
||||
@@ -311,9 +316,12 @@ export const setSelectPluginsToExportActiveSheet = (
|
||||
payload,
|
||||
});
|
||||
|
||||
export const setExportDataToFileActiveSheet = (file: string): Action => ({
|
||||
export const setExportDataToFileActiveSheet = (payload: {
|
||||
file: string;
|
||||
closeOnFinish: boolean;
|
||||
}): Action => ({
|
||||
type: ACTIVE_SHEET_SHARE_DATA_IN_FILE,
|
||||
payload: {file},
|
||||
payload: payload,
|
||||
});
|
||||
|
||||
export const setActiveSheet = (payload: ActiveSheet): Action => ({
|
||||
|
||||
Reference in New Issue
Block a user