@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/esm/index.js CHANGED
@@ -1248,6 +1248,7 @@ var SaveLayoutPanel = (props) => {
1248
1248
  const [radioValue, setRadioValue] = useState3(radioValues[0]);
1249
1249
  const [screenshot, setScreenshot] = useState3();
1250
1250
  const [screenshotErrorMessage, setScreenshotErrorMessage] = useState3();
1251
+ const [username] = getAuthDetailsFromCookies();
1251
1252
  useEffect4(() => {
1252
1253
  if (componentId) {
1253
1254
  takeScreenshot(document.getElementById(componentId)).then((screenshot2) => {
@@ -1262,7 +1263,7 @@ var SaveLayoutPanel = (props) => {
1262
1263
  name: layoutName,
1263
1264
  group,
1264
1265
  screenshot: screenshot != null ? screenshot : "",
1265
- user: "User"
1266
+ user: username
1266
1267
  });
1267
1268
  };
1268
1269
  const screenshotContent = useMemo2(() => {
@@ -1715,12 +1716,60 @@ var defaultApplicationJson = {
1715
1716
  // src/persistence-management/LocalPersistenceManager.ts
1716
1717
  import { getLocalEntity, saveLocalEntity } from "@vuu-ui/vuu-filters";
1717
1718
  import { formatDate, getUniqueId as getUniqueId2 } from "@vuu-ui/vuu-utils";
1718
- var metadataSaveLocation = "layouts/metadata";
1719
- var layoutsSaveLocation = "layouts/layouts";
1719
+ var baseMetadataSaveLocation = "layouts/metadata";
1720
+ var baseLayoutsSaveLocation = "layouts/layouts";
1720
1721
  var _urlKey;
1721
1722
  var LocalPersistenceManager = class {
1722
1723
  constructor(urlKey) {
1723
- __privateAdd(this, _urlKey, "api/vui");
1724
+ this.username = getAuthDetailsFromCookies()[0];
1725
+ this.metadataSaveLocation = `${baseMetadataSaveLocation}/${this.username}`;
1726
+ this.layoutsSaveLocation = `${baseLayoutsSaveLocation}/${this.username}`;
1727
+ __privateAdd(this, _urlKey, `api/vui/${this.username}`);
1728
+ this.loadLayouts = () => {
1729
+ return new Promise((resolve) => {
1730
+ const layouts = getLocalEntity(this.layoutsSaveLocation);
1731
+ resolve(layouts || []);
1732
+ });
1733
+ };
1734
+ this.saveLayoutsWithMetadata = (layouts, metadata) => {
1735
+ saveLocalEntity(this.layoutsSaveLocation, layouts);
1736
+ saveLocalEntity(this.metadataSaveLocation, metadata);
1737
+ };
1738
+ // Ensures that there is exactly one Layout entry and exactly one Metadata
1739
+ // entry in local storage corresponding to the provided ID.
1740
+ this.validateIds = async (id) => {
1741
+ return Promise.all([
1742
+ this.validateId(id, "metadata").catch((error2) => error2.message),
1743
+ this.validateId(id, "layout").catch((error2) => error2.message)
1744
+ ]).then((errorMessages) => {
1745
+ const combinedMessage = errorMessages.filter((msg) => msg !== void 0).join("; ");
1746
+ if (combinedMessage) {
1747
+ throw new Error(combinedMessage);
1748
+ }
1749
+ });
1750
+ };
1751
+ // Ensures that there is exactly one element (Layout or Metadata) in local
1752
+ // storage corresponding to the provided ID.
1753
+ this.validateId = (id, dataType) => {
1754
+ return new Promise((resolve, reject) => {
1755
+ const loadFunc = dataType === "metadata" ? () => this.loadMetadata() : () => this.loadLayouts();
1756
+ loadFunc().then((array) => {
1757
+ const count = array.filter((element) => element.id === id).length;
1758
+ switch (count) {
1759
+ case 1: {
1760
+ resolve();
1761
+ break;
1762
+ }
1763
+ case 0: {
1764
+ reject(new Error(`No ${dataType} with ID ${id}`));
1765
+ break;
1766
+ }
1767
+ default:
1768
+ reject(new Error(`Non-unique ${dataType} with ID ${id}`));
1769
+ }
1770
+ });
1771
+ });
1772
+ };
1724
1773
  if (urlKey) {
1725
1774
  __privateSet(this, _urlKey, urlKey);
1726
1775
  }
@@ -1786,7 +1835,9 @@ var LocalPersistenceManager = class {
1786
1835
  }
1787
1836
  loadMetadata() {
1788
1837
  return new Promise((resolve) => {
1789
- const metadata = getLocalEntity(metadataSaveLocation);
1838
+ const metadata = getLocalEntity(
1839
+ this.metadataSaveLocation
1840
+ );
1790
1841
  resolve(metadata || []);
1791
1842
  });
1792
1843
  }
@@ -1813,51 +1864,6 @@ var LocalPersistenceManager = class {
1813
1864
  }
1814
1865
  });
1815
1866
  }
1816
- loadLayouts() {
1817
- return new Promise((resolve) => {
1818
- const layouts = getLocalEntity(layoutsSaveLocation);
1819
- resolve(layouts || []);
1820
- });
1821
- }
1822
- saveLayoutsWithMetadata(layouts, metadata) {
1823
- saveLocalEntity(layoutsSaveLocation, layouts);
1824
- saveLocalEntity(metadataSaveLocation, metadata);
1825
- }
1826
- // Ensures that there is exactly one Layout entry and exactly one Metadata
1827
- // entry in local storage corresponding to the provided ID.
1828
- async validateIds(id) {
1829
- return Promise.all([
1830
- this.validateId(id, "metadata").catch((error2) => error2.message),
1831
- this.validateId(id, "layout").catch((error2) => error2.message)
1832
- ]).then((errorMessages) => {
1833
- const combinedMessage = errorMessages.filter((msg) => msg !== void 0).join("; ");
1834
- if (combinedMessage) {
1835
- throw new Error(combinedMessage);
1836
- }
1837
- });
1838
- }
1839
- // Ensures that there is exactly one element (Layout or Metadata) in local
1840
- // storage corresponding to the provided ID.
1841
- validateId(id, dataType) {
1842
- return new Promise((resolve, reject) => {
1843
- const loadFunc = dataType === "metadata" ? this.loadMetadata : this.loadLayouts;
1844
- loadFunc().then((array) => {
1845
- const count = array.filter((element) => element.id === id).length;
1846
- switch (count) {
1847
- case 1: {
1848
- resolve();
1849
- break;
1850
- }
1851
- case 0: {
1852
- reject(new Error(`No ${dataType} with ID ${id}`));
1853
- break;
1854
- }
1855
- default:
1856
- reject(new Error(`Non-unique ${dataType} with ID ${id}`));
1857
- }
1858
- });
1859
- });
1860
- }
1861
1867
  };
1862
1868
  _urlKey = new WeakMap();
1863
1869