diff --git a/src/csui/src/PlayerUiPanels/BaseExtensionSettings.vue b/src/csui/src/PlayerUiPanels/BaseExtensionSettings.vue index e8b8518..b9dff07 100644 --- a/src/csui/src/PlayerUiPanels/BaseExtensionSettings.vue +++ b/src/csui/src/PlayerUiPanels/BaseExtensionSettings.vue @@ -113,7 +113,7 @@ class="danger" :class="{'disabled': !allowSettingsEditing}" :disabled="!allowSettingsEditing" - @click="saveSettingsChanges" + @click="() => saveSettingsChanges()" > Save @@ -129,6 +129,31 @@ > + +

Settings migration report

+
+        {{settings.migrationReport}}
+      
+ +

Settings snapshots

+
+
+ {{snapshot.createdAt.toISOString()}} +
+
+ {{snapshot.name}} +
+
(auto)
+
(protected)
+
(default)
+
+
+ + + +
+
+
@@ -151,6 +176,7 @@ export default { allowSettingsEditing: false, editorSaveFinished: false, settingsJson: {}, + settingsSnapshots: [] } }, mixins: [ @@ -236,10 +262,18 @@ export default { this.resetSettingsEditor(); }, - saveSettingsChanges() { + async saveSettingsChanges() { if (this.allowSettingsEditing) { + const currentVersion = this.settings.active?.version; this.settings.active = this.settingsJson; - this.settings.saveWithoutReload(); + + if (currentVersion !== this.settingsJson.version) { + await this.settings.save({forcePreserveVersion: true}); + return; + } else { + await this.settings.saveWithoutReload(); + } + this.resetSettingsEditor(); this.editorSaveFinished = true; @@ -251,10 +285,32 @@ export default { resetSettingsEditor() { this.settingsJson = JSON.parse(JSON.stringify(this.settings?.active ?? {})); - } + }, //#endregion - } + //#region settings snapshot management + async loadSettingsSnapshots() { + this.settingsSnapshots = await this.settings.snapshotManager.listSnapshots(); + }, + + async markDefaultSnapshot(index) { + await this.settings.snapshotManager.setDefaultSnapshot(index, !this.settingsSnapshots[index].isDefault); + await this.loadSettingsSnapshots(); + this.settings.active.dev.loadFromSnapshot = this.settingsSnapshots[index].isDefault; + this.saveSettingsChanges(); + }, + + async toggleSnapshotProtection(index) { + await this.settings.snapshotManager.setSnapshotAsProtected(index, !this.settingsSnapshots[index].isProtected); + await this.loadSettingsSnapshots(); + }, + + async deleteSnapshot(index) { + await this.settings.snapshotManager.deleteSnapshot(index); + await this.loadSettingsSnapshots(); + }, + } + //#endregion }