@teambit/lanes 0.0.388 → 0.0.389

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.
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { RouteProps } from 'react-router-dom';
2
3
  import { Harmony } from '@teambit/harmony';
3
4
  import { UiUI } from '@teambit/ui';
@@ -31,6 +32,16 @@ export declare class LanesUI {
31
32
  private readonly hostAspect?;
32
33
  private readonly host;
33
34
  private registerHostAspectRoutes;
35
+ getLaneRoutes(): {
36
+ path: string;
37
+ children: JSX.Element;
38
+ }[];
39
+ getLaneGallery(): JSX.Element;
40
+ getMenuRoutes(): {
41
+ path: string;
42
+ children: JSX.Element;
43
+ }[];
44
+ getLanesOverviewMenu(): JSX.Element;
34
45
  registerMenuWidget(...menuItems: MenuWidget[]): void;
35
46
  private registerLanesRoutes;
36
47
  private registerRoutes;
@@ -159,7 +159,12 @@ class LanesUI {
159
159
 
160
160
  registerHostAspectRoutes() {
161
161
  if (!this.hostAspect) return;
162
- this.hostAspect.registerRoutes([{
162
+ this.hostAspect.registerRoutes(this.getLaneRoutes());
163
+ this.hostAspect.registerMenuRoutes(this.getMenuRoutes());
164
+ }
165
+
166
+ getLaneRoutes() {
167
+ return [{
163
168
  path: _lanesUi().LanesModel.lanesPrefix,
164
169
  children: /*#__PURE__*/_react().default.createElement(_react().default.Fragment, null, /*#__PURE__*/_react().default.createElement(_reactRouterDom().Route, {
165
170
  path: _lanesUi().LanesModel.lanePath
@@ -172,11 +177,7 @@ class LanesUI {
172
177
  })
173
178
  }), /*#__PURE__*/_react().default.createElement(_reactRouterDom().Route, {
174
179
  path: "~gallery",
175
- element: /*#__PURE__*/_react().default.createElement(_lanesUi().LaneGallery, {
176
- routeSlot: this.routeSlot,
177
- overviewSlot: this.overviewSlot,
178
- host: this.lanesHost
179
- })
180
+ element: this.getLaneGallery()
180
181
  }), /*#__PURE__*/_react().default.createElement(_reactRouterDom().Route, {
181
182
  path: "~component/*",
182
183
  element: this.componentUi.getComponentUI(this.host)
@@ -187,22 +188,37 @@ class LanesUI {
187
188
  path: "*",
188
189
  element: /*#__PURE__*/_react().default.createElement(_designUiPages().NotFoundPage, null)
189
190
  }))
190
- }]);
191
- this.hostAspect.registerMenuRoutes([{
191
+ }];
192
+ }
193
+
194
+ getLaneGallery() {
195
+ return /*#__PURE__*/_react().default.createElement(_lanesUi().LaneGallery, {
196
+ routeSlot: this.routeSlot,
197
+ overviewSlot: this.overviewSlot,
198
+ host: this.lanesHost
199
+ });
200
+ }
201
+
202
+ getMenuRoutes() {
203
+ return [{
192
204
  path: _lanesUi().LanesModel.lanesPrefix,
193
205
  children: /*#__PURE__*/_react().default.createElement(_reactRouterDom().Route, {
194
206
  path: `${_lanesUi().LanesModel.lanePath}/*`
195
207
  }, /*#__PURE__*/_react().default.createElement(_reactRouterDom().Route, {
196
208
  path: "*",
197
- element: /*#__PURE__*/_react().default.createElement(_lanesUi().LanesOverviewMenu, {
198
- navigationSlot: this.navSlot,
199
- widgetSlot: this.menuWidgetSlot
200
- })
209
+ element: this.getLanesOverviewMenu()
201
210
  }), /*#__PURE__*/_react().default.createElement(_reactRouterDom().Route, {
202
211
  path: "~component/*",
203
212
  element: this.componentUi.getMenu(this.host)
204
213
  }))
205
- }]);
214
+ }];
215
+ }
216
+
217
+ getLanesOverviewMenu() {
218
+ return /*#__PURE__*/_react().default.createElement(_lanesUi().LanesOverviewMenu, {
219
+ navigationSlot: this.navSlot,
220
+ widgetSlot: this.menuWidgetSlot
221
+ });
206
222
  }
207
223
 
208
224
  registerMenuWidget(...menuItems) {
@@ -273,7 +289,7 @@ class LanesUI {
273
289
  }
274
290
 
275
291
  const lanesUi = new LanesUI(componentUi, routeSlot, navSlot, overviewSlot, menuWidgetSlot, workspace, scope);
276
- uiUi.registerRenderHooks({
292
+ if (uiUi) uiUi.registerRenderHooks({
277
293
  reactContext: lanesUi.renderContext
278
294
  });
279
295
  const drawer = new (_lanesUi().LanesDrawer)({
@@ -1 +1 @@
1
- {"version":3,"names":["LanesUI","constructor","componentUi","routeSlot","navSlot","menuWidgetSlot","overviewSlot","workspace","scope","children","hostAspect","lanesHost","host","WorkspaceAspect","id","ScopeAspect","registerHostAspectRoutes","registerRoutes","path","LanesModel","lanesPrefix","lanePath","getComponentUI","registerMenuRoutes","getMenu","registerMenuWidget","menuItems","register","registerLanesRoutes","registerNavigation","props","href","exact","order","hide","lanesContext","useLanesContext","viewedLane","readmeComponent","registerRoute","route","registerOverviewLine","lines","routes","provider","uiUi","workspaceUi","scopeUi","sidebarUi","_","harmony","config","String","get","lanesUi","registerRenderHooks","reactContext","renderContext","drawer","LanesDrawer","showScope","registerDrawer","UIAspect","ComponentAspect","SidebarAspect","UIRuntime","Slot","withType","LanesAspect","addRuntime"],"sources":["lanes.ui.runtime.tsx"],"sourcesContent":["import React, { ReactNode } from 'react';\nimport { Route, RouteProps } from 'react-router-dom';\nimport { Slot, Harmony } from '@teambit/harmony';\nimport { UIRuntime, UiUI, UIAspect } from '@teambit/ui';\nimport { LanesAspect } from '@teambit/lanes';\nimport { NavigationSlot, RouteSlot } from '@teambit/ui-foundation.ui.react-router.slot-router';\nimport {\n LanesDrawer,\n LanesHost,\n LaneGallery,\n LanesOrderedNavigationSlot,\n LanesModel,\n LanesOverviewMenu,\n ViewedLaneFromUrl,\n LaneOverviewLineSlot,\n LaneOverviewLine,\n UseLaneMenu,\n useLanesContext,\n LanesNavPlugin,\n LaneReadmeOverview,\n} from '@teambit/lanes.ui.lanes';\nimport { NotFoundPage } from '@teambit/design.ui.pages.not-found';\nimport ScopeAspect, { ScopeUI } from '@teambit/scope';\nimport WorkspaceAspect, { WorkspaceUI } from '@teambit/workspace';\nimport ComponentAspect, { ComponentUI } from '@teambit/component';\nimport SidebarAspect, { SidebarUI } from '@teambit/sidebar';\nimport { MenuWidget, MenuWidgetSlot } from '@teambit/ui-foundation.ui.menu';\n\nexport class LanesUI {\n static dependencies = [UIAspect, ComponentAspect, WorkspaceAspect, ScopeAspect, SidebarAspect];\n static runtime = UIRuntime;\n static slots = [\n Slot.withType<RouteProps>(),\n Slot.withType<LaneOverviewLineSlot>(),\n Slot.withType<NavigationSlot>(),\n Slot.withType<MenuWidgetSlot>(),\n ];\n\n constructor(\n private componentUi: ComponentUI,\n private routeSlot: RouteSlot,\n private navSlot: LanesOrderedNavigationSlot,\n private menuWidgetSlot: MenuWidgetSlot,\n /**\n * overview line slot to add new lines beneath the overview section\n */\n private overviewSlot: LaneOverviewLineSlot,\n private workspace?: WorkspaceUI,\n private scope?: ScopeUI\n ) {\n this.hostAspect = workspace || scope;\n this.lanesHost = workspace ? 'workspace' : 'scope';\n this.host = workspace ? WorkspaceAspect.id : ScopeAspect.id;\n }\n\n private readonly lanesHost: LanesHost;\n private readonly hostAspect?: WorkspaceUI | ScopeUI;\n private readonly host: string;\n\n private registerHostAspectRoutes() {\n if (!this.hostAspect) return;\n this.hostAspect.registerRoutes([\n {\n path: LanesModel.lanesPrefix,\n children: (\n <>\n <Route path={LanesModel.lanePath}>\n <Route\n index\n element={\n <LaneReadmeOverview host={this.host} overviewSlot={this.overviewSlot} routeSlot={this.routeSlot} />\n }\n />\n <Route\n path=\"~gallery\"\n element={\n <LaneGallery routeSlot={this.routeSlot} overviewSlot={this.overviewSlot} host={this.lanesHost} />\n }\n />\n <Route path=\"~component/*\" element={this.componentUi.getComponentUI(this.host)} />\n <Route path=\"*\" element={<NotFoundPage />} />\n </Route>\n <Route path=\"*\" element={<NotFoundPage />} />\n </>\n ),\n },\n ]);\n this.hostAspect.registerMenuRoutes([\n {\n path: LanesModel.lanesPrefix,\n children: (\n <Route path={`${LanesModel.lanePath}/*`}>\n <Route\n path=\"*\"\n element={<LanesOverviewMenu navigationSlot={this.navSlot} widgetSlot={this.menuWidgetSlot} />}\n />\n <Route path=\"~component/*\" element={this.componentUi.getMenu(this.host)} />\n </Route>\n ),\n },\n ]);\n }\n\n registerMenuWidget(...menuItems: MenuWidget[]) {\n this.menuWidgetSlot.register(menuItems);\n }\n\n private registerLanesRoutes() {\n this.registerNavigation([\n {\n props: {\n href: '.',\n exact: true,\n children: 'README',\n },\n order: 1,\n hide: () => {\n const lanesContext = useLanesContext();\n return !lanesContext?.viewedLane?.readmeComponent;\n },\n },\n {\n props: {\n href: '~gallery',\n children: 'Gallery',\n exact: true,\n },\n order: 1,\n },\n ]);\n }\n\n private registerRoutes() {\n this.registerHostAspectRoutes();\n this.registerLanesRoutes();\n }\n\n private renderContext = ({ children }: { children: ReactNode }) => {\n return <ViewedLaneFromUrl>{children}</ViewedLaneFromUrl>;\n };\n\n registerRoute(route: RouteProps) {\n this.routeSlot.register(route);\n return this;\n }\n\n /**\n * register a new line beneath the lane overview section.\n */\n registerOverviewLine(...lines: LaneOverviewLine[]) {\n this.overviewSlot.register(lines);\n return this;\n }\n\n registerNavigation(routes: LanesNavPlugin[]) {\n this.navSlot.register(routes);\n }\n\n static async provider(\n [uiUi, componentUi, workspaceUi, scopeUi, sidebarUi]: [UiUI, ComponentUI, WorkspaceUI, ScopeUI, SidebarUI],\n _,\n [routeSlot, overviewSlot, navSlot, menuWidgetSlot]: [\n RouteSlot,\n LaneOverviewLineSlot,\n LanesOrderedNavigationSlot,\n MenuWidgetSlot\n ],\n harmony: Harmony\n ) {\n const { config } = harmony;\n const host = String(config.get('teambit.harmony/bit'));\n let workspace: WorkspaceUI | undefined;\n let scope: ScopeUI | undefined;\n if (host === WorkspaceAspect.id) {\n workspace = workspaceUi;\n }\n if (host === ScopeAspect.id) {\n scope = scopeUi;\n }\n const lanesUi = new LanesUI(componentUi, routeSlot, navSlot, overviewSlot, menuWidgetSlot, workspace, scope);\n uiUi.registerRenderHooks({ reactContext: lanesUi.renderContext });\n const drawer = new LanesDrawer({ showScope: lanesUi.lanesHost === 'workspace' });\n sidebarUi.registerDrawer(drawer);\n lanesUi.registerRoutes();\n lanesUi.registerMenuWidget(() => <UseLaneMenu host={lanesUi.lanesHost} />);\n return lanesUi;\n }\n}\n\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XhE,O,aAEMiE,e;gCAFNjE,O,WAGI,CACbkE,eAAA,CAAKC,QAAL,EADa,EAEbD,eAAA,CAAKC,QAAL,EAFa,EAGbD,eAAA,CAAKC,QAAL,EAHa,EAIbD,eAAA,CAAKC,QAAL,EAJa,C;eA8JFnE,O;;;AAEfoE,oBAAA,CAAYC,UAAZ,CAAuBrE,OAAvB"}
1
+ {"version":3,"names":["LanesUI","constructor","componentUi","routeSlot","navSlot","menuWidgetSlot","overviewSlot","workspace","scope","children","hostAspect","lanesHost","host","WorkspaceAspect","id","ScopeAspect","registerHostAspectRoutes","registerRoutes","getLaneRoutes","registerMenuRoutes","getMenuRoutes","path","LanesModel","lanesPrefix","lanePath","getLaneGallery","getComponentUI","getLanesOverviewMenu","getMenu","registerMenuWidget","menuItems","register","registerLanesRoutes","registerNavigation","props","href","exact","order","hide","lanesContext","useLanesContext","viewedLane","readmeComponent","registerRoute","route","registerOverviewLine","lines","routes","provider","uiUi","workspaceUi","scopeUi","sidebarUi","_","harmony","config","String","get","lanesUi","registerRenderHooks","reactContext","renderContext","drawer","LanesDrawer","showScope","registerDrawer","UIAspect","ComponentAspect","SidebarAspect","UIRuntime","Slot","withType","LanesAspect","addRuntime"],"sources":["lanes.ui.runtime.tsx"],"sourcesContent":["import React, { ReactNode } from 'react';\nimport { Route, RouteProps } from 'react-router-dom';\nimport { Slot, Harmony } from '@teambit/harmony';\nimport { UIRuntime, UiUI, UIAspect } from '@teambit/ui';\nimport { LanesAspect } from '@teambit/lanes';\nimport { NavigationSlot, RouteSlot } from '@teambit/ui-foundation.ui.react-router.slot-router';\nimport {\n LanesDrawer,\n LanesHost,\n LaneGallery,\n LanesOrderedNavigationSlot,\n LanesModel,\n LanesOverviewMenu,\n ViewedLaneFromUrl,\n LaneOverviewLineSlot,\n LaneOverviewLine,\n UseLaneMenu,\n useLanesContext,\n LanesNavPlugin,\n LaneReadmeOverview,\n} from '@teambit/lanes.ui.lanes';\nimport { NotFoundPage } from '@teambit/design.ui.pages.not-found';\nimport ScopeAspect, { ScopeUI } from '@teambit/scope';\nimport WorkspaceAspect, { WorkspaceUI } from '@teambit/workspace';\nimport ComponentAspect, { ComponentUI } from '@teambit/component';\nimport SidebarAspect, { SidebarUI } from '@teambit/sidebar';\nimport { MenuWidget, MenuWidgetSlot } from '@teambit/ui-foundation.ui.menu';\n\nexport class LanesUI {\n static dependencies = [UIAspect, ComponentAspect, WorkspaceAspect, ScopeAspect, SidebarAspect];\n static runtime = UIRuntime;\n static slots = [\n Slot.withType<RouteProps>(),\n Slot.withType<LaneOverviewLineSlot>(),\n Slot.withType<NavigationSlot>(),\n Slot.withType<MenuWidgetSlot>(),\n ];\n\n constructor(\n private componentUi: ComponentUI,\n private routeSlot: RouteSlot,\n private navSlot: LanesOrderedNavigationSlot,\n private menuWidgetSlot: MenuWidgetSlot,\n /**\n * overview line slot to add new lines beneath the overview section\n */\n private overviewSlot: LaneOverviewLineSlot,\n private workspace?: WorkspaceUI,\n private scope?: ScopeUI\n ) {\n this.hostAspect = workspace || scope;\n this.lanesHost = workspace ? 'workspace' : 'scope';\n this.host = workspace ? WorkspaceAspect.id : ScopeAspect.id;\n }\n\n private readonly lanesHost: LanesHost;\n private readonly hostAspect?: WorkspaceUI | ScopeUI;\n private readonly host: string;\n\n private registerHostAspectRoutes() {\n if (!this.hostAspect) return;\n this.hostAspect.registerRoutes(this.getLaneRoutes());\n this.hostAspect.registerMenuRoutes(this.getMenuRoutes());\n }\n\n getLaneRoutes() {\n return [\n {\n path: LanesModel.lanesPrefix,\n children: (\n <>\n <Route path={LanesModel.lanePath}>\n <Route\n index\n element={\n <LaneReadmeOverview host={this.host} overviewSlot={this.overviewSlot} routeSlot={this.routeSlot} />\n }\n />\n <Route\n path=\"~gallery\"\n element={this.getLaneGallery()}\n />\n <Route path=\"~component/*\" element={this.componentUi.getComponentUI(this.host)} />\n <Route path=\"*\" element={<NotFoundPage />} />\n </Route>\n <Route path=\"*\" element={<NotFoundPage />} />\n </>\n ),\n },\n ];\n }\n\n getLaneGallery() {\n return <LaneGallery routeSlot={this.routeSlot} overviewSlot={this.overviewSlot} host={this.lanesHost} />;\n }\n\n getMenuRoutes() {\n return [\n {\n path: LanesModel.lanesPrefix,\n children: (\n <Route path={`${LanesModel.lanePath}/*`}>\n <Route\n path=\"*\"\n element={this.getLanesOverviewMenu()}\n />\n <Route path=\"~component/*\" element={this.componentUi.getMenu(this.host)} />\n </Route>\n ),\n },\n ];\n }\n\n getLanesOverviewMenu() {\n return <LanesOverviewMenu navigationSlot={this.navSlot} widgetSlot={this.menuWidgetSlot} />;\n }\n\n registerMenuWidget(...menuItems: MenuWidget[]) {\n this.menuWidgetSlot.register(menuItems);\n }\n\n private registerLanesRoutes() {\n this.registerNavigation([\n {\n props: {\n href: '.',\n exact: true,\n children: 'README',\n },\n order: 1,\n hide: () => {\n const lanesContext = useLanesContext();\n return !lanesContext?.viewedLane?.readmeComponent;\n },\n },\n {\n props: {\n href: '~gallery',\n children: 'Gallery',\n exact: true,\n },\n order: 1,\n },\n ]);\n }\n\n private registerRoutes() {\n this.registerHostAspectRoutes();\n this.registerLanesRoutes();\n }\n\n private renderContext = ({ children }: { children: ReactNode }) => {\n return <ViewedLaneFromUrl>{children}</ViewedLaneFromUrl>;\n };\n\n registerRoute(route: RouteProps) {\n this.routeSlot.register(route);\n return this;\n }\n\n /**\n * register a new line beneath the lane overview section.\n */\n registerOverviewLine(...lines: LaneOverviewLine[]) {\n this.overviewSlot.register(lines);\n return this;\n }\n\n registerNavigation(routes: LanesNavPlugin[]) {\n this.navSlot.register(routes);\n }\n\n static async provider(\n [uiUi, componentUi, workspaceUi, scopeUi, sidebarUi]: [UiUI, ComponentUI, WorkspaceUI, ScopeUI, SidebarUI],\n _,\n [routeSlot, overviewSlot, navSlot, menuWidgetSlot]: [\n RouteSlot,\n LaneOverviewLineSlot,\n LanesOrderedNavigationSlot,\n MenuWidgetSlot\n ],\n harmony: Harmony\n ) {\n const { config } = harmony;\n const host = String(config.get('teambit.harmony/bit'));\n let workspace: WorkspaceUI | undefined;\n let scope: ScopeUI | undefined;\n if (host === WorkspaceAspect.id) {\n workspace = workspaceUi;\n }\n if (host === ScopeAspect.id) {\n scope = scopeUi;\n }\n const lanesUi = new LanesUI(componentUi, routeSlot, navSlot, overviewSlot, menuWidgetSlot, workspace, scope);\n if (uiUi) uiUi.registerRenderHooks({ reactContext: lanesUi.renderContext });\n const drawer = new LanesDrawer({ showScope: lanesUi.lanesHost === 'workspace' });\n sidebarUi.registerDrawer(drawer);\n lanesUi.registerRoutes();\n lanesUi.registerMenuWidget(() => <UseLaneMenu host={lanesUi.lanesHost} />);\n return lanesUi;\n }\n}\n\nexport default LanesUI;\n\nLanesAspect.addRuntime(LanesUI);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAeA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAGO,MAAMA,OAAN,CAAc;EAUnBC,WAAW,CACDC,WADC,EAEDC,SAFC,EAGDC,OAHC,EAIDC,cAJC;EAKT;AACJ;AACA;EACYC,YARC,EASDC,SATC,EAUDC,KAVC,EAWT;IAAA,KAVQN,WAUR,GAVQA,WAUR;IAAA,KATQC,SASR,GATQA,SASR;IAAA,KARQC,OAQR,GARQA,OAQR;IAAA,KA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IAAI1D,OAAJ,CAAYE,WAAZ,EAAyBC,SAAzB,EAAoCC,OAApC,EAA6CE,YAA7C,EAA2DD,cAA3D,EAA2EE,SAA3E,EAAsFC,KAAtF,CAAhB;IACA,IAAIyC,IAAJ,EAAUA,IAAI,CAACU,mBAAL,CAAyB;MAAEC,YAAY,EAAEF,OAAO,CAACG;IAAxB,CAAzB;IACV,MAAMC,MAAM,GAAG,KAAIC,sBAAJ,EAAgB;MAAEC,SAAS,EAAEN,OAAO,CAAC/C,SAAR,KAAsB;IAAnC,CAAhB,CAAf;IACAyC,SAAS,CAACa,cAAV,CAAyBH,MAAzB;IACAJ,OAAO,CAACzC,cAAR;IACAyC,OAAO,CAAC7B,kBAAR,CAA2B,mBAAM,+BAAC,sBAAD;MAAa,IAAI,EAAE6B,OAAO,CAAC/C;IAA3B,EAAjC;IACA,OAAO+C,OAAP;EACD;;AA5KkB;;;gCAAR1D,O,kBACW,CAACkE,cAAD,EAAWC,oBAAX,EAA4BtD,oBAA5B,EAA6CE,gBAA7C,EAA0DqD,kBAA1D,C;gCADXpE,O,aAEMqE,e;gCAFNrE,O,WAGI,CACbsE,eAAA,CAAKC,QAAL,EADa,EAEbD,eAAA,CAAKC,QAAL,EAFa,EAGbD,eAAA,CAAKC,QAAL,EAHa,EAIbD,eAAA,CAAKC,QAAL,EAJa,C;eA4KFvE,O;;;AAEfwE,oBAAA,CAAYC,UAAZ,CAAuBzE,OAAvB"}
@@ -59,7 +59,12 @@ export class LanesUI {
59
59
 
60
60
  private registerHostAspectRoutes() {
61
61
  if (!this.hostAspect) return;
62
- this.hostAspect.registerRoutes([
62
+ this.hostAspect.registerRoutes(this.getLaneRoutes());
63
+ this.hostAspect.registerMenuRoutes(this.getMenuRoutes());
64
+ }
65
+
66
+ getLaneRoutes() {
67
+ return [
63
68
  {
64
69
  path: LanesModel.lanesPrefix,
65
70
  children: (
@@ -73,9 +78,7 @@ export class LanesUI {
73
78
  />
74
79
  <Route
75
80
  path="~gallery"
76
- element={
77
- <LaneGallery routeSlot={this.routeSlot} overviewSlot={this.overviewSlot} host={this.lanesHost} />
78
- }
81
+ element={this.getLaneGallery()}
79
82
  />
80
83
  <Route path="~component/*" element={this.componentUi.getComponentUI(this.host)} />
81
84
  <Route path="*" element={<NotFoundPage />} />
@@ -84,21 +87,32 @@ export class LanesUI {
84
87
  </>
85
88
  ),
86
89
  },
87
- ]);
88
- this.hostAspect.registerMenuRoutes([
90
+ ];
91
+ }
92
+
93
+ getLaneGallery() {
94
+ return <LaneGallery routeSlot={this.routeSlot} overviewSlot={this.overviewSlot} host={this.lanesHost} />;
95
+ }
96
+
97
+ getMenuRoutes() {
98
+ return [
89
99
  {
90
100
  path: LanesModel.lanesPrefix,
91
101
  children: (
92
102
  <Route path={`${LanesModel.lanePath}/*`}>
93
103
  <Route
94
104
  path="*"
95
- element={<LanesOverviewMenu navigationSlot={this.navSlot} widgetSlot={this.menuWidgetSlot} />}
105
+ element={this.getLanesOverviewMenu()}
96
106
  />
97
107
  <Route path="~component/*" element={this.componentUi.getMenu(this.host)} />
98
108
  </Route>
99
109
  ),
100
110
  },
101
- ]);
111
+ ];
112
+ }
113
+
114
+ getLanesOverviewMenu() {
115
+ return <LanesOverviewMenu navigationSlot={this.navSlot} widgetSlot={this.menuWidgetSlot} />;
102
116
  }
103
117
 
104
118
  registerMenuWidget(...menuItems: MenuWidget[]) {
@@ -178,7 +192,7 @@ export class LanesUI {
178
192
  scope = scopeUi;
179
193
  }
180
194
  const lanesUi = new LanesUI(componentUi, routeSlot, navSlot, overviewSlot, menuWidgetSlot, workspace, scope);
181
- uiUi.registerRenderHooks({ reactContext: lanesUi.renderContext });
195
+ if (uiUi) uiUi.registerRenderHooks({ reactContext: lanesUi.renderContext });
182
196
  const drawer = new LanesDrawer({ showScope: lanesUi.lanesHost === 'workspace' });
183
197
  sidebarUi.registerDrawer(drawer);
184
198
  lanesUi.registerRoutes();
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@teambit/lanes",
3
- "version": "0.0.388",
3
+ "version": "0.0.389",
4
4
  "homepage": "https://bit.dev/teambit/lanes/lanes",
5
5
  "main": "dist/index.js",
6
6
  "componentId": {
7
7
  "scope": "teambit.lanes",
8
8
  "name": "lanes",
9
- "version": "0.0.388"
9
+ "version": "0.0.389"
10
10
  },
11
11
  "dependencies": {
12
12
  "chalk": "2.4.2",
@@ -18,23 +18,23 @@
18
18
  "core-js": "^3.0.0",
19
19
  "@teambit/harmony": "0.3.3",
20
20
  "@teambit/bit-error": "0.0.394",
21
- "@teambit/lane-id": "0.0.63",
22
- "@teambit/cli": "0.0.544",
23
- "@teambit/merging": "0.0.131",
24
- "@teambit/scope": "0.0.816",
25
- "@teambit/workspace": "0.0.816",
26
- "@teambit/graphql": "0.0.816",
27
- "@teambit/community": "0.0.92",
28
- "@teambit/component": "0.0.816",
29
- "@teambit/lanes.modules.diff": "0.0.173",
21
+ "@teambit/lane-id": "0.0.64",
22
+ "@teambit/cli": "0.0.545",
23
+ "@teambit/merging": "0.0.132",
24
+ "@teambit/scope": "0.0.817",
25
+ "@teambit/workspace": "0.0.817",
26
+ "@teambit/graphql": "0.0.817",
27
+ "@teambit/community": "0.0.93",
28
+ "@teambit/component": "0.0.817",
29
+ "@teambit/lanes.modules.diff": "0.0.174",
30
30
  "@teambit/legacy-bit-id": "0.0.402",
31
- "@teambit/logger": "0.0.637",
31
+ "@teambit/logger": "0.0.638",
32
32
  "@teambit/design.ui.pages.not-found": "0.0.356",
33
- "@teambit/lanes.ui.lanes": "0.0.113",
34
- "@teambit/sidebar": "0.0.816",
33
+ "@teambit/lanes.ui.lanes": "0.0.114",
34
+ "@teambit/sidebar": "0.0.817",
35
35
  "@teambit/ui-foundation.ui.menu": "0.0.487",
36
36
  "@teambit/ui-foundation.ui.react-router.slot-router": "0.0.490",
37
- "@teambit/ui": "0.0.816",
37
+ "@teambit/ui": "0.0.817",
38
38
  "@teambit/component-id": "0.0.405"
39
39
  },
40
40
  "devDependencies": {
@@ -51,7 +51,7 @@
51
51
  },
52
52
  "peerDependencies": {
53
53
  "react-router-dom": "^6.0.0",
54
- "@teambit/legacy": "1.0.327",
54
+ "@teambit/legacy": "1.0.328",
55
55
  "react-dom": "^16.8.0 || ^17.0.0",
56
56
  "react": "^16.8.0 || ^17.0.0"
57
57
  },
@@ -1,5 +1,5 @@
1
- import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.lanes_lanes@0.0.388/dist/lanes.composition.js';
2
- import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.lanes_lanes@0.0.388/dist/lanes.docs.mdx';
1
+ import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.lanes_lanes@0.0.389/dist/lanes.composition.js';
2
+ import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.lanes_lanes@0.0.389/dist/lanes.docs.mdx';
3
3
 
4
4
  export const compositions = [compositions_0];
5
5
  export const overview = [overview_0];