A fully open source & end-to-end encrypted note taking alternative to Evernote.
TypeScript asp-net-coredotnet-coreelectronfosshacktoberfestnote-managmentnote-takingnote-taking-appnotebooknotesnotes-appopen-sourceopensourceprivacyproductivityreactreact-nativereactjsself-hosted
web: hide undo & redo buttons for readonly notes (#7541)
01zulfiada98fca93e3
diff --git a/apps/web/__e2e__/editor.test.ts b/apps/web/__e2e__/editor.test.tsindex 5f79ab377..d603233e8 100644--- a/apps/web/__e2e__/editor.test.ts+++ b/apps/web/__e2e__/editor.test.ts@@ -258,6 +258,21 @@ test("creating a new note and toggling read-only mode should not empty editor coexpect(await notes.editor.getContent("text")).toBe(NOTE.content);});+test("toggling read-only should hide undo & redo buttons", async ({ page }) => {+ const app = new AppModel(page);+ await app.goto();+ const notes = await app.goToNotes();+ const note = await notes.createNote(NOTE);++ await notes.editor.undoButton.waitFor({ state: "visible" });+ await notes.editor.redoButton.waitFor({ state: "visible" });+ await note?.properties.readonly();++ expect(await note?.properties.isReadonly()).toBeTruthy();+ expect(notes.editor.undoButton).not.toBeVisible();+ expect(notes.editor.redoButton).not.toBeVisible();+});+test("#1468 count words separated by newlines", async ({ page }) => {const app = new AppModel(page);await app.goto();diff --git a/apps/web/__e2e__/models/editor.model.ts b/apps/web/__e2e__/models/editor.model.tsindex bcaf2d572..9a7b82e08 100644--- a/apps/web/__e2e__/models/editor.model.ts+++ b/apps/web/__e2e__/models/editor.model.ts@@ -41,6 +41,8 @@ export class EditorModel {private readonly newTabButton: Locator;readonly savedIcon: Locator;readonly notSavedIcon: Locator;+ readonly undoButton: Locator;+ readonly redoButton: Locator;constructor(page: Page) {this.page = page;@@ -65,6 +67,8 @@ export class EditorModel {this.goBackButton = page.locator(getTestId("go-back"));this.goForwardButton = page.locator(getTestId("go-forward"));this.newTabButton = page.locator(getTestId("New tab"));+ this.undoButton = page.locator(getTestId("Undo"));+ this.redoButton = page.locator(getTestId("Redo"));}async waitForLoading(title?: string, content?: string) {diff --git a/apps/web/src/components/editor/action-bar.tsx b/apps/web/src/components/editor/action-bar.tsxindex fd07aa328..c35d2245b 100644--- a/apps/web/src/components/editor/action-bar.tsx+++ b/apps/web/src/components/editor/action-bar.tsx@@ -117,13 +117,15 @@ export function EditorActionBar() {title: strings.undo(),icon: Undo,enabled: editorManager?.canUndo,- onClick: () => editorManager?.editor?.undo()+ onClick: () => editorManager?.editor?.undo(),+ hidden: activeSession?.type === "readonly"},{title: strings.redo(),icon: Redo,enabled: editorManager?.canRedo,- onClick: () => editorManager?.editor?.redo()+ onClick: () => editorManager?.editor?.redo(),+ hidden: activeSession?.type === "readonly"},{title: isNotePublished ? strings.published() : strings.publish(),