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
2846f45a
Commit
2846f45a
authored
Jun 03, 2021
by
Kev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Say when MR was approved by me
Changelog: changed
parent
817d5d87
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
115 additions
and
27 deletions
+115
-27
app/assets/javascripts/vue_merge_request_widget/components/approvals/approvals_summary.vue
...request_widget/components/approvals/approvals_summary.vue
+54
-20
app/assets/javascripts/vue_merge_request_widget/components/approvals/messages.js
...vue_merge_request_widget/components/approvals/messages.js
+3
-1
locale/gitlab.pot
locale/gitlab.pot
+6
-3
spec/features/merge_request/user_approves_spec.rb
spec/features/merge_request/user_approves_spec.rb
+1
-1
spec/frontend/vue_mr_widget/components/approvals/approvals_summary_spec.js
..._mr_widget/components/approvals/approvals_summary_spec.js
+51
-2
No files found.
app/assets/javascripts/vue_merge_request_widget/components/approvals/approvals_summary.vue
View file @
2846f45a
<
script
>
import
{
toNounSeriesText
}
from
'
~/lib/utils/grammar
'
;
import
{
n__
,
sprintf
}
from
'
~/locale
'
;
import
{
APPROVED_MESSAGE
}
from
'
~/vue_merge_request_widget/components/approvals/messages
'
;
import
{
APPROVED_BY_YOU_AND_OTHERS
,
APPROVED_BY_YOU
,
APPROVED_BY_OTHERS
,
}
from
'
~/vue_merge_request_widget/components/approvals/messages
'
;
import
UserAvatarList
from
'
~/vue_shared/components/user_avatar/user_avatar_list.vue
'
;
export
default
{
...
...
@@ -29,19 +33,8 @@ export default {
},
},
computed
:
{
message
()
{
if
(
this
.
approved
)
{
return
APPROVED_MESSAGE
;
}
if
(
!
this
.
rulesLeft
.
length
)
{
return
n__
(
'
Requires %d approval from eligible users.
'
,
'
Requires %d approvals from eligible users.
'
,
this
.
approvalsLeft
,
);
}
approvalLeftMessage
()
{
if
(
this
.
rulesLeft
.
length
)
{
return
sprintf
(
n__
(
'
Requires %{count} approval from %{names}.
'
,
...
...
@@ -54,20 +47,61 @@ export default {
},
false
,
);
}
if
(
!
this
.
approved
)
{
return
n__
(
'
Requires %d approval from eligible users.
'
,
'
Requires %d approvals from eligible users.
'
,
this
.
approvalsLeft
,
);
}
return
''
;
},
message
()
{
if
(
this
.
approvedByMe
&&
this
.
approvedByOthers
)
{
return
APPROVED_BY_YOU_AND_OTHERS
;
}
if
(
this
.
approvedByMe
)
{
return
APPROVED_BY_YOU
;
}
if
(
this
.
approved
)
{
return
APPROVED_BY_OTHERS
;
}
return
''
;
},
hasApprovers
()
{
return
Boolean
(
this
.
approvers
.
length
);
},
approvedByMe
()
{
if
(
!
this
.
currentUserId
)
{
return
false
;
}
return
this
.
approvers
.
some
((
approver
)
=>
approver
.
id
===
this
.
currentUserId
);
},
approvedByOthers
()
{
if
(
!
this
.
currentUserId
)
{
return
false
;
}
return
this
.
approvers
.
some
((
approver
)
=>
approver
.
id
!==
this
.
currentUserId
);
},
currentUserId
()
{
return
gon
.
current_user_id
;
},
},
APPROVED_MESSAGE
,
};
</
script
>
<
template
>
<div
data-qa-selector=
"approvals_summary_content"
>
<strong>
{{
m
essage
}}
</strong>
<strong>
{{
approvalLeftM
essage
}}
</strong>
<template
v-if=
"hasApprovers"
>
<span>
{{
s__
(
'
mrWidget|Approved by
'
)
}}
</span>
<span
v-if=
"approvalLeftMessage"
>
{{
message
}}
</span>
<strong
v-else
>
{{
message
}}
</strong>
<user-avatar-list
class=
"d-inline-block align-middle"
:items=
"approvers"
/>
</
template
>
</div>
...
...
app/assets/javascripts/vue_merge_request_widget/components/approvals/messages.js
View file @
2846f45a
...
...
@@ -6,4 +6,6 @@ export const FETCH_ERROR = s__(
);
export
const
APPROVE_ERROR
=
s__
(
'
mrWidget|An error occurred while submitting your approval.
'
);
export
const
UNAPPROVE_ERROR
=
s__
(
'
mrWidget|An error occurred while removing your approval.
'
);
export
const
APPROVED_MESSAGE
=
s__
(
'
mrWidget|Merge request approved.
'
);
export
const
APPROVED_BY_YOU_AND_OTHERS
=
s__
(
'
mrWidget|Approved by you and others
'
);
export
const
APPROVED_BY_YOU
=
s__
(
'
mrWidget|Approved by you
'
);
export
const
APPROVED_BY_OTHERS
=
s__
(
'
mrWidget|Approved by
'
);
locale/gitlab.pot
View file @
2846f45a
...
...
@@ -40755,6 +40755,12 @@ msgstr ""
msgid "mrWidget|Approved by"
msgstr ""
msgid "mrWidget|Approved by you"
msgstr ""
msgid "mrWidget|Approved by you and others"
msgstr ""
msgid "mrWidget|Are you adding technical debt or code vulnerabilities?"
msgstr ""
...
...
@@ -40852,9 +40858,6 @@ msgstr ""
msgid "mrWidget|Merge locally"
msgstr ""
msgid "mrWidget|Merge request approved."
msgstr ""
msgid "mrWidget|Merged by"
msgstr ""
...
...
spec/features/merge_request/user_approves_spec.rb
View file @
2846f45a
...
...
@@ -17,7 +17,7 @@ RSpec.describe 'Merge request > User approves', :js do
it
'approves merge request'
do
click_approval_button
(
'Approve'
)
expect
(
page
).
to
have_content
(
'
Merge request approved
'
)
expect
(
page
).
to
have_content
(
'
Approved by you
'
)
verify_approvals_count_on_index!
...
...
spec/frontend/vue_mr_widget/components/approvals/approvals_summary_spec.js
View file @
2846f45a
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
{
toNounSeriesText
}
from
'
~/lib/utils/grammar
'
;
import
ApprovalsSummary
from
'
~/vue_merge_request_widget/components/approvals/approvals_summary.vue
'
;
import
{
APPROVED_MESSAGE
}
from
'
~/vue_merge_request_widget/components/approvals/messages
'
;
import
{
APPROVED_BY_OTHERS
,
APPROVED_BY_YOU
,
APPROVED_BY_YOU_AND_OTHERS
,
}
from
'
~/vue_merge_request_widget/components/approvals/messages
'
;
import
UserAvatarList
from
'
~/vue_shared/components/user_avatar/user_avatar_list.vue
'
;
const
exampleUserId
=
1
;
const
testApprovers
=
()
=>
Array
.
from
({
length
:
5
},
(
_
,
i
)
=>
i
).
map
((
id
)
=>
({
id
}));
const
testRulesLeft
=
()
=>
[
'
Lorem
'
,
'
Ipsum
'
,
'
dolar & sit
'
];
const
TEST_APPROVALS_LEFT
=
3
;
describe
(
'
MRWidget approvals summary
'
,
()
=>
{
const
originalUserId
=
gon
.
current_user_id
;
let
wrapper
;
const
createComponent
=
(
props
=
{})
=>
{
...
...
@@ -28,6 +34,7 @@ describe('MRWidget approvals summary', () => {
afterEach
(()
=>
{
wrapper
.
destroy
();
wrapper
=
null
;
gon
.
current_user_id
=
originalUserId
;
});
describe
(
'
when approved
'
,
()
=>
{
...
...
@@ -38,7 +45,7 @@ describe('MRWidget approvals summary', () => {
});
it
(
'
shows approved message
'
,
()
=>
{
expect
(
wrapper
.
text
()).
toContain
(
APPROVED_
MESSAGE
);
expect
(
wrapper
.
text
()).
toContain
(
APPROVED_
BY_OTHERS
);
});
it
(
'
renders avatar list for approvers
'
,
()
=>
{
...
...
@@ -51,6 +58,48 @@ describe('MRWidget approvals summary', () => {
}),
);
});
describe
(
'
by the current user
'
,
()
=>
{
beforeEach
(()
=>
{
gon
.
current_user_id
=
exampleUserId
;
createComponent
({
approvers
:
[{
id
:
exampleUserId
}],
approved
:
true
,
});
});
it
(
'
shows "Approved by you" message
'
,
()
=>
{
expect
(
wrapper
.
text
()).
toContain
(
APPROVED_BY_YOU
);
});
});
describe
(
'
by the current user and others
'
,
()
=>
{
beforeEach
(()
=>
{
gon
.
current_user_id
=
exampleUserId
;
createComponent
({
approvers
:
[{
id
:
exampleUserId
},
{
id
:
exampleUserId
+
1
}],
approved
:
true
,
});
});
it
(
'
shows "Approved by you and others" message
'
,
()
=>
{
expect
(
wrapper
.
text
()).
toContain
(
APPROVED_BY_YOU_AND_OTHERS
);
});
});
describe
(
'
by other users than the current user
'
,
()
=>
{
beforeEach
(()
=>
{
gon
.
current_user_id
=
exampleUserId
;
createComponent
({
approvers
:
[{
id
:
exampleUserId
+
1
}],
approved
:
true
,
});
});
it
(
'
shows "Approved by others" message
'
,
()
=>
{
expect
(
wrapper
.
text
()).
toContain
(
APPROVED_BY_OTHERS
);
});
});
});
describe
(
'
when not approved
'
,
()
=>
{
...
...
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