From b454e3be035b8ba9d765ba65fee76bb5bb50fe72 Mon Sep 17 00:00:00 2001 From: Erik Michelson Date: Sun, 16 Apr 2023 22:21:29 +0200 Subject: [PATCH] enhancement(sidebar): move note info modal into sidebar Signed-off-by: Erik Michelson --- frontend/cypress/e2e/word-count.spec.ts | 18 +++--- frontend/locales/en.json | 26 ++++---- .../time-from-now.tsx | 2 +- .../document-infobar.tsx | 8 +-- .../sidebar-menu-info-entry.module.css | 14 +++++ .../sidebar-menu-info-entry.tsx | 46 ++++++++++++++ .../editor-page/sidebar/sidebar.tsx | 8 ++- .../note-info-line-created.tsx | 31 ---------- .../note-info-line-updated.tsx | 49 --------------- .../note-info-modal/note-info-line.tsx | 31 ---------- .../note-info-modal/note-info-modal.tsx | 51 ---------------- .../note-info-modal/note-info-time-line.ts | 8 --- .../note-info-modal/unitalic-bold-content.tsx | 33 ---------- .../utils/unitalic-bold-time-from-now.tsx | 17 ------ .../utils/unitalic-bold-trans.tsx | 20 ------- .../note-info-sidebar-entry.tsx | 38 ------------ .../note-info-line-contributors.tsx | 12 ++-- .../note-info-line-created-at.tsx | 27 +++++++++ .../note-info-line-updated-at.tsx | 27 +++++++++ .../note-info-line-updated-by.tsx | 34 +++++++++++ .../note-info-line-word-count.tsx | 22 +++---- .../note-info-sidebar-menu.tsx | 60 +++++++++++++++++++ .../components/editor-page/sidebar/types.ts | 3 +- 23 files changed, 258 insertions(+), 327 deletions(-) rename frontend/src/components/{editor-page/sidebar/specific-sidebar-entries/note-info-sidebar-entry/note-info-modal => common}/time-from-now.tsx (84%) create mode 100644 frontend/src/components/editor-page/sidebar/sidebar-menu-info-entry/sidebar-menu-info-entry.module.css create mode 100644 frontend/src/components/editor-page/sidebar/sidebar-menu-info-entry/sidebar-menu-info-entry.tsx delete mode 100644 frontend/src/components/editor-page/sidebar/specific-sidebar-entries/note-info-sidebar-entry/note-info-modal/note-info-line-created.tsx delete mode 100644 frontend/src/components/editor-page/sidebar/specific-sidebar-entries/note-info-sidebar-entry/note-info-modal/note-info-line-updated.tsx delete mode 100644 frontend/src/components/editor-page/sidebar/specific-sidebar-entries/note-info-sidebar-entry/note-info-modal/note-info-line.tsx delete mode 100644 frontend/src/components/editor-page/sidebar/specific-sidebar-entries/note-info-sidebar-entry/note-info-modal/note-info-modal.tsx delete mode 100644 frontend/src/components/editor-page/sidebar/specific-sidebar-entries/note-info-sidebar-entry/note-info-modal/note-info-time-line.ts delete mode 100644 frontend/src/components/editor-page/sidebar/specific-sidebar-entries/note-info-sidebar-entry/note-info-modal/unitalic-bold-content.tsx delete mode 100644 frontend/src/components/editor-page/sidebar/specific-sidebar-entries/note-info-sidebar-entry/note-info-modal/utils/unitalic-bold-time-from-now.tsx delete mode 100644 frontend/src/components/editor-page/sidebar/specific-sidebar-entries/note-info-sidebar-entry/note-info-modal/utils/unitalic-bold-trans.tsx delete mode 100644 frontend/src/components/editor-page/sidebar/specific-sidebar-entries/note-info-sidebar-entry/note-info-sidebar-entry.tsx rename frontend/src/components/editor-page/sidebar/specific-sidebar-entries/{note-info-sidebar-entry/note-info-modal => note-info-sidebar-menu/note-info-line}/note-info-line-contributors.tsx (61%) create mode 100644 frontend/src/components/editor-page/sidebar/specific-sidebar-entries/note-info-sidebar-menu/note-info-line/note-info-line-created-at.tsx create mode 100644 frontend/src/components/editor-page/sidebar/specific-sidebar-entries/note-info-sidebar-menu/note-info-line/note-info-line-updated-at.tsx create mode 100644 frontend/src/components/editor-page/sidebar/specific-sidebar-entries/note-info-sidebar-menu/note-info-line/note-info-line-updated-by.tsx rename frontend/src/components/editor-page/sidebar/specific-sidebar-entries/{note-info-sidebar-entry/note-info-modal => note-info-sidebar-menu/note-info-line}/note-info-line-word-count.tsx (77%) create mode 100644 frontend/src/components/editor-page/sidebar/specific-sidebar-entries/note-info-sidebar-menu/note-info-sidebar-menu.tsx diff --git a/frontend/cypress/e2e/word-count.spec.ts b/frontend/cypress/e2e/word-count.spec.ts index e07202a4c..f7c648615 100644 --- a/frontend/cypress/e2e/word-count.spec.ts +++ b/frontend/cypress/e2e/word-count.spec.ts @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file) + * SPDX-FileCopyrightText: 2023 The HedgeDoc developers (see AUTHORS file) * * SPDX-License-Identifier: AGPL-3.0-only */ @@ -11,32 +11,32 @@ describe('Test word count with', () => { it('empty note', () => { cy.setCodemirrorContent('') - cy.getByCypressId('sidebar-btn-document-info').click() - cy.getByCypressId('document-info-modal').should('be.visible') + cy.getByCypressId('sidebar-menu-info').click() + cy.getByCypressId('document-info-word-count').should('be.visible') cy.getByCypressId('document-info-word-count').contains('0') }) it('simple words', () => { cy.setCodemirrorContent('five words should be enough') cy.getMarkdownBody().contains('five words should be enough') - cy.getByCypressId('sidebar-btn-document-info').click() - cy.getByCypressId('document-info-modal').should('be.visible') + cy.getByCypressId('sidebar-menu-info').click() + cy.getByCypressId('document-info-word-count').should('be.visible') cy.getByCypressId('document-info-word-count').contains('5') }) it('excluded codeblocks', () => { cy.setCodemirrorContent('```\nthis is should be ignored\n```\n\ntwo `words`') cy.getMarkdownBody().contains('two words') - cy.getByCypressId('sidebar-btn-document-info').click() - cy.getByCypressId('document-info-modal').should('be.visible') + cy.getByCypressId('sidebar-menu-info').click() + cy.getByCypressId('document-info-word-count').should('be.visible') cy.getByCypressId('document-info-word-count').contains('2') }) it('excluded images', () => { cy.setCodemirrorContent('![ignored alt text](https://dummyimage.com/48) not ignored text') cy.getMarkdownBody().contains('not ignored text') - cy.getByCypressId('sidebar-btn-document-info').click() - cy.getByCypressId('document-info-modal').should('be.visible') + cy.getByCypressId('sidebar-menu-info').click() + cy.getByCypressId('document-info-word-count').should('be.visible') cy.getByCypressId('document-info-word-count').contains('3') }) }) diff --git a/frontend/locales/en.json b/frontend/locales/en.json index eef80afe9..2217d8934 100644 --- a/frontend/locales/en.json +++ b/frontend/locales/en.json @@ -383,20 +383,20 @@ "tagTime": "Time tag", "spoiler": "Spoiler" }, + "noteInfo": { + "title": "Note info", + "created": "Note created", + "lastUpdated": "Last updated", + "lastUpdatedBy": "Last updated by", + "contributors": "Count of contributors", + "wordCount": "Count of words" + }, "modal": { "snippetImport": { "title": "Import from Snippet", "selectProject": "Select From Available Projects", "selectSnippet": "Select From Available Snippets" }, - "documentInfo": { - "title": "Document info", - "created": "This note was created <0>", - "edited": "<0> was the last editor <1>", - "usersContributed": "<0> users contributed to this document", - "revisions": "<0> revisions are saved", - "words": "<0> words in document" - }, "gistImport": { "title": "Import from Gist", "insertGistUrl": "Paste your gist url hereā€¦" @@ -645,7 +645,7 @@ }, "cheatsheet": { "button": "Open Cheatsheet", - "modal":{ + "modal": { "popup": "Open in new tab", "title": "Cheatsheet", "headlines": { @@ -778,11 +778,11 @@ "example": "I :heart: :hedgehog:" }, "csv": { - "title" : "CSV", - "table" : { + "title": "CSV", + "table": { "title": "Table", - "description" : "You can render a CSV text as table by using a code block with `csv` as language. You must specify the delimiter.", - "example" : "```csv delimiter=;\nUsername; Identifier;First name;Last name\n\"booker12; rbooker\";9012;Rachel;Booker\ngrey07;2070;Laura;Grey\njohnson81;4081;Craig;Johnson\njenkins46;9346;Mary;Jenkins\nsmith79;5079;Jamie;Smith\n```" + "description": "You can render a CSV text as table by using a code block with `csv` as language. You must specify the delimiter.", + "example": "```csv delimiter=;\nUsername; Identifier;First name;Last name\n\"booker12; rbooker\";9012;Rachel;Booker\ngrey07;2070;Laura;Grey\njohnson81;4081;Craig;Johnson\njenkins46;9346;Mary;Jenkins\nsmith79;5079;Jamie;Smith\n```" }, "header": { "title": "Header", diff --git a/frontend/src/components/editor-page/sidebar/specific-sidebar-entries/note-info-sidebar-entry/note-info-modal/time-from-now.tsx b/frontend/src/components/common/time-from-now.tsx similarity index 84% rename from frontend/src/components/editor-page/sidebar/specific-sidebar-entries/note-info-sidebar-entry/note-info-modal/time-from-now.tsx rename to frontend/src/components/common/time-from-now.tsx index 0de3f0c46..69d157b5c 100644 --- a/frontend/src/components/editor-page/sidebar/specific-sidebar-entries/note-info-sidebar-entry/note-info-modal/time-from-now.tsx +++ b/frontend/src/components/common/time-from-now.tsx @@ -17,7 +17,7 @@ export interface TimeFromNowProps { */ export const TimeFromNow: React.FC = ({ time }) => { return ( -