Skip to content

Commit d8bf40e

Browse files
committed
add missing edit permissions button for media create options modal
1 parent 5c0b915 commit d8bf40e

File tree

1 file changed

+51
-16
lines changed

1 file changed

+51
-16
lines changed

src/packages/media/media/entity-actions/create/media-create-options-modal.element.ts

Lines changed: 51 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,19 @@ import type {
33
UmbMediaCreateOptionsModalData,
44
UmbMediaCreateOptionsModalValue,
55
} from './media-create-options-modal.token.js';
6-
import { html, nothing, customElement, state, ifDefined } from '@umbraco-cms/backoffice/external/lit';
6+
import {
7+
html,
8+
nothing,
9+
customElement,
10+
state,
11+
ifDefined,
12+
repeat,
13+
css,
14+
when,
15+
} from '@umbraco-cms/backoffice/external/lit';
716
import { UmbModalBaseElement } from '@umbraco-cms/backoffice/modal';
817
import { UmbMediaTypeStructureRepository, type UmbAllowedMediaTypeModel } from '@umbraco-cms/backoffice/media-type';
18+
import { UmbTextStyles } from '@umbraco-cms/backoffice/style';
919

1020
@customElement('umb-media-create-options-modal')
1121
export class UmbMediaCreateOptionsModalElement extends UmbModalBaseElement<
@@ -63,21 +73,10 @@ export class UmbMediaCreateOptionsModalElement extends UmbModalBaseElement<
6373
return html`
6474
<umb-body-layout headline=${this._headline ?? ''}>
6575
<uui-box>
66-
${this._allowedMediaTypes.length === 0
67-
? html`<umb-localize key="create_noMediaTypes"></umb-localize>`
68-
: nothing}
69-
${this._allowedMediaTypes.map(
70-
(mediaType) => html`
71-
<uui-ref-node-document-type
72-
data-id=${ifDefined(mediaType.unique)}
73-
.name=${mediaType.name}
74-
.alias=${mediaType.description}
75-
select-only
76-
selectable
77-
@selected=${() => this.#onNavigate(mediaType)}>
78-
${mediaType.icon ? html`<umb-icon slot="icon" name=${mediaType.icon}></umb-icon>` : nothing}
79-
</uui-ref-node-document-type>
80-
`,
76+
${when(
77+
this._allowedMediaTypes.length === 0,
78+
() => this.#renderNotAllowed(),
79+
() => this.#renderAllowedMediaTypes(),
8180
)}
8281
</uui-box>
8382
<uui-button
@@ -88,6 +87,42 @@ export class UmbMediaCreateOptionsModalElement extends UmbModalBaseElement<
8887
</umb-body-layout>
8988
`;
9089
}
90+
91+
#renderNotAllowed() {
92+
return html`<umb-localize key="create_noMediaTypes"></umb-localize><br />
93+
<uui-button
94+
id="edit-permissions"
95+
look="secondary"
96+
@click=${() => this._rejectModal()}
97+
href=${`/section/settings/workspace/media-type/edit/${this.data?.mediaType?.unique}/view/structure`}
98+
label=${this.localize.term('create_noMediaTypesEditPermissions')}></uui-button>`;
99+
}
100+
101+
#renderAllowedMediaTypes() {
102+
return repeat(
103+
this._allowedMediaTypes,
104+
(mediaType) => mediaType.unique,
105+
(mediaType) =>
106+
html`<uui-ref-node-document-type
107+
data-id=${ifDefined(mediaType.unique)}
108+
.name=${mediaType.name}
109+
.alias=${mediaType.description ?? ''}
110+
select-only
111+
selectable
112+
@selected=${() => this.#onNavigate(mediaType)}>
113+
${mediaType.icon ? html`<umb-icon slot="icon" name=${mediaType.icon}></umb-icon>` : nothing}
114+
</uui-ref-node-document-type>`,
115+
);
116+
}
117+
118+
static styles = [
119+
UmbTextStyles,
120+
css`
121+
#edit-permissions {
122+
margin-top: var(--uui-size-6);
123+
}
124+
`,
125+
];
91126
}
92127

93128
export default UmbMediaCreateOptionsModalElement;

0 commit comments

Comments
 (0)