Skip to content

Commit a4c373d

Browse files
OskarKrugerOskar krugerleekelleher
authored
Entity Actions: Create button discernible text (fixes #20205) (#20434)
* added hovering and focus border to RTE * fix main to OG * fix to main again * I'm going to cry * Missing localiztion feature, maybe UmbLitElement? * added localization controller to fetch localized version * localization successful for viewActionsFor and CreateFor * clean up button text * Changed label for content header to display proper name * clean up code * Included button labels for media section * clean code * Relocated localization keys, as `actions_viewActionsFor` already existed. Also made into a function, to support a fallback label. * Simplified the "Create for" label/localization Removed the need for a `getCreateAriaLabel()` method. * Removed the double-localizations (of `actions_viewActionsFor`) as the "umb-entity-actions-bundle" component handles this now. * imports tidy-up * Simplified localization key condition --------- Co-authored-by: Oskar kruger <[email protected]> Co-authored-by: leekelleher <[email protected]>
1 parent bcedc8d commit a4c373d

File tree

14 files changed

+62
-57
lines changed

14 files changed

+62
-57
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export default {
1818
changeDataType: 'Datentyp ändern',
1919
copy: 'Kopieren',
2020
create: 'Neu',
21+
createFor: (name: string) => (name ? `Neu erstellen für ${name}` : 'Neu'),
2122
export: 'Exportieren',
2223
createPackage: 'Neues Paket',
2324
createGroup: 'Neue Gruppe',
@@ -63,6 +64,7 @@ export default {
6364
unlock: 'Freigeben',
6465
createblueprint: 'Inhaltsvorlage anlegen',
6566
resendInvite: 'Einladung erneut versenden',
67+
viewActionsFor: (name: string) => (name ? `Aktionen anzeigen für ${name}` : 'Aktionen anzeigen'),
6668
},
6769
actionCategories: {
6870
content: 'Inhalt',

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export default {
2323
copy: 'Duplicate',
2424
copyTo: 'Duplicate to',
2525
create: 'Create',
26+
createFor: (name: string) => (name ? `Create item for ${name}` : 'Create'),
2627
createblueprint: 'Create Document Blueprint',
2728
createGroup: 'Create group',
2829
createPackage: 'Create Package',

src/Umbraco.Web.UI.Client/src/packages/clipboard/clipboard-entry/picker/clipboard-entry-picker.element.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ export class UmbClipboardEntryPickerElement extends UmbLitElement {
156156
slot="actions"
157157
.entityType=${item.entityType}
158158
.unique=${item.unique}
159-
.label=${this.localize.term('actions_viewActionsFor', [item.name])}>
159+
.label=${this.localize.string(item.name)}>
160160
</umb-entity-actions-bundle>
161161
`;
162162
}

src/Umbraco.Web.UI.Client/src/packages/core/components/entity-actions-bundle/entity-actions-bundle.element.ts

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { UmbEntityContext } from '../../entity/entity.context.js';
2-
import type { UmbEntityAction, ManifestEntityActionDefaultKind } from '@umbraco-cms/backoffice/entity-action';
3-
import type { PropertyValueMap } from '@umbraco-cms/backoffice/external/lit';
4-
import { html, nothing, customElement, property, state, ifDefined, css } from '@umbraco-cms/backoffice/external/lit';
5-
import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element';
2+
import { css, customElement, html, ifDefined, nothing, property, state } from '@umbraco-cms/backoffice/external/lit';
63
import { umbExtensionsRegistry } from '@umbraco-cms/backoffice/extension-registry';
74
import { UmbExtensionsManifestInitializer, createExtensionApi } from '@umbraco-cms/backoffice/extension-api';
5+
import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element';
6+
import type { PropertyValueMap } from '@umbraco-cms/backoffice/external/lit';
7+
import type { UmbEntityAction, ManifestEntityActionDefaultKind } from '@umbraco-cms/backoffice/entity-action';
88

99
@customElement('umb-entity-actions-bundle')
1010
export class UmbEntityActionsBundleElement extends UmbLitElement {
@@ -114,28 +114,29 @@ export class UmbEntityActionsBundleElement extends UmbLitElement {
114114

115115
override render() {
116116
if (this._numberOfActions === 0) return nothing;
117-
return html`<uui-action-bar slot="actions">${this.#renderMore()} ${this.#renderFirstAction()} </uui-action-bar>`;
117+
return html`<uui-action-bar slot="actions">${this.#renderMore()}${this.#renderFirstAction()}</uui-action-bar>`;
118118
}
119119

120120
#renderMore() {
121121
if (this._numberOfActions === 1) return nothing;
122-
123122
return html`
124-
<umb-entity-actions-dropdown .label=${this.label} compact>
123+
<umb-entity-actions-dropdown compact .label=${this.localize.term('actions_viewActionsFor', this.label)}>
125124
<uui-symbol-more slot="label"></uui-symbol-more>
126125
</umb-entity-actions-dropdown>
127126
`;
128127
}
129128

130129
#renderFirstAction() {
131130
if (!this._firstActionApi || !this._firstActionManifest) return nothing;
132-
return html`<uui-button
133-
label=${this.localize.string(this._firstActionManifest.meta.label)}
134-
data-mark=${'entity-action:' + this._firstActionManifest.alias}
135-
@click=${this.#onFirstActionClick}
136-
href="${ifDefined(this._firstActionHref)}">
137-
<uui-icon name=${ifDefined(this._firstActionManifest.meta.icon)}></uui-icon>
138-
</uui-button>`;
131+
return html`
132+
<uui-button
133+
label=${this.localize.string(this._firstActionManifest.meta.label, this.label)}
134+
data-mark=${'entity-action:' + this._firstActionManifest.alias}
135+
href=${ifDefined(this._firstActionHref)}
136+
@click=${this.#onFirstActionClick}>
137+
<umb-icon name=${ifDefined(this._firstActionManifest.meta.icon)}></umb-icon>
138+
</uui-button>
139+
`;
139140
}
140141

141142
static override styles = [

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export const manifest: UmbExtensionManifestKind = {
1515
forEntityTypes: [],
1616
meta: {
1717
icon: 'icon-add',
18-
label: '#actions_create',
18+
label: '#actions_createFor',
1919
additionalOptions: true,
2020
},
2121
},

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

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,15 @@ import { UmbEntityActionBase } from '../../entity-action-base.js';
22
import type { UmbEntityActionArgs } from '../../types.js';
33
import type { MetaEntityActionCreateKind } from './types.js';
44
import { UMB_ENTITY_CREATE_OPTION_ACTION_LIST_MODAL } from './modal/constants.js';
5+
import { createExtensionApi, UmbExtensionsManifestInitializer } from '@umbraco-cms/backoffice/extension-api';
56
import { umbOpenModal } from '@umbraco-cms/backoffice/modal';
6-
import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api';
77
import { umbExtensionsRegistry } from '@umbraco-cms/backoffice/extension-registry';
8-
import {
9-
type UmbExtensionManifestInitializer,
10-
createExtensionApi,
11-
UmbExtensionsManifestInitializer,
12-
type PermittedControllerType,
13-
} from '@umbraco-cms/backoffice/extension-api';
148
import type {
159
ManifestEntityCreateOptionAction,
1610
UmbEntityCreateOptionAction,
1711
} from '@umbraco-cms/backoffice/entity-create-option-action';
12+
import type { PermittedControllerType, UmbExtensionManifestInitializer } from '@umbraco-cms/backoffice/extension-api';
13+
import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api';
1814

1915
export class UmbCreateEntityAction extends UmbEntityActionBase<MetaEntityActionCreateKind> {
2016
#hasSingleOption = true;

src/Umbraco.Web.UI.Client/src/packages/core/entity-action/global-components/entity-actions-table-column-view/entity-actions-table-column-view.element.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export class UmbEntityActionsTableColumnViewElement extends UmbLitElement {
1414
<umb-entity-actions-bundle
1515
.entityType=${this.value.entityType}
1616
.unique=${this.value.unique}
17-
.label=${this.localize.term('actions_viewActionsFor', [(this.value as any).name])}>
17+
.label=${this.localize.string((this.value as any).name)}>
1818
</umb-entity-actions-bundle>
1919
`;
2020
}

src/Umbraco.Web.UI.Client/src/packages/core/menu/components/menu-item-layout/menu-item-layout.element.ts

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { html, customElement, property, ifDefined, state } from '@umbraco-cms/backoffice/external/lit';
1+
import { customElement, html, ifDefined, property, state, when } from '@umbraco-cms/backoffice/external/lit';
22
import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element';
33
import { ensureSlash } from '@umbraco-cms/backoffice/router';
44
import { debounce } from '@umbraco-cms/backoffice/utils';
@@ -72,24 +72,28 @@ export class UmbMenuItemLayoutElement extends UmbLitElement {
7272
}
7373

7474
override render() {
75-
return html`<uui-menu-item
76-
href="${ifDefined(this.href)}"
77-
label=${this.label}
78-
.caretLabel=${this.localize.term('visuallyHiddenTexts_expandChildItems') + ' ' + this.label}
79-
?active=${this._isActive}
80-
?has-children=${this.hasChildren}
81-
target=${ifDefined(this.href && this.target ? this.target : undefined)}>
82-
<umb-icon slot="icon" name=${this.iconName}></umb-icon>
83-
${this.entityType
84-
? html`<umb-entity-actions-bundle
85-
slot="actions"
86-
.entityType=${this.entityType}
87-
.unique=${null}
88-
.label=${this.localize.term('actions_viewActionsFor', [this.label])}>
89-
</umb-entity-actions-bundle>`
90-
: ''}
91-
<slot></slot>
92-
</uui-menu-item>`;
75+
return html`
76+
<uui-menu-item
77+
label=${this.label}
78+
href=${ifDefined(this.href)}
79+
target=${ifDefined(this.href && this.target ? this.target : undefined)}
80+
.caretLabel=${this.localize.term('visuallyHiddenTexts_expandChildItems') + ' ' + this.label}
81+
?active=${this._isActive}
82+
?has-children=${this.hasChildren}>
83+
<umb-icon slot="icon" name=${this.iconName}></umb-icon>
84+
${when(
85+
this.entityType,
86+
() => html`
87+
<umb-entity-actions-bundle
88+
slot="actions"
89+
.entityType=${this.entityType}
90+
.unique=${null}
91+
.label=${this.label}></umb-entity-actions-bundle>
92+
`,
93+
)}
94+
<slot></slot>
95+
</uui-menu-item>
96+
`;
9397
}
9498

9599
override disconnectedCallback() {

src/Umbraco.Web.UI.Client/src/packages/core/menu/section-sidebar-menu-with-entity-actions/section-sidebar-menu-with-entity-actions.element.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,15 @@ export class UmbSectionSidebarMenuWithEntityActionsElement extends UmbSectionSid
2121
}
2222

2323
override renderHeader() {
24+
const label = this.localize.string(this.manifest?.meta?.label ?? '');
2425
return html`
2526
<div id="header">
26-
<h3>${this.localize.string(this.manifest?.meta?.label ?? '')}</h3>
27+
<h3>${label}</h3>
2728
<umb-entity-actions-bundle
2829
slot="actions"
2930
.unique=${this._unique}
3031
.entityType=${this.manifest?.meta.entityType}
31-
.label=${this.localize.term('actions_viewActionsFor', [this.manifest?.meta.label])}>
32+
.label=${label}>
3233
</umb-entity-actions-bundle>
3334
</div>
3435
`;

src/Umbraco.Web.UI.Client/src/packages/core/tree/tree-item/tree-item-base/tree-item-element-base.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,9 @@ export abstract class UmbTreeItemElementBase<
138138
// Note: Currently we want to prevent opening when the item is in a selectable context, but this might change in the future.
139139
// If we like to be able to open items in selectable context, then we might want to make it as a menu item action, so you have to click ... and chose an action called 'Edit'
140140
override render() {
141+
const caretLabelKey = this._isOpen
142+
? 'visuallyHiddenTexts_collapseChildItems'
143+
: 'visuallyHiddenTexts_expandChildItems';
141144
return html`
142145
<uui-menu-item
143146
@show-children=${this._onShowChildren}
@@ -151,11 +154,9 @@ export abstract class UmbTreeItemElementBase<
151154
.loading=${this._isLoading}
152155
.hasChildren=${this._hasChildren}
153156
.showChildren=${this._isOpen}
154-
.caretLabel=${this._isOpen
155-
? this.localize.term('visuallyHiddenTexts_collapseChildItems') + ' ' + this._label
156-
: this.localize.term('visuallyHiddenTexts_expandChildItems') + ' ' + this._label}
157+
.caretLabel=${this.localize.term(caretLabelKey) + ' ' + this._label}
157158
label=${ifDefined(this._label)}
158-
href="${ifDefined(this._isSelectableContext ? undefined : this._href)}">
159+
href=${ifDefined(this._isSelectableContext ? undefined : this._href)}>
159160
${this.renderIconContainer()} ${this.renderLabel()} ${this.#renderActions()} ${this.#renderChildItems()}
160161
<slot></slot>
161162
${this.#renderPaging()}
@@ -224,7 +225,7 @@ export abstract class UmbTreeItemElementBase<
224225
slot="actions"
225226
.entityType=${this.#api.entityType}
226227
.unique=${this.#api.unique}
227-
.label=${this.localize.term('actions_viewActionsFor', [this._label])}>
228+
.label=${this._label}>
228229
</umb-entity-actions-bundle>
229230
`;
230231
}

0 commit comments

Comments
 (0)