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} />;
|
return <ExportDataPluginSheet onHide={onHide} />;
|
||||||
case ACTIVE_SHEET_SHARE_DATA:
|
case ACTIVE_SHEET_SHARE_DATA:
|
||||||
return (
|
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:
|
case ACTIVE_SHEET_SHARE_DATA_IN_FILE:
|
||||||
return this.props.share && this.props.share.type === 'file' ? (
|
return this.props.share && this.props.share.type === 'file' ? (
|
||||||
|
|||||||
@@ -196,7 +196,11 @@ function getTemplate(
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
store.dispatch(
|
store.dispatch(
|
||||||
setSelectPluginsToExportActiveSheet({type: 'file', file: file}),
|
setSelectPluginsToExportActiveSheet({
|
||||||
|
type: 'file',
|
||||||
|
file: file,
|
||||||
|
closeOnFinish: false,
|
||||||
|
}),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
@@ -208,7 +212,12 @@ function getTemplate(
|
|||||||
label: 'Sharable Link',
|
label: 'Sharable Link',
|
||||||
accelerator: 'CommandOrControl+Shift+E',
|
accelerator: 'CommandOrControl+Shift+E',
|
||||||
click: function() {
|
click: function() {
|
||||||
store.dispatch(setSelectPluginsToExportActiveSheet({type: 'link'}));
|
store.dispatch(
|
||||||
|
setSelectPluginsToExportActiveSheet({
|
||||||
|
type: 'link',
|
||||||
|
closeOnFinish: false,
|
||||||
|
}),
|
||||||
|
);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,7 +37,10 @@ type StateFromProps = {
|
|||||||
type DispatchFromProps = {
|
type DispatchFromProps = {
|
||||||
selectedPlugins: (payload: Array<string>) => void;
|
selectedPlugins: (payload: Array<string>) => void;
|
||||||
setActiveSheet: (payload: ActiveSheet) => void;
|
setActiveSheet: (payload: ActiveSheet) => void;
|
||||||
setExportDataToFileActiveSheet: (payload: string) => void;
|
setExportDataToFileActiveSheet: (payload: {
|
||||||
|
file: string;
|
||||||
|
closeOnFinish: boolean;
|
||||||
|
}) => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
type Props = OwnProps & StateFromProps & DispatchFromProps;
|
type Props = OwnProps & StateFromProps & DispatchFromProps;
|
||||||
@@ -61,7 +64,10 @@ class ExportDataPluginSheet extends Component<Props> {
|
|||||||
case 'file': {
|
case 'file': {
|
||||||
const file = share.file;
|
const file = share.file;
|
||||||
if (file) {
|
if (file) {
|
||||||
this.props.setExportDataToFileActiveSheet(file);
|
this.props.setExportDataToFileActiveSheet({
|
||||||
|
file,
|
||||||
|
closeOnFinish: true,
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
console.error('share.file is undefined');
|
console.error('share.file is undefined');
|
||||||
}
|
}
|
||||||
@@ -100,7 +106,10 @@ export default connect<StateFromProps, DispatchFromProps, OwnProps, Store>(
|
|||||||
setActiveSheet: (payload: ActiveSheet) => {
|
setActiveSheet: (payload: ActiveSheet) => {
|
||||||
dispatch(getActiveSheetAction(payload));
|
dispatch(getActiveSheetAction(payload));
|
||||||
},
|
},
|
||||||
setExportDataToFileActiveSheet: (payload: string) => {
|
setExportDataToFileActiveSheet: (payload: {
|
||||||
|
file: string;
|
||||||
|
closeOnFinish: boolean;
|
||||||
|
}) => {
|
||||||
dispatch(getExportDataToFileActiveSheetAction(payload));
|
dispatch(getExportDataToFileActiveSheetAction(payload));
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
|
|||||||
@@ -69,6 +69,7 @@ const ErrorMessage = styled(Text)({
|
|||||||
type Props = {
|
type Props = {
|
||||||
onHide: () => any;
|
onHide: () => any;
|
||||||
logger: Logger;
|
logger: Logger;
|
||||||
|
closeOnFinish: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
type State = {
|
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) {
|
renderPending(cancelAndHide: () => void, statusUpdate: string | null) {
|
||||||
return (
|
return (
|
||||||
<ShareSheetPendingDialog
|
<ShareSheetPendingDialog
|
||||||
@@ -182,9 +201,9 @@ export default class ShareSheetExportUrl extends Component<Props, State> {
|
|||||||
render() {
|
render() {
|
||||||
const cancelAndHide = () => {
|
const cancelAndHide = () => {
|
||||||
this.context.store.dispatch(unsetShare());
|
this.context.store.dispatch(unsetShare());
|
||||||
this.props.onHide();
|
this.hideSheet();
|
||||||
this.idler.cancel();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const {result, statusUpdate, errorArray} = this.state;
|
const {result, statusUpdate, errorArray} = this.state;
|
||||||
if (!result || !(result as DataExportResult).flipperUrl) {
|
if (!result || !(result as DataExportResult).flipperUrl) {
|
||||||
return this.renderPending(cancelAndHide, statusUpdate);
|
return this.renderPending(cancelAndHide, statusUpdate);
|
||||||
|
|||||||
@@ -63,6 +63,7 @@ type SubShareType =
|
|||||||
|
|
||||||
export type ShareType = {
|
export type ShareType = {
|
||||||
statusComponent?: React.ReactNode;
|
statusComponent?: React.ReactNode;
|
||||||
|
closeOnFinish: boolean;
|
||||||
} & SubShareType;
|
} & SubShareType;
|
||||||
|
|
||||||
export type State = {
|
export type State = {
|
||||||
@@ -99,7 +100,7 @@ export type Action =
|
|||||||
}
|
}
|
||||||
| {
|
| {
|
||||||
type: typeof ACTIVE_SHEET_SHARE_DATA_IN_FILE;
|
type: typeof ACTIVE_SHEET_SHARE_DATA_IN_FILE;
|
||||||
payload: {file: string};
|
payload: {file: string; closeOnFinish: boolean};
|
||||||
}
|
}
|
||||||
| {
|
| {
|
||||||
type: typeof ACTIVE_SHEET_SELECT_PLUGINS_TO_EXPORT;
|
type: typeof ACTIVE_SHEET_SELECT_PLUGINS_TO_EXPORT;
|
||||||
@@ -219,7 +220,11 @@ export default function reducer(
|
|||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
activeSheet: ACTIVE_SHEET_SHARE_DATA_IN_FILE,
|
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) {
|
} else if (action.type === ACTIVE_SHEET_SELECT_PLUGINS_TO_EXPORT) {
|
||||||
return {
|
return {
|
||||||
@@ -311,9 +316,12 @@ export const setSelectPluginsToExportActiveSheet = (
|
|||||||
payload,
|
payload,
|
||||||
});
|
});
|
||||||
|
|
||||||
export const setExportDataToFileActiveSheet = (file: string): Action => ({
|
export const setExportDataToFileActiveSheet = (payload: {
|
||||||
|
file: string;
|
||||||
|
closeOnFinish: boolean;
|
||||||
|
}): Action => ({
|
||||||
type: ACTIVE_SHEET_SHARE_DATA_IN_FILE,
|
type: ACTIVE_SHEET_SHARE_DATA_IN_FILE,
|
||||||
payload: {file},
|
payload: payload,
|
||||||
});
|
});
|
||||||
|
|
||||||
export const setActiveSheet = (payload: ActiveSheet): Action => ({
|
export const setActiveSheet = (payload: ActiveSheet): Action => ({
|
||||||
|
|||||||
Reference in New Issue
Block a user