From 99fd62100d9d2de3fc356804ccd72d676f26ced6 Mon Sep 17 00:00:00 2001 From: David Lechner Date: Wed, 27 May 2020 13:00:46 -0500 Subject: [PATCH] rename open and save as buttons --- src/actions/editor.ts | 10 +++++----- src/components/{LoadButton.tsx => OpenButton.tsx} | 2 +- src/components/{SaveButton.tsx => SaveAsButton.tsx} | 4 ++-- src/components/Toolbar.tsx | 8 ++++---- src/services/editor.ts | 6 +++--- 5 files changed, 15 insertions(+), 15 deletions(-) rename src/components/{LoadButton.tsx => OpenButton.tsx} (98%) rename src/components/{SaveButton.tsx => SaveAsButton.tsx} (94%) diff --git a/src/actions/editor.ts b/src/actions/editor.ts index 3c78ecda..98348da9 100644 --- a/src/actions/editor.ts +++ b/src/actions/editor.ts @@ -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; +export type EditorSaveAsAction = Action; /** * 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; diff --git a/src/components/LoadButton.tsx b/src/components/OpenButton.tsx similarity index 98% rename from src/components/LoadButton.tsx rename to src/components/OpenButton.tsx index 392aef63..5d9dad06 100644 --- a/src/components/LoadButton.tsx +++ b/src/components/OpenButton.tsx @@ -34,7 +34,7 @@ const mergeProps = ( ownProps: OwnProps, ): OpenFileButtonProps => ({ fileExtension: '.py', - tooltip: 'Load file', + tooltip: 'Open file', icon: openIcon, ...ownProps, ...stateProps, diff --git a/src/components/SaveButton.tsx b/src/components/SaveAsButton.tsx similarity index 94% rename from src/components/SaveButton.tsx rename to src/components/SaveAsButton.tsx index 844adb34..4444e643 100644 --- a/src/components/SaveButton.tsx +++ b/src/components/SaveAsButton.tsx @@ -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, diff --git a/src/components/Toolbar.tsx b/src/components/Toolbar.tsx index d701b438..58a930f3 100644 --- a/src/components/Toolbar.tsx +++ b/src/components/Toolbar.tsx @@ -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 ( - - + + diff --git a/src/services/editor.ts b/src/services/editor.ts index 44f3d50e..b4bfc2a5 100644 --- a/src/services/editor.ts +++ b/src/services/editor.ts @@ -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);