Skip to content

Commit 8fe61e1

Browse files
committed
Add a repository select box UI to Jira issue
1 parent 60f7013 commit 8fe61e1

File tree

1 file changed

+16
-15
lines changed

1 file changed

+16
-15
lines changed

src/frontend/index.jsx

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,31 @@
11
import React, { useEffect, useState } from "react";
2-
import ForgeReconciler, { Text, useProductContext } from "@forge/react";
2+
import ForgeReconciler, { Select, Text, useProductContext } from "@forge/react";
33
import { requestJira } from "@forge/bridge";
44

55
const App = () => {
6+
// Get Jira cloud ID (== workspace ID)
67
const context = useProductContext();
7-
const [comments, setComments] = useState();
8-
console.log(`Number of comments on this issue: ${comments?.length}`);
9-
10-
const fetchCommentsForIssue = async (issueIdOrKey) => {
11-
const res = await requestJira(`/rest/api/3/issue/${issueIdOrKey}/comment`);
12-
const data = await res.json();
13-
return data.comments;
14-
};
15-
16-
// This is a test of the requestJira function
8+
const [cloudId, setCloudId] = useState(null);
179
useEffect(() => {
1810
if (context) {
19-
const issueId = context.extension.issue.id;
20-
fetchCommentsForIssue(issueId).then(setComments);
11+
setCloudId(context.cloudId);
12+
console.log({ context });
13+
console.log(`Jira cloud ID: ${context.cloudId}`);
2114
}
2215
}, [context]);
2316

17+
// Get repository list where GitAuto is installed
18+
const repositories = ["gitautoai/gitauto", "gitautoai/gitauto-jira"];
19+
const [selectedRepo, setSelectedRepo] = useState(repositories[0]);
20+
2421
return (
2522
<>
26-
<Text>Hello world!</Text>
27-
<Text>Number of comments on this issue: {comments?.length}</Text>
23+
<Text>Target GitHub Repository:</Text>
24+
<Select
25+
value={selectedRepo}
26+
onChange={setSelectedRepo}
27+
options={repositories.map((repo) => ({ label: repo, value: repo }))}
28+
/>
2829
</>
2930
);
3031
};

0 commit comments

Comments
 (0)