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: adding notes in tag/color should also add it to default notebook (#7732)
01zulfi85a5f3859008
diff --git a/apps/web/__e2e__/models/notebook-item.model.ts b/apps/web/__e2e__/models/notebook-item.model.tsindex 2d37c92f5..9ef686344 100644--- a/apps/web/__e2e__/models/notebook-item.model.ts+++ b/apps/web/__e2e__/models/notebook-item.model.ts@@ -98,4 +98,9 @@ export class NotebookItemModel extends BaseItemModel {await this.contextMenu.close();return state;}++ async setAsDefault() {+ await this.contextMenu.open(this.locator);+ await new ToggleModel(this.page, "menu-button-set-as-default").on();+ }}diff --git a/apps/web/__e2e__/notebooks.test.ts b/apps/web/__e2e__/notebooks.test.tsindex 0075494dd..468875ff3 100644--- a/apps/web/__e2e__/notebooks.test.ts+++ b/apps/web/__e2e__/notebooks.test.ts@@ -271,3 +271,86 @@ test(`sort notebooks`, async ({ page }, info) => {}}});++test("when default notebook is set, created note in notes context should go to default notebook", async ({+ page+}) => {+ const app = new AppModel(page);+ await app.goto();+ let notebooks = await app.goToNotebooks();+ let notebook = await notebooks.createNotebook(NOTEBOOK);+ await notebook?.setAsDefault();++ const notes = await app.goToNotes();+ await notes?.createNote(NOTE);+ notebooks = await app.goToNotebooks();+ notebook = await notebooks.findNotebook(NOTEBOOK);+ const openedNotebook = await notebook?.openNotebook();++ expect(await openedNotebook?.notes.findNote(NOTE)).toBeDefined();+});++test("when default notebook is set, created note in other notebook's context should not go to default notebook", async ({+ page+}) => {+ const app = new AppModel(page);+ await app.goto();+ let notebooks = await app.goToNotebooks();+ let notebook = await notebooks.createNotebook(NOTEBOOK);+ await notebook?.setAsDefault();++ const otherNotebook = await notebooks.createNotebook({+ title: "Other Notebook"+ });+ const openedOtherNotebook = await otherNotebook?.openNotebook();+ await openedOtherNotebook?.notes.createNote(NOTE);+ notebooks = await app.goToNotebooks();+ notebook = await notebooks.findNotebook(NOTEBOOK);+ const openedNotebook = await notebook?.openNotebook();++ expect(await openedNotebook?.notes.findNote(NOTE)).toBeUndefined();+});++test("when default notebook is set, created note in tags context should go to default notebook", async ({+ page+}) => {+ const app = new AppModel(page);+ await app.goto();+ let notebooks = await app.goToNotebooks();+ let notebook = await notebooks.createNotebook(NOTEBOOK);+ await notebook?.setAsDefault();++ const tags = await app.goToTags();+ const tag = await tags.createItem({ title: "TestTag" });+ const openedTag = await tag?.open();+ await openedTag?.createNote(NOTE);+ notebooks = await app.goToNotebooks();+ notebook = await notebooks.findNotebook(NOTEBOOK);+ const openedNotebook = await notebook?.openNotebook();++ expect(await openedNotebook?.notes.findNote(NOTE)).toBeDefined();+});++test("when default notebook is set, created note in colors context should go to default notebook", async ({+ page+}, info) => {+ info.setTimeout(2 * 60 * 1000);++ const coloredNote = { title: "Red note", content: NOTE.content };+ const app = new AppModel(page);+ await app.goto();+ let notebooks = await app.goToNotebooks();+ let notebook = await notebooks.createNotebook(NOTEBOOK);+ await notebook?.setAsDefault();++ const notes = await app.goToNotes();+ const note = await notes.createNote(NOTE);+ await note?.contextMenu.newColor(coloredNote);+ const color = await app.goToColor("red");+ await color?.createNote(coloredNote);+ notebooks = await app.goToNotebooks();+ notebook = await notebooks.findNotebook(NOTEBOOK);+ const openedNotebook = await notebook?.openNotebook();++ expect(await openedNotebook?.notes.findNote(coloredNote)).toBeDefined();+});diff --git a/apps/web/src/stores/editor-store.ts b/apps/web/src/stores/editor-store.tsindex 8a8e9f1d1..9ed54a412 100644--- a/apps/web/src/stores/editor-store.ts+++ b/apps/web/src/stores/editor-store.ts@@ -959,17 +959,20 @@ class EditorStore extends BaseStore<EditorStore> {if (currentSession.type === "new") {const context = useNoteStore.getState().context;+ const defaultNotebook = db.settings.getDefaultNotebook();if (context) {const { type } = context;if (type === "notebook")await db.notes.addToNotebook(context.id, note.id);- else if (type === "color" || type === "tag")+ else if (type === "color" || type === "tag") {await db.relations.add({ type, id: context.id },{ id: note.id, type: "note" });+ if (defaultNotebook)+ await db.notes.addToNotebook(defaultNotebook, note.id);+ }} else {- const defaultNotebook = db.settings.getDefaultNotebook();if (defaultNotebook)await db.notes.addToNotebook(defaultNotebook, note.id);}