@vuu-ui/vuu-shell 0.8.20-debug → 0.8.21-debug

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/cjs/index.js CHANGED
@@ -1302,6 +1302,7 @@ var SaveLayoutPanel = (props) => {
1302
1302
  const [radioValue, setRadioValue] = (0, import_react7.useState)(radioValues[0]);
1303
1303
  const [screenshot, setScreenshot] = (0, import_react7.useState)();
1304
1304
  const [screenshotErrorMessage, setScreenshotErrorMessage] = (0, import_react7.useState)();
1305
+ const [username] = getAuthDetailsFromCookies();
1305
1306
  (0, import_react7.useEffect)(() => {
1306
1307
  if (componentId) {
1307
1308
  takeScreenshot(document.getElementById(componentId)).then((screenshot2) => {
@@ -1316,7 +1317,7 @@ var SaveLayoutPanel = (props) => {
1316
1317
  name: layoutName,
1317
1318
  group,
1318
1319
  screenshot: screenshot != null ? screenshot : "",
1319
- user: "User"
1320
+ user: username
1320
1321
  });
1321
1322
  };
1322
1323
  const screenshotContent = (0, import_react7.useMemo)(() => {
@@ -1761,12 +1762,60 @@ var defaultApplicationJson = {
1761
1762
  // src/persistence-management/LocalPersistenceManager.ts
1762
1763
  var import_vuu_filters = require("@vuu-ui/vuu-filters");
1763
1764
  var import_vuu_utils4 = require("@vuu-ui/vuu-utils");
1764
- var metadataSaveLocation = "layouts/metadata";
1765
- var layoutsSaveLocation = "layouts/layouts";
1765
+ var baseMetadataSaveLocation = "layouts/metadata";
1766
+ var baseLayoutsSaveLocation = "layouts/layouts";
1766
1767
  var _urlKey;
1767
1768
  var LocalPersistenceManager = class {
1768
1769
  constructor(urlKey) {
1769
- __privateAdd(this, _urlKey, "api/vui");
1770
+ this.username = getAuthDetailsFromCookies()[0];
1771
+ this.metadataSaveLocation = `${baseMetadataSaveLocation}/${this.username}`;
1772
+ this.layoutsSaveLocation = `${baseLayoutsSaveLocation}/${this.username}`;
1773
+ __privateAdd(this, _urlKey, `api/vui/${this.username}`);
1774
+ this.loadLayouts = () => {
1775
+ return new Promise((resolve) => {
1776
+ const layouts = (0, import_vuu_filters.getLocalEntity)(this.layoutsSaveLocation);
1777
+ resolve(layouts || []);
1778
+ });
1779
+ };
1780
+ this.saveLayoutsWithMetadata = (layouts, metadata) => {
1781
+ (0, import_vuu_filters.saveLocalEntity)(this.layoutsSaveLocation, layouts);
1782
+ (0, import_vuu_filters.saveLocalEntity)(this.metadataSaveLocation, metadata);
1783
+ };
1784
+ // Ensures that there is exactly one Layout entry and exactly one Metadata
1785
+ // entry in local storage corresponding to the provided ID.
1786
+ this.validateIds = async (id) => {
1787
+ return Promise.all([
1788
+ this.validateId(id, "metadata").catch((error2) => error2.message),
1789
+ this.validateId(id, "layout").catch((error2) => error2.message)
1790
+ ]).then((errorMessages) => {
1791
+ const combinedMessage = errorMessages.filter((msg) => msg !== void 0).join("; ");
1792
+ if (combinedMessage) {
1793
+ throw new Error(combinedMessage);
1794
+ }
1795
+ });
1796
+ };
1797
+ // Ensures that there is exactly one element (Layout or Metadata) in local
1798
+ // storage corresponding to the provided ID.
1799
+ this.validateId = (id, dataType) => {
1800
+ return new Promise((resolve, reject) => {
1801
+ const loadFunc = dataType === "metadata" ? () => this.loadMetadata() : () => this.loadLayouts();
1802
+ loadFunc().then((array) => {
1803
+ const count = array.filter((element) => element.id === id).length;
1804
+ switch (count) {
1805
+ case 1: {
1806
+ resolve();
1807
+ break;
1808
+ }
1809
+ case 0: {
1810
+ reject(new Error(`No ${dataType} with ID ${id}`));
1811
+ break;
1812
+ }
1813
+ default:
1814
+ reject(new Error(`Non-unique ${dataType} with ID ${id}`));
1815
+ }
1816
+ });
1817
+ });
1818
+ };
1770
1819
  if (urlKey) {
1771
1820
  __privateSet(this, _urlKey, urlKey);
1772
1821
  }
@@ -1832,7 +1881,9 @@ var LocalPersistenceManager = class {
1832
1881
  }
1833
1882
  loadMetadata() {
1834
1883
  return new Promise((resolve) => {
1835
- const metadata = (0, import_vuu_filters.getLocalEntity)(metadataSaveLocation);
1884
+ const metadata = (0, import_vuu_filters.getLocalEntity)(
1885
+ this.metadataSaveLocation
1886
+ );
1836
1887
  resolve(metadata || []);
1837
1888
  });
1838
1889
  }
@@ -1859,51 +1910,6 @@ var LocalPersistenceManager = class {
1859
1910
  }
1860
1911
  });
1861
1912
  }
1862
- loadLayouts() {
1863
- return new Promise((resolve) => {
1864
- const layouts = (0, import_vuu_filters.getLocalEntity)(layoutsSaveLocation);
1865
- resolve(layouts || []);
1866
- });
1867
- }
1868
- saveLayoutsWithMetadata(layouts, metadata) {
1869
- (0, import_vuu_filters.saveLocalEntity)(layoutsSaveLocation, layouts);
1870
- (0, import_vuu_filters.saveLocalEntity)(metadataSaveLocation, metadata);
1871
- }
1872
- // Ensures that there is exactly one Layout entry and exactly one Metadata
1873
- // entry in local storage corresponding to the provided ID.
1874
- async validateIds(id) {
1875
- return Promise.all([
1876
- this.validateId(id, "metadata").catch((error2) => error2.message),
1877
- this.validateId(id, "layout").catch((error2) => error2.message)
1878
- ]).then((errorMessages) => {
1879
- const combinedMessage = errorMessages.filter((msg) => msg !== void 0).join("; ");
1880
- if (combinedMessage) {
1881
- throw new Error(combinedMessage);
1882
- }
1883
- });
1884
- }
1885
- // Ensures that there is exactly one element (Layout or Metadata) in local
1886
- // storage corresponding to the provided ID.
1887
- validateId(id, dataType) {
1888
- return new Promise((resolve, reject) => {
1889
- const loadFunc = dataType === "metadata" ? this.loadMetadata : this.loadLayouts;
1890
- loadFunc().then((array) => {
1891
- const count = array.filter((element) => element.id === id).length;
1892
- switch (count) {
1893
- case 1: {
1894
- resolve();
1895
- break;
1896
- }
1897
- case 0: {
1898
- reject(new Error(`No ${dataType} with ID ${id}`));
1899
- break;
1900
- }
1901
- default:
1902
- reject(new Error(`Non-unique ${dataType} with ID ${id}`));
1903
- }
1904
- });
1905
- });
1906
- }
1907
1913
  };
1908
1914
  _urlKey = new WeakMap();
1909
1915