Skip to content
This repository has been archived by the owner on Nov 22, 2024. It is now read-only.

Commit

Permalink
make sure at least one Plugin is selected
Browse files Browse the repository at this point in the history
Summary:
Selecting no plugins during Flipper file / link export would continue the export process but yield meaningless export files. Added validation something is selected

See https://fb.workplace.com/groups/flippersupport/permalink/1805444636602853/

Reviewed By: LukeDefeo

Differential Revision: D55467979

fbshipit-source-id: 331c70fc80817bc193bace44f16a0d29259a250b
  • Loading branch information
Michel Weststrate authored and facebook-github-bot committed Mar 28, 2024
1 parent 8b658dd commit e85a6a2
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
3 changes: 3 additions & 0 deletions desktop/flipper-plugin/src/ui/Dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ export const Dialog = {
select<T>({
defaultValue,
renderer,
onValidate,
...rest
}: {
defaultValue: T;
Expand All @@ -250,10 +251,12 @@ export const Dialog = {
onChange: (newValue: T) => void,
onCancel: () => void,
) => React.ReactElement;
onValidate?: (value: T) => string;
} & BaseDialogOptions): DialogResult<false | T> {
const handle = Dialog.show<T>({
...rest,
defaultValue,
onValidate,
children: (currentValue, setValue): React.ReactElement =>
renderer(currentValue, setValue, () => handle.close()),
});
Expand Down
2 changes: 1 addition & 1 deletion desktop/flipper-ui/src/chrome/ExportDataPluginSheet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class ExportDataPluginSheet extends Component<Props, {}> {
<Container>
<ListView
type="multiple"
title="Select the plugins for which you want to export the data"
title="Select the plugins of the currently active device / application for which you want to export the data"
leftPadding={8}
onChange={(selectedArray) => {
this.props.setSelectedPlugins(selectedArray);
Expand Down
2 changes: 2 additions & 0 deletions desktop/flipper-ui/src/utils/exportData.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -772,6 +772,8 @@ async function selectPlugins() {
return await Dialog.select<string[]>({
title: 'Select plugins to export',
defaultValue: [],
onValidate: (plugins) =>
plugins.length === 0 ? 'Please select at least one plugin.' : '',
renderer: (value, onChange, onCancel) => (
<ExportDataPluginSheet
onHide={onCancel}
Expand Down

0 comments on commit e85a6a2

Please sign in to comment.