@quincarter/create-lit-app 1.1.4 → 1.1.6

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.
Files changed (2) hide show
  1. package/create-app-shell.sh +58 -13
  2. package/package.json +1 -1
@@ -867,7 +867,7 @@ if [ "$ENABLE_ROUTER" = true ]; then
867
867
  directory: \"todos-page\",
868
868
  component: \"todos-page\",
869
869
  filePath: \"../../views/todos-page/todos-page.ts\",
870
- levelOfAccess: [\"public\"],
870
+ levelOfAccess: [\"private\"],
871
871
  tagName: \"todos-page\",
872
872
  isMfe: false,
873
873
  }"
@@ -953,6 +953,11 @@ export const routesBuilt = (
953
953
  icon: navItem.icon || ("" as IconType),
954
954
  mfeComponent: getMfeComponent(navItem.tagName),
955
955
  userHasPermission: getAccessPermissions(navItem, accesses),
956
+ children: navItem.children?.map((child: NavItem) => ({
957
+ ...child,
958
+ icon: child.icon || ("" as IconType),
959
+ userHasPermission: getAccessPermissions(child, accesses),
960
+ })),
956
961
  }));
957
962
  };
958
963
  EOF
@@ -1262,10 +1267,12 @@ export class AppShellHeader extends LitElement {
1262
1267
  ${
1263
1268
  this.routes.length > 0
1264
1269
  ? html`<ul>
1265
- ${this.routes.map(
1266
- (route) =>
1267
- html`<li><a href="${withBase(route.path)}">${route.name}</a></li>`,
1268
- )}
1270
+ ${this.routes
1271
+ .filter((route) => route.userHasPermission !== false)
1272
+ .map(
1273
+ (route) =>
1274
+ html`<li><a href="${withBase(route.path)}">${route.name}</a></li>`,
1275
+ )}
1269
1276
  </ul>`
1270
1277
  : nothing
1271
1278
  }
@@ -1623,7 +1630,7 @@ export const ViewMixin = <T extends Constructor<LitElement>>(superClass: T) => {
1623
1630
  return this.renderUnderConstruction();
1624
1631
  }
1625
1632
 
1626
- if (customTemplate) return html`${customTemplate}`;
1633
+ if (customTemplate && this.featureIsEnabled) return html`${customTemplate}`;
1627
1634
 
1628
1635
  return html`${
1629
1636
  this.featureIsEnabled && this.isMfe
@@ -1675,6 +1682,7 @@ import "../../components/todos/todo-list/todo-list";
1675
1682
 
1676
1683
  @customElement("todos-page")
1677
1684
  export class TodosPage extends ViewMixin(LitElement) {
1685
+ tagName = "todos-page";
1678
1686
  featureIsEnabled = true;
1679
1687
  isMfe = false;
1680
1688
  static styles = [TodosPageStyles];
@@ -1703,6 +1711,7 @@ import "../../components/card/generic-card";
1703
1711
 
1704
1712
  @customElement("card-examples")
1705
1713
  export class CardExamples extends ViewMixin(LitElement) {
1714
+ tagName = "card-examples";
1706
1715
  featureIsEnabled = true;
1707
1716
  isMfe = false;
1708
1717
  static styles = [CardPageStyles];
@@ -1731,6 +1740,7 @@ import "../../components/chart-js/chart-js";
1731
1740
 
1732
1741
  @customElement("chart-examples")
1733
1742
  export class ChartExamples extends ViewMixin(LitElement) {
1743
+ tagName = "chart-examples";
1734
1744
  featureIsEnabled = true;
1735
1745
  isMfe = false;
1736
1746
 
@@ -1792,7 +1802,10 @@ EOF
1792
1802
  IMPORTS="import { type HTMLTemplateResult, html, LitElement } from 'lit';
1793
1803
  import { customElement, property, state } from 'lit/decorators.js';
1794
1804
  import { AppShellStyles } from './app-shell.styles';
1795
- import type { NavItem } from './shared/interfaces/navigation.interface';"
1805
+ import type { NavItem } from './shared/interfaces/navigation.interface';
1806
+ import \"./shared/internal-views/404-not-found/page-not-found\";
1807
+ import \"./shared/internal-views/no-access/no-access\";
1808
+ import \"./shared/internal-views/under-construction/under-construction\";"
1796
1809
 
1797
1810
  if [ "$ENABLE_CONTEXT" = true ]; then
1798
1811
  IMPORTS="$IMPORTS
@@ -1814,9 +1827,10 @@ if [ "$ENABLE_ROUTER" = true ]; then
1814
1827
  import { Router } from '@lit-labs/router';
1815
1828
  import { html as staticHtml, unsafeStatic } from 'lit/static-html.js';
1816
1829
  import 'urlpattern-polyfill';
1817
- import { navigationRouting } from './shared/configuration/nav';
1830
+ import { navigationRouting, sidePages } from './shared/configuration/nav';
1818
1831
  import { routesBuilt } from './shared/configuration/routes';
1819
- import { withBase } from './shared/configuration/base-path';"
1832
+ import { withBase } from './shared/configuration/base-path';
1833
+ import { AppRootUtilities } from './shared/utilities/app-root.utility';"
1820
1834
  fi
1821
1835
 
1822
1836
  if [ "$ENABLE_HEADER" = true ]; then
@@ -1847,6 +1861,24 @@ cat <<EOF >> src/app-shell.ts
1847
1861
  @property({ type: Array })
1848
1862
  accesses: string[] = ["public"];
1849
1863
  EOF
1864
+ else
1865
+ cat <<EOF >> src/app-shell.ts
1866
+ @property({ type: Array })
1867
+ routing: NavItem[] = [];
1868
+
1869
+ @property({ type: Array })
1870
+ accesses: string[] = ["public"];
1871
+ EOF
1872
+ fi
1873
+
1874
+ if [ "$ENABLE_ROUTER" = true ]; then
1875
+ cat <<EOF >> src/app-shell.ts
1876
+ @state()
1877
+ navRoutes: NavItem[] = [] as NavItem[];
1878
+
1879
+ @state()
1880
+ notAllowedRouteList: NavItem[] = [];
1881
+ EOF
1850
1882
  fi
1851
1883
 
1852
1884
  # Provide the MFE loader independently of ENABLE_CONTEXT so that the MFE
@@ -1875,6 +1907,7 @@ EOF
1875
1907
 
1876
1908
  if [ "$ENABLE_ROUTER" = true ]; then
1877
1909
  cat <<EOF >> src/app-shell.ts
1910
+ this.navRoutes = this._buildNavBarRoutes(navigationRouting);
1878
1911
  await this._setupRoutes();
1879
1912
  EOF
1880
1913
  fi
@@ -1894,8 +1927,20 @@ EOF
1894
1927
  if [ "$ENABLE_ROUTER" = true ]; then
1895
1928
  cat <<EOF >> src/app-shell.ts
1896
1929
 
1930
+ private _buildNavBarRoutes(navItems: NavItem[]): NavItem[] {
1931
+ const navi = routesBuilt(navItems, this.accesses);
1932
+ const { notAllowed, navItems: filtered } =
1933
+ AppRootUtilities.getNotAllowedRoutes(navi, this.notAllowedRouteList);
1934
+ this.notAllowedRouteList = notAllowed;
1935
+ return filtered;
1936
+ }
1937
+
1897
1938
  private async _setupRoutes(): Promise<void> {
1898
- this.routing = routesBuilt(navigationRouting, ["public"]);
1939
+ const detailRoutes = this._buildNavBarRoutes([...sidePages]);
1940
+ this.routing = routesBuilt(
1941
+ [...this.navRoutes, ...this.notAllowedRouteList, ...detailRoutes],
1942
+ this.accesses,
1943
+ );
1899
1944
  const routeConfigs = this.routing.map((navItem) => ({
1900
1945
  path: withBase(navItem.path),
1901
1946
  enter: async () => {
@@ -1908,8 +1953,8 @@ cat <<EOF >> src/app-shell.ts
1908
1953
  },
1909
1954
  }));
1910
1955
 
1911
- const firstPath = navigationRouting[0]?.path || "/home";
1912
- const firstItem = navigationRouting[0];
1956
+ const firstPath = this.navRoutes[0]?.path || "/home";
1957
+ const firstItem = this.navRoutes[0];
1913
1958
 
1914
1959
  this._router.routes = [
1915
1960
  {
@@ -1943,7 +1988,7 @@ EOF
1943
1988
 
1944
1989
  if [ "$ENABLE_HEADER" = true ]; then
1945
1990
  cat <<EOF >> src/app-shell.ts
1946
- <app-shell-header .routes="\${this.routing}" enable-theme-switcher>
1991
+ <app-shell-header .routes="\${this.navRoutes}" enable-theme-switcher>
1947
1992
  <main>
1948
1993
  EOF
1949
1994
  else
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quincarter/create-lit-app",
3
- "version": "1.1.4",
3
+ "version": "1.1.6",
4
4
  "description": "Interactive CLI initializer for Lit Element App Shell architecture",
5
5
  "type": "module",
6
6
  "bin": {