Skip to content

Commit d4cfe4d

Browse files
authored
Merge pull request #18183 from umbraco/15.2/hotfix/clipboard-delete-confirm-dialog
Hotfix: Clipboard confirm delete labels
2 parents 9c6e3ff + 4dfe421 commit d4cfe4d

File tree

10 files changed

+50
-15
lines changed

10 files changed

+50
-15
lines changed

src/Umbraco.Web.UI.Client/src/assets/lang/da-dk.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,7 @@ export default {
478478
anchorLinkPicker: 'Lokalt link / querystreng',
479479
anchorInsert: 'Navn på lokalt link',
480480
closeThisWindow: 'Luk denne dialog',
481-
confirmdelete: 'Er du sikker på at du vil slette',
481+
confirmdelete: (name: string) => `Er du sikker på at du vil slette${name ? ` <strong>${name}</strong>` : ''}?`,
482482
confirmdisable: 'Er du sikker på du vil deaktivere',
483483
confirmremove: 'Er du sikker på at du vil fjerne',
484484
confirmremoveusageof: 'Er du sikker på du vil fjerne brugen af <strong>%0%</strong>',
@@ -2249,6 +2249,8 @@ export default {
22492249
labelForRemoveAllEntries: 'Fjern alle elementer',
22502250
labelForClearClipboard: 'Ryd udklipsholder',
22512251
labelForCopyToClipboard: 'Kopier til udklipsholder',
2252+
confirmDeleteHeadline: 'Slet fra udklipsholderen',
2253+
confirmDeleteDescription: 'Er du sikker på at du vil slette <strong>{0}</strong> fra udklipsholderen?',
22522254
},
22532255
propertyActions: {
22542256
tooltipForPropertyActionsMenu: 'Åben egenskabshandlinger',

src/Umbraco.Web.UI.Client/src/assets/lang/en-us.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,6 @@ export default {
508508
anchorLinkPicker: 'Anchor or querystring',
509509
anchorInsert: 'Name',
510510
closeThisWindow: 'Close this window',
511-
confirmdelete: 'Are you sure you want to delete',
512511
confirmdeleteNumberOfItems: 'Are you sure you want to delete <strong>%0%</strong> of <strong>%1%</strong> items',
513512
confirmdisable: 'Are you sure you want to disable',
514513
confirmremove: 'Are you sure you want to remove',

src/Umbraco.Web.UI.Client/src/assets/lang/en.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -497,7 +497,7 @@ export default {
497497
anchorLinkPicker: 'Anchor or querystring',
498498
anchorInsert: 'Name',
499499
closeThisWindow: 'Close this window',
500-
confirmdelete: 'Are you sure you want to delete',
500+
confirmdelete: (name: string) => `Are you sure you want to delete${name ? ` <strong>${name}</strong>` : ''}?`,
501501
confirmdeleteNumberOfItems: 'Are you sure you want to delete <strong>%0%</strong> of <strong>%1%</strong> items',
502502
confirmdisable: 'Are you sure you want to disable',
503503
confirmremove: 'Are you sure you want to remove',
@@ -2388,6 +2388,8 @@ export default {
23882388
labelForRemoveAllEntries: 'Remove all items',
23892389
labelForClearClipboard: 'Clear clipboard',
23902390
labelForCopyToClipboard: 'Copy to clipboard',
2391+
confirmDeleteHeadline: 'Delete from clipboard',
2392+
confirmDeleteDescription: 'Are you sure you want to delete <strong>{0}</strong> from the clipboard?',
23912393
},
23922394
propertyActions: {
23932395
tooltipForPropertyActionsMenu: 'Open Property Actions',

src/Umbraco.Web.UI.Client/src/libs/localization-api/localization.controller.test.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,20 @@ describe('UmbLocalizeController', () => {
302302
expect(controller.string({})).to.equal('');
303303
expect(controller.string(undefined)).to.equal('');
304304
});
305+
306+
it('should return an empty string if the input is an empty string', async () => {
307+
expect(controller.string('')).to.equal('');
308+
});
309+
310+
it('should return the input string if the input is not prefixed with a #', async () => {
311+
const str = 'close';
312+
expect(controller.string(str)).to.equal('close');
313+
});
314+
315+
it('should replace tokens in each key with the provided args', async () => {
316+
const str = '#withInlineToken #withInlineTokenLegacy';
317+
expect(controller.string(str, 'value1', 'value2')).to.equal('value1 value2 value1 value2');
318+
});
305319
});
306320

307321
describe('host element', () => {

src/Umbraco.Web.UI.Client/src/libs/localization-api/localization.controller.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -191,9 +191,10 @@ export class UmbLocalizationController<LocalizationSetType extends UmbLocalizati
191191
* If the term is found in the localization set, it will be replaced with the localized term.
192192
* If the term is not found, the original term will be returned.
193193
* @param {string} text The text to translate.
194+
* @param {...any} args The arguments to parse for this localization entry.
194195
* @returns {string} The translated text.
195196
*/
196-
string(text: unknown): string {
197+
string(text: unknown, ...args: any): string {
197198
if (typeof text !== 'string') {
198199
return '';
199200
}
@@ -203,10 +204,10 @@ export class UmbLocalizationController<LocalizationSetType extends UmbLocalizati
203204

204205
const localizedText = text.replace(regex, (match: string) => {
205206
const key = match.slice(1);
206-
// TODO: find solution to pass dynamic string to term
207+
207208
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
208209
// @ts-ignore
209-
const localized = this.term(key);
210+
const localized = this.term(key, ...args);
210211
// we didn't find a localized string, so we return the original string with the #
211212
return localized === key ? match : localized;
212213
});

src/Umbraco.Web.UI.Client/src/packages/clipboard/clipboard-entry/detail/manifests.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,15 @@ export const manifests: Array<UmbExtensionManifest> = [
1919
type: 'entityAction',
2020
kind: 'delete',
2121
alias: 'Umb.EntityAction.ClipboardEntry.Delete',
22-
name: 'Delete Dictionary Entry Entity Action',
22+
name: 'Delete Clipboard Entry Entity Action',
2323
forEntityTypes: [UMB_CLIPBOARD_ENTRY_ENTITY_TYPE],
2424
meta: {
2525
itemRepositoryAlias: UMB_CLIPBOARD_ENTRY_ITEM_REPOSITORY_ALIAS,
2626
detailRepositoryAlias: UMB_CLIPBOARD_ENTRY_DETAIL_REPOSITORY_ALIAS,
27+
confirm: {
28+
headline: '#clipboard_confirmDeleteHeadline',
29+
message: '#clipboard_confirmDeleteDescription',
30+
},
2731
},
2832
},
2933
];

src/Umbraco.Web.UI.Client/src/packages/core/entity-action/common/delete/delete.action.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@ import { createExtensionApiByAlias } from '@umbraco-cms/backoffice/extension-reg
55
import { umbConfirmModal } from '@umbraco-cms/backoffice/modal';
66
import type { UmbDetailRepository, UmbItemRepository } from '@umbraco-cms/backoffice/repository';
77
import { UMB_ACTION_EVENT_CONTEXT } from '@umbraco-cms/backoffice/action';
8+
import { UmbLocalizationController } from '@umbraco-cms/backoffice/localization-api';
89

910
export class UmbDeleteEntityAction extends UmbEntityActionBase<MetaEntityActionDeleteKind> {
1011
// TODO: make base type for item and detail models
12+
#localize = new UmbLocalizationController(this);
1113

1214
override async execute() {
1315
if (!this.args.unique) throw new Error('Cannot delete an item without a unique identifier.');
@@ -21,12 +23,15 @@ export class UmbDeleteEntityAction extends UmbEntityActionBase<MetaEntityActionD
2123
const item = data?.[0];
2224
if (!item) throw new Error('Item not found.');
2325

26+
const headline = this.args.meta.confirm?.headline ?? '#actions_delete';
27+
const message = this.args.meta.confirm?.message ?? '#defaultdialogs_confirmdelete';
28+
2429
// TODO: handle items with variants
2530
await umbConfirmModal(this._host, {
26-
headline: `Delete`,
27-
content: `Are you sure you want to delete ${item.name}?`,
31+
headline,
32+
content: this.#localize.string(message, item.name),
2833
color: 'danger',
29-
confirmLabel: 'Delete',
34+
confirmLabel: '#general_delete',
3035
});
3136

3237
const detailRepository = await createExtensionApiByAlias<UmbDetailRepository<any>>(

src/Umbraco.Web.UI.Client/src/packages/core/entity-action/common/delete/types.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ export interface ManifestEntityActionDeleteKind extends ManifestEntityAction<Met
88
export interface MetaEntityActionDeleteKind extends MetaEntityActionDefaultKind {
99
detailRepositoryAlias: string;
1010
itemRepositoryAlias: string;
11+
confirm?: {
12+
headline?: string;
13+
message?: string;
14+
};
1115
}
1216

1317
declare global {

src/Umbraco.Web.UI.Client/src/packages/core/sorter/sorter.controller.test.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,27 +120,30 @@ describe('UmbSorterController', () => {
120120
expect(items.length).to.equal(4);
121121
});
122122

123-
it('sets all allowed draggable items to draggable', () => {
123+
it('sets all allowed draggable items to draggable', async () => {
124124
const items = element.getSortableItems();
125125
expect(items.length).to.equal(3);
126+
await aTimeout(100);
126127
items.forEach((item) => {
127128
expect(item.draggable).to.be.true;
128129
});
129130
});
130131

131-
it('sets all disabled items non draggable', () => {
132+
it('sets all disabled items non draggable', async () => {
132133
const items = element.getDisabledItems();
133134
expect(items.length).to.equal(1);
135+
await aTimeout(100);
134136
items.forEach((item) => {
135137
expect(item.draggable).to.be.false;
136138
});
137139
});
138140
});
139141

140142
describe('disable', () => {
141-
it('sets all items to non draggable', () => {
143+
it('sets all items to non draggable', async () => {
142144
element.sorter.disable();
143145
const items = element.getAllItems();
146+
await aTimeout(100);
144147
items.forEach((item) => {
145148
expect(item.draggable).to.be.false;
146149
});
@@ -161,9 +164,10 @@ describe('UmbSorterController', () => {
161164
});
162165
});
163166

164-
it('sets all disabled items non draggable', () => {
167+
it('sets all disabled items non draggable', async () => {
165168
const items = element.getDisabledItems();
166169
expect(items.length).to.equal(1);
170+
await aTimeout(100);
167171
items.forEach((item) => {
168172
expect(item.draggable).to.be.false;
169173
});

src/Umbraco.Web.UI.Client/utils/all-umb-consts/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ export const foundConsts = [{
404404
},
405405
{
406406
path: '@umbraco-cms/backoffice/user',
407-
consts: ["UMB_CREATE_USER_CLIENT_CREDENTIAL_MODAL","UMB_CREATE_USER_CLIENT_CREDENTIAL_MODAL_ALIAS","UMB_USER_CLIENT_CREDENTIAL_REPOSITORY_ALIAS","UMB_USER_COLLECTION_ALIAS","UMB_USER_COLLECTION_REPOSITORY_ALIAS","UMB_USER_COLLECTION_CONTEXT","UMB_COLLECTION_VIEW_USER_TABLE","UMB_COLLECTION_VIEW_USER_GRID","UMB_USER_ALLOW_CHANGE_PASSWORD_CONDITION_ALIAS","UMB_USER_ALLOW_DELETE_CONDITION_ALIAS","UMB_USER_ALLOW_DISABLE_CONDITION_ALIAS","UMB_USER_ALLOW_ENABLE_CONDITION_ALIAS","UMB_USER_ALLOW_EXTERNAL_LOGIN_CONDITION_ALIAS","UMB_USER_ALLOW_MFA_CONDITION_ALIAS","UMB_USER_ALLOW_UNLOCK_CONDITION_ALIAS","UMB_USER_IS_DEFAULT_KIND_CONDITION_ALIAS","UMB_CREATE_USER_MODAL","UMB_CREATE_USER_SUCCESS_MODAL","UMB_CREATE_USER_MODAL_ALIAS","UMB_USER_ENTITY_TYPE","UMB_USER_ROOT_ENTITY_TYPE","UMB_INVITE_USER_MODAL","UMB_RESEND_INVITE_TO_USER_MODAL","UMB_INVITE_USER_REPOSITORY_ALIAS","UMB_USER_MFA_MODAL","UMB_USER_PICKER_MODAL","UMB_USER_WORKSPACE_PATH","UMB_USER_ROOT_WORKSPACE_PATH","UMB_USER_AVATAR_REPOSITORY_ALIAS","UMB_CHANGE_USER_PASSWORD_REPOSITORY_ALIAS","UMB_USER_CONFIG_REPOSITORY_ALIAS","UMB_USER_CONFIG_STORE_ALIAS","UMB_USER_CONFIG_STORE_CONTEXT","UMB_CURRENT_USER_CONFIG_STORE_CONTEXT","UMB_USER_DETAIL_REPOSITORY_ALIAS","UMB_USER_DETAIL_STORE_ALIAS","UMB_USER_DETAIL_STORE_CONTEXT","UMB_DISABLE_USER_REPOSITORY_ALIAS","UMB_ENABLE_USER_REPOSITORY_ALIAS","UMB_USER_ITEM_REPOSITORY_ALIAS","UMB_USER_ITEM_STORE_ALIAS","UMB_USER_ITEM_STORE_CONTEXT","UMB_NEW_USER_PASSWORD_REPOSITORY_ALIAS","UMB_UNLOCK_USER_REPOSITORY_ALIAS","UMB_USER_WORKSPACE_ALIAS","UMB_USER_WORKSPACE_CONTEXT","UMB_USER_ROOT_WORKSPACE_ALIAS"]
407+
consts: ["UMB_CREATE_USER_CLIENT_CREDENTIAL_MODAL","UMB_CREATE_USER_CLIENT_CREDENTIAL_MODAL_ALIAS","UMB_USER_CLIENT_CREDENTIAL_REPOSITORY_ALIAS","UMB_USER_COLLECTION_ALIAS","UMB_USER_COLLECTION_REPOSITORY_ALIAS","UMB_USER_COLLECTION_CONTEXT","UMB_COLLECTION_VIEW_USER_TABLE","UMB_COLLECTION_VIEW_USER_GRID","UMB_USER_ALLOW_CHANGE_PASSWORD_CONDITION_ALIAS","UMB_CURRENT_USER_ALLOW_CHANGE_PASSWORD_CONDITION_ALIAS","UMB_USER_ALLOW_DELETE_CONDITION_ALIAS","UMB_USER_ALLOW_DISABLE_CONDITION_ALIAS","UMB_USER_ALLOW_ENABLE_CONDITION_ALIAS","UMB_USER_ALLOW_EXTERNAL_LOGIN_CONDITION_ALIAS","UMB_USER_ALLOW_MFA_CONDITION_ALIAS","UMB_CURRENT_USER_ALLOW_MFA_CONDITION_ALIAS","UMB_USER_ALLOW_UNLOCK_CONDITION_ALIAS","UMB_USER_IS_DEFAULT_KIND_CONDITION_ALIAS","UMB_CREATE_USER_MODAL","UMB_CREATE_USER_SUCCESS_MODAL","UMB_CREATE_USER_MODAL_ALIAS","UMB_USER_ENTITY_TYPE","UMB_USER_ROOT_ENTITY_TYPE","UMB_INVITE_USER_MODAL","UMB_RESEND_INVITE_TO_USER_MODAL","UMB_INVITE_USER_REPOSITORY_ALIAS","UMB_USER_MFA_MODAL","UMB_USER_PICKER_MODAL","UMB_USER_WORKSPACE_PATH","UMB_USER_ROOT_WORKSPACE_PATH","UMB_USER_AVATAR_REPOSITORY_ALIAS","UMB_CHANGE_USER_PASSWORD_REPOSITORY_ALIAS","UMB_USER_CONFIG_REPOSITORY_ALIAS","UMB_USER_CONFIG_STORE_ALIAS","UMB_CURRENT_USER_CONFIG_REPOSITORY_ALIAS","UMB_CURRENT_USER_CONFIG_STORE_ALIAS","UMB_CURRENT_USER_CONFIG_STORE_CONTEXT","UMB_USER_CONFIG_STORE_CONTEXT","UMB_USER_DETAIL_REPOSITORY_ALIAS","UMB_USER_DETAIL_STORE_ALIAS","UMB_USER_DETAIL_STORE_CONTEXT","UMB_DISABLE_USER_REPOSITORY_ALIAS","UMB_ENABLE_USER_REPOSITORY_ALIAS","UMB_USER_ITEM_REPOSITORY_ALIAS","UMB_USER_ITEM_STORE_ALIAS","UMB_USER_ITEM_STORE_CONTEXT","UMB_NEW_USER_PASSWORD_REPOSITORY_ALIAS","UMB_UNLOCK_USER_REPOSITORY_ALIAS","UMB_USER_WORKSPACE_ALIAS","UMB_USER_WORKSPACE_CONTEXT","UMB_USER_ROOT_WORKSPACE_ALIAS"]
408408
},
409409
{
410410
path: '@umbraco-cms/backoffice/utils',

0 commit comments

Comments
 (0)