From fc84ec33bf35893b2df248ceb7f8645e8987413a Mon Sep 17 00:00:00 2001 From: Garrett Date: Thu, 7 Sep 2023 11:24:17 -0700 Subject: [PATCH 1/2] Ensure pages always save once --- src/renderer/src/stories/Dashboard.js | 3 +++ src/renderer/src/stories/pages/Page.js | 4 +++- .../src/stories/pages/guided-mode/data/GuidedStructure.js | 2 ++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/renderer/src/stories/Dashboard.js b/src/renderer/src/stories/Dashboard.js index 3d3240331..68a3c01a3 100644 --- a/src/renderer/src/stories/Dashboard.js +++ b/src/renderer/src/stories/Dashboard.js @@ -229,10 +229,13 @@ export class Dashboard extends LitElement { pageState = state.pages[id] = { visited: false, active: false, + saved: false, pageLabel: page.info.label, pageTitle: page.info.title, }; + info.states =pageState + state.active = false; pageState.active = false; diff --git a/src/renderer/src/stories/pages/Page.js b/src/renderer/src/stories/pages/Page.js index bbcc0d0a6..3eb6b1e45 100644 --- a/src/renderer/src/stories/pages/Page.js +++ b/src/renderer/src/stories/pages/Page.js @@ -63,8 +63,9 @@ export class Page extends LitElement { to = async (transition) => { this.beforeTransition(); + // Otherwise note unsaved updates if present - if (this.unsavedUpdates) { + if (this.unsavedUpdates || this.info.states?.saved) { if (transition === 1) await this.save(); // Save before a single forward transition else { Swal.fire({ @@ -95,6 +96,7 @@ export class Page extends LitElement { save = async (overrides, runBeforeSave = true) => { if (runBeforeSave) await this.beforeSave(); save(this, overrides); + this.info.states.saved = true this.unsavedUpdates = false; }; diff --git a/src/renderer/src/stories/pages/guided-mode/data/GuidedStructure.js b/src/renderer/src/stories/pages/guided-mode/data/GuidedStructure.js index 93938a8ca..5b32d2821 100644 --- a/src/renderer/src/stories/pages/guided-mode/data/GuidedStructure.js +++ b/src/renderer/src/stories/pages/guided-mode/data/GuidedStructure.js @@ -75,6 +75,8 @@ export class GuidedStructurePage extends Page { }; async updated() { + + console.log(this.info) const selected = this.info.globalState.interfaces; if (Object.keys(selected).length > 0) this.list.emptyMessage = "Loading valid interfaces..."; From 75c85e7a96601fc60387da5cb20a675189b210cd Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 7 Sep 2023 18:29:24 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/renderer/src/stories/Dashboard.js | 2 +- src/renderer/src/stories/pages/Page.js | 3 +-- .../src/stories/pages/guided-mode/data/GuidedStructure.js | 3 +-- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/renderer/src/stories/Dashboard.js b/src/renderer/src/stories/Dashboard.js index 68a3c01a3..a75846ca6 100644 --- a/src/renderer/src/stories/Dashboard.js +++ b/src/renderer/src/stories/Dashboard.js @@ -234,7 +234,7 @@ export class Dashboard extends LitElement { pageTitle: page.info.title, }; - info.states =pageState + info.states = pageState; state.active = false; pageState.active = false; diff --git a/src/renderer/src/stories/pages/Page.js b/src/renderer/src/stories/pages/Page.js index 3eb6b1e45..c4a52659b 100644 --- a/src/renderer/src/stories/pages/Page.js +++ b/src/renderer/src/stories/pages/Page.js @@ -63,7 +63,6 @@ export class Page extends LitElement { to = async (transition) => { this.beforeTransition(); - // Otherwise note unsaved updates if present if (this.unsavedUpdates || this.info.states?.saved) { if (transition === 1) await this.save(); // Save before a single forward transition @@ -96,7 +95,7 @@ export class Page extends LitElement { save = async (overrides, runBeforeSave = true) => { if (runBeforeSave) await this.beforeSave(); save(this, overrides); - this.info.states.saved = true + this.info.states.saved = true; this.unsavedUpdates = false; }; diff --git a/src/renderer/src/stories/pages/guided-mode/data/GuidedStructure.js b/src/renderer/src/stories/pages/guided-mode/data/GuidedStructure.js index 5b32d2821..d5f82e0a7 100644 --- a/src/renderer/src/stories/pages/guided-mode/data/GuidedStructure.js +++ b/src/renderer/src/stories/pages/guided-mode/data/GuidedStructure.js @@ -75,8 +75,7 @@ export class GuidedStructurePage extends Page { }; async updated() { - - console.log(this.info) + console.log(this.info); const selected = this.info.globalState.interfaces; if (Object.keys(selected).length > 0) this.list.emptyMessage = "Loading valid interfaces...";