Skip to content

Commit

Permalink
feat: Show pull request labels in PR view (#985)
Browse files Browse the repository at this point in the history
to more easily see which PRs need testing etc
  • Loading branch information
GeckoEidechse authored Jul 30, 2024
1 parent baffc20 commit ed1488f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src-tauri/bindings/PullsApiResponseElement.ts
Original file line number Diff line number Diff line change
@@ -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, };
export type PullsApiResponseElement = { number: bigint, title: string, url: string, head: CommitHead, html_url: string, labels: Array<string>, };
10 changes: 10 additions & 0 deletions src-tauri/src/github/pull_requests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ pub struct PullsApiResponseElement {
url: String,
head: CommitHead,
html_url: String,
labels: Vec<String>,
}

// GitHub API response JSON elements as structs
Expand Down Expand Up @@ -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<String> = 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,
Expand All @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions src-vue/src/components/PullRequestsSelector.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
<a target="_blank" :href="pull_request.html_url">
{{ pull_request.number }}: {{ pull_request.title }}
</a>
<el-tag v-for="label in pull_request.labels">{{ label }}</el-tag>
</el-card>
<div v-else class="no_matching_pr">
No matching PR found.
Expand Down Expand Up @@ -67,6 +68,7 @@
<a target="_blank" :href="pull_request.html_url">
{{ pull_request.number }}: {{ pull_request.title }}
</a>
<el-tag v-for="label in pull_request.labels">{{ label }}</el-tag>
</el-card>
<div v-else class="no_matching_pr">
No matching PR found.
Expand Down

0 comments on commit ed1488f

Please sign in to comment.