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 ;
1415const =  shallowRef (null );
1516
16- const =  computed (() =>  new  Date (issue .value .created_at ).toLocaleDateString (undefined , {year: ' numeric' ' short' ' numeric' 
17+ const =  computed (() =>  {
18+   return  new  Date (issue .value .created_at ).toLocaleDateString (undefined , {year: ' numeric' ' short' ' numeric'  
19+ }); 
20+ 
1721const =  computed (() =>  {
1822  const =  issue .value .body .replace (/ \n + / g '  '  
19-   if  (body .length  >  85 ) { 
20-     return  ` ${body .substring (0 , 85 )}… ` ; 
21-   } 
22-   return  body ; 
23+   return  body .length  >  85  ?  ` ${body .substring (0 , 85 )}… `  :  body ; 
2324}); 
2425
25- const =  useTemplateRef (' root' 
26- 
2726onMounted (() =>  {
28-   root .value .addEventListener (' ce-load-context-popup' e :  CustomEventInit <IssuePathInfo >) =>  { 
29-     if  (! loading .value  &&  issue .value  ===  null ) { 
30-       load (e .detail ); 
31-     } 
32-   }); 
27+   load (); 
3328}); 
3429
35- async  function  load(issuePathInfo :   IssuePathInfo ) {
30+ async  function  load() {
3631  loading .value  =  true ; 
3732  i18nErrorMessage .value  =  null ; 
38- 
3933  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 ; 
34+     const =  await  GET (props .loadIssueInfoUrl ); 
35+     if  (! resp .ok ) { 
36+       i18nErrorMessage .value  =  resp .status  ?  resp .statusText  :  ' Unknown network error'  
4437      return ; 
4538    } 
39+     const =  await  resp .json (); 
4640    issue .value  =  respJson .convertedIssue ; 
4741    renderedLabels .value  =  respJson .renderedLabels ; 
48-   } catch  { 
49-     i18nErrorMessage .value  =  i18n .network_error ; 
5042  } finally  { 
5143    loading .value  =  false ; 
5244  } 
5345} 
5446script >
5547
5648<template >
57-   <div  ref = " root " 
49+   <div  class = " tw-p-4 " 
5850    <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 >
51+     <div  v-else-if =" issue" class =" tw-flex tw-flex-col tw-gap-2" 
52+       <div  class =" tw-text-12" 
53+         <a  :href =" repoLink" class =" muted" a >
54+         on {{ createdAt }}
55+       </div >
6156      <div  class =" flex-text-block" 
6257        <svg-icon  :name =" getIssueIcon(issue)" :class =" ['text', getIssueColor(issue)]" 
6358        <span  class =" issue-title tw-font-semibold tw-break-anywhere" 
@@ -69,9 +64,8 @@ async function load(issuePathInfo: IssuePathInfo) {
6964      <!--  eslint-disable-next-line vue/no-v-html --> 
7065      <div  v-if =" issue.labels.length" v-html =" renderedLabels" 
7166    </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 >
67+     <div  v-else >
68+       {{ i18nErrorMessage }}
7569    </div >
7670  </div >
7771</template >
0 commit comments