fix(frontend): wrong notification key

The notification key 'editor.modal.permissions.error' was meant to be used with the ErrorToI18nKeyMapper as a base
which gets different suffixes added depending on the error code and not as a normal error code by itself.

Signed-off-by: Philip Molares <philip.molares@udo.edu>
This commit is contained in:
Philip Molares
2026-05-13 22:49:00 +02:00
committed by Erik Michelson
parent 3a4f2c8551
commit e852bef113
3 changed files with 51 additions and 7 deletions
@@ -17,6 +17,7 @@ import { Eye as IconEye, Pencil as IconPencil, SlashCircle as IconSlashCircle }
import { useTranslation } from 'react-i18next'
import { PermissionInconsistentAlert } from './permission-inconsistent-alert'
import { cypressId } from '../../../../../../utils/cypress-attribute'
import { ErrorToI18nKeyMapper } from '../../../../../../api/common/error-to-i18n-key-mapper'
export interface PermissionEntrySpecialGroupProps {
level: PermissionLevel
@@ -50,7 +51,13 @@ export const PermissionEntrySpecialGroup: React.FC<PermissionEntrySpecialGroupPr
.then((updatedPermissions) => {
setNotePermissionsFromServer(updatedPermissions)
})
.catch(showErrorNotificationBuilder('editor.modal.permissions.error'))
.catch((error) => {
const errorI18nKey = new ErrorToI18nKeyMapper(error, 'editor.modal.permissions.error')
.withHttpCode(404, 'missingUser')
.withHttpCode(403, 'missingPermissions')
.orFallbackI18nKey('other')
showErrorNotificationBuilder(errorI18nKey)(error)
})
}, [noteAlias, showErrorNotificationBuilder, type])
const onSetEntryWriteable = useCallback(() => {
@@ -61,7 +68,13 @@ export const PermissionEntrySpecialGroup: React.FC<PermissionEntrySpecialGroupPr
.then((updatedPermissions) => {
setNotePermissionsFromServer(updatedPermissions)
})
.catch(showErrorNotificationBuilder('editor.modal.permissions.error'))
.catch((error) => {
const errorI18nKey = new ErrorToI18nKeyMapper(error, 'editor.modal.permissions.error')
.withHttpCode(404, 'missingUser')
.withHttpCode(403, 'missingPermissions')
.orFallbackI18nKey('other')
showErrorNotificationBuilder(errorI18nKey)(error)
})
}, [noteAlias, showErrorNotificationBuilder, type])
const onSetEntryDenied = useCallback(() => {
@@ -72,7 +85,13 @@ export const PermissionEntrySpecialGroup: React.FC<PermissionEntrySpecialGroupPr
.then((updatedPermissions) => {
setNotePermissionsFromServer(updatedPermissions)
})
.catch(showErrorNotificationBuilder('editor.modal.permissions.error'))
.catch((error) => {
const errorI18nKey = new ErrorToI18nKeyMapper(error, 'editor.modal.permissions.error')
.withHttpCode(404, 'missingUser')
.withHttpCode(403, 'missingPermissions')
.orFallbackI18nKey('other')
showErrorNotificationBuilder(errorI18nKey)(error)
})
}, [noteAlias, showErrorNotificationBuilder, type])
const name = useMemo(() => {
@@ -18,6 +18,7 @@ import { PermissionInconsistentAlert } from './permission-inconsistent-alert'
import { useGetSpecialPermissions } from './hooks/use-get-special-permissions'
import { AsyncLoadingBoundary } from '../../../../../common/async-loading-boundary/async-loading-boundary'
import { UserAvatar } from '../../../../../common/user-avatar/user-avatar'
import { ErrorToI18nKeyMapper } from '../../../../../../api/common/error-to-i18n-key-mapper'
export interface PermissionEntryUserProps {
entry: NoteUserPermissionEntryInterface
@@ -53,7 +54,13 @@ export const PermissionEntryUser: React.FC<PermissionEntryUserProps & Permission
.then((updatedPermissions) => {
setNotePermissionsFromServer(updatedPermissions)
})
.catch(showErrorNotificationBuilder('editor.modal.permissions.error'))
.catch((error) => {
const errorI18nKey = new ErrorToI18nKeyMapper(error, 'editor.modal.permissions.error')
.withHttpCode(400, 'missingUser')
.withHttpCode(403, 'missingPermissions')
.orFallbackI18nKey('other')
showErrorNotificationBuilder(errorI18nKey)(error)
})
}, [noteAlias, entry.username, showErrorNotificationBuilder])
const onSetEntryReadOnly = useCallback(() => {
@@ -64,7 +71,13 @@ export const PermissionEntryUser: React.FC<PermissionEntryUserProps & Permission
.then((updatedPermissions) => {
setNotePermissionsFromServer(updatedPermissions)
})
.catch(showErrorNotificationBuilder('editor.modal.permissions.error'))
.catch((error) => {
const errorI18nKey = new ErrorToI18nKeyMapper(error, 'editor.modal.permissions.error')
.withHttpCode(404, 'missingUser')
.withHttpCode(403, 'missingPermissions')
.orFallbackI18nKey('other')
showErrorNotificationBuilder(errorI18nKey)(error)
})
}, [noteAlias, entry.username, showErrorNotificationBuilder])
const onSetEntryWriteable = useCallback(() => {
@@ -75,7 +88,13 @@ export const PermissionEntryUser: React.FC<PermissionEntryUserProps & Permission
.then((updatedPermissions) => {
setNotePermissionsFromServer(updatedPermissions)
})
.catch(showErrorNotificationBuilder('editor.modal.permissions.error'))
.catch((error) => {
const errorI18nKey = new ErrorToI18nKeyMapper(error, 'editor.modal.permissions.error')
.withHttpCode(404, 'missingUser')
.withHttpCode(403, 'missingPermissions')
.orFallbackI18nKey('other')
showErrorNotificationBuilder(errorI18nKey)(error)
})
}, [noteAlias, entry.username, showErrorNotificationBuilder])
const { value, loading, error } = useAsync(async () => {
@@ -11,6 +11,7 @@ import type { PermissionDisabledProps } from './permission-disabled.prop'
import React, { type ChangeEvent, Fragment, useCallback } from 'react'
import { Trans } from 'react-i18next'
import { Form, OverlayTrigger, Tooltip } from 'react-bootstrap'
import { ErrorToI18nKeyMapper } from '../../../../../../api/common/error-to-i18n-key-mapper'
/**
* Section in the permissions modal for managing whether the note should be visible on the explore page.
@@ -32,7 +33,12 @@ export const PermissionSectionVisibility: React.FC<PermissionDisabledProps> = ({
.then((updatedPermissions) => {
setNotePermissionsFromServer(updatedPermissions)
})
.catch(showErrorNotificationBuilder('editor.modal.permissions.error'))
.catch((error) => {
const errorI18nKey = new ErrorToI18nKeyMapper(error, 'editor.modal.permissions.error')
.withHttpCode(403, 'missingPermissions')
.orFallbackI18nKey('other')
showErrorNotificationBuilder(errorI18nKey)(error)
})
},
[noteAlias, showErrorNotificationBuilder]
)