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
eacfd911
Commit
eacfd911
authored
Dec 19, 2019
by
Florie Guibert
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update labels in non vue js
Impacts labels displayed in sidebars after editing labels
parent
dd1aedef
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
49 additions
and
20 deletions
+49
-20
app/assets/javascripts/labels_select.js
app/assets/javascripts/labels_select.js
+28
-6
changelogs/unreleased/38145-replace-labels-in-non-vue-js-with-gitlab-ui-component.yml
...replace-labels-in-non-vue-js-with-gitlab-ui-component.yml
+5
-0
spec/frontend/labels_select_spec.js
spec/frontend/labels_select_spec.js
+16
-14
No files found.
app/assets/javascripts/labels_select.js
View file @
eacfd911
...
@@ -479,24 +479,46 @@ export default class LabelsSelect {
...
@@ -479,24 +479,46 @@ export default class LabelsSelect {
// concatenation
// concatenation
// see: http://2ality.com/2016/05/template-literal-whitespace.html#joining-arrays
// see: http://2ality.com/2016/05/template-literal-whitespace.html#joining-arrays
const
linkOpenTag
=
'
<a href="<%- issueUpdateURL.slice(0, issueUpdateURL.lastIndexOf("/")) %>?label_name[]=<%- encodeURIComponent(label.title) %>" class="gl-link gl-label-link has-tooltip" <%= linkAttrs %> title="<%= tooltipTitleTemplate({ label, isScopedLabel, enableScopedLabels, escapeStr }) %>">
'
;
const
spanOpenTag
=
'
<span class="gl-label-text" style="background-color: <%= escapeStr(label.color) %>; color: <%= escapeStr(label.text_color) %>;">
'
;
const
labelTemplate
=
_
.
template
(
const
labelTemplate
=
_
.
template
(
[
[
'
<a href="<%- issueUpdateURL.slice(0, issueUpdateURL.lastIndexOf("/")) %>?label_name[]=<%- encodeURIComponent(label.title) %>">
'
,
'
<span class="gl-label">
'
,
'
<span class="badge label has-tooltip color-label" <%= linkAttrs %> title="<%= tooltipTitleTemplate({ label, isScopedLabel, enableScopedLabels, escapeStr }) %>" style="background-color: <%= escapeStr(label.color) %>; color: <%= escapeStr(label.text_color) %>;">
'
,
linkOpenTag
,
spanOpenTag
,
'
<%- label.title %>
'
,
'
<%- label.title %>
'
,
'
</span>
'
,
'
</span>
'
,
'
</a>
'
,
'
</a>
'
,
'
</span>
'
,
].
join
(
''
),
].
join
(
''
),
);
);
const
infoIconTemplate
=
_
.
template
(
const
infoIconTemplate
=
_
.
template
(
[
[
'
<a href="<%= scopedLabelsDocumentationLink %>" class="
label scoped-label
" target="_blank" rel="noopener">
'
,
'
<a href="<%= scopedLabelsDocumentationLink %>" class="
gl-link gl-label-icon
" target="_blank" rel="noopener">
'
,
'
<i class="fa fa-question-circle"
style="background-color: <%= escapeStr(label.color) %>; color: <%= escapeStr(label.text_color) %>;"
></i>
'
,
'
<i class="fa fa-question-circle"></i>
'
,
'
</a>
'
,
'
</a>
'
,
].
join
(
''
),
].
join
(
''
),
);
);
const
scopedLabelTemplate
=
_
.
template
(
[
'
<span class="gl-label gl-label-scoped" style="color: <%= escapeStr(label.color) %>;">
'
,
linkOpenTag
,
spanOpenTag
,
'
<%- label.title.slice(0, label.title.lastIndexOf("::")) %>
'
,
'
</span>
'
,
'
<span class="gl-label-text" style="color: <%= escapeStr(label.color) %>;">
'
,
'
<%- label.title.slice(label.title.lastIndexOf("::") + 2) %>
'
,
'
</span>
'
,
'
</a>
'
,
'
<%= infoIconTemplate({ label, scopedLabelsDocumentationLink, escapeStr }) %>
'
,
'
</span>
'
,
].
join
(
''
),
);
const
tooltipTitleTemplate
=
_
.
template
(
const
tooltipTitleTemplate
=
_
.
template
(
[
[
'
<% if (isScopedLabel(label) && enableScopedLabels) { %>
'
,
'
<% if (isScopedLabel(label) && enableScopedLabels) { %>
'
,
...
@@ -514,8 +536,7 @@ export default class LabelsSelect {
...
@@ -514,8 +536,7 @@ export default class LabelsSelect {
'
<% _.each(labels, function(label){ %>
'
,
'
<% _.each(labels, function(label){ %>
'
,
'
<% if (isScopedLabel(label) && enableScopedLabels) { %>
'
,
'
<% if (isScopedLabel(label) && enableScopedLabels) { %>
'
,
'
<span class="d-inline-block position-relative scoped-label-wrapper">
'
,
'
<span class="d-inline-block position-relative scoped-label-wrapper">
'
,
'
<%= labelTemplate({ label, issueUpdateURL, isScopedLabel, enableScopedLabels, tooltipTitleTemplate, escapeStr, linkAttrs:
\'
data-html="true"
\'
}) %>
'
,
'
<%= scopedLabelTemplate({ label, issueUpdateURL, isScopedLabel, enableScopedLabels, infoIconTemplate, scopedLabelsDocumentationLink, tooltipTitleTemplate, escapeStr, linkAttrs:
\'
data-html="true"
\'
}) %>
'
,
'
<%= infoIconTemplate({ label, scopedLabelsDocumentationLink, escapeStr }) %>
'
,
'
</span>
'
,
'
</span>
'
,
'
<% } else { %>
'
,
'
<% } else { %>
'
,
'
<%= labelTemplate({ label, issueUpdateURL, isScopedLabel, enableScopedLabels, tooltipTitleTemplate, escapeStr, linkAttrs: "" }) %>
'
,
'
<%= labelTemplate({ label, issueUpdateURL, isScopedLabel, enableScopedLabels, tooltipTitleTemplate, escapeStr, linkAttrs: "" }) %>
'
,
...
@@ -528,6 +549,7 @@ export default class LabelsSelect {
...
@@ -528,6 +549,7 @@ export default class LabelsSelect {
...
tplData
,
...
tplData
,
labelTemplate
,
labelTemplate
,
infoIconTemplate
,
infoIconTemplate
,
scopedLabelTemplate
,
tooltipTitleTemplate
,
tooltipTitleTemplate
,
isScopedLabel
,
isScopedLabel
,
escapeStr
:
_
.
escape
,
escapeStr
:
_
.
escape
,
...
...
changelogs/unreleased/38145-replace-labels-in-non-vue-js-with-gitlab-ui-component.yml
0 → 100644
View file @
eacfd911
---
title
:
Correctly style scoped labels in sidebar after updating
merge_request
:
22071
author
:
type
:
changed
spec/frontend/labels_select_spec.js
View file @
eacfd911
...
@@ -41,29 +41,29 @@ describe('LabelsSelect', () => {
...
@@ -41,29 +41,29 @@ describe('LabelsSelect', () => {
});
});
it
(
'
generated label item template has correct label URL
'
,
()
=>
{
it
(
'
generated label item template has correct label URL
'
,
()
=>
{
expect
(
$labelEl
.
attr
(
'
href
'
)).
toBe
(
'
/foo/bar?label_name[]=Foo%20Label
'
);
expect
(
$labelEl
.
find
(
'
a
'
).
attr
(
'
href
'
)).
toBe
(
'
/foo/bar?label_name[]=Foo%20Label
'
);
});
});
it
(
'
generated label item template has correct label title
'
,
()
=>
{
it
(
'
generated label item template has correct label title
'
,
()
=>
{
expect
(
$labelEl
.
find
(
'
span.
label
'
).
text
()).
toBe
(
label
.
title
);
expect
(
$labelEl
.
find
(
'
span.
gl-label-text
'
).
text
()).
toBe
(
label
.
title
);
});
});
it
(
'
generated label item template has label description as title attribute
'
,
()
=>
{
it
(
'
generated label item template has label description as title attribute
'
,
()
=>
{
expect
(
$labelEl
.
find
(
'
span.label
'
).
attr
(
'
title
'
)).
toBe
(
label
.
description
);
expect
(
$labelEl
.
find
(
'
a
'
).
attr
(
'
title
'
)).
toBe
(
label
.
description
);
});
});
it
(
'
generated label item template has correct label styles
'
,
()
=>
{
it
(
'
generated label item template has correct label styles
'
,
()
=>
{
expect
(
$labelEl
.
find
(
'
span.
label
'
).
attr
(
'
style
'
)).
toBe
(
expect
(
$labelEl
.
find
(
'
span.
gl-label-text
'
).
attr
(
'
style
'
)).
toBe
(
`background-color:
${
label
.
color
}
; color:
${
label
.
text_color
}
;`
,
`background-color:
${
label
.
color
}
; color:
${
label
.
text_color
}
;`
,
);
);
});
});
it
(
'
generated label item has a
badge
class
'
,
()
=>
{
it
(
'
generated label item has a
gl-label-text
class
'
,
()
=>
{
expect
(
$labelEl
.
find
(
'
span
'
).
hasClass
(
'
badge
'
)).
toEqual
(
true
);
expect
(
$labelEl
.
find
(
'
span
'
).
hasClass
(
'
gl-label-text
'
)).
toEqual
(
true
);
});
});
it
(
'
generated label item template does not have
scoped-label
class
'
,
()
=>
{
it
(
'
generated label item template does not have
gl-label-icon
class
'
,
()
=>
{
expect
(
$labelEl
.
find
(
'
.
scoped-label
'
)).
toHaveLength
(
0
);
expect
(
$labelEl
.
find
(
'
.
gl-label-icon
'
)).
toHaveLength
(
0
);
});
});
});
});
...
@@ -87,29 +87,31 @@ describe('LabelsSelect', () => {
...
@@ -87,29 +87,31 @@ describe('LabelsSelect', () => {
});
});
it
(
'
generated label item template has correct label title
'
,
()
=>
{
it
(
'
generated label item template has correct label title
'
,
()
=>
{
expect
(
$labelEl
.
find
(
'
span.label
'
).
text
()).
toBe
(
label
.
title
);
const
scopedTitle
=
label
.
title
.
split
(
'
::
'
);
expect
(
$labelEl
.
find
(
'
span.gl-label-text
'
).
text
()).
toContain
(
scopedTitle
[
0
]);
expect
(
$labelEl
.
find
(
'
span.gl-label-text
'
).
text
()).
toContain
(
scopedTitle
[
1
]);
});
});
it
(
'
generated label item template has html flag as true
'
,
()
=>
{
it
(
'
generated label item template has html flag as true
'
,
()
=>
{
expect
(
$labelEl
.
find
(
'
span.label
'
).
attr
(
'
data-html
'
)).
toBe
(
'
true
'
);
expect
(
$labelEl
.
find
(
'
a
'
).
attr
(
'
data-html
'
)).
toBe
(
'
true
'
);
});
});
it
(
'
generated label item template has question icon
'
,
()
=>
{
it
(
'
generated label item template has question icon
'
,
()
=>
{
expect
(
$labelEl
.
find
(
'
i.fa-question-circle
'
)).
toHaveLength
(
1
);
expect
(
$labelEl
.
find
(
'
i.fa-question-circle
'
)).
toHaveLength
(
1
);
});
});
it
(
'
generated label item template has
scoped-label
class
'
,
()
=>
{
it
(
'
generated label item template has
gl-label-icon
class
'
,
()
=>
{
expect
(
$labelEl
.
find
(
'
.
scoped-label
'
)).
toHaveLength
(
1
);
expect
(
$labelEl
.
find
(
'
.
gl-label-icon
'
)).
toHaveLength
(
1
);
});
});
it
(
'
generated label item template has correct label styles
'
,
()
=>
{
it
(
'
generated label item template has correct label styles
'
,
()
=>
{
expect
(
$labelEl
.
find
(
'
span.
label
'
).
attr
(
'
style
'
)).
toBe
(
expect
(
$labelEl
.
find
(
'
span.
gl-label-text
'
).
attr
(
'
style
'
)).
toBe
(
`background-color:
${
label
.
color
}
; color:
${
label
.
text_color
}
;`
,
`background-color:
${
label
.
color
}
; color:
${
label
.
text_color
}
;`
,
);
);
});
});
it
(
'
generated label item has a badge class
'
,
()
=>
{
it
(
'
generated label item has a badge class
'
,
()
=>
{
expect
(
$labelEl
.
find
(
'
span
'
).
hasClass
(
'
badge
'
)).
toEqual
(
true
);
expect
(
$labelEl
.
find
(
'
span
'
).
hasClass
(
'
gl-label-text
'
)).
toEqual
(
true
);
});
});
});
});
});
});
...
...
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