mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-10-10 19:32:02 +00:00
fix: use another method for suggestions
This commit is contained in:
parent
3d4372c8bf
commit
6e2c72cd70
9 changed files with 122 additions and 102 deletions
|
@ -1,3 +1,6 @@
|
|||
import { GET } from '../modules/fetch.js';
|
||||
import {parseIssueHref, parseRepoOwnerPathInfo} from '../utils.js'
|
||||
|
||||
export function getIssueIcon(issue) {
|
||||
if (issue.pull_request) {
|
||||
if (issue.state === 'open') {
|
||||
|
@ -15,16 +18,37 @@ export function getIssueIcon(issue) {
|
|||
return 'octicon-issue-closed'; // Closed Issue
|
||||
}
|
||||
|
||||
export function getIssueColor(issue) {
|
||||
if (issue.pull_request) {
|
||||
if (issue.pull_request.draft === true) {
|
||||
return 'grey'; // WIP PR
|
||||
} else if (issue.pull_request.merged === true) {
|
||||
return 'purple'; // Merged PR
|
||||
}
|
||||
export function getIssueColor(issue) {
|
||||
if (issue.pull_request) {
|
||||
if (issue.pull_request.draft === true) {
|
||||
return 'grey'; // WIP PR
|
||||
} else if (issue.pull_request.merged === true) {
|
||||
return 'purple'; // Merged PR
|
||||
}
|
||||
if (issue.state === 'open') {
|
||||
return 'green'; // Open Issue
|
||||
}
|
||||
return 'red'; // Closed Issue
|
||||
}
|
||||
}
|
||||
if (issue.state === 'open') {
|
||||
return 'green'; // Open Issue
|
||||
}
|
||||
return 'red'; // Closed Issue
|
||||
}
|
||||
|
||||
export function isIssueSuggestionsLoaded() {
|
||||
return !!window.config.issueValues
|
||||
}
|
||||
|
||||
async function fetchIssueSuggestions() {
|
||||
const issuePathInfo = parseIssueHref(window.location.href);
|
||||
if (!issuePathInfo.ownerName) {
|
||||
const repoOwnerPathInfo = parseRepoOwnerPathInfo(window.location.pathname);
|
||||
issuePathInfo.ownerName = repoOwnerPathInfo.ownerName;
|
||||
issuePathInfo.repoName = repoOwnerPathInfo.repoName;
|
||||
// then no issuePathInfo.indexString here, it is only used to exclude the current issue when "matchIssue"
|
||||
}
|
||||
if (!issuePathInfo.ownerName) {
|
||||
throw new Error('unexpected');
|
||||
}
|
||||
|
||||
const res = await GET(`${window.config.appSubUrl}/${issuePathInfo.ownerName}/${issuePathInfo.repoName}/issues/suggestions`);
|
||||
const issues = await res.json();
|
||||
window.config.issueValues = issues;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue