@umbraco-cms/backoffice 17.2.0-rc → 17.2.0

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.
@@ -6,7 +6,7 @@
6
6
  "build": "vite build"
7
7
  },
8
8
  "dependencies": {
9
- "@umbraco-ui/uui": "^1.17.0-rc.5",
10
- "@umbraco-ui/uui-css": "^1.17.0-rc.5"
9
+ "@umbraco-ui/uui": "^1.17.0",
10
+ "@umbraco-ui/uui-css": "^1.17.0"
11
11
  }
12
12
  }
@@ -8,8 +8,8 @@ import type { UmbWorkspaceViewElement } from '../../../../../core/workspace/inde
8
8
  */
9
9
  export declare class UmbBlockWorkspaceViewEditContentNoRouterElement extends UmbLitElement implements UmbWorkspaceViewElement {
10
10
  #private;
11
- private _hasRootProperties;
12
- private _hasRootGroups;
11
+ private _hasRootProperties?;
12
+ private _hasRootGroups?;
13
13
  private _tabs?;
14
14
  private _activeTabKey?;
15
15
  constructor();
@@ -17,12 +17,9 @@ import { UmbLitElement } from '../../../../../core/lit-element/index.js';
17
17
  */
18
18
  let UmbBlockWorkspaceViewEditContentNoRouterElement = class UmbBlockWorkspaceViewEditContentNoRouterElement extends UmbLitElement {
19
19
  #blockWorkspace;
20
- #tabsStructureHelper;
20
+ #tabsStructureHelper = new UmbContentTypeContainerStructureHelper(this);
21
21
  constructor() {
22
22
  super();
23
- this._hasRootProperties = false;
24
- this._hasRootGroups = false;
25
- this.#tabsStructureHelper = new UmbContentTypeContainerStructureHelper(this);
26
23
  this.#tabsStructureHelper.setIsRoot(true);
27
24
  this.#tabsStructureHelper.setContainerChildType('Tab');
28
25
  this.observe(this.#tabsStructureHelper.childContainers, (tabs) => {
@@ -48,8 +45,12 @@ let UmbBlockWorkspaceViewEditContentNoRouterElement = class UmbBlockWorkspaceVie
48
45
  }, 'observeGroups');
49
46
  }
50
47
  #checkDefaultTabName() {
51
- if (!this._tabs || !this.#blockWorkspace)
48
+ if (!this._tabs ||
49
+ !this.#blockWorkspace ||
50
+ this._hasRootGroups === undefined ||
51
+ this._hasRootProperties === undefined) {
52
52
  return;
53
+ }
53
54
  // Find the default tab to grab
54
55
  if (this._activeTabKey === undefined) {
55
56
  if (this._hasRootGroups || this._hasRootProperties) {
@@ -74,9 +75,7 @@ let UmbBlockWorkspaceViewEditContentNoRouterElement = class UmbBlockWorkspaceVie
74
75
  ? html `<uui-tab
75
76
  label=${this.localize.term('general_generic')}
76
77
  .active=${this._activeTabKey === null}
77
- @click=${() => this.#setTabKey(null)}
78
- >Content</uui-tab
79
- >`
78
+ @click=${() => this.#setTabKey(null)}></uui-tab>`
80
79
  : nothing}
81
80
  ${repeat(this._tabs, (tab) => tab.name, (tab) => {
82
81
  const tabKey = tab.ownerId ?? tab.ids[0];
@@ -5,7 +5,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
5
5
  return c > 3 && r && Object.defineProperty(target, key, r), r;
6
6
  };
7
7
  import { UMB_BLOCK_WORKSPACE_CONTEXT } from '../../block-workspace.context-token.js';
8
- import { css, html, customElement, state, repeat, property } from '../../../../../../external/lit/index.js';
8
+ import { css, html, customElement, state, repeat, property, nothing } from '../../../../../../external/lit/index.js';
9
9
  import { UmbTextStyles } from '../../../../../core/style/index.js';
10
10
  import { UmbContentTypeContainerStructureHelper } from '../../../../../content/content-type/index.js';
11
11
  import { encodeFolderName } from '../../../../../core/router/index.js';
@@ -63,6 +63,16 @@ let UmbBlockWorkspaceViewEditElement = class UmbBlockWorkspaceViewEditElement ex
63
63
  if (!this._tabs || !this.#blockWorkspace)
64
64
  return;
65
65
  const routes = [];
66
+ if (this._hasRootGroups || this._hasRootProperties) {
67
+ routes.push({
68
+ path: 'root',
69
+ component: () => import('./block-workspace-view-edit-tab.element.js'),
70
+ setup: (component) => {
71
+ component.managerName = this.#managerName;
72
+ component.containerId = null;
73
+ },
74
+ });
75
+ }
66
76
  if (this._tabs.length > 0) {
67
77
  this._tabs?.forEach((tab) => {
68
78
  const tabName = tab.name ?? '';
@@ -76,24 +86,12 @@ let UmbBlockWorkspaceViewEditElement = class UmbBlockWorkspaceViewEditElement ex
76
86
  });
77
87
  });
78
88
  }
79
- if (this._hasRootGroups || this._hasRootProperties) {
89
+ if (routes.length !== 0) {
80
90
  routes.push({
91
+ ...routes[0],
92
+ unique: 'emptyPathFor_' + routes[0].path,
81
93
  path: '',
82
- component: () => import('./block-workspace-view-edit-tab.element.js'),
83
- setup: (component) => {
84
- component.managerName = this.#managerName;
85
- component.containerId = null;
86
- },
87
94
  });
88
- }
89
- if (routes.length !== 0) {
90
- if (!this._hasRootGroups) {
91
- routes.push({
92
- path: '',
93
- pathMatch: 'full',
94
- redirectTo: routes[0]?.path,
95
- });
96
- }
97
95
  routes.push({
98
96
  path: `**`,
99
97
  component: async () => (await import('../../../../../core/router/index.js')).UmbRouteNotFoundElement,
@@ -106,26 +104,15 @@ let UmbBlockWorkspaceViewEditElement = class UmbBlockWorkspaceViewEditElement ex
106
104
  return;
107
105
  return html `
108
106
  <umb-body-layout header-fit-height>
109
- ${this._routerPath && (this._tabs.length > 1 || (this._tabs.length === 1 && (this._hasRootGroups || this._hasRootProperties)))
107
+ ${this._routerPath &&
108
+ (this._tabs.length > 1 || (this._tabs.length === 1 && (this._hasRootGroups || this._hasRootProperties)))
110
109
  ? html ` <uui-tab-group slot="header">
111
110
  ${(this._hasRootGroups || this._hasRootProperties) && this._tabs.length > 0
112
- ? html `
113
- <uui-tab
114
- label="Content"
115
- .active=${this._routerPath + '/' === this._activePath}
116
- href=${this._routerPath + '/'}>
117
- <umb-localize key="general_content">Content</umb-localize>
118
- </uui-tab>
119
- `
120
- : ''}
121
- ${repeat(this._tabs, (tab) => tab.name, (tab) => {
122
- const path = this._routerPath + '/tab/' + encodeFolderName(tab.name || '');
123
- return html `<uui-tab
124
- label=${this.localize.string(tab.name ?? '#general_unknown')}
125
- .active=${path === this._activePath}
126
- href=${path}>
127
- ${this.localize.string(tab.name)}
128
- </uui-tab>`;
111
+ ? this.#renderTab(null, '#general_generic')
112
+ : nothing}
113
+ ${repeat(this._tabs, (tab) => tab.name, (tab, index) => {
114
+ const path = 'tab/' + encodeFolderName(tab.name || '');
115
+ return this.#renderTab(path, tab.name, index);
129
116
  })}
130
117
  </uui-tab-group>`
131
118
  : ''}
@@ -142,6 +129,22 @@ let UmbBlockWorkspaceViewEditElement = class UmbBlockWorkspaceViewEditElement ex
142
129
  </umb-body-layout>
143
130
  `;
144
131
  }
132
+ #renderTab(path, name, index = 0) {
133
+ const isRootTab = path === null;
134
+ const hasRootItems = this._hasRootGroups || this._hasRootProperties;
135
+ const basePath = this._routerPath + '/';
136
+ const fullPath = basePath + (path ? path : 'root');
137
+ const active = fullPath === this._activePath ||
138
+ // When there are no root items, the first tab should be active on the alias path.
139
+ (!hasRootItems && index === 0 && basePath === this._activePath) ||
140
+ // When there are root items, the root tab should be active on both the canonical `/root` and alias `/` paths.
141
+ (hasRootItems && isRootTab && basePath === this._activePath);
142
+ return html `<uui-tab
143
+ label=${this.localize.string(name ?? '#general_unnamed')}
144
+ .active=${active}
145
+ href=${isRootTab ? basePath : fullPath}
146
+ data-mark="content-tab:${path ?? 'root'}"></uui-tab>`;
147
+ }
145
148
  static { this.styles = [
146
149
  UmbTextStyles,
147
150
  css `
@@ -67,6 +67,7 @@ export class UmbContentTypeStructureManager extends UmbControllerBase {
67
67
  this.ownerContentTypeAlias = createObservablePart(this.ownerContentType, (x) => x?.alias);
68
68
  this.ownerContentTypeName = createObservablePart(this.ownerContentType, (x) => x?.name);
69
69
  this.ownerContentTypeCompositions = createObservablePart(this.ownerContentType, (x) => x?.compositions);
70
+ // TODO: for v.18 make it pausable for this to be undefined when no content-type are present. [NL]
70
71
  this.contentTypeCompositions = this.#contentTypes.asObservablePart((contentTypes) => {
71
72
  return contentTypes.flatMap((x) => x.compositions ?? []);
72
73
  });