mirror of
https://github.com/pybricks/pybricks-code.git
synced 2026-09-12 01:23:52 +00:00
rename open and save as buttons
This commit is contained in:
committed by
David Lechner
parent
9d789c13e1
commit
99fd62100d
@@ -12,7 +12,7 @@ export enum EditorActionType {
|
||||
/**
|
||||
* Save the current file to disk.
|
||||
*/
|
||||
Save = 'editor.action.save',
|
||||
SaveAs = 'editor.action.saveAs',
|
||||
/**
|
||||
* Open a file.
|
||||
*/
|
||||
@@ -36,13 +36,13 @@ export function setEditSession(
|
||||
/**
|
||||
* Action that saves the current file.
|
||||
*/
|
||||
export type EditorSaveAction = Action<EditorActionType.Save>;
|
||||
export type EditorSaveAsAction = Action<EditorActionType.SaveAs>;
|
||||
|
||||
/**
|
||||
* Creates an action to save the current file
|
||||
*/
|
||||
export function save(): EditorSaveAction {
|
||||
return { type: EditorActionType.Save };
|
||||
export function saveAs(): EditorSaveAsAction {
|
||||
return { type: EditorActionType.SaveAs };
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -64,4 +64,4 @@ export function open(data: ArrayBuffer): EditorOpenAction {
|
||||
/**
|
||||
* Common type for all editor actions.
|
||||
*/
|
||||
export type EditorAction = CurrentEditorAction | EditorOpenAction | EditorSaveAction;
|
||||
export type EditorAction = CurrentEditorAction | EditorOpenAction | EditorSaveAsAction;
|
||||
|
||||
@@ -34,7 +34,7 @@ const mergeProps = (
|
||||
ownProps: OwnProps,
|
||||
): OpenFileButtonProps => ({
|
||||
fileExtension: '.py',
|
||||
tooltip: 'Load file',
|
||||
tooltip: 'Open file',
|
||||
icon: openIcon,
|
||||
...ownProps,
|
||||
...stateProps,
|
||||
@@ -18,7 +18,7 @@ const mapStateToProps = (state: RootState): StateProps => ({
|
||||
|
||||
const mapDispatchToProps = (dispatch: Dispatch): DispatchProps => ({
|
||||
onAction: (): void => {
|
||||
dispatch(editor.save());
|
||||
dispatch(editor.saveAs());
|
||||
},
|
||||
});
|
||||
|
||||
@@ -27,7 +27,7 @@ const mergeProps = (
|
||||
dispatchProps: DispatchProps,
|
||||
ownProps: OwnProps,
|
||||
): ActionButtonProps => ({
|
||||
tooltip: 'Save file',
|
||||
tooltip: 'Download file',
|
||||
icon: downloadIcon,
|
||||
...ownProps,
|
||||
...stateProps,
|
||||
@@ -6,10 +6,10 @@ import ButtonGroup from 'react-bootstrap/ButtonGroup';
|
||||
import ButtonToolbar from 'react-bootstrap/ButtonToolbar';
|
||||
import BluetoothButton from './BluetoothButton';
|
||||
import FlashButton from './FlashButton';
|
||||
import LoadButton from './LoadButton';
|
||||
import OpenButton from './OpenButton';
|
||||
import ReplButton from './ReplButton';
|
||||
import RunButton from './RunButton';
|
||||
import SaveButton from './SaveButton';
|
||||
import SaveAsButton from './SaveAsButton';
|
||||
import StopButton from './StopButton';
|
||||
|
||||
class Toolbar extends React.Component {
|
||||
@@ -17,8 +17,8 @@ class Toolbar extends React.Component {
|
||||
return (
|
||||
<ButtonToolbar className="m-2">
|
||||
<ButtonGroup className="mr-2" size="lg">
|
||||
<LoadButton id="load" />
|
||||
<SaveButton id="save" />
|
||||
<OpenButton id="open" />
|
||||
<SaveAsButton id="saveAs" />
|
||||
</ButtonGroup>
|
||||
<ButtonGroup className="mr-2" size="lg">
|
||||
<BluetoothButton id="bluetooth" />
|
||||
|
||||
@@ -22,8 +22,8 @@ function open(action: Action, _dispatch: Dispatch, state: RootState): void {
|
||||
state.editor.current.getDocument().setValue(text);
|
||||
}
|
||||
|
||||
function save(action: Action, _dispatch: Dispatch, state: RootState): void {
|
||||
if (action.type !== EditorActionType.Save) {
|
||||
function saveAs(action: Action, _dispatch: Dispatch, state: RootState): void {
|
||||
if (action.type !== EditorActionType.SaveAs) {
|
||||
return;
|
||||
}
|
||||
// istanbul ignore next: currently, it is a bug if there is no current editor
|
||||
@@ -36,4 +36,4 @@ function save(action: Action, _dispatch: Dispatch, state: RootState): void {
|
||||
FileSaver.saveAs(blob, 'main.py');
|
||||
}
|
||||
|
||||
export default combineServices(open, save);
|
||||
export default combineServices(open, saveAs);
|
||||
|
||||
Reference in New Issue
Block a user