@eclipse-docks/core 0.7.104 → 0.7.106

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eclipse-docks/core",
3
- "version": "0.7.104",
3
+ "version": "0.7.106",
4
4
  "description": "Eclipse Docks platform core: registries, services, parts, widgets, and API",
5
5
  "type": "module",
6
6
  "license": "EPL-2.0",
@@ -1,3 +1,3 @@
1
1
  // Re-export framework constants for app usage
2
2
  export * from '../core/constants';
3
-
3
+ export * from '../core/ui-ids';
@@ -11,18 +11,21 @@ registerAll({
11
11
  description: "Opens a dashboard view in the editor area",
12
12
  parameters: [
13
13
  { name: "name", description: "View contribution name", required: true },
14
- { name: "sourceContributionSlot", description: "source contribution slot (default: SYSTEM_VIEWS)", required: false }
14
+ { name: "sourceContributionSlot", description: "source contribution slot (default: SYSTEM_VIEWS)", required: false },
15
+ { name: "singleTab", description: "If true, close all other editor tabs first so only this view remains open", required: false }
15
16
  ]
16
17
  },
17
18
  handler: {
18
- execute: async ({ params }: { params?: { name?: string, sourceContributionSlot?: string } }) => {
19
+ execute: async ({ params }: { params?: { name?: string, sourceContributionSlot?: string, singleTab?: boolean } }) => {
19
20
  const name = params?.name;
20
21
  if (!name) return;
21
22
  const slot = params?.sourceContributionSlot ?? SYSTEM_VIEWS
22
23
  const contributions = contributionRegistry.getContributions(slot) as TabContribution[];
23
24
  const contribution = contributions.find(c => c.name === name);
24
25
  if (!contribution?.component) return;
25
- await editorRegistry.openTab(contribution as TabContribution);
26
+ await editorRegistry.openTab(contribution as TabContribution, {
27
+ singleTab: params?.singleTab === true,
28
+ });
26
29
  }
27
30
  }
28
31
  });
@@ -43,6 +43,9 @@ export class DocksCommand extends DocksWidget {
43
43
  @property()
44
44
  dropdown?: string
45
45
 
46
+ @property({ type: Boolean, attribute: 'with-caret' })
47
+ withCaret: boolean = true
48
+
46
49
  @property()
47
50
  placement: 'top' | 'top-start' | 'top-end' | 'bottom' | 'bottom-start' | 'bottom-end' | 'left' | 'left-start' | 'left-end' | 'right' | 'right-start' | 'right-end' = 'bottom-start'
48
51
 
@@ -161,7 +164,7 @@ export class DocksCommand extends DocksWidget {
161
164
  variant=${this.variant}
162
165
  size=${this.size}
163
166
  ?disabled=${this.disabled}
164
- with-caret
167
+ ?with-caret=${this.withCaret}
165
168
  title=${keybinding ? `${this.title} (${keybinding})` : this.title}>
166
169
  ${icon(this.icon, { label: this.title, slot: 'start' })}
167
170
  <slot></slot>
@@ -226,7 +226,7 @@ class EditorRegistry {
226
226
  } as TabContribution)
227
227
  }
228
228
 
229
- async openTab(tabContribution: TabContribution) {
229
+ async openTab(tabContribution: TabContribution, options?: { singleTab?: boolean }) {
230
230
  const editorArea = this.getEditorArea();
231
231
 
232
232
  if (!editorArea) {
@@ -234,6 +234,13 @@ class EditorRegistry {
234
234
  return;
235
235
  }
236
236
 
237
+ if (options?.singleTab) {
238
+ const closed = await editorArea.closeAllTabs();
239
+ if (!closed) return;
240
+ editorArea.open(tabContribution);
241
+ return;
242
+ }
243
+
237
244
  if (editorArea.has(tabContribution.name)) {
238
245
  editorArea.activate(tabContribution.name)
239
246
  return
package/src/parts/tabs.ts CHANGED
@@ -41,6 +41,9 @@ export class DocksTabs extends DocksContainer {
41
41
  @property({type: Boolean, reflect: true, attribute: 'with-toolbar'})
42
42
  withToolbar: boolean = false;
43
43
 
44
+ @property({ type: Boolean, reflect: true, attribute: 'hide-tabs' })
45
+ hideTabs: boolean = false;
46
+
44
47
  /** Tab contributions for this container */
45
48
  @state()
46
49
  private contributions: TabContribution[] = [];
@@ -152,17 +155,37 @@ export class DocksTabs extends DocksContainer {
152
155
 
153
156
  async closeTab(event: Event, tabName: string): Promise<void> {
154
157
  event.stopPropagation();
155
-
156
- if (this.isDirty(tabName) && !await confirmDialog("Unsaved changes will be lost: Do you really want to close?")) {
157
- return;
158
+ await this.tryCloseTab(tabName, true);
159
+ }
160
+
161
+ /**
162
+ * Closes every tab in this group. Returns false if the user cancels a dirty-tab prompt.
163
+ */
164
+ async closeAllTabs(): Promise<boolean> {
165
+ const names = [...this.contributions.map((c) => c.name)];
166
+ for (const tabName of names) {
167
+ const ok = await this.tryCloseTab(tabName, true);
168
+ if (!ok) return false;
158
169
  }
159
-
170
+ return true;
171
+ }
172
+
173
+ /**
174
+ * @returns false if the user cancelled closing a dirty tab; true if the tab was removed or was absent.
175
+ */
176
+ private async tryCloseTab(tabName: string, confirmIfDirty: boolean): Promise<boolean> {
177
+ if (confirmIfDirty && this.isDirty(tabName)) {
178
+ if (!await confirmDialog("Unsaved changes will be lost: Do you really want to close?")) {
179
+ return false;
180
+ }
181
+ }
182
+
160
183
  const tabPanel = this.getTabPanel(tabName);
161
- if (!tabPanel) return;
162
-
184
+ if (!tabPanel) return true;
185
+
163
186
  const contribution = this.contributions.find(c => c.name === tabName);
164
- if (!contribution) return;
165
-
187
+ if (!contribution) return true;
188
+
166
189
  this.cleanupTabInstance(tabPanel);
167
190
  this.clearActiveSignalsIfPartInPanel(tabPanel);
168
191
 
@@ -172,10 +195,11 @@ export class DocksTabs extends DocksContainer {
172
195
  }
173
196
 
174
197
  this.requestUpdate();
175
-
198
+
176
199
  this.updateComplete.then(() => {
177
200
  this.activateNextAvailableTab();
178
201
  });
202
+ return true;
179
203
  }
180
204
 
181
205
  markDirty(name: string, dirty: boolean): void {
@@ -421,6 +445,14 @@ export class DocksTabs extends DocksContainer {
421
445
  min-height: 0;
422
446
  }
423
447
 
448
+ :host([hide-tabs]) wa-tab {
449
+ display: none !important;
450
+ }
451
+
452
+ :host([hide-tabs]:not([with-toolbar])) wa-tab-group::part(nav) {
453
+ display: none;
454
+ }
455
+
424
456
  :host(:is([placement="top"], [placement="bottom"])) wa-tab-group::part(base) {
425
457
  display: grid;
426
458
  grid-template-rows: auto minmax(0, 1fr);