translate manifest strings
This commit is contained in:
@@ -5,9 +5,13 @@ import { createExtensionApiByAlias } from '@umbraco-cms/backoffice/extension-reg
|
||||
import { umbConfirmModal } from '@umbraco-cms/backoffice/modal';
|
||||
import type { UmbDetailRepository, UmbItemRepository } from '@umbraco-cms/backoffice/repository';
|
||||
import { UMB_ACTION_EVENT_CONTEXT } from '@umbraco-cms/backoffice/action';
|
||||
import { UmbLocalizationController } from '@umbraco-cms/backoffice/localization-api';
|
||||
|
||||
type UmbLocalizeStringArgsMap = Record<string, Array<string>>;
|
||||
|
||||
export class UmbDeleteEntityAction extends UmbEntityActionBase<MetaEntityActionDeleteKind> {
|
||||
// TODO: make base type for item and detail models
|
||||
#localize = new UmbLocalizationController(this);
|
||||
|
||||
override async execute() {
|
||||
if (!this.args.unique) throw new Error('Cannot delete an item without a unique identifier.');
|
||||
@@ -21,10 +25,18 @@ export class UmbDeleteEntityAction extends UmbEntityActionBase<MetaEntityActionD
|
||||
const item = data?.[0];
|
||||
if (!item) throw new Error('Item not found.');
|
||||
|
||||
const headline = this.args.meta.confirm?.headline ?? '#actions_delete';
|
||||
const content = this.args.meta.confirm?.content ?? '#defaultdialogs_confirmdelete';
|
||||
const keysFromString = this.#localize.getKeysFromString(content);
|
||||
const argsMap: UmbLocalizeStringArgsMap = keysFromString.reduce((acc: UmbLocalizeStringArgsMap, key) => {
|
||||
acc[key] = [item.name];
|
||||
return acc;
|
||||
}, {});
|
||||
|
||||
// TODO: handle items with variants
|
||||
await umbConfirmModal(this._host, {
|
||||
headline: `Delete`,
|
||||
content: `Are you sure you want to delete ${item.name}?`,
|
||||
headline: this.#localize.string(headline),
|
||||
content: this.#localize.string(content, argsMap),
|
||||
color: 'danger',
|
||||
confirmLabel: 'Delete',
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user