fix(deletion-modal): include note title fallback

The note deletion modal previously only used the set title of
the note. This commit changes the dialog to use the result of
useNoteTitle() which contains a fallback string.

Signed-off-by: Erik Michelson <github@erik.michelson.eu>
This commit is contained in:
Erik Michelson 2023-06-30 15:22:27 +02:00
parent 2276b4205d
commit aacdc2a046
3 changed files with 6 additions and 6 deletions

View file

@ -16,7 +16,7 @@ describe('Delete note', () => {
}) })
cy.getByCypressId('sidebar.deleteNote.button').click() cy.getByCypressId('sidebar.deleteNote.button').click()
cy.getByCypressId('sidebar.deleteNote.modal').should('be.visible') cy.getByCypressId('sidebar.deleteNote.modal').should('be.visible')
cy.getByCypressId('sidebar.deleteNote.modal.noteTitle').should('be.visible').text().should('eq', '') cy.getByCypressId('sidebar.deleteNote.modal.noteTitle').should('be.visible').text().should('eq', 'Untitled')
cy.getByCypressId('deletionModal.confirmButton').should('be.visible').click() cy.getByCypressId('deletionModal.confirmButton').should('be.visible').click()
cy.getByCypressId('sidebar.deleteNote.modal').should('not.be.exist') cy.getByCypressId('sidebar.deleteNote.modal').should('not.be.exist')
cy.getByCypressId('notification-toast').should('not.exist') cy.getByCypressId('notification-toast').should('not.exist')
@ -28,7 +28,7 @@ describe('Delete note', () => {
}) })
cy.getByCypressId('sidebar.deleteNote.button').click() cy.getByCypressId('sidebar.deleteNote.button').click()
cy.getByCypressId('sidebar.deleteNote.modal').should('be.visible') cy.getByCypressId('sidebar.deleteNote.modal').should('be.visible')
cy.getByCypressId('sidebar.deleteNote.modal.noteTitle').should('be.visible').text().should('eq', '') cy.getByCypressId('sidebar.deleteNote.modal.noteTitle').should('be.visible').text().should('eq', 'Untitled')
cy.getByCypressId('deletionModal.confirmButton').should('be.visible').click() cy.getByCypressId('deletionModal.confirmButton').should('be.visible').click()
cy.getByCypressId('sidebar.deleteNote.modal').should('not.exist') cy.getByCypressId('sidebar.deleteNote.modal').should('not.exist')
cy.getByCypressId('notification-toast').should('be.visible') cy.getByCypressId('notification-toast').should('be.visible')

View file

@ -3,7 +3,7 @@
* *
* SPDX-License-Identifier: AGPL-3.0-only * SPDX-License-Identifier: AGPL-3.0-only
*/ */
import { useApplicationState } from '../../../../../hooks/common/use-application-state' import { useNoteTitle } from '../../../../../hooks/common/use-note-title'
import { Logger } from '../../../../../utils/logger' import { Logger } from '../../../../../utils/logger'
import { useUiNotifications } from '../../../../notifications/ui-notification-boundary' import { useUiNotifications } from '../../../../notifications/ui-notification-boundary'
import type { MessageTransporter } from '@hedgedoc/commons' import type { MessageTransporter } from '@hedgedoc/commons'
@ -21,7 +21,7 @@ const logger = new Logger('UseOnNoteDeleted')
*/ */
export const useOnNoteDeleted = (websocketConnection: MessageTransporter): void => { export const useOnNoteDeleted = (websocketConnection: MessageTransporter): void => {
const router = useRouter() const router = useRouter()
const noteTitle = useApplicationState((state) => state.noteDetails.title) const noteTitle = useNoteTitle()
const { dispatchUiNotification } = useUiNotifications() const { dispatchUiNotification } = useUiNotifications()
const noteDeletedHandler = useCallback(() => { const noteDeletedHandler = useCallback(() => {

View file

@ -3,7 +3,7 @@
* *
* SPDX-License-Identifier: AGPL-3.0-only * SPDX-License-Identifier: AGPL-3.0-only
*/ */
import { useApplicationState } from '../../../../../hooks/common/use-application-state' import { useNoteTitle } from '../../../../../hooks/common/use-note-title'
import { cypressId } from '../../../../../utils/cypress-attribute' import { cypressId } from '../../../../../utils/cypress-attribute'
import type { ModalVisibilityProps } from '../../../../common/modals/common-modal' import type { ModalVisibilityProps } from '../../../../common/modals/common-modal'
import { DeletionModal } from '../../../../common/modals/deletion-modal' import { DeletionModal } from '../../../../common/modals/deletion-modal'
@ -44,7 +44,7 @@ export const DeleteNoteModal: React.FC<DeleteNoteModalProps & DeleteHistoryNoteM
modalWarningI18nKey, modalWarningI18nKey,
modalButtonI18nKey modalButtonI18nKey
}) => { }) => {
const noteTitle = useApplicationState((state) => state.noteDetails.title) const noteTitle = useNoteTitle()
return ( return (
<DeletionModal <DeletionModal