From ed1488f5e96a07da61f60ff8af931be5af62b48a Mon Sep 17 00:00:00 2001 From: GeckoEidechse <40122905+GeckoEidechse@users.noreply.github.com> Date: Tue, 30 Jul 2024 17:05:43 +0200 Subject: feat: Show pull request labels in PR view (#985) to more easily see which PRs need testing etc --- src-tauri/bindings/PullsApiResponseElement.ts | 2 +- src-tauri/src/github/pull_requests.rs | 10 ++++++++++ src-vue/src/components/PullRequestsSelector.vue | 2 ++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src-tauri/bindings/PullsApiResponseElement.ts b/src-tauri/bindings/PullsApiResponseElement.ts index 489039e3..2db93fe2 100644 --- a/src-tauri/bindings/PullsApiResponseElement.ts +++ b/src-tauri/bindings/PullsApiResponseElement.ts @@ -1,4 +1,4 @@ // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. import type { CommitHead } from "./CommitHead"; -export type PullsApiResponseElement = { number: bigint, title: string, url: string, head: CommitHead, html_url: string, }; \ No newline at end of file +export type PullsApiResponseElement = { number: bigint, title: string, url: string, head: CommitHead, html_url: string, labels: Array, }; \ No newline at end of file diff --git a/src-tauri/src/github/pull_requests.rs b/src-tauri/src/github/pull_requests.rs index 7e400c1a..de733feb 100644 --- a/src-tauri/src/github/pull_requests.rs +++ b/src-tauri/src/github/pull_requests.rs @@ -32,6 +32,7 @@ pub struct PullsApiResponseElement { url: String, head: CommitHead, html_url: String, + labels: Vec, } // GitHub API response JSON elements as structs @@ -102,6 +103,14 @@ pub async fn get_pull_requests( repo, }; + // Get labels and their names and put the into vector + let label_names: Vec = item + .labels + .unwrap_or_else(Vec::new) + .into_iter() + .map(|label| label.name) + .collect(); + // TODO there's probably a way to automatically serialize into the struct but I don't know yet how to let elem = PullsApiResponseElement { number: item.number, @@ -112,6 +121,7 @@ pub async fn get_pull_requests( .html_url .ok_or(anyhow!("html_url not found"))? .to_string(), + labels: label_names, }; all_pull_requests.push(elem); diff --git a/src-vue/src/components/PullRequestsSelector.vue b/src-vue/src/components/PullRequestsSelector.vue index fe103edc..bd17ed14 100644 --- a/src-vue/src/components/PullRequestsSelector.vue +++ b/src-vue/src/components/PullRequestsSelector.vue @@ -28,6 +28,7 @@ {{ pull_request.number }}: {{ pull_request.title }} + {{ label }}
No matching PR found. @@ -67,6 +68,7 @@ {{ pull_request.number }}: {{ pull_request.title }} + {{ label }}
No matching PR found. -- cgit v1.2.3