Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
b4d265cc
Commit
b4d265cc
authored
Dec 16, 2016
by
Bryce Johnson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simplify logic for approverNamesStringified.
parent
44fa842f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
16 deletions
+10
-16
app/assets/javascripts/merge_request_widget/approvals/components/approvals_body.js.es6
...request_widget/approvals/components/approvals_body.js.es6
+10
-16
No files found.
app/assets/javascripts/merge_request_widget/approvals/components/approvals_body.js.es6
View file @
b4d265cc
...
...
@@ -12,25 +12,19 @@
},
approverNamesStringified() {
const approvers = this.suggestedApprovers;
if (approvers && approvers.length) {
if (approvers.length === 1) {
return approvers[0].name;
}
const lastIndex = approvers.length - 1;
const nextToLastIndex = approvers.length - 2;
if (approvers.length === 1) {
return approvers[0].name;
} else {
return approvers.reduce((memo, curr, index) => {
let suffix
;
const nextMemo = `${memo}${curr.name}`
;
if (index === nextToLastIndex) {
suffix = ' or ';
} else if (index === lastIndex) {
suffix = '';
} else {
suffix = ', ';
if (index === approvers.length - 2) { // second to last index
return `${nextMemo} or `;
} else if (index === approvers.length - 1) { // last index
return nextMemo;
}
const nameToAdd = `${curr.name}${suffix}`;
return `${memo}${nameToAdd}`;
return `${nextMemo}, `;
}, '');
}
return null;
...
...
@@ -39,7 +33,7 @@
return this.userCanApprove && !this.userHasApproved;
},
showApprovalsBody() {
return !this.widgetLoading && this.approvalsLeft;
return !this.widgetLoading && this.approvalsLeft
&& this.suggestedApprovers.length
;
}
},
methods: {
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment