2 files changed +14
-3
lines changed Original file line number Diff line number Diff line change 48
48
< div class ="browser-style man "> < input type ="radio " required name ="jira_ticket_link_label_type " value ="icon " id ="jira_ticket_link_label_type_icon " class ="man "> < label for ="jira_ticket_link_label_type_icon "> An icon</ label > </ div >
49
49
</ div >
50
50
</ div >
51
- < div class ="pts pbs row ">
51
+ < div class ="pts row ">
52
52
< div class ="w40p txt-center browser-style ">
53
53
< input type ="checkbox " id ="enable_button_to_toggle_wip_status ">
54
54
</ div >
55
55
< div >
56
56
< label for ="enable_button_to_toggle_wip_status "> Enable button allowing to toggle WIP status</ label >
57
57
</ div >
58
58
</ div >
59
+ < div class ="pbs pll ">
60
+ < small class ="txt-muted "> This feature is automatically disabled if logged-out</ small >
61
+ </ div >
59
62
< div class ="txt-center pts pbs "> < button type ="submit " class ="browser-style "> Save preferences</ button > </ div >
60
63
</ form >
61
64
Original file line number Diff line number Diff line change 123
123
124
124
this . baseUrl = location . protocol + '//' + location . host ;
125
125
this . baseApiUrl = this . baseUrl + '/api/v4/' ;
126
+ this . userAuthenticated = this . isUserAuthenticated ( ) ;
126
127
this . apiClient = new GitLabApiClient ( this . baseApiUrl , this . getCsrfToken ( ) ) ;
127
128
128
129
let currentMergeRequestIds = this . getCurrentMergeRequestIds ( ) ;
167
168
return meta ? meta . getAttribute ( 'content' ) : null ;
168
169
}
169
170
171
+ /**
172
+ * Determines if the current user is logged-in to GitLab.
173
+ */
174
+ isUserAuthenticated ( ) {
175
+ return document . querySelector ( '.navbar-nav .header-user' ) ? true : false ;
176
+ }
177
+
170
178
/**
171
179
* Gets all Merge Requests IDs that are currently displayed.
172
180
*/
199
207
self . attachClickEventToCopyMergeRequestInfoButtons ( ) ;
200
208
}
201
209
202
- if ( self . preferences . enable_button_to_toggle_wip_status ) {
210
+ if ( self . userAuthenticated && self . preferences . enable_button_to_toggle_wip_status ) {
203
211
self . attachClickEventToToggleWipStatusButtons ( ) ;
204
212
}
205
213
} else {
275
283
// -----------------------------------------------
276
284
// Toggle WIP status button
277
285
278
- if ( this . preferences . enable_button_to_toggle_wip_status ) {
286
+ if ( this . userAuthenticated && this . preferences . enable_button_to_toggle_wip_status ) {
279
287
let toggleWipStatusButton = '<button class="btn btn-secondary btn-md btn-default btn-transparent btn-clipboard has-tooltip gmrle-toggle-wip-status" title="Toggle WIP status" style="padding-left: 0">' +
280
288
'<i class="fa fa-wrench" aria-hidden="true"></i>' +
281
289
'</button> ' ;
0 commit comments