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
544e281d
Commit
544e281d
authored
Jun 30, 2020
by
Justin Boyson
Committed by
Martin Wortschack
Jun 30, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update toNounSeriesText to not escape text
Update tests and grammar.js to account for no escaping as well
parent
a7974822
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
27 additions
and
14 deletions
+27
-14
app/assets/javascripts/lib/utils/grammar.js
app/assets/javascripts/lib/utils/grammar.js
+11
-7
ee/app/assets/javascripts/vue_merge_request_widget/components/approvals/approvals_summary.vue
...request_widget/components/approvals/approvals_summary.vue
+1
-0
ee/changelogs/unreleased/jdb-fix-wrongly-escaped-ampersand.yml
...angelogs/unreleased/jdb-fix-wrongly-escaped-ampersand.yml
+5
-0
ee/spec/frontend/vue_mr_widget/components/approvals/approvals_summary_spec.js
..._mr_widget/components/approvals/approvals_summary_spec.js
+1
-1
locale/gitlab.pot
locale/gitlab.pot
+3
-0
spec/frontend/lib/utils/grammar_spec.js
spec/frontend/lib/utils/grammar_spec.js
+6
-6
No files found.
app/assets/javascripts/lib/utils/grammar.js
View file @
544e281d
...
...
@@ -20,18 +20,22 @@ export const toNounSeriesText = items => {
if
(
items
.
length
===
0
)
{
return
''
;
}
else
if
(
items
.
length
===
1
)
{
return
items
[
0
]
;
return
sprintf
(
s__
(
`nounSeries|%{item}`
),
{
item
:
items
[
0
]
},
false
)
;
}
else
if
(
items
.
length
===
2
)
{
return
sprintf
(
s__
(
'
nounSeries|%{firstItem} and %{lastItem}
'
),
{
firstItem
:
items
[
0
],
lastItem
:
items
[
1
],
});
return
sprintf
(
s__
(
'
nounSeries|%{firstItem} and %{lastItem}
'
),
{
firstItem
:
items
[
0
],
lastItem
:
items
[
1
],
},
false
,
);
}
return
items
.
reduce
((
item
,
nextItem
,
idx
)
=>
idx
===
items
.
length
-
1
?
sprintf
(
s__
(
'
nounSeries|%{item}, and %{lastItem}
'
),
{
item
,
lastItem
:
nextItem
})
:
sprintf
(
s__
(
'
nounSeries|%{item}, %{nextItem}
'
),
{
item
,
nextItem
}),
?
sprintf
(
s__
(
'
nounSeries|%{item}, and %{lastItem}
'
),
{
item
,
lastItem
:
nextItem
}
,
false
)
:
sprintf
(
s__
(
'
nounSeries|%{item}, %{nextItem}
'
),
{
item
,
nextItem
}
,
false
),
);
};
...
...
ee/app/assets/javascripts/vue_merge_request_widget/components/approvals/approvals_summary.vue
View file @
544e281d
...
...
@@ -48,6 +48,7 @@ export default {
names
:
toNounSeriesText
(
this
.
rulesLeft
),
count
:
this
.
approvalsLeft
,
},
false
,
);
},
hasApprovers
()
{
...
...
ee/changelogs/unreleased/jdb-fix-wrongly-escaped-ampersand.yml
0 → 100644
View file @
544e281d
---
title
:
Fix character escaping on approvals summary
merge_request
:
35564
author
:
type
:
fixed
ee/spec/frontend/vue_mr_widget/components/approvals/approvals_summary_spec.js
View file @
544e281d
...
...
@@ -5,7 +5,7 @@ import { toNounSeriesText } from '~/lib/utils/grammar';
import
UserAvatarList
from
'
~/vue_shared/components/user_avatar/user_avatar_list.vue
'
;
const
testApprovers
=
()
=>
Array
.
from
({
length
:
5
},
(
_
,
i
)
=>
i
).
map
(
id
=>
({
id
}));
const
testRulesLeft
=
()
=>
[
'
Lorem
'
,
'
Ipsum
'
,
'
dolar sit
'
];
const
testRulesLeft
=
()
=>
[
'
Lorem
'
,
'
Ipsum
'
,
'
dolar
&
sit
'
];
const
TEST_APPROVALS_LEFT
=
3
;
describe
(
'
EE MRWidget approvals summary
'
,
()
=>
{
...
...
locale/gitlab.pot
View file @
544e281d
...
...
@@ -27740,6 +27740,9 @@ msgstr ""
msgid "nounSeries|%{firstItem} and %{lastItem}"
msgstr ""
msgid "nounSeries|%{item}"
msgstr ""
msgid "nounSeries|%{item}, %{nextItem}"
msgstr ""
...
...
spec/frontend/lib/utils/grammar_spec.js
View file @
544e281d
...
...
@@ -7,27 +7,27 @@ describe('utils/grammar', () => {
});
it
(
'
with single item returns item
'
,
()
=>
{
const
items
=
[
'
Lorem Ipsum
'
];
const
items
=
[
'
Lorem
&
Ipsum
'
];
expect
(
grammar
.
toNounSeriesText
(
items
)).
toBe
(
items
[
0
]);
});
it
(
'
with 2 items returns item1 and item2
'
,
()
=>
{
const
items
=
[
'
Dolar
'
,
'
Sit Amit
'
];
const
items
=
[
'
Dolar
'
,
'
Sit
&
Amit
'
];
expect
(
grammar
.
toNounSeriesText
(
items
)).
toBe
(
`
${
items
[
0
]}
and
${
items
[
1
]}
`
);
});
it
(
'
with 3 items returns comma separated series
'
,
()
=>
{
const
items
=
[
'
Lorem
'
,
'
Ipsum
'
,
'
dolar
'
];
const
expected
=
'
Lorem, Ipsum, and
dolar
'
;
const
items
=
[
'
Lorem
'
,
'
Ipsum
'
,
'
Sit & Amit
'
];
const
expected
=
'
Lorem, Ipsum, and
Sit & Amit
'
;
expect
(
grammar
.
toNounSeriesText
(
items
)).
toBe
(
expected
);
});
it
(
'
with 6 items returns comma separated series
'
,
()
=>
{
const
items
=
[
'
Lorem
'
,
'
ipsum
'
,
'
dolar
'
,
'
sit
'
,
'
amit
'
,
'
consectetur
'
];
const
expected
=
'
Lorem, ipsum, dolar, sit, amit, and consectetur
'
;
const
items
=
[
'
Lorem
'
,
'
ipsum
'
,
'
dolar
'
,
'
sit
'
,
'
amit
'
,
'
consectetur
& adipiscing
'
];
const
expected
=
'
Lorem, ipsum, dolar, sit, amit, and consectetur
& adipiscing
'
;
expect
(
grammar
.
toNounSeriesText
(
items
)).
toBe
(
expected
);
});
...
...
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