|
1 | 1 | import React, { useEffect, useState } from "react"; |
2 | | -import ForgeReconciler, { Text, useProductContext } from "@forge/react"; |
| 2 | +import ForgeReconciler, { Select, Text, useProductContext } from "@forge/react"; |
3 | 3 | import { requestJira } from "@forge/bridge"; |
4 | 4 |
|
5 | 5 | const App = () => { |
| 6 | + // Get Jira cloud ID (== workspace ID) |
6 | 7 | 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); |
17 | 9 | useEffect(() => { |
18 | 10 | 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}`); |
21 | 14 | } |
22 | 15 | }, [context]); |
23 | 16 |
|
| 17 | + // Get repository list where GitAuto is installed |
| 18 | + const repositories = ["gitautoai/gitauto", "gitautoai/gitauto-jira"]; |
| 19 | + const [selectedRepo, setSelectedRepo] = useState(repositories[0]); |
| 20 | + |
24 | 21 | return ( |
25 | 22 | <> |
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 | + /> |
28 | 29 | </> |
29 | 30 | ); |
30 | 31 | }; |
|
0 commit comments