@uxland/primary-shell 7.40.4 → 7.41.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.
@@ -13,6 +13,7 @@ export interface PrimariaRegionManager extends HarmonixRegionManager {
13
13
  registerNavigationMenu(view: HarmonixViewDefinition): Promise<void>;
14
14
  registerMainView(view: HarmonixViewDefinition): Promise<void>;
15
15
  activateMainView(viewId: string): Promise<void>;
16
+ activatePluginView(regionName: string, pluginId: string, viewId: string): Promise<void>;
16
17
  getCurrentMainViewActive(): string | undefined;
17
18
  _destroy(): void;
18
19
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uxland/primary-shell",
3
- "version": "7.40.4",
3
+ "version": "7.41.0",
4
4
  "description": "Primaria Shell",
5
5
  "author": "UXLand <dev@uxland.es>",
6
6
  "homepage": "https://github.com/uxland/harmonix/tree/app#readme",
@@ -106,6 +106,18 @@ describe("RegionManagerProxy", () => {
106
106
  expect(broker.publish).toHaveBeenCalledWith(BROKER_EVENTS.shell.mainViewChanged, { viewId: "view1" });
107
107
  });
108
108
 
109
+ it("activatePluginView should activate using the owner pluginId, not the caller's", async () => {
110
+ await proxy.activatePluginView("test-region", "other-plugin", "view1");
111
+ expect(regionMock.activate).toHaveBeenCalledWith("other-plugin::view1");
112
+ expect(broker.publish).not.toHaveBeenCalled();
113
+ });
114
+
115
+ it("activatePluginView should notify when activating in the main region", async () => {
116
+ await proxy.activatePluginView(proxy.regions.shell.main, "other-plugin", "view1");
117
+ expect(regionMock.activate).toHaveBeenCalledWith("other-plugin::view1");
118
+ expect(broker.publish).toHaveBeenCalledWith(BROKER_EVENTS.shell.mainViewChanged, { viewId: "view1" });
119
+ });
120
+
109
121
  it("getCurrentMainViewActive should return id of the active main view", () => {
110
122
  const result = proxy.getCurrentMainViewActive();
111
123
  expect(result).toBe("view1");
@@ -16,6 +16,7 @@ export interface PrimariaRegionManager extends HarmonixRegionManager {
16
16
  registerNavigationMenu(view: HarmonixViewDefinition): Promise<void>;
17
17
  registerMainView(view: HarmonixViewDefinition): Promise<void>;
18
18
  activateMainView(viewId: string): Promise<void>;
19
+ activatePluginView(regionName: string, pluginId: string, viewId: string): Promise<void>;
19
20
  getCurrentMainViewActive(): string | undefined;
20
21
  _destroy(): void;
21
22
  }
@@ -130,6 +131,23 @@ class RegionManagerProxy implements PrimariaRegionManager {
130
131
  this._notifyMainViewChanged(viewId);
131
132
  return Promise.resolve();
132
133
  }
134
+ /**
135
+ * Activates a view that was registered by another plugin.
136
+ *
137
+ * Unlike `activateView`, which always prefixes with the calling plugin's id, this method
138
+ * lets an orchestrator activate views owned by a different plugin by passing the owner's
139
+ * pluginId explicitly. Use only when crossing plugin boundaries.
140
+ *
141
+ * @param {string} regionName - The name of the region where the view is located.
142
+ * @param {string} pluginId - The id of the plugin that registered the view.
143
+ * @param {string} viewId - The id of the view to be activated.
144
+ * @return {Promise<void>} A promise that resolves when the view is successfully activated.
145
+ */
146
+ activatePluginView(regionName: string, pluginId: string, viewId: string): Promise<void> {
147
+ this.regionManager.getRegion(regionName).activate(`${pluginId}::${viewId}`);
148
+ if (regionName === this.regions.shell.main) this._notifyMainViewChanged(viewId);
149
+ return Promise.resolve();
150
+ }
133
151
 
134
152
  getCurrentMainViewActive() {
135
153
  const mainView = this.regionManager.getRegion(this.regions.shell.main).currentActiveViews[0] as HarmonixViewDefinition;