1
1
<script lang="ts">
2
- import {createApp , nextTick } from ' vue' ;
2
+ import {nextTick } from ' vue' ;
3
3
import {SvgIcon } from ' ../svg.ts' ;
4
4
import {showErrorToast } from ' ../modules/toast.ts' ;
5
5
import {GET } from ' ../modules/fetch.ts' ;
@@ -17,11 +17,11 @@ type SelectedTab = 'branches' | 'tags';
17
17
18
18
type TabLoadingStates = Record <SelectedTab , ' ' | ' loading' | ' done' >
19
19
20
- let currentElRoot: HTMLElement ;
21
-
22
20
const sfc = {
23
21
components: {SvgIcon },
24
-
22
+ props: {
23
+ elRoot: HTMLElement ,
24
+ },
25
25
computed: {
26
26
searchFieldPlaceholder() {
27
27
return this .selectedTab === ' branches' ? this .textFilterBranch : this .textFilterTag ;
@@ -55,18 +55,15 @@ const sfc = {
55
55
return ` ${this .currentRepoLink }/branches/_new/${this .currentRefType }/${pathEscapeSegments (this .currentRefShortName )} ` ;
56
56
},
57
57
},
58
-
59
58
watch: {
60
- menuVisible(visible ) {
59
+ menuVisible(visible : boolean ) {
61
60
if (! visible ) return ;
62
61
this .focusSearchField ();
63
62
this .loadTabItems ();
64
63
},
65
64
},
66
-
67
65
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' ;
70
67
return {
71
68
csrfToken: window .config .csrfToken ,
72
69
allItems: [] as ListItem [],
@@ -76,37 +73,35 @@ const sfc = {
76
73
activeItemIndex: 0 ,
77
74
tabLoadingStates: {} as TabLoadingStates ,
78
75
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' ),
91
88
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' ),
97
94
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' ),
101
98
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' ,
107
103
};
108
104
},
109
-
110
105
beforeMount() {
111
106
document .body .addEventListener (' click' , (e ) => {
112
107
if (this .$el .contains (e .target )) return ;
@@ -219,16 +214,6 @@ const sfc = {
219
214
},
220
215
};
221
216
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
-
232
217
export default sfc ; // activate IDE's Vue plugin
233
218
</script >
234
219
<template >
0 commit comments