Skip to content
This repository was archived by the owner on Aug 31, 2023. It is now read-only.

Commit a2456ba

Browse files
committed
Check pipelines are enabled
1 parent 96f62c1 commit a2456ba

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

html/options.html

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,17 @@
6262
<div class="pbs pll">
6363
<small class="txt-muted">This feature is automatically disabled if logged-out</small>
6464
</div>
65-
<div class="pts pbs row">
65+
<div class="pts row">
6666
<div class="w40p txt-center browser-style">
6767
<input type="checkbox" id="automatically_update_pipeline_status_icons">
6868
</div>
6969
<div>
7070
<label for="automatically_update_pipeline_status_icons">Automatically update pipeline status icons every 10 seconds</label>
7171
</div>
7272
</div>
73+
<div class="pbs pll">
74+
<small class="txt-muted">This feature is automatically disabled if the GitLab "pipeline" feature is disabled</small>
75+
</div>
7376
<div class="txt-center pts pbs"><button type="submit" class="browser-style">Save preferences</button></div>
7477
</form>
7578

js/content.js

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -132,16 +132,18 @@
132132
this.baseUrl = location.protocol + '//' + location.host;
133133
this.baseApiUrl = this.baseUrl + '/api/v4/';
134134
this.userAuthenticated = this.isUserAuthenticated();
135+
this.pipelineFeatureEnabled = this.isPipelineFeatureEnabled();
135136
this.apiClient = new GitLabApiClient(this.baseApiUrl, this.getCsrfToken());
136137

137-
let currentMergeRequestIds = this.getCurrentMergeRequestIds();
138+
this.currentMergeRequestIds = this.getCurrentMergeRequestIds();
139+
138140
let preferencesManager = new globals.Gmrle.PreferencesManager();
139141

140142
let self = this;
141143

142144
preferencesManager.getAll(function(preferences) {
143145
self.preferences = preferences;
144-
self.fetchMergeRequestsDetailsThenUpdateUI(currentMergeRequestIds);
146+
self.fetchMergeRequestsDetailsThenUpdateUI(self.currentMergeRequestIds);
145147
});
146148
}
147149

@@ -183,6 +185,13 @@
183185
return document.querySelector('.navbar-nav .header-user') ? true : false;
184186
}
185187

188+
/**
189+
* Determines if the project do uses the Gitlab "pipeline" feature.
190+
*/
191+
isPipelineFeatureEnabled() {
192+
return document.querySelector('.issuable-pipeline-status') ? true : false;
193+
}
194+
186195
/**
187196
* Gets all Merge Requests IDs that are currently displayed.
188197
*/
@@ -220,7 +229,7 @@
220229
self.attachClickEventToToggleWipStatusButtons();
221230
}
222231

223-
if (self.preferences.automatically_update_pipeline_status_icons) {
232+
if (self.pipelineFeatureEnabled && self.preferences.automatically_update_pipeline_status_icons) {
224233
self.schedulePipelineStatusIconsUpdate();
225234
}
226235
});
@@ -596,8 +605,8 @@
596605
updatePipelineStatusIcons() {
597606
let self = this;
598607

599-
this.fetchMergeRequestsDetails(mergeRequestIds).then(function(responseData) {
600-
// TODO actually update icons
608+
this.fetchMergeRequestsDetails(this.currentMergeRequestIds).then(function(responseData) {
609+
// TODO Actually update icons
601610

602611
self.schedulePipelineStatusIconsUpdate();
603612
});

0 commit comments

Comments
 (0)