@@ -3,9 +3,19 @@ import type {
3
3
UmbMediaCreateOptionsModalData ,
4
4
UmbMediaCreateOptionsModalValue ,
5
5
} 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' ;
7
16
import { UmbModalBaseElement } from '@umbraco-cms/backoffice/modal' ;
8
17
import { UmbMediaTypeStructureRepository , type UmbAllowedMediaTypeModel } from '@umbraco-cms/backoffice/media-type' ;
18
+ import { UmbTextStyles } from '@umbraco-cms/backoffice/style' ;
9
19
10
20
@customElement ( 'umb-media-create-options-modal' )
11
21
export class UmbMediaCreateOptionsModalElement extends UmbModalBaseElement <
@@ -63,21 +73,10 @@ export class UmbMediaCreateOptionsModalElement extends UmbModalBaseElement<
63
73
return html `
64
74
<umb- body- layout headline= ${ this . _headline ?? '' } >
65
75
<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( ) ,
81
80
) }
82
81
</ uui- box>
83
82
<uui- butto n
@@ -88,6 +87,42 @@ export class UmbMediaCreateOptionsModalElement extends UmbModalBaseElement<
88
87
</ umb- body- layout>
89
88
` ;
90
89
}
90
+
91
+ #renderNotAllowed( ) {
92
+ return html `<umb- localize key= "create_noMediaTypes" > </ umb- localize> <br / >
93
+ <uui- butto n
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- butto n> ` ;
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
+ ] ;
91
126
}
92
127
93
128
export default UmbMediaCreateOptionsModalElement ;
0 commit comments