Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hotfix: Clipboard confirm delete labels #18183

Merged
merged 17 commits into from
Jan 31, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/Umbraco.Web.UI.Client/src/assets/lang/da-dk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ export default {
anchorLinkPicker: 'Lokalt link / querystreng',
anchorInsert: 'Navn på lokalt link',
closeThisWindow: 'Luk denne dialog',
confirmdelete: 'Er du sikker på at du vil slette',
confirmdelete: (name: string) => `Er du sikker på at du vil slette${name ? ` <strong>${name}</strong>` : ''}?`,
confirmdisable: 'Er du sikker på du vil deaktivere',
confirmremove: 'Er du sikker på at du vil fjerne',
confirmremoveusageof: 'Er du sikker på du vil fjerne brugen af <strong>%0%</strong>',
Expand Down Expand Up @@ -2249,6 +2249,8 @@ export default {
labelForRemoveAllEntries: 'Fjern alle elementer',
labelForClearClipboard: 'Ryd udklipsholder',
labelForCopyToClipboard: 'Kopier til udklipsholder',
confirmDeleteHeadline: 'Slet fra udklipsholderen',
confirmDeleteDescription: 'Er du sikker på at du vil slette <strong>{0}</strong> fra udklipsholderen?',
},
propertyActions: {
tooltipForPropertyActionsMenu: 'Åben egenskabshandlinger',
Expand Down
1 change: 0 additions & 1 deletion src/Umbraco.Web.UI.Client/src/assets/lang/en-us.ts
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,6 @@ export default {
anchorLinkPicker: 'Anchor or querystring',
anchorInsert: 'Name',
closeThisWindow: 'Close this window',
confirmdelete: 'Are you sure you want to delete',
confirmdeleteNumberOfItems: 'Are you sure you want to delete <strong>%0%</strong> of <strong>%1%</strong> items',
confirmdisable: 'Are you sure you want to disable',
confirmremove: 'Are you sure you want to remove',
Expand Down
4 changes: 3 additions & 1 deletion src/Umbraco.Web.UI.Client/src/assets/lang/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ export default {
anchorLinkPicker: 'Anchor or querystring',
anchorInsert: 'Name',
closeThisWindow: 'Close this window',
confirmdelete: 'Are you sure you want to delete',
confirmdelete: (name: string) => `Are you sure you want to delete${name ? ` <strong>${name}</strong>` : ''}?`,
confirmdeleteNumberOfItems: 'Are you sure you want to delete <strong>%0%</strong> of <strong>%1%</strong> items',
confirmdisable: 'Are you sure you want to disable',
confirmremove: 'Are you sure you want to remove',
Expand Down Expand Up @@ -2388,6 +2388,8 @@ export default {
labelForRemoveAllEntries: 'Remove all items',
labelForClearClipboard: 'Clear clipboard',
labelForCopyToClipboard: 'Copy to clipboard',
confirmDeleteHeadline: 'Delete from clipboard',
confirmDeleteDescription: 'Are you sure you want to delete <strong>{0}</strong> from the clipboard?',
},
propertyActions: {
tooltipForPropertyActionsMenu: 'Open Property Actions',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,20 @@ describe('UmbLocalizeController', () => {
expect(controller.string({})).to.equal('');
expect(controller.string(undefined)).to.equal('');
});

it('should return an empty string if the input is an empty string', async () => {
expect(controller.string('')).to.equal('');
});

it('should return the input string if the input is not prefixed with a #', async () => {
const str = 'close';
expect(controller.string(str)).to.equal('close');
});

it('should replace tokens in each key with the provided args', async () => {
const str = '#withInlineToken #withInlineTokenLegacy';
expect(controller.string(str, 'value1', 'value2')).to.equal('value1 value2 value1 value2');
});
});

describe('host element', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,10 @@ export class UmbLocalizationController<LocalizationSetType extends UmbLocalizati
* If the term is found in the localization set, it will be replaced with the localized term.
* If the term is not found, the original term will be returned.
* @param {string} text The text to translate.
* @param {...any} args The arguments to parse for this localization entry.
* @returns {string} The translated text.
*/
string(text: unknown): string {
string(text: unknown, ...args: any): string {
if (typeof text !== 'string') {
return '';
}
Expand All @@ -203,10 +204,10 @@ export class UmbLocalizationController<LocalizationSetType extends UmbLocalizati

const localizedText = text.replace(regex, (match: string) => {
const key = match.slice(1);
// TODO: find solution to pass dynamic string to term

// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
const localized = this.term(key);
const localized = this.term(key, ...args);
// we didn't find a localized string, so we return the original string with the #
return localized === key ? match : localized;
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,15 @@ export const manifests: Array<UmbExtensionManifest> = [
type: 'entityAction',
kind: 'delete',
alias: 'Umb.EntityAction.ClipboardEntry.Delete',
name: 'Delete Dictionary Entry Entity Action',
name: 'Delete Clipboard Entry Entity Action',
forEntityTypes: [UMB_CLIPBOARD_ENTRY_ENTITY_TYPE],
meta: {
itemRepositoryAlias: UMB_CLIPBOARD_ENTRY_ITEM_REPOSITORY_ALIAS,
detailRepositoryAlias: UMB_CLIPBOARD_ENTRY_DETAIL_REPOSITORY_ALIAS,
confirm: {
headline: '#clipboard_confirmDeleteHeadline',
message: '#clipboard_confirmDeleteDescription',
},
},
},
];
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ 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';

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.');
Expand All @@ -21,12 +23,15 @@ 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 message = this.args.meta.confirm?.message ?? '#defaultdialogs_confirmdelete';

// TODO: handle items with variants
await umbConfirmModal(this._host, {
headline: `Delete`,
content: `Are you sure you want to delete ${item.name}?`,
headline,
content: this.#localize.string(message, item.name),
color: 'danger',
confirmLabel: 'Delete',
confirmLabel: '#general_delete',
});

const detailRepository = await createExtensionApiByAlias<UmbDetailRepository<any>>(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ export interface ManifestEntityActionDeleteKind extends ManifestEntityAction<Met
export interface MetaEntityActionDeleteKind extends MetaEntityActionDefaultKind {
detailRepositoryAlias: string;
itemRepositoryAlias: string;
confirm?: {
headline?: string;
message?: string;
};
}

declare global {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,27 +120,30 @@ describe('UmbSorterController', () => {
expect(items.length).to.equal(4);
});

it('sets all allowed draggable items to draggable', () => {
it('sets all allowed draggable items to draggable', async () => {
const items = element.getSortableItems();
expect(items.length).to.equal(3);
await aTimeout(100);
items.forEach((item) => {
expect(item.draggable).to.be.true;
});
});

it('sets all disabled items non draggable', () => {
it('sets all disabled items non draggable', async () => {
const items = element.getDisabledItems();
expect(items.length).to.equal(1);
await aTimeout(100);
items.forEach((item) => {
expect(item.draggable).to.be.false;
});
});
});

describe('disable', () => {
it('sets all items to non draggable', () => {
it('sets all items to non draggable', async () => {
element.sorter.disable();
const items = element.getAllItems();
await aTimeout(100);
items.forEach((item) => {
expect(item.draggable).to.be.false;
});
Expand All @@ -161,9 +164,10 @@ describe('UmbSorterController', () => {
});
});

it('sets all disabled items non draggable', () => {
it('sets all disabled items non draggable', async () => {
const items = element.getDisabledItems();
expect(items.length).to.equal(1);
await aTimeout(100);
items.forEach((item) => {
expect(item.draggable).to.be.false;
});
Expand Down
2 changes: 1 addition & 1 deletion src/Umbraco.Web.UI.Client/utils/all-umb-consts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ export const foundConsts = [{
},
{
path: '@umbraco-cms/backoffice/user',
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"]
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"]
},
{
path: '@umbraco-cms/backoffice/utils',
Expand Down
Loading