diff options
author | GeckoEidechse <gecko.eidechse+git@pm.me> | 2024-01-27 22:21:12 +0100 |
---|---|---|
committer | GeckoEidechse <gecko.eidechse+git@pm.me> | 2024-01-27 22:21:12 +0100 |
commit | 5284445cab89bb5af6d415c825a2cfa45cb92592 (patch) | |
tree | 5880b3ab4b48fdf28c7c5189a874494fcac31b97 | |
parent | bcb77c2f326450e0cac78dd965cd6cb4dceaa736 (diff) | |
parent | 83ed4bedc183975f2f1a65b9cd38881410605904 (diff) | |
download | FlightCore-5284445cab89bb5af6d415c825a2cfa45cb92592.tar.gz FlightCore-5284445cab89bb5af6d415c825a2cfa45cb92592.zip |
Merge branch 'main' into refactor/pass-launch-options-object
-rw-r--r-- | .github/workflows/push-test.yml | 20 | ||||
-rw-r--r-- | .github/workflows/release.yml | 10 | ||||
-rw-r--r-- | src-tauri/Cargo.lock | 16 | ||||
-rw-r--r-- | src-tauri/Cargo.toml | 2 | ||||
-rw-r--r-- | src-tauri/src/main.rs | 1 | ||||
-rw-r--r-- | src-tauri/src/northstar/profile.rs | 28 | ||||
-rw-r--r-- | src-tauri/src/util.rs | 1 | ||||
-rw-r--r-- | src-vue/package-lock.json | 8 | ||||
-rw-r--r-- | src-vue/package.json | 2 | ||||
-rw-r--r-- | src-vue/src/components/PlayButton.vue | 9 | ||||
-rw-r--r-- | src-vue/src/i18n/lang/en.json | 4 | ||||
-rw-r--r-- | src-vue/src/views/SettingsView.vue | 32 |
12 files changed, 99 insertions, 34 deletions
diff --git a/.github/workflows/push-test.yml b/.github/workflows/push-test.yml index 4cac9da3..9da3c9db 100644 --- a/.github/workflows/push-test.yml +++ b/.github/workflows/push-test.yml @@ -6,7 +6,7 @@ jobs: ensure-same-version: runs-on: ubuntu-22.04 steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: install dependencies run: | pip install toml @@ -19,7 +19,7 @@ jobs: name: format-check runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@stable with: toolchain: stable @@ -36,7 +36,7 @@ jobs: name: clippy-check runs-on: ${{ matrix.platform }} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@stable with: toolchain: stable @@ -59,7 +59,7 @@ jobs: autogen-ts-bindings-check: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@stable with: toolchain: stable @@ -96,9 +96,9 @@ jobs: runs-on: ${{ matrix.platform }} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: setup node - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: node-version: 16 - uses: dtolnay/rust-toolchain@stable @@ -132,21 +132,21 @@ jobs: TAURI_PRIVATE_KEY: ${{ secrets.TAURI_PRIVATE_KEY }} - name: Upload Linux artifact if: matrix.platform == 'ubuntu-22.04' - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: linux-artifacts path: | src-tauri/target/release/bundle/appimage/* - name: Upload Linux AppImage if: matrix.platform == 'ubuntu-22.04' - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: linux-appimage path: | src-tauri/target/release/bundle/appimage/*.AppImage - name: Upload Windows artifact if: matrix.platform == 'windows-latest' - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: windows-artifacts path: | @@ -154,7 +154,7 @@ jobs: src-tauri/target/release/app.pdb - name: Additionally upload Windows installer separately if: matrix.platform == 'windows-latest' - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: windows-msi path: | diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 80c33a6a..6a5096c4 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -12,7 +12,7 @@ jobs: ensure-same-version: runs-on: ubuntu-22.04 steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: install dependencies run: | pip install toml @@ -29,9 +29,9 @@ jobs: runs-on: ${{ matrix.platform }} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: setup node - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: node-version: 16 - name: install Rust stable @@ -59,7 +59,7 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} TAURI_PRIVATE_KEY: ${{ secrets.TAURI_PRIVATE_KEY }} - name: upload build artifact - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: path: | src-tauri/target/release/bundle/appimage/*AppImage* @@ -89,7 +89,7 @@ jobs: needs: build runs-on: ubuntu-22.04 steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: actions/download-artifact@v3 - name: Create release file run: | diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index 89400211..2fdd1077 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.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f2c685bad3eb3d45a01354cedb7d5faa66194d1d58ba6e267a8de788f79db38" +checksum = "9f13690e35a5e4ace198e7beea2895d29f3a9cc55015fcebe6336bd2010af9eb" 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]] @@ -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", diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index 389089b3..7934366b 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.33" # TypeScript bindings ts-rs = "7.1" # const formatting 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<std::path::Path>, dst: impl AsRef<std::path::Path>, 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({ </template> <style scoped> +nav { + margin-right: 20px; +} + button { text-transform: uppercase; padding: 30px; @@ -133,12 +137,11 @@ button { /* Release canal selector */ .el-select { - width: 0; - margin-right: 50px; + width: 31px; border-left: 1px solid rgb(176, 205, 255); } -.el-select:deep(.el-input__wrapper) { +.el-select:deep(.el-select__wrapper) { padding: 0 9px 0 0; background-color: var(--el-color-primary); border: none; 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 @@ </el-button> </template> </el-popconfirm> + <el-button @click="cloneProfileDialog(scope.row.name)"> + {{ $t('settings.profile.dialog.clone') }} + </el-button> </template> </el-table-column> </el-table> @@ -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", { |