File tree Expand file tree Collapse file tree 1 file changed +21
-7
lines changed Expand file tree Collapse file tree 1 file changed +21
-7
lines changed Original file line number Diff line number Diff line change 1- import React , { useEffect , useState } from ' react' ;
2- import ForgeReconciler , { Text } from ' @forge/react' ;
3- import { invoke } from ' @forge/bridge' ;
1+ import React , { useEffect , useState } from " react" ;
2+ import ForgeReconciler , { Text , useProductContext } from " @forge/react" ;
3+ import { requestJira } from " @forge/bridge" ;
44
55const App = ( ) => {
6- const [ data , setData ] = useState ( null ) ;
6+ 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
717 useEffect ( ( ) => {
8- invoke ( 'getText' , { example : 'my-invoke-variable' } ) . then ( setData ) ;
9- } , [ ] ) ;
18+ if ( context ) {
19+ const issueId = context . extension . issue . id ;
20+ fetchCommentsForIssue ( issueId ) . then ( setComments ) ;
21+ }
22+ } , [ context ] ) ;
23+
1024 return (
1125 < >
1226 < Text > Hello world!</ Text >
13- < Text > { data ? data : 'Loading...' } </ Text >
27+ < Text > Number of comments on this issue: { comments ?. length } </ Text >
1428 </ >
1529 ) ;
1630} ;
You can’t perform that action at this time.
0 commit comments