feat(app): editor Général, Références and Vertèbres tabs, delete with dependents
This commit is contained in:
1 parent
6aba9711f0
commit
d163b2ce9a
24 files changed
+2239
-12
No files matched your search
@@ -0,0 +1,33 @@
|
||||
import type { CommitOutcome } from './state/editorTypes'
|
||||
|
||||
type Translate = (key: string) => string
|
||||
|
||||
const EDIT_KINDS: ReadonlySet<string> = new Set([
|
||||
'unknown_key',
|
||||
'duplicate_key',
|
||||
'invalid_target',
|
||||
'id_changed',
|
||||
'invalid_position',
|
||||
'too_deep',
|
||||
'has_dependents',
|
||||
])
|
||||
|
||||
/**
|
||||
* The words for a command that was not kept: the core's closed kind, or the store's
|
||||
* block. Never the core's detail text (it can echo document content).
|
||||
*/
|
||||
export function refusalMessage(
|
||||
t: Translate,
|
||||
outcome: Exclude<CommitOutcome, { ok: true }>,
|
||||
): string {
|
||||
if (outcome.reason === 'blocked') {
|
||||
return outcome.kind === 'recovery.pending'
|
||||
? t('editor.refusal.recovery')
|
||||
: t('editor.refusal.blocked')
|
||||
}
|
||||
if (outcome.reason !== 'core') return t('editor.refusal.blocked')
|
||||
const { kind } = outcome.failure
|
||||
return EDIT_KINDS.has(kind)
|
||||
? t(`editor.refusal.core.${kind}`)
|
||||
: t('editor.refusal.core.other').replace('{kind}', kind)
|
||||
}
|
||||
Reference in new issue
Block a user