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-tauri/src/main.rs | 1 + src-tauri/src/northstar/profile.rs | 28 ++++++++++++++++++++++++++++ src-tauri/src/util.rs | 1 - src-vue/src/i18n/lang/en.json | 4 +++- src-vue/src/views/SettingsView.vue | 32 ++++++++++++++++++++++++++++++++ 5 files changed, 64 insertions(+), 2 deletions(-) diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index a2e293b0..1fc55678 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -138,6 +138,7 @@ fn main() { northstar::install::install_northstar_wrapper, northstar::install::update_northstar, northstar::launch_northstar, + northstar::profile::clone_profile, northstar::profile::delete_profile, northstar::profile::fetch_profiles, northstar::profile::validate_profile, diff --git a/src-tauri/src/northstar/profile.rs b/src-tauri/src/northstar/profile.rs index b0c6c418..26a32d6b 100644 --- a/src-tauri/src/northstar/profile.rs +++ b/src-tauri/src/northstar/profile.rs @@ -1,3 +1,4 @@ +use crate::util::copy_dir_all; use crate::GameInstall; // These folders are part of Titanfall 2 and @@ -91,3 +92,30 @@ pub fn delete_profile(game_install: GameInstall, profile: String) -> Result<(), Err(err) => Err(format!("Failed to delete Profile: {}", err)), } } + +/// Clones a profile by simply duplicating the folder under a new name +#[tauri::command] +pub fn clone_profile( + game_install: GameInstall, + old_profile: String, + new_profile: String, +) -> Result<(), String> { + // Check if the old Profile already exists + if !validate_profile(game_install.clone(), old_profile.clone()) { + return Err(format!("{} is not a valid Profile", old_profile)); + } + + // Check that new Profile does not already exist + if validate_profile(game_install.clone(), new_profile.clone()) { + return Err(format!("{} already exists", new_profile)); + } + + log::info!("Cloning Profile {} to {}", old_profile, new_profile); + + let old_profile_path = format!("{}/{}", game_install.game_path, old_profile); + let new_profile_path = format!("{}/{}", game_install.game_path, new_profile); + + copy_dir_all(old_profile_path, new_profile_path).unwrap(); + + Ok(()) +} diff --git a/src-tauri/src/util.rs b/src-tauri/src/util.rs index 15511d21..ad09eec2 100644 --- a/src-tauri/src/util.rs +++ b/src-tauri/src/util.rs @@ -188,7 +188,6 @@ pub fn check_northstar_running() -> bool { } /// Copies a folder and all its contents to a new location -#[allow(dead_code)] pub fn copy_dir_all( src: impl AsRef, dst: impl AsRef, diff --git a/src-vue/src/i18n/lang/en.json b/src-vue/src/i18n/lang/en.json index 6bbb6919..e0460fd1 100644 --- a/src-vue/src/i18n/lang/en.json +++ b/src-vue/src/i18n/lang/en.json @@ -119,7 +119,9 @@ "title": "Profiles", "delete_confirm": "Are you sure to delete this profile?", "delete": "Delete", - "clone": "Clone" + "clone": "Clone", + "new_profile_name": "Enter the new Profile name", + "create_empty": "New Profile" } }, 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 From c16ef555f6d44bbc575eff3a69397b5c290600ca Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 22 Jan 2024 16:15:51 +0100 Subject: chore: bump regex from 1.10.2 to 1.10.3 in /src-tauri (#762) Bumps [regex](https://github.com/rust-lang/regex) from 1.10.2 to 1.10.3. - [Release notes](https://github.com/rust-lang/regex/releases) - [Changelog](https://github.com/rust-lang/regex/blob/master/CHANGELOG.md) - [Commits](https://github.com/rust-lang/regex/compare/1.10.2...1.10.3) --- updated-dependencies: - dependency-name: regex dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- src-tauri/Cargo.lock | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index 89400211..d7fcff2f 100644 --- a/src-tauri/Cargo.lock +++ b/src-tauri/Cargo.lock @@ -3181,13 +3181,13 @@ dependencies = [ [[package]] name = "regex" -version = "1.10.2" +version = "1.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "380b951a9c5e80ddfd6136919eef32310721aa4aacd4889a8d39124b026ab343" +checksum = "b62dbe01f0b06f9d8dc7d49e05a0785f153b00b2c227856282f671e0318c9b15" dependencies = [ "aho-corasick", "memchr", - "regex-automata 0.4.3", + "regex-automata 0.4.4", "regex-syntax 0.8.2", ] @@ -3202,9 +3202,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.3" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f804c7828047e88b2d32e2d7fe5a105da8ee3264f01902f796c8e067dc2483f" +checksum = "3b7fa1134405e2ec9353fd416b17f8dacd46c473d7d3fd1cf202706a14eb792a" dependencies = [ "aho-corasick", "memchr", -- cgit v1.2.3 From e90b9a3791f10e44ae6ce2b14ffd23fb2b3cf72d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 23 Jan 2024 13:08:32 +0100 Subject: chore: bump chrono from 0.4.31 to 0.4.32 in /src-tauri (#764) Bumps [chrono](https://github.com/chronotope/chrono) from 0.4.31 to 0.4.32. - [Release notes](https://github.com/chronotope/chrono/releases) - [Changelog](https://github.com/chronotope/chrono/blob/main/CHANGELOG.md) - [Commits](https://github.com/chronotope/chrono/compare/v0.4.31...v0.4.32) --- updated-dependencies: - dependency-name: chrono dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- src-tauri/Cargo.lock | 6 +++--- src-tauri/Cargo.toml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index d7fcff2f..162c8edf 100644 --- a/src-tauri/Cargo.lock +++ b/src-tauri/Cargo.lock @@ -498,9 +498,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chrono" -version = "0.4.31" +version = "0.4.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f2c685bad3eb3d45a01354cedb7d5faa66194d1d58ba6e267a8de788f79db38" +checksum = "41daef31d7a747c5c847246f36de49ced6f7403b4cdabc807a97b5cc184cda7a" dependencies = [ "android-tzdata", "iana-time-zone", @@ -508,7 +508,7 @@ dependencies = [ "num-traits", "serde", "wasm-bindgen", - "windows-targets 0.48.1", + "windows-targets 0.52.0", ] [[package]] diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index 389089b3..98c7f0b9 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -49,7 +49,7 @@ json5 = "0.4.1" # Async recursion for recursive mod install async-recursion = "1.0.5" # For parsing timestamps -chrono = "0.4.31" +chrono = "0.4.32" # TypeScript bindings ts-rs = "7.1" # const formatting -- cgit v1.2.3 From 49ce8b2c7037996ba77b08f2949a406406e66529 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 24 Jan 2024 20:08:52 +0100 Subject: chore: bump element-plus from 2.4.4 to 2.5.3 in /src-vue (#765) * chore: bump element-plus from 2.4.4 to 2.5.3 in /src-vue Bumps [element-plus](https://github.com/element-plus/element-plus) from 2.4.4 to 2.5.3. - [Release notes](https://github.com/element-plus/element-plus/releases) - [Changelog](https://github.com/element-plus/element-plus/blob/dev/CHANGELOG.en-US.md) - [Commits](https://github.com/element-plus/element-plus/compare/2.4.4...2.5.3) --- updated-dependencies: - dependency-name: element-plus dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] * fix: el-select breaking change * fix: button right margin is valid at all times --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Remy Raes --- src-vue/package-lock.json | 8 ++++---- src-vue/package.json | 2 +- src-vue/src/components/PlayButton.vue | 9 ++++++--- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src-vue/package-lock.json b/src-vue/package-lock.json index 499f5352..e087cec2 100644 --- a/src-vue/package-lock.json +++ b/src-vue/package-lock.json @@ -9,7 +9,7 @@ "version": "0.0.0", "dependencies": { "@element-plus/icons-vue": "^2.0.9", - "element-plus": "^2.4.4", + "element-plus": "^2.5.3", "marked": "^11.1.1", "tauri-plugin-store-api": "github:tauri-apps/tauri-plugin-store#9bd993aa67766596638bbfd91e79a1bf8f632014", "vue": "^3.4.15", @@ -491,9 +491,9 @@ "dev": true }, "node_modules/element-plus": { - "version": "2.4.4", - "resolved": "https://registry.npmjs.org/element-plus/-/element-plus-2.4.4.tgz", - "integrity": "sha512-TlKubXJgxwhER0dw+8ULn9hr9kZjraV4R6Q/eidwWUwCKxwXYPBGmMKsZ/85tlxlhMYbcLZd/YZh6G3QkHX4fg==", + "version": "2.5.3", + "resolved": "https://registry.npmjs.org/element-plus/-/element-plus-2.5.3.tgz", + "integrity": "sha512-wmtstxaMkD6UinIgD+45CjrhbRh4u0vt+/GgxfPeMLt5pDpIVwZFjkUaVcWqqxcxd5a80HP3XlDF74fW7wim9A==", "dependencies": { "@ctrl/tinycolor": "^3.4.1", "@element-plus/icons-vue": "^2.3.1", diff --git a/src-vue/package.json b/src-vue/package.json index c5777b16..32be0476 100644 --- a/src-vue/package.json +++ b/src-vue/package.json @@ -10,7 +10,7 @@ }, "dependencies": { "@element-plus/icons-vue": "^2.0.9", - "element-plus": "^2.4.4", + "element-plus": "^2.5.3", "marked": "^11.1.1", "tauri-plugin-store-api": "github:tauri-apps/tauri-plugin-store#9bd993aa67766596638bbfd91e79a1bf8f632014", "vue": "^3.4.15", diff --git a/src-vue/src/components/PlayButton.vue b/src-vue/src/components/PlayButton.vue index 83a23ae5..57b408c2 100644 --- a/src-vue/src/components/PlayButton.vue +++ b/src-vue/src/components/PlayButton.vue @@ -119,6 +119,10 @@ export default defineComponent({