11<script  lang="ts">
2- import  {createApp ,  nextTick } from  ' vue'  ;
2+ import  {nextTick } from  ' vue'  ;
33import  {SvgIcon } from  ' ../svg.ts'  ;
44import  {showErrorToast } from  ' ../modules/toast.ts'  ;
55import  {GET } from  ' ../modules/fetch.ts'  ;
@@ -17,11 +17,11 @@ type SelectedTab = 'branches' | 'tags';
1717
1818type  TabLoadingStates  =  Record <SelectedTab , ' '   |  ' loading'   |  ' done'  >
1919
20- let  currentElRoot:  HTMLElement ;
21- 
2220const   sfc =  {
2321  components: {SvgIcon }, 
24- 
22+   props: { 
23+     elRoot: HTMLElement , 
24+   }, 
2525  computed: { 
2626    searchFieldPlaceholder() { 
2727      return  this .selectedTab  ===  ' branches'   ?  this .textFilterBranch  :  this .textFilterTag ; 
@@ -55,18 +55,15 @@ const sfc = {
5555      return  ` ${this .currentRepoLink }/branches/_new/${this .currentRefType }/${pathEscapeSegments (this .currentRefShortName )} ` ; 
5656    }, 
5757  }, 
58- 
5958  watch: { 
60-     menuVisible(visible ) { 
59+     menuVisible(visible :   boolean ) { 
6160      if  (! visible ) return ; 
6261      this .focusSearchField (); 
6362      this .loadTabItems (); 
6463    }, 
6564  }, 
66- 
6765  data() { 
68-     const   elRoot =  currentElRoot ; 
69-     const   shouldShowTabBranches =  elRoot .getAttribute (' data-show-tab-branches'  ) ===  ' true'  ; 
66+     const   shouldShowTabBranches =  this .elRoot .getAttribute (' data-show-tab-branches'  ) ===  ' true'  ; 
7067    return  { 
7168      csrfToken: window .config .csrfToken , 
7269      allItems: [] as  ListItem [], 
@@ -76,37 +73,35 @@ const sfc = {
7673      activeItemIndex: 0 , 
7774      tabLoadingStates: {} as  TabLoadingStates , 
7875
79-       textReleaseCompare: elRoot .getAttribute (' data-text-release-compare'  ), 
80-       textBranches: elRoot .getAttribute (' data-text-branches'  ), 
81-       textTags: elRoot .getAttribute (' data-text-tags'  ), 
82-       textFilterBranch: elRoot .getAttribute (' data-text-filter-branch'  ), 
83-       textFilterTag: elRoot .getAttribute (' data-text-filter-tag'  ), 
84-       textDefaultBranchLabel: elRoot .getAttribute (' data-text-default-branch-label'  ), 
85-       textCreateTag: elRoot .getAttribute (' data-text-create-tag'  ), 
86-       textCreateBranch: elRoot .getAttribute (' data-text-create-branch'  ), 
87-       textCreateRefFrom: elRoot .getAttribute (' data-text-create-ref-from'  ), 
88-       textNoResults: elRoot .getAttribute (' data-text-no-results'  ), 
89-       textViewAllBranches: elRoot .getAttribute (' data-text-view-all-branches'  ), 
90-       textViewAllTags: elRoot .getAttribute (' data-text-view-all-tags'  ), 
76+       textReleaseCompare: this . elRoot .getAttribute (' data-text-release-compare'  ), 
77+       textBranches: this . elRoot .getAttribute (' data-text-branches'  ), 
78+       textTags: this . elRoot .getAttribute (' data-text-tags'  ), 
79+       textFilterBranch: this . elRoot .getAttribute (' data-text-filter-branch'  ), 
80+       textFilterTag: this . elRoot .getAttribute (' data-text-filter-tag'  ), 
81+       textDefaultBranchLabel: this . elRoot .getAttribute (' data-text-default-branch-label'  ), 
82+       textCreateTag: this . elRoot .getAttribute (' data-text-create-tag'  ), 
83+       textCreateBranch: this . elRoot .getAttribute (' data-text-create-branch'  ), 
84+       textCreateRefFrom: this . elRoot .getAttribute (' data-text-create-ref-from'  ), 
85+       textNoResults: this . elRoot .getAttribute (' data-text-no-results'  ), 
86+       textViewAllBranches: this . elRoot .getAttribute (' data-text-view-all-branches'  ), 
87+       textViewAllTags: this . elRoot .getAttribute (' data-text-view-all-tags'  ), 
9188
92-       currentRepoDefaultBranch: elRoot .getAttribute (' data-current-repo-default-branch'  ), 
93-       currentRepoLink: elRoot .getAttribute (' data-current-repo-link'  ), 
94-       currentTreePath: elRoot .getAttribute (' data-current-tree-path'  ), 
95-       currentRefType: elRoot .getAttribute (' data-current-ref-type'  ), 
96-       currentRefShortName: elRoot .getAttribute (' data-current-ref-short-name'  ), 
89+       currentRepoDefaultBranch: this . elRoot .getAttribute (' data-current-repo-default-branch'  ), 
90+       currentRepoLink: this . elRoot .getAttribute (' data-current-repo-link'  ), 
91+       currentTreePath: this . elRoot .getAttribute (' data-current-tree-path'  ), 
92+       currentRefType: this . elRoot .getAttribute (' data-current-ref-type'  ), 
93+       currentRefShortName: this . elRoot .getAttribute (' data-current-ref-short-name'  ), 
9794
98-       refLinkTemplate: elRoot .getAttribute (' data-ref-link-template'  ), 
99-       refFormActionTemplate: elRoot .getAttribute (' data-ref-form-action-template'  ), 
100-       dropdownFixedText: elRoot .getAttribute (' data-dropdown-fixed-text'  ), 
95+       refLinkTemplate: this . elRoot .getAttribute (' data-ref-link-template'  ), 
96+       refFormActionTemplate: this . elRoot .getAttribute (' data-ref-form-action-template'  ), 
97+       dropdownFixedText: this . elRoot .getAttribute (' data-dropdown-fixed-text'  ), 
10198      showTabBranches: shouldShowTabBranches , 
102-       showTabTags: elRoot .getAttribute (' data-show-tab-tags'  ) ===  ' true'  , 
103-       allowCreateNewRef: elRoot .getAttribute (' data-allow-create-new-ref'  ) ===  ' true'  , 
104-       showViewAllRefsEntry: elRoot .getAttribute (' data-show-view-all-refs-entry'  ) ===  ' true'  , 
105- 
106-       enableFeed: elRoot .getAttribute (' data-enable-feed'  ) ===  ' true'  , 
99+       showTabTags: this .elRoot .getAttribute (' data-show-tab-tags'  ) ===  ' true'  , 
100+       allowCreateNewRef: this .elRoot .getAttribute (' data-allow-create-new-ref'  ) ===  ' true'  , 
101+       showViewAllRefsEntry: this .elRoot .getAttribute (' data-show-view-all-refs-entry'  ) ===  ' true'  , 
102+       enableFeed: this .elRoot .getAttribute (' data-enable-feed'  ) ===  ' true'  , 
107103    }; 
108104  }, 
109- 
110105  beforeMount() { 
111106    document .body .addEventListener (' click'  , (e ) =>  { 
112107      if  (this .$el .contains (e .target )) return ; 
@@ -219,16 +214,6 @@ const sfc = {
219214  }, 
220215}; 
221216
222- export  function  initRepoBranchTagSelector(selector ) {
223-   for  (const   elRoot of  document .querySelectorAll (selector )) { 
224-     //  it is very hacky, but it is the only way to pass the elRoot to the "data()" function 
225-     //  it could be improved in the future to do more rewriting. 
226-     currentElRoot  =  elRoot ; 
227-     const   comp =  {... sfc }; 
228-     createApp (comp ).mount (elRoot ); 
229-   } 
230- } 
231- 
232217export  default  sfc ; //  activate IDE's Vue plugin
233218 </script >
234219<template >
0 commit comments