@axinom/mosaic-fe-samples-host 0.1.4 → 0.2.0-rc.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.
package/dist/index.js CHANGED
@@ -148,6 +148,7 @@ var ErrorBoundary = /*#__PURE__*/function (_React$Component) {
148
148
 
149
149
  const KEY_PROFILE_DATA = 'AX_PROFILE_DATA';
150
150
  const KEY_USER_SETTINGS = 'AX_USER_SETTINGS';
151
+ const KEY_ACTIVE_PROFILE = 'AX_ACTIVE_PROFILE';
151
152
  /**
152
153
  * The structure of the `ProfileConfig` type maintained in code can undergo several structural changes overtime.
153
154
  * However, there may exist objects that were created using prior versions of the type persisted on client local-storages.
@@ -250,6 +251,12 @@ const setUserSettings = (value) => {
250
251
  const generateShortUniqueId = (length = 8) => {
251
252
  const randomId = Math.floor(Math.random() * Math.pow(16, length)).toString(16);
252
253
  return ('0'.repeat(length - randomId.length) + randomId).toUpperCase();
254
+ };
255
+ const getActiveProfileId = () => {
256
+ return JSON.parse(localStorage.getItem(KEY_ACTIVE_PROFILE) || '');
257
+ };
258
+ const setActiveProfileId = (value) => {
259
+ localStorage.setItem(KEY_ACTIVE_PROFILE, JSON.stringify(value));
253
260
  };
254
261
 
255
262
  /**
@@ -305,7 +312,15 @@ const ScenarioHost = ({ scenarios }) => {
305
312
  const handleProfileChanged = (event, data) => {
306
313
  const activeProfileIndex = profiles.findIndex((profile) => profile.id === data.value);
307
314
  setActiveProfile(profiles[activeProfileIndex]);
315
+ setActiveProfileId(data.value);
308
316
  };
317
+ React.useEffect(() => {
318
+ const storageProfileId = getActiveProfileId();
319
+ if (storageProfileId !== (activeProfile === null || activeProfile === void 0 ? void 0 : activeProfile.id)) {
320
+ const activeProfileIndex = profiles.findIndex((profile) => profile.id === storageProfileId);
321
+ setActiveProfile(profiles[activeProfileIndex]);
322
+ }
323
+ }, [activeProfile === null || activeProfile === void 0 ? void 0 : activeProfile.id, profiles]);
309
324
  const ScenarioErrorFallback = (info) => {
310
325
  return (React__default['default'].createElement(semanticUiReact.Segment, { basic: true },
311
326
  React__default['default'].createElement(semanticUiReact.Header, { size: "huge" }, "Something went wrong"),