From 7e42fd13ba2bffd38f9d15bd77bf270198b224e3 Mon Sep 17 00:00:00 2001
From: GeckoEidechse <40122905+GeckoEidechse@users.noreply.github.com>
Date: Wed, 3 Apr 2024 17:46:11 +0200
Subject: feat: Add disable all mods button to local mod view (#871)

Adds a button to LocalModView to disable all but core mods.
Re-uses existing backend logic

Co-authored-by: Remy Raes <contact@remyraes.com>
---
 src-vue/src/views/mods/LocalModsView.vue | 21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)

(limited to 'src-vue/src/views/mods/LocalModsView.vue')

diff --git a/src-vue/src/views/mods/LocalModsView.vue b/src-vue/src/views/mods/LocalModsView.vue
index 38f7a914..3979ca14 100644
--- a/src-vue/src/views/mods/LocalModsView.vue
+++ b/src-vue/src/views/mods/LocalModsView.vue
@@ -5,14 +5,19 @@
     </div>
 
     <el-scrollbar v-else>
+        <el-button class="disableModsBtn" type="primary" @click="disableAllModsButCore">
+            {{ $t('settings.repair.window.disable_all_but_core') }}
+        </el-button>
         <local-mod-card v-for="mod of mods" v-bind:key="mod.name" :mod="mod" />
     </el-scrollbar>
 </template>
 
 <script lang="ts">
 import { defineComponent } from 'vue';
+import { invoke } from "@tauri-apps/api";
 import { NorthstarMod } from "../../../../src-tauri/bindings/NorthstarMod";
 import { fuzzy_filter } from "../../utils/filter";
+import { showErrorNotification, showNotification } from "../../utils/ui";
 import LocalModCard from "../../components/LocalModCard.vue";
 
 export default defineComponent({
@@ -41,6 +46,16 @@ export default defineComponent({
         };
     },
     methods: {
+        async disableAllModsButCore() {
+            await invoke("disable_all_but_core", { gameInstall: this.$store.state.game_install })
+                .then((message) => {
+                    showNotification(this.$t('generic.success'), this.$t('settings.repair.window.disable_all_but_core_success'));
+                    this.$store.commit('loadInstalledMods');
+                })
+                .catch((error) => {
+                    showErrorNotification(error);
+                });
+        },
     },
     mounted() {
         this.$store.commit('loadInstalledMods');
@@ -49,5 +64,9 @@ export default defineComponent({
 </script>
 
 <style scoped>
-
+.disableModsBtn {
+    margin-bottom: 10px;
+    top: 10px;
+    position: sticky;
+}
 </style>
-- 
cgit v1.2.3

