Files
pybricks-code/src/explorer/newFileWizard/actions.ts
T
David Lechner fad7b0114a explorer/newFileWizard: refactor
This refactors the new file wizard to be more independent. Most of the
control is now done through the saga instead of splitting it between
react and the sagas.

Also fix a few issues while we are touching this:
- pressing enter now accepts the dialog
- newly created file is now activated in the editor
2022-04-08 10:52:54 -05:00

43 lines
1.1 KiB
TypeScript

// SPDX-License-Identifier: MIT
// Copyright (c) 2022 The Pybricks Authors
import { createAction } from '../../actions';
import { pythonFileExtension } from '../../pybricksMicropython/lib';
/** Supported file extensions. */
type SupportedFileExtension = typeof pythonFileExtension;
/** Supported hub types. */
export enum Hub {
/** BOOST Move hub */
Move = 'movehub',
/** City hub */
City = 'cityhub',
/** Technic hub */
Technic = 'technichub',
/** MINDSTORMS Robot Inventor hub */
Inventor = 'inventorhub',
/** SPIKE Prime hub */
Prime = 'primehub',
/** SPIKE Essential hub */
Essential = 'essentialhub',
}
export const newFileWizardShow = createAction(() => ({
type: 'explorer.newFileWizard.action.show',
}));
export const newFileWizardDidAccept = createAction(
(fileName: string, fileExtension: SupportedFileExtension, hubType: Hub) => ({
type: 'explorer.newFileWizard.action.didAccept',
fileName,
fileExtension,
hubType,
}),
);
export const newFileWizardDidCancel = createAction(() => ({
type: 'explorer.newFileWizard.action.didCancel',
}));