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

Commit e167c11

Browse files
committed
Finalize
1 parent 73f3180 commit e167c11

File tree

3 files changed

+53
-31
lines changed

3 files changed

+53
-31
lines changed

html/options.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
</head>
77
<body>
88
<form>
9-
<div class="pts pbs row">
9+
<div class="pts row">
1010
<div class="w40p txt-center browser-style">
1111
<input type="checkbox" id="display_source_and_target_branches">
1212
</div>

js/content.js

Lines changed: 36 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,10 @@
196196
this.apiClient.getProjectMergeRequests(
197197
function() {
198198
if (this.status == 200) {
199-
self.removeExistingTargetBranchNodes();
199+
if (self.preferences.display_source_and_target_branches) {
200+
self.removeExistingTargetBranchNodes();
201+
}
202+
200203
self.updateMergeRequestsNodes(this.response);
201204

202205
if (self.preferences.enable_buttons_to_copy_source_and_target_branches_name) {
@@ -346,38 +349,41 @@
346349
// -----------------------------------------------
347350
// Source and target branches info
348351

349-
// Source branch name
350-
let newInfoLineToInject = '<div class="issuable-info">' +
351-
'<span class="project-ref-path has-tooltip" title="Source branch">' +
352-
'<a class="ref-name" href="' + this.baseProjectUrl + '/-/commits/' + mergeRequest.source_branch + '">' + mergeRequest.source_branch + '</a>' +
353-
'</span>';
354-
355-
// Copy source branch name button
356-
if (this.preferences.enable_buttons_to_copy_source_and_target_branches_name) {
357-
newInfoLineToInject += ' <button class="btn btn-secondary btn-md btn-default btn-transparent btn-clipboard has-tooltip gmrle-copy-branch-name" title="Copy branch name" data-branch-name-to-copy="source">' +
358-
'<i class="fa fa-clipboard" aria-hidden="true"></i>' +
359-
'</button>';
360-
}
352+
if (this.preferences.display_source_and_target_branches) {
353+
let newInfoLineToInject = '<div class="issuable-info">';
361354

362-
// Target branch name
363-
newInfoLineToInject += ' <i class="fa fa-long-arrow-right" aria-hidden="true"></i> ' +
364-
'<span class="project-ref-path has-tooltip" title="Target branch">' +
365-
'<a class="ref-name" href="' + this.baseProjectUrl + '/-/commits/' + mergeRequest.target_branch + '">' + mergeRequest.target_branch + '</a>' +
366-
'</span>';
367-
368-
// Copy target branch name button
369-
if (this.preferences.enable_buttons_to_copy_source_and_target_branches_name) {
370-
newInfoLineToInject += ' <button class="btn btn-secondary btn-md btn-default btn-transparent btn-clipboard has-tooltip gmrle-copy-branch-name" title="Copy branch name" data-branch-name-to-copy="target">' +
371-
'<i class="fa fa-clipboard" aria-hidden="true"></i>' +
372-
'</button>';
373-
}
355+
// Source branch name
356+
newInfoLineToInject += '<span class="project-ref-path has-tooltip" title="Source branch">' +
357+
'<a class="ref-name" href="' + this.baseProjectUrl + '/-/commits/' + mergeRequest.source_branch + '">' + mergeRequest.source_branch + '</a>' +
358+
'</span>';
359+
360+
// Copy source branch name button
361+
if (this.preferences.enable_buttons_to_copy_source_and_target_branches_name) {
362+
newInfoLineToInject += ' <button class="btn btn-secondary btn-md btn-default btn-transparent btn-clipboard has-tooltip gmrle-copy-branch-name" title="Copy branch name" data-branch-name-to-copy="source">' +
363+
'<i class="fa fa-clipboard" aria-hidden="true"></i>' +
364+
'</button>';
365+
}
366+
367+
// Target branch name
368+
newInfoLineToInject += ' <i class="fa fa-long-arrow-right" aria-hidden="true"></i> ' +
369+
'<span class="project-ref-path has-tooltip" title="Target branch">' +
370+
'<a class="ref-name" href="' + this.baseProjectUrl + '/-/commits/' + mergeRequest.target_branch + '">' + mergeRequest.target_branch + '</a>' +
371+
'</span>';
372+
373+
// Copy target branch name button
374+
if (this.preferences.enable_buttons_to_copy_source_and_target_branches_name) {
375+
newInfoLineToInject += ' <button class="btn btn-secondary btn-md btn-default btn-transparent btn-clipboard has-tooltip gmrle-copy-branch-name" title="Copy branch name" data-branch-name-to-copy="target">' +
376+
'<i class="fa fa-clipboard" aria-hidden="true"></i>' +
377+
'</button>';
378+
}
374379

375-
newInfoLineToInject += '</div>';
380+
newInfoLineToInject += '</div>';
376381

377-
this.parseHtmlAndAppend(
378-
mergeRequestNode.querySelector('.issuable-main-info'),
379-
newInfoLineToInject
380-
);
382+
this.parseHtmlAndAppend(
383+
mergeRequestNode.querySelector('.issuable-main-info'),
384+
newInfoLineToInject
385+
);
386+
}
381387
}, this);
382388
}
383389

js/options.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,12 @@
7878
this.optionsForm.addEventListener('submit', function(e) {
7979
e.preventDefault();
8080

81+
if (self.userDisabledAllFeatures()) {
82+
alert('That would make the extension useless! Please enable at least one feature.');
83+
84+
return false;
85+
}
86+
8187
if (!self.initializeVisualFeedbackOnSubmitButton()) {
8288
return false;
8389
}
@@ -134,6 +140,16 @@
134140
);
135141
}
136142

143+
/**
144+
* Check if the user disabled all the features of the extension (which is useless).
145+
*/
146+
userDisabledAllFeatures() {
147+
return !this.displaySourceAndTargetBranchesCheckbox.checked
148+
&& !this.enableButtonToCopyMrInfoCheckbox.checked
149+
&& !this.enableJiraTicketLinkCheckbox.checked
150+
&& !this.enableButtonToToggleWipStatusCheckbox.checked;
151+
}
152+
137153
/**
138154
* Returns the browser name the extension is currently running on.
139155
*/

0 commit comments

Comments
 (0)