From a22486193ef49113851fab6f277d50f796ecc636 Mon Sep 17 00:00:00 2001
From: GeckoEidechse <40122905+GeckoEidechse@users.noreply.github.com>
Date: Tue, 21 Mar 2023 18:28:18 +0100
Subject: Add buttons to download PRs (#203)
* feat: Add button to download Mods PR
Simply opens the browser on the repo download link
* feat: Add button to download Launcher PR
Uses existing function to fetch nightly.link link and opens it in
browser
* refactor: Open Mods PR download link via TS
as opposed to having a link directly
This way it acts the same way as the Launcher PR download button.
Reason behind this change being consistent UI style.
* chore: Revert introduced formatting changes
Those were added by accident, whoops
* fix: Remove introduced unused dependency
* fix: Remove unused dependencies
---
src-tauri/src/github/pull_requests.rs | 3 ++-
src-tauri/src/main.rs | 5 ++++-
src-vue/src/components/PullRequestsSelector.vue | 10 ++++++++--
src-vue/src/plugins/modules/pull_requests.ts | 21 ++++++++++++++++++++-
4 files changed, 34 insertions(+), 5 deletions(-)
diff --git a/src-tauri/src/github/pull_requests.rs b/src-tauri/src/github/pull_requests.rs
index 586a4fb3..4bba2a2c 100644
--- a/src-tauri/src/github/pull_requests.rs
+++ b/src-tauri/src/github/pull_requests.rs
@@ -142,7 +142,8 @@ fn get_mods_download_link(pull_request: PullsApiResponseElement) -> Result Result {
// Iterate over the first 10 pages of
diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs
index 0733d5a0..d2f7951d 100644
--- a/src-tauri/src/main.rs
+++ b/src-tauri/src/main.rs
@@ -15,7 +15,9 @@ use app::{
};
mod github;
-use github::pull_requests::{apply_launcher_pr, apply_mods_pr, get_pull_requests_wrapper};
+use github::pull_requests::{
+ apply_launcher_pr, apply_mods_pr, get_launcher_download_link, get_pull_requests_wrapper,
+};
use github::release_notes::{
check_is_flightcore_outdated, get_newest_flightcore_version, get_northstar_release_notes,
};
@@ -128,6 +130,7 @@ fn main() {
get_pull_requests_wrapper,
apply_launcher_pr,
apply_mods_pr,
+ get_launcher_download_link,
close_application,
])
.run(tauri::generate_context!())
diff --git a/src-vue/src/components/PullRequestsSelector.vue b/src-vue/src/components/PullRequestsSelector.vue
index 58a355f4..9ddefc7e 100644
--- a/src-vue/src/components/PullRequestsSelector.vue
+++ b/src-vue/src/components/PullRequestsSelector.vue
@@ -15,6 +15,7 @@
Install
+ Download
{{ pull_request.number }}: {{ pull_request.title }}
@@ -41,6 +42,7 @@
Install
+ Download
{{ pull_request.number }}: {{ pull_request.title }}
@@ -54,8 +56,6 @@
import { defineComponent } from 'vue'
import { PullRequestType } from '../../../src-tauri/bindings/PullRequestType';
import { PullsApiResponseElement } from '../../../src-tauri/bindings/PullsApiResponseElement';
-import { invoke } from "@tauri-apps/api";
-import { ElNotification } from "element-plus";
export default defineComponent({
name: 'PullRequestsSelector',
@@ -80,6 +80,12 @@ export default defineComponent({
async getPullRequests(pull_request_type: PullRequestType) {
this.$store.commit('getPullRequests', pull_request_type);
},
+ async downloadLauncherPR(pull_request: PullsApiResponseElement) {
+ this.$store.commit('downloadLauncherPR', pull_request);
+ },
+ async downloadModsPR(pull_request: PullsApiResponseElement) {
+ this.$store.commit('downloadModsPR', pull_request);
+ },
async installLauncherPR(pull_request: PullsApiResponseElement) {
this.$store.commit('installLauncherPR', pull_request);
},
diff --git a/src-vue/src/plugins/modules/pull_requests.ts b/src-vue/src/plugins/modules/pull_requests.ts
index 573856ad..64c85b77 100644
--- a/src-vue/src/plugins/modules/pull_requests.ts
+++ b/src-vue/src/plugins/modules/pull_requests.ts
@@ -1,5 +1,5 @@
import { ElNotification } from "element-plus";
-import { invoke } from "@tauri-apps/api";
+import { invoke, shell } from "@tauri-apps/api";
import { PullsApiResponseElement } from "../../../../src-tauri/bindings/PullsApiResponseElement";
import { PullRequestType } from '../../../../src-tauri/bindings/PullRequestType';
import { store } from "../store";
@@ -41,6 +41,25 @@ export const pullRequestModule = {
});
});
},
+ async downloadLauncherPR(state: PullRequestStoreState, pull_request: PullsApiResponseElement) {
+ await invoke("get_launcher_download_link", { pullRequest: pull_request })
+ .then((url) => {
+ // Open URL in default HTTPS handler (i.e. default browser)
+ shell.open(url);
+ })
+ .catch((error) => {
+ ElNotification({
+ title: 'Error',
+ message: error,
+ type: 'error',
+ position: 'bottom-right'
+ });
+ });
+ },
+ async downloadModsPR(state: PullRequestStoreState, pull_request: PullsApiResponseElement) {
+ let url = `https://github.com/${pull_request.head.repo.full_name}/archive/refs/heads/${pull_request.head.ref}.zip`
+ shell.open(url);
+ },
async installLauncherPR(state: PullRequestStoreState, pull_request: PullsApiResponseElement) {
// Send notification telling the user to wait for the process to finish
const notification = ElNotification({
--
cgit v1.2.3