Skip to content

Commit 95745a7

Browse files
committed
fix: find the parent name to localize when creating a folder
1 parent 1a31496 commit 95745a7

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

src/packages/documents/document-blueprints/entity-actions/create/modal/document-blueprint-options-create-modal.element.ts

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import { UMB_DOCUMENT_BLUEPRINT_FOLDER_REPOSITORY_ALIAS } from '../../../tree/folder/manifests.js';
2+
import { UmbDocumentBlueprintFolderRepository } from '../../../tree/index.js';
23
import type {
34
UmbDocumentBlueprintOptionsCreateModalData,
45
UmbDocumentBlueprintOptionsCreateModalValue,
56
} from './index.js';
67
import { UmbTextStyles } from '@umbraco-cms/backoffice/style';
7-
import { html, customElement, css } from '@umbraco-cms/backoffice/external/lit';
8+
import { html, customElement, css, state } from '@umbraco-cms/backoffice/external/lit';
89
import { UmbModalBaseElement } from '@umbraco-cms/backoffice/modal';
910
import { type UmbSelectedEvent, UmbSelectionChangeEvent } from '@umbraco-cms/backoffice/event';
1011
import { UmbCreateFolderEntityAction, type UmbTreeElement } from '@umbraco-cms/backoffice/tree';
@@ -14,12 +15,24 @@ export class UmbDocumentBlueprintOptionsCreateModalElement extends UmbModalBaseE
1415
UmbDocumentBlueprintOptionsCreateModalData,
1516
UmbDocumentBlueprintOptionsCreateModalValue
1617
> {
18+
@state()
19+
private _parentName?: string;
20+
1721
#createFolderAction?: UmbCreateFolderEntityAction;
1822

19-
override connectedCallback(): void {
23+
#itemRepository = new UmbDocumentBlueprintFolderRepository(this);
24+
25+
override async connectedCallback(): Promise<void> {
2026
super.connectedCallback();
2127
if (!this.data?.parent) throw new Error('A parent is required to create a folder');
2228

29+
if (this.data.parent.unique) {
30+
const { data: parent } = await this.#itemRepository.request(this.data.parent.unique.toString());
31+
this._parentName = parent?.name ?? this.localize.term('general_unknown');
32+
} else {
33+
this._parentName = this.localize.term('treeHeaders_contentBlueprints');
34+
}
35+
2336
// TODO: render the info from this instance in the list of actions
2437
this.#createFolderAction = new UmbCreateFolderEntityAction(this, {
2538
unique: this.data.parent.unique,
@@ -54,7 +67,7 @@ export class UmbDocumentBlueprintOptionsCreateModalElement extends UmbModalBaseE
5467
override render() {
5568
return html`
5669
<umb-body-layout headline=${this.localize.term('actions_createblueprint')}>
57-
<uui-box headline="Create a folder under Content Templates">
70+
<uui-box headline=${this.localize.term('blueprints_createBlueprintFolderUnder', this._parentName)}>
5871
<uui-menu-item @click=${this.#onCreateFolderClick} label="New Folder...">
5972
<uui-icon slot="icon" name="icon-folder"></uui-icon>
6073
</uui-menu-item>

0 commit comments

Comments
 (0)