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
d05f4fc2
Commit
d05f4fc2
authored
Jul 07, 2020
by
Martin Wortschack
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Apply label color to tokens
- Add background color and text color to selected label tokens.
parent
3bb340f2
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
66 additions
and
4 deletions
+66
-4
ee/app/assets/javascripts/analytics/shared/components/tokens/label_token.vue
...cripts/analytics/shared/components/tokens/label_token.vue
+42
-3
ee/changelogs/unreleased/223063-glfilteredsearch-apply-label-color-to-token-in-analytics-space.yml
...dsearch-apply-label-color-to-token-in-analytics-space.yml
+5
-0
ee/spec/frontend/analytics/shared/components/tokens/label_token_spec.js
...nd/analytics/shared/components/tokens/label_token_spec.js
+19
-1
No files found.
ee/app/assets/javascripts/analytics/shared/components/tokens/label_token.vue
View file @
d05f4fc2
<
script
>
import
{
GlToken
,
GlFilteredSearchToken
,
GlFilteredSearchSuggestion
,
GlDropdownDivider
,
...
...
@@ -11,6 +12,7 @@ import { DEBOUNCE_DELAY } from '~/vue_shared/components/filtered_search_bar/cons
export
default
{
components
:
{
GlToken
,
GlFilteredSearchToken
,
GlFilteredSearchSuggestion
,
GlDropdownDivider
,
...
...
@@ -26,11 +28,40 @@ export default {
type
:
Object
,
required
:
true
,
},
active
:
{
type
:
Boolean
,
required
:
false
,
default
:
false
,
},
},
data
()
{
return
{
activeLabel
:
null
,
};
},
computed
:
{
labels
()
{
return
this
.
config
.
labels
;
},
containerStyle
()
{
if
(
this
.
activeLabel
)
{
const
{
color
,
text_color
}
=
this
.
activeLabel
;
return
{
backgroundColor
:
color
,
color
:
text_color
};
}
return
{};
},
},
watch
:
{
active
:
{
immediate
:
true
,
handler
(
newValue
)
{
if
(
!
newValue
&&
this
.
labels
)
{
this
.
activeLabel
=
this
.
labels
.
find
(
l
=>
l
.
title
===
this
.
value
?.
data
);
}
},
},
},
created
()
{
this
.
searchLabels
(
this
.
value
);
...
...
@@ -56,9 +87,17 @@ export default {
v-on="$listeners"
@input="searchLabels"
>
<template
#view
="
{ inputValue }">
<template
v-if=
"config.symbol"
>
{{
config
.
symbol
}}
</
template
>
{{ inputValue }}
<template
#view-token
="
{ inputValue, cssClasses, listeners }">
<gl-token
variant=
"search-value"
:class=
"cssClasses"
:style=
"containerStyle"
data-testid=
"selected-label"
v-on=
"listeners"
>
<template
v-if=
"config.symbol"
>
{{
config
.
symbol
}}
</
template
>
{{ activeLabel ? activeLabel.title : inputValue }}
</gl-token>
</template>
<
template
#suggestions
>
<gl-loading-icon
v-if=
"config.isLoading"
/>
...
...
ee/changelogs/unreleased/223063-glfilteredsearch-apply-label-color-to-token-in-analytics-space.yml
0 → 100644
View file @
d05f4fc2
---
title
:
Apply label color to shared Analytics label token
merge_request
:
36205
author
:
type
:
other
ee/spec/frontend/analytics/shared/components/tokens/label_token_spec.js
View file @
d05f4fc2
...
...
@@ -16,9 +16,10 @@ describe('LabelToken', () => {
isLoading
:
false
,
fetchData
:
jest
.
fn
(),
};
const
stubs
=
{
GlFilteredSearchToken
:
{
template
:
`<div><slot name="suggestions"></slot></div>`
,
template
:
`<div><slot name="
view-token"></slot><slot name="
suggestions"></slot></div>`
,
},
};
...
...
@@ -38,6 +39,7 @@ describe('LabelToken', () => {
const
findFilteredSearchToken
=
()
=>
wrapper
.
find
(
GlFilteredSearchToken
);
const
findAllLabelSuggestions
=
()
=>
wrapper
.
findAll
({
ref
:
'
labelItem
'
});
const
findLoadingIcon
=
()
=>
wrapper
.
find
(
GlLoadingIcon
);
const
findSelectedLabelToken
=
()
=>
wrapper
.
find
(
'
[data-testid="selected-label"]
'
);
it
(
'
renders a loading icon
'
,
()
=>
{
createComponent
({
config
:
{
...
defaultConfig
,
isLoading
:
true
},
value
:
{}
},
{
stubs
});
...
...
@@ -45,6 +47,22 @@ describe('LabelToken', () => {
expect
(
findLoadingIcon
().
exists
()).
toBe
(
true
);
});
it
(
'
renders the selected label
'
,
()
=>
{
const
selectedLabel
=
mockLabels
[
0
];
createComponent
({
value
:
{
data
:
selectedLabel
.
title
}
});
expect
(
findSelectedLabelToken
().
text
()).
toContain
(
selectedLabel
.
title
);
});
it
(
"
sets the label's background and text color on the gl-token component
"
,
()
=>
{
const
selectedLabel
=
mockLabels
[
0
];
createComponent
({
value
:
{
data
:
selectedLabel
.
title
}
});
expect
(
findSelectedLabelToken
().
attributes
(
'
style
'
)).
toEqual
(
'
background-color: rgb(98, 53, 242); color: rgb(255, 255, 255);
'
,
);
});
describe
(
'
suggestions
'
,
()
=>
{
it
(
'
renders a suggestion for each item
'
,
()
=>
{
createComponent
();
...
...
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