From dc2a6d7bcee85481f3e53daffdb00436af01c309 Mon Sep 17 00:00:00 2001 From: GeckoEidechse <40122905+GeckoEidechse@users.noreply.github.com> Date: Sun, 21 Jan 2024 13:02:43 +0100 Subject: feat: Add option to clone existing profile (#761) * add dev button to refetch profiles * add dialog box with a table of all profiles * add button to delete non default profiles to dialog box * add button to clone profile to dialog box * style: Add trailing comma * docs: Add doc comment explaining function * fix: Remove leftover testing code * fix: Delete duplicate function registration * chore: Sort Tauri function registrations alphabetically --------- Co-authored-by: Jan200101 --- src-vue/src/views/SettingsView.vue | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'src-vue/src/views') diff --git a/src-vue/src/views/SettingsView.vue b/src-vue/src/views/SettingsView.vue index 70bffbc5..16b894d5 100644 --- a/src-vue/src/views/SettingsView.vue +++ b/src-vue/src/views/SettingsView.vue @@ -21,6 +21,9 @@ + + {{ $t('settings.profile.dialog.clone') }} + @@ -140,6 +143,7 @@ import LanguageSelector from "../components/LanguageSelector.vue"; const persistentStore = new Store('flight-core-settings.json'); import { open } from '@tauri-apps/api/shell'; import { i18n } from '../main'; +import { ElMessageBox } from 'element-plus' export default defineComponent({ name: "SettingsView", @@ -274,6 +278,34 @@ export default defineComponent({ showErrorNotification(error); }); }, + async cloneProfileDialog(profile: string) { + ElMessageBox.prompt( + i18n.global.tc("settings.profile.dialog.new_profile_name"), + i18n.global.tc("settings.profile.dialog.title"), + { + confirmButtonText: i18n.global.tc("generic.confirm"), + cancelButtonText: i18n.global.tc("generic.cancel"), + } + ).then(async ({ value }) => { + await this.cloneProfile(profile, value); + }).catch(() => { + // Nothing to do here + }) + }, + async cloneProfile(old_profile: string, new_profile: string) { + let store = this.$store; + await invoke("clone_profile", { + gameInstall: store.state.game_install, + oldProfile: old_profile, + newProfile: new_profile + }).then(async (message) => { + store.commit('fetchProfiles'); + showNotification('Success'); + }).catch((error) => { + console.error(error); + showErrorNotification(error); + }); + }, async deleteProfile(profile: string) { let store = this.$store; await invoke("delete_profile", { -- cgit v1.2.3