Skip to content

Commit

Permalink
#2490 Fix issue with saving component state, re-add to project modal
Browse files Browse the repository at this point in the history
  • Loading branch information
dwalizer committed Jan 3, 2024
1 parent 8766676 commit fc13116
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
10 changes: 5 additions & 5 deletions dashboard/src/components/projects/EditProject.vue
Original file line number Diff line number Diff line change
Expand Up @@ -239,14 +239,14 @@ limitations under the License.
},
internalProject: {
handler(newValue) {
// this.saveComponentState(this.componentName, newValue);
this.saveComponentState(this.componentName, newValue);
},
deep: true,
},
},
methods: {
discardChanges(reload = false) {
// this.clearComponentState(this.componentName);
this.clearComponentState(this.componentName);
if (reload) {
this.restoredFromStorage = false;
this.loadComponent();
Expand Down Expand Up @@ -308,7 +308,7 @@ limitations under the License.
this.canEditProjectId = canEdit;
},
close(e) {
// this.clearComponentState(this.componentName);
this.clearComponentState(this.componentName);
this.hideModal(e);
},
publishHidden(e) {
Expand All @@ -318,7 +318,7 @@ limitations under the License.
this.msgConfirm('You have unsaved changes. Discard?', 'Discard Changes?', 'Discard Changes', 'Continue Editing')
.then((res) => {
if (res) {
// this.clearComponentState(this.componentName);
this.clearComponentState(this.componentName);
this.hideModal(e);
this.$nextTick(() => this.$announcer.polite('Changes discarded'));
} else {
Expand All @@ -328,7 +328,7 @@ limitations under the License.
} else if (this.tooltipShowing && typeof e.preventDefault === 'function') {
e.preventDefault();
} else {
// this.clearComponentState(this.componentName);
this.clearComponentState(this.componentName);
this.hideModal(e);
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ limitations under the License.
import {
get, set, del,
} from 'idb-keyval';
import { isProxy, toRaw } from 'vue';
export default {
name: 'SaveComponentStateLocallyMixin',
Expand All @@ -28,7 +29,11 @@ limitations under the License.
},
methods: {
saveComponentState(key, data) {
set(key, data);
let dataToSave = data;
if (isProxy(dataToSave)) {
dataToSave = toRaw(dataToSave);
}
set(key, dataToSave);
},
loadComponentState(key) {
return get(key);
Expand Down

0 comments on commit fc13116

Please sign in to comment.