From bc0b6e18883a0956b2d2a603dc6949b7c6bf8f7b Mon Sep 17 00:00:00 2001 From: Aakansha Doshi Date: Fri, 28 May 2021 02:10:33 +0530 Subject: [PATCH] refactor: rename UIOptions.canvasActions.saveScene to UIOptions.canvasActions.saveToActiveFile (#3657) * refactor rename action saveScene to saveFileToDisk * docs * fix * fix --- src/actions/actionExport.tsx | 4 ++-- src/actions/index.ts | 2 +- src/actions/types.ts | 2 +- src/components/BackgroundPickerAndDarkModeToggle.tsx | 2 +- src/constants.ts | 2 +- src/packages/excalidraw/CHANGELOG.md | 8 ++++---- src/packages/excalidraw/README_NEXT.md | 2 +- src/tests/excalidrawPackage.test.tsx | 6 ++++-- src/types.ts | 2 +- 9 files changed, 16 insertions(+), 14 deletions(-) diff --git a/src/actions/actionExport.tsx b/src/actions/actionExport.tsx index fee21782..a583bcb6 100644 --- a/src/actions/actionExport.tsx +++ b/src/actions/actionExport.tsx @@ -71,8 +71,8 @@ export const actionChangeExportEmbedScene = register({ ), }); -export const actionSaveScene = register({ - name: "saveScene", +export const actionSaveToActiveFile = register({ + name: "saveToActiveFile", perform: async (elements, appState, value) => { const fileHandleExists = !!appState.fileHandle; try { diff --git a/src/actions/index.ts b/src/actions/index.ts index f2bf2254..3c699da3 100644 --- a/src/actions/index.ts +++ b/src/actions/index.ts @@ -34,7 +34,7 @@ export { actionFinalize } from "./actionFinalize"; export { actionChangeProjectName, actionChangeExportBackground, - actionSaveScene, + actionSaveToActiveFile, actionSaveAsScene, actionLoadScene, } from "./actionExport"; diff --git a/src/actions/types.ts b/src/actions/types.ts index 97b7e1d5..eff523f9 100644 --- a/src/actions/types.ts +++ b/src/actions/types.ts @@ -66,7 +66,7 @@ export type ActionName = | "changeProjectName" | "changeExportBackground" | "changeExportEmbedScene" - | "saveScene" + | "saveToActiveFile" | "saveAsScene" | "loadScene" | "duplicateSelection" diff --git a/src/components/BackgroundPickerAndDarkModeToggle.tsx b/src/components/BackgroundPickerAndDarkModeToggle.tsx index 39185b4c..9e3adf4d 100644 --- a/src/components/BackgroundPickerAndDarkModeToggle.tsx +++ b/src/components/BackgroundPickerAndDarkModeToggle.tsx @@ -18,7 +18,7 @@ export const BackgroundPickerAndDarkModeToggle = ({ {showThemeBtn && actionManager.renderAction("toggleTheme")} {appState.fileHandle && (
- {actionManager.renderAction("saveScene")} + {actionManager.renderAction("saveToActiveFile")}
)} diff --git a/src/constants.ts b/src/constants.ts index 0911d7eb..1575a627 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -134,7 +134,7 @@ export const DEFAULT_UI_OPTIONS: AppProps["UIOptions"] = { export: true, loadScene: true, saveAsScene: true, - saveScene: true, + saveToActiveFile: true, theme: true, }, }; diff --git a/src/packages/excalidraw/CHANGELOG.md b/src/packages/excalidraw/CHANGELOG.md index 42e0cb49..80056e07 100644 --- a/src/packages/excalidraw/CHANGELOG.md +++ b/src/packages/excalidraw/CHANGELOG.md @@ -17,10 +17,10 @@ Please add the latest change on the top under the correct section. ### Refactor -#### BREAKING CHANGE - -- Removed `shouldAddWatermark: boolean` attribute from options for [export](https://github.com/excalidraw/excalidraw/blob/master/src/packages/excalidraw/README.md#export-utilities) APIs [#3639](https://github.com/excalidraw/excalidraw/pull/3639). -- Removed `appState.shouldAddWatermark` so in case you were passing `shouldAddWatermark` in [initialData.AppState](https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#L42) it will not work anymore. +- #### BREAKING CHANGE + - Rename `UIOptions.canvasActions.saveScene` to `UIOptions.canvasActions.saveToActiveFile`[#3657](https://github.com/excalidraw/excalidraw/pull/3657). + - Removed `shouldAddWatermark: boolean` attribute from options for [export](https://github.com/excalidraw/excalidraw/blob/master/src/packages/excalidraw/README.md#export-utilities) APIs [#3639](https://github.com/excalidraw/excalidraw/pull/3639). + - Removed `appState.shouldAddWatermark` so in case you were passing `shouldAddWatermark` in [initialData.AppState](https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#L42) it will not work anymore. ## 0.8.0 (2021-05-15) diff --git a/src/packages/excalidraw/README_NEXT.md b/src/packages/excalidraw/README_NEXT.md index 20d094ac..f1e5a612 100644 --- a/src/packages/excalidraw/README_NEXT.md +++ b/src/packages/excalidraw/README_NEXT.md @@ -574,7 +574,7 @@ This prop can be used to customise UI of Excalidraw. Currently we support custom | `export` | boolean | true | Implies whether to show `Export button` | | `loadScene` | boolean | true | Implies whether to show `Load button` | | `saveAsScene` | boolean | true | Implies whether to show `Save as button` | -| `saveScene` | boolean | true | Implies whether to show `Save button` | +| `saveToActiveFile` | boolean | true | Implies whether to show `Save button` to save to current file | | `theme` | boolean | true | Implies whether to show `Theme toggle` | #### `onPaste` diff --git a/src/tests/excalidrawPackage.test.tsx b/src/tests/excalidrawPackage.test.tsx index 83225226..f2149b12 100644 --- a/src/tests/excalidrawPackage.test.tsx +++ b/src/tests/excalidrawPackage.test.tsx @@ -186,9 +186,11 @@ describe("", () => { expect(queryByTestId(container, "save-as-button")).toBeNull(); }); - it("should hide save button when saveScene is false", async () => { + it("should hide save button when saveToActiveFile is false", async () => { const { container } = await render( - , + , ); expect(queryByTestId(container, "save-button")).toBeNull(); diff --git a/src/types.ts b/src/types.ts index 7df1d0ce..f33b465d 100644 --- a/src/types.ts +++ b/src/types.ts @@ -219,7 +219,7 @@ type CanvasActions = { export?: boolean; loadScene?: boolean; saveAsScene?: boolean; - saveScene?: boolean; + saveToActiveFile?: boolean; theme?: boolean; };