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

Commit adeebb9

Browse files
authored
Merge pull request #14 from EpocDotFr/unresolved-discussions-indicator
Unresolved discussions indicator
2 parents 24f0060 + 011a5c6 commit adeebb9

File tree

8 files changed

+52
-14
lines changed

8 files changed

+52
-14
lines changed

README.md

+3
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ A browser extension that enhance all Merge Requests lists on any instance of Git
2323
- Base Jira URL is configured in extension preferences
2424
- The ticket ID or an icon can be displayed as the link label (configured in extension preferences)
2525
- WIP toggle button (can be enabled/disabled in the extension preferences)
26+
- Show an indicator when there's unresolved discussions left on Merge Requests
27+
- Can be enabled/disabled in the extension preferences
28+
- Note the **All discussions must be resolved** option must be enabled for this feature to be working as expected. This option is enabled per project and is located in **Settings > General > Merge Requests > Merge checks**
2629
- Compatible with all GitLab editions (GitLab CE, GitLab EE, GitLab.com) (look at the prerequisites, though)
2730

2831
## Prerequisites

css/options.css

+4-4
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,12 @@ body.is-chrome {
8585
* Layout styles */
8686

8787
.row {
88-
display: table;
89-
width: 100%;
88+
display: flex;
89+
flex-direction: row;
9090
}
9191

92-
.row > * {
93-
display: table-cell;
92+
.row > .fluid {
93+
flex-grow: 1;
9494
}
9595

9696
/************************************************************************

html/options.html

+15-4
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<div class="w40p txt-center browser-style">
1111
<input type="checkbox" id="display_source_and_target_branches">
1212
</div>
13-
<div>
13+
<div class="fluid">
1414
<label for="display_source_and_target_branches">Display source and target branches</label>
1515
</div>
1616
</div>
@@ -21,7 +21,7 @@
2121
<div class="w40p txt-center browser-style">
2222
<input type="checkbox" id="enable_button_to_copy_mr_info">
2323
</div>
24-
<div>
24+
<div class="fluid">
2525
<label for="enable_button_to_copy_mr_info">Enable button allowing to copy Merge Request information</label>
2626
</div>
2727
</div>
@@ -37,7 +37,7 @@
3737
<div class="w40p txt-center browser-style">
3838
<input type="checkbox" id="enable_jira_ticket_link">
3939
</div>
40-
<div>
40+
<div class="fluid">
4141
<label for="enable_jira_ticket_link">Enable Jira ticket link</label>
4242
</div>
4343
</div>
@@ -55,13 +55,24 @@
5555
<div class="w40p txt-center browser-style">
5656
<input type="checkbox" id="enable_button_to_toggle_wip_status">
5757
</div>
58-
<div>
58+
<div class="fluid">
5959
<label for="enable_button_to_toggle_wip_status">Enable button allowing to toggle WIP status</label>
6060
</div>
6161
</div>
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 row">
66+
<div class="w40p txt-center browser-style">
67+
<input type="checkbox" id="enable_unresolved_discussions_indicator">
68+
</div>
69+
<div class="fluid">
70+
<label for="enable_unresolved_discussions_indicator">Show an indicator when there's unresolved discussion(s) left</label>
71+
</div>
72+
</div>
73+
<div class="pbs pll">
74+
<small class="txt-muted">Note the <strong>All discussions must be resolved</strong> option must be enabled for this feature to be working as expected. This option is enabled per project and is located in <strong>Settings > General > Merge Requests > Merge checks</strong>.</small>
75+
</div>
6576
<div class="txt-center pts pbs"><button type="submit" class="browser-style">Save preferences</button></div>
6677
</form>
6778

js/content.js

+14-2
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,18 @@
416416
newInfoLineToInject
417417
);
418418
}
419+
420+
// -----------------------------------------------
421+
// Unresolved discussions indicator
422+
423+
if (this.preferences.enable_unresolved_discussions_indicator && !mergeRequest.blocking_discussions_resolved) {
424+
let unresolvedDiscussionsIndicatorToInject = '<li><span class="has-tooltip" title="Unresolved discussion(s) left">' + this.buildSpriteIcon('comment-dots', 'danger-title') + '</span></li>';
425+
426+
this.parseHtmlAndPrepend(
427+
mergeRequestNode.querySelector('.issuable-meta .controls'),
428+
unresolvedDiscussionsIndicatorToInject
429+
);
430+
}
419431
}, this);
420432
}
421433

@@ -597,8 +609,8 @@
597609
/**
598610
* Generate the HTML code corresponding to an SVG icon.
599611
*/
600-
buildSpriteIcon(iconName) {
601-
return '<svg class="s16" data-testid="' + iconName + '-icon">' +
612+
buildSpriteIcon(iconName, classes = '') {
613+
return '<svg class="s16 ' + classes + '" data-testid="' + iconName + '-icon">' +
602614
'<use xlink:href="' + this.baseIconsUrl + '#' + iconName + '"></use>' +
603615
'</svg>';
604616
}

js/options.js

+13-2
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@
3737
this.jiraTicketLinkLabelTypeRadioButtons = Array.from(document.querySelectorAll('input[name="jira_ticket_link_label_type"]'));
3838

3939
this.enableButtonToToggleWipStatusCheckbox = document.querySelector('input#enable_button_to_toggle_wip_status');
40+
41+
this.enableUnresolvedDiscussionsIndicatorCheckbox = document.querySelector('input#enable_unresolved_discussions_indicator');
4042
}
4143

4244
/**
@@ -67,6 +69,9 @@
6769

6870
self.enableButtonToToggleWipStatusCheckbox.checked = preferences.enable_button_to_toggle_wip_status;
6971
self.enableButtonToToggleWipStatusCheckbox.dispatchEvent(new CustomEvent('change'));
72+
73+
self.enableUnresolvedDiscussionsIndicatorCheckbox.checked = preferences.enable_unresolved_discussions_indicator;
74+
self.enableUnresolvedDiscussionsIndicatorCheckbox.dispatchEvent(new CustomEvent('change'));
7075
});
7176
}
7277

@@ -117,6 +122,10 @@
117122
this.enableButtonToToggleWipStatusCheckbox.addEventListener('change', function() {
118123
self.forceUserToEnableAtLeastOneFeatureIfNecessarily();
119124
});
125+
126+
this.enableUnresolvedDiscussionsIndicatorCheckbox.addEventListener('change', function() {
127+
self.forceUserToEnableAtLeastOneFeatureIfNecessarily();
128+
});
120129
}
121130

122131
/**
@@ -138,7 +147,8 @@
138147
enable_jira_ticket_link: this.enableJiraTicketLinkCheckbox.checked,
139148
base_jira_url: this.baseJiraUrlInput.value,
140149
jira_ticket_link_label_type: jira_ticket_link_label_type,
141-
enable_button_to_toggle_wip_status: this.enableButtonToToggleWipStatusCheckbox.checked
150+
enable_button_to_toggle_wip_status: this.enableButtonToToggleWipStatusCheckbox.checked,
151+
enable_unresolved_discussions_indicator: this.enableUnresolvedDiscussionsIndicatorCheckbox.checked
142152
},
143153
function() {
144154
self.setSuccessfulVisualFeedbackOnSubmitButton();
@@ -173,7 +183,8 @@
173183
return !this.displaySourceAndTargetBranchesCheckbox.checked
174184
&& !this.enableButtonToCopyMrInfoCheckbox.checked
175185
&& !this.enableJiraTicketLinkCheckbox.checked
176-
&& !this.enableButtonToToggleWipStatusCheckbox.checked;
186+
&& !this.enableButtonToToggleWipStatusCheckbox.checked
187+
&& !this.enableUnresolvedDiscussionsIndicatorCheckbox.checked;
177188
}
178189

179190
/**

js/preferences.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
enable_jira_ticket_link: false,
1414
base_jira_url: '',
1515
jira_ticket_link_label_type: 'ticket_id',
16-
enable_button_to_toggle_wip_status: true
16+
enable_button_to_toggle_wip_status: true,
17+
enable_unresolved_discussions_indicator: true
1718
};
1819
}
1920

screenshot.png

19.9 KB
Loading

scripts/settings.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
MANIFEST_FILE = {
22
'manifest_version': 2,
33
'name': 'GitLab Merge Requests lists enhancer',
4-
'version': '1.5.1',
4+
'version': '1.6.0',
55
'description': 'An extension that enhance all Merge Requests lists on any instance of Gitlab and GitLab.com.',
66
'homepage_url': 'https://github.com/EpocDotFr/gitlab-merge-requests-lists-enhancer',
77
'author': 'Maxime \'Epoc\' G.',

0 commit comments

Comments
 (0)