22import  {SvgIcon } from  ' ../svg.ts' 
33import  {GET } from  ' ../modules/fetch.ts' 
44import  {getIssueColor , getIssueIcon } from  ' ../features/issue.ts' 
5- import  {computed , onMounted , shallowRef , useTemplateRef } from  ' vue' 
6- import  type  {IssuePathInfo } from  ' ../types.ts' 
5+ import  {computed , onMounted , shallowRef } from  ' vue' 
76
8- const =  window .config ;
7+ const =  defineProps <{
8+   repoLink:  string , 
9+   loadIssueInfoUrl:  string , 
10+ }>(); 
911
1012const =  shallowRef (false );
1113const =  shallowRef (null );
1214const =  shallowRef (' ' 
13- const =  i18n .error_occurred ;
14- const =  shallowRef (null );
15+ const =  shallowRef (null );
1516
16- const =  computed (() =>  new  Date (issue .value .created_at ).toLocaleDateString (undefined , {year: ' numeric' ' short' ' numeric' 
17- const =  computed (() =>  {
18-   const =  issue .value .body .replace (/ \n + / g '  '  
19-   if  (body .length  >  85 ) { 
20-     return  ` ${body .substring (0 , 85 )}… ` ; 
21-   } 
22-   return  body ; 
17+ const =  computed (() =>  {
18+   return  new  Date (issue .value .created_at ).toLocaleDateString (undefined , {year: ' numeric' ' short' ' numeric'  
2319}); 
2420
25- const =  useTemplateRef (' root' 
26- 
27- onMounted (() =>  {
28-   root .value .addEventListener (' ce-load-context-popup' e :  CustomEventInit <IssuePathInfo >) =>  { 
29-     if  (! loading .value  &&  issue .value  ===  null ) { 
30-       load (e .detail ); 
31-     } 
32-   }); 
21+ const =  computed (() =>  {
22+   const =  issue .value .body .replace (/ \n + / g '  '  
23+   return  body .length  >  85  ?  ` ${body .substring (0 , 85 )}… `  :  body ; 
3324}); 
3425
35- async  function  load( issuePathInfo :   IssuePathInfo )  {
26+ onMounted ( async  ()  =>  {
3627  loading .value  =  true ; 
37-   i18nErrorMessage .value  =  null ; 
38- 
28+   errorMessage .value  =  null ; 
3929  try  { 
40-     const =  await  GET (` ${appSubUrl }/${issuePathInfo .ownerName }/${issuePathInfo .repoName }/issues/${issuePathInfo .indexString }/info ` ); //  backend: GetIssueInfo 
41-     const =  await  response .json (); 
42-     if  (! response .ok ) { 
43-       i18nErrorMessage .value  =  respJson .message  ??  i18n .network_error ; 
30+     const =  await  GET (props .loadIssueInfoUrl ); 
31+     if  (! resp .ok ) { 
32+       errorMessage .value  =  resp .status  ?  resp .statusText  :  ' Unknown network error'  
4433      return ; 
4534    } 
35+     const =  await  resp .json (); 
4636    issue .value  =  respJson .convertedIssue ; 
4737    renderedLabels .value  =  respJson .renderedLabels ; 
48-   } catch  { 
49-     i18nErrorMessage .value  =  i18n .network_error ; 
5038  } finally  { 
5139    loading .value  =  false ; 
5240  } 
53- } 
41+ });  
5442script >
5543
5644<template >
57-   <div  ref = " root " 
45+   <div  class = " tw-p-4 " 
5846    <div  v-if =" loading" class =" tw-h-12 tw-w-12 is-loading" 
59-     <div  v-if =" !loading && issue !== null" class =" tw-flex tw-flex-col tw-gap-2" 
60-       <div  class =" tw-text-12" div >
47+     <div  v-else-if =" issue" class =" tw-flex tw-flex-col tw-gap-2" 
48+       <div  class =" tw-text-12" 
49+         <a  :href =" repoLink" class =" muted" a >
50+         on {{ createdAt }}
51+       </div >
6152      <div  class =" flex-text-block" 
6253        <svg-icon  :name =" getIssueIcon(issue)" :class =" ['text', getIssueColor(issue)]" 
6354        <span  class =" issue-title tw-font-semibold tw-break-anywhere" 
@@ -69,9 +60,8 @@ async function load(issuePathInfo: IssuePathInfo) {
6960      <!--  eslint-disable-next-line vue/no-v-html --> 
7061      <div  v-if =" issue.labels.length" v-html =" renderedLabels" 
7162    </div >
72-     <div  class =" tw-flex tw-flex-col tw-gap-2" v-if =" !loading && issue === null" 
73-       <div  class =" tw-text-12" div >
74-       <div >{{ i18nErrorMessage }}</div >
63+     <div  v-else >
64+       {{ errorMessage }}
7565    </div >
7666  </div >
7767</template >
0 commit comments