@umbraco-cms/backoffice 17.5.1 → 17.5.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist-cms/packages/documents/documents/workspace/document-workspace-editor.element.js
CHANGED
|
@@ -10,6 +10,7 @@ import { customElement, state, css, html } from '../../../../external/lit/index.
|
|
|
10
10
|
import { UmbLitElement } from '../../../core/lit-element/index.js';
|
|
11
11
|
import { UmbTextStyles } from '../../../core/style/index.js';
|
|
12
12
|
import { UMB_APP_LANGUAGE_CONTEXT } from '../../../language/index.js';
|
|
13
|
+
import { createObservablePart } from '../../../../libs/observable-api/index.js';
|
|
13
14
|
// TODO: This seem fully identical with Media Workspace Editor, so we can refactor this to a generic component. [NL]
|
|
14
15
|
let UmbDocumentWorkspaceEditorElement = class UmbDocumentWorkspaceEditorElement extends UmbLitElement {
|
|
15
16
|
#appLanguage;
|
|
@@ -17,13 +18,11 @@ let UmbDocumentWorkspaceEditorElement = class UmbDocumentWorkspaceEditorElement
|
|
|
17
18
|
#workspaceRoute;
|
|
18
19
|
#appCulture;
|
|
19
20
|
#variants;
|
|
20
|
-
#isForbidden;
|
|
21
21
|
constructor() {
|
|
22
22
|
super();
|
|
23
23
|
//
|
|
24
24
|
// TODO: Refactor: when having a split view/variants context token, we can rename the split view/variants component to a generic and make this component generic as well. [NL]
|
|
25
25
|
this._splitViewElement = new UmbDocumentWorkspaceSplitViewElement();
|
|
26
|
-
this.#isForbidden = false;
|
|
27
26
|
this._loading = true;
|
|
28
27
|
this._gotWorkspaceRoute = (e) => {
|
|
29
28
|
this.#workspaceRoute = e.target.absoluteRouterPath;
|
|
@@ -34,20 +33,25 @@ let UmbDocumentWorkspaceEditorElement = class UmbDocumentWorkspaceEditorElement
|
|
|
34
33
|
this.observe(this.#appLanguage?.appLanguageCulture, (appCulture) => {
|
|
35
34
|
const previousCulture = this.#appCulture;
|
|
36
35
|
this.#appCulture = appCulture;
|
|
37
|
-
|
|
36
|
+
if (previousCulture === undefined) {
|
|
37
|
+
// Only relevant to call generate routes initially, a later update of appCulture has no effect on the routes.
|
|
38
|
+
this.#generateRoutes();
|
|
39
|
+
}
|
|
38
40
|
this.#syncUrlToCulture(previousCulture, appCulture);
|
|
39
41
|
});
|
|
40
42
|
});
|
|
41
43
|
this.consumeContext(UMB_DOCUMENT_WORKSPACE_CONTEXT, (instance) => {
|
|
42
44
|
this.#workspaceContext = instance;
|
|
43
|
-
this.observe(this.#workspaceContext
|
|
45
|
+
this.observe(this.#workspaceContext
|
|
46
|
+
? createObservablePart(this.#workspaceContext.variantOptions, (variants) => variants.map((v) => ({
|
|
47
|
+
culture: v.culture,
|
|
48
|
+
segment: v.segment,
|
|
49
|
+
unique: v.unique,
|
|
50
|
+
})))
|
|
51
|
+
: undefined, (variants) => {
|
|
44
52
|
this.#variants = variants;
|
|
45
53
|
this.#generateRoutes();
|
|
46
54
|
}, '_observeVariants');
|
|
47
|
-
this.observe(this.#workspaceContext?.forbidden.isOn, (isForbidden) => {
|
|
48
|
-
this.#isForbidden = isForbidden ?? false;
|
|
49
|
-
this.#generateRoutes();
|
|
50
|
-
}, '_observeForbidden');
|
|
51
55
|
this.observe(this.#workspaceContext?.loading.isOn, (loading) => {
|
|
52
56
|
this._loading = loading ?? false;
|
|
53
57
|
}, '_observeLoading');
|
|
@@ -80,8 +84,7 @@ let UmbDocumentWorkspaceEditorElement = class UmbDocumentWorkspaceEditorElement
|
|
|
80
84
|
}
|
|
81
85
|
#generateRoutes() {
|
|
82
86
|
if (!this.#variants || this.#variants.length === 0 || !this.#appCulture) {
|
|
83
|
-
this._routes = [];
|
|
84
|
-
this.#ensureForbiddenRoute(this._routes);
|
|
87
|
+
this._routes = [this.#createNotFoundRoute()];
|
|
85
88
|
return;
|
|
86
89
|
}
|
|
87
90
|
// Generate split view routes for all available routes
|
|
@@ -143,23 +146,19 @@ let UmbDocumentWorkspaceEditorElement = class UmbDocumentWorkspaceEditorElement
|
|
|
143
146
|
},
|
|
144
147
|
});
|
|
145
148
|
}
|
|
146
|
-
this.#
|
|
149
|
+
routes.push(this.#createNotFoundRoute());
|
|
147
150
|
this._routes = routes;
|
|
148
151
|
}
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
* This route will display a forbidden message when the user does not have permission to access certain resources.
|
|
152
|
-
* Also handles not found routes.
|
|
153
|
-
* @param routes
|
|
154
|
-
*/
|
|
155
|
-
#ensureForbiddenRoute(routes = []) {
|
|
156
|
-
routes.push({
|
|
152
|
+
#createNotFoundRoute() {
|
|
153
|
+
return {
|
|
157
154
|
path: '**',
|
|
158
155
|
component: async () => {
|
|
159
156
|
const router = await import('../../../core/router/index.js');
|
|
160
|
-
return this.#
|
|
157
|
+
return this.#workspaceContext?.forbidden.getIsOn()
|
|
158
|
+
? router.UmbRouteForbiddenElement
|
|
159
|
+
: router.UmbRouteNotFoundElement;
|
|
161
160
|
},
|
|
162
|
-
}
|
|
161
|
+
};
|
|
163
162
|
}
|
|
164
163
|
render() {
|
|
165
164
|
return !this._loading && this._routes
|
|
@@ -9,16 +9,15 @@ import { UMB_MEDIA_WORKSPACE_CONTEXT } from './media-workspace.context-token.js'
|
|
|
9
9
|
import { UmbTextStyles } from '../../../core/style/index.js';
|
|
10
10
|
import { UmbLitElement } from '../../../core/lit-element/index.js';
|
|
11
11
|
import { customElement, state, css, html } from '../../../../external/lit/index.js';
|
|
12
|
+
import { createObservablePart } from '../../../../libs/observable-api/index.js';
|
|
12
13
|
let UmbMediaWorkspaceEditorElement = class UmbMediaWorkspaceEditorElement extends UmbLitElement {
|
|
13
14
|
#workspaceContext;
|
|
14
15
|
#variants;
|
|
15
|
-
#isForbidden;
|
|
16
16
|
constructor() {
|
|
17
17
|
super();
|
|
18
18
|
//
|
|
19
19
|
// TODO: Refactor: when having a split view/variants context token, we can rename the split view/variants component to a generic and make this component generic as well. [NL]
|
|
20
20
|
this._splitViewElement = new UmbMediaWorkspaceSplitViewElement();
|
|
21
|
-
this.#isForbidden = false;
|
|
22
21
|
this._loading = true;
|
|
23
22
|
this._gotWorkspaceRoute = (e) => {
|
|
24
23
|
this.#workspaceContext?.splitView.setWorkspaceRoute(e.target.absoluteRouterPath);
|
|
@@ -26,22 +25,21 @@ let UmbMediaWorkspaceEditorElement = class UmbMediaWorkspaceEditorElement extend
|
|
|
26
25
|
this.consumeContext(UMB_MEDIA_WORKSPACE_CONTEXT, (instance) => {
|
|
27
26
|
this.#workspaceContext = instance;
|
|
28
27
|
this.#observeVariants();
|
|
29
|
-
this.#observeForbidden();
|
|
30
28
|
this.#observeLoading();
|
|
31
29
|
});
|
|
32
30
|
}
|
|
33
31
|
#observeVariants() {
|
|
34
|
-
this.observe(this.#workspaceContext
|
|
32
|
+
this.observe(this.#workspaceContext
|
|
33
|
+
? createObservablePart(this.#workspaceContext.variantOptions, (variants) => variants.map((v) => ({
|
|
34
|
+
culture: v.culture,
|
|
35
|
+
segment: v.segment,
|
|
36
|
+
unique: v.unique,
|
|
37
|
+
})))
|
|
38
|
+
: undefined, (options) => {
|
|
35
39
|
this.#variants = options;
|
|
36
40
|
this._generateRoutes();
|
|
37
41
|
}, '_observeVariants');
|
|
38
42
|
}
|
|
39
|
-
#observeForbidden() {
|
|
40
|
-
this.observe(this.#workspaceContext?.forbidden.isOn, (forbidden) => {
|
|
41
|
-
this.#isForbidden = forbidden ?? false;
|
|
42
|
-
this._generateRoutes();
|
|
43
|
-
}, '_observeForbidden');
|
|
44
|
-
}
|
|
45
43
|
#observeLoading() {
|
|
46
44
|
this.observe(this.#workspaceContext?.loading.isOn, (loading) => {
|
|
47
45
|
this._loading = loading ?? false;
|
|
@@ -49,8 +47,7 @@ let UmbMediaWorkspaceEditorElement = class UmbMediaWorkspaceEditorElement extend
|
|
|
49
47
|
}
|
|
50
48
|
async _generateRoutes() {
|
|
51
49
|
if (!this.#variants || this.#variants.length === 0) {
|
|
52
|
-
this._routes = [];
|
|
53
|
-
this.#ensureForbiddenRoute(this._routes);
|
|
50
|
+
this._routes = [this.#createNotFoundRoute()];
|
|
54
51
|
return;
|
|
55
52
|
}
|
|
56
53
|
// Generate split view routes for all available routes
|
|
@@ -90,23 +87,19 @@ let UmbMediaWorkspaceEditorElement = class UmbMediaWorkspaceEditorElement extend
|
|
|
90
87
|
redirectTo: routes[this.#variants.length * this.#variants.length]?.path,
|
|
91
88
|
});
|
|
92
89
|
}
|
|
93
|
-
this.#
|
|
90
|
+
routes.push(this.#createNotFoundRoute());
|
|
94
91
|
this._routes = routes;
|
|
95
92
|
}
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
* This route will display a forbidden message when the user does not have permission to access certain resources.
|
|
99
|
-
* Also handles not found routes.
|
|
100
|
-
* @param {Array<UmbRoute>} routes - The array of routes to append the forbidden route to
|
|
101
|
-
*/
|
|
102
|
-
#ensureForbiddenRoute(routes = []) {
|
|
103
|
-
routes.push({
|
|
93
|
+
#createNotFoundRoute() {
|
|
94
|
+
return {
|
|
104
95
|
path: '**',
|
|
105
96
|
component: async () => {
|
|
106
97
|
const router = await import('../../../core/router/index.js');
|
|
107
|
-
return this.#
|
|
98
|
+
return this.#workspaceContext?.forbidden.getIsOn()
|
|
99
|
+
? router.UmbRouteForbiddenElement
|
|
100
|
+
: router.UmbRouteNotFoundElement;
|
|
108
101
|
},
|
|
109
|
-
}
|
|
102
|
+
};
|
|
110
103
|
}
|
|
111
104
|
render() {
|
|
112
105
|
return !this._loading && this._routes && this._routes.length > 0
|