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
>
<
script
>
import
{
import
{
GlToken
,
GlFilteredSearchToken
,
GlFilteredSearchToken
,
GlFilteredSearchSuggestion
,
GlFilteredSearchSuggestion
,
GlDropdownDivider
,
GlDropdownDivider
,
...
@@ -11,6 +12,7 @@ import { DEBOUNCE_DELAY } from '~/vue_shared/components/filtered_search_bar/cons
...
@@ -11,6 +12,7 @@ import { DEBOUNCE_DELAY } from '~/vue_shared/components/filtered_search_bar/cons
export
default
{
export
default
{
components
:
{
components
:
{
GlToken
,
GlFilteredSearchToken
,
GlFilteredSearchToken
,
GlFilteredSearchSuggestion
,
GlFilteredSearchSuggestion
,
GlDropdownDivider
,
GlDropdownDivider
,
...
@@ -26,11 +28,40 @@ export default {
...
@@ -26,11 +28,40 @@ export default {
type
:
Object
,
type
:
Object
,
required
:
true
,
required
:
true
,
},
},
active
:
{
type
:
Boolean
,
required
:
false
,
default
:
false
,
},
},
data
()
{
return
{
activeLabel
:
null
,
};
},
},
computed
:
{
computed
:
{
labels
()
{
labels
()
{
return
this
.
config
.
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
()
{
created
()
{
this
.
searchLabels
(
this
.
value
);
this
.
searchLabels
(
this
.
value
);
...
@@ -56,9 +87,17 @@ export default {
...
@@ -56,9 +87,17 @@ export default {
v-on="$listeners"
v-on="$listeners"
@input="searchLabels"
@input="searchLabels"
>
>
<template
#view
="
{ inputValue }">
<template
#view-token
="
{ inputValue, cssClasses, listeners }">
<template
v-if=
"config.symbol"
>
{{
config
.
symbol
}}
</
template
<gl-token
>
{{ inputValue }}
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>
<
template
#suggestions
>
<
template
#suggestions
>
<gl-loading-icon
v-if=
"config.isLoading"
/>
<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', () => {
...
@@ -16,9 +16,10 @@ describe('LabelToken', () => {
isLoading
:
false
,
isLoading
:
false
,
fetchData
:
jest
.
fn
(),
fetchData
:
jest
.
fn
(),
};
};
const
stubs
=
{
const
stubs
=
{
GlFilteredSearchToken
:
{
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', () => {
...
@@ -38,6 +39,7 @@ describe('LabelToken', () => {
const
findFilteredSearchToken
=
()
=>
wrapper
.
find
(
GlFilteredSearchToken
);
const
findFilteredSearchToken
=
()
=>
wrapper
.
find
(
GlFilteredSearchToken
);
const
findAllLabelSuggestions
=
()
=>
wrapper
.
findAll
({
ref
:
'
labelItem
'
});
const
findAllLabelSuggestions
=
()
=>
wrapper
.
findAll
({
ref
:
'
labelItem
'
});
const
findLoadingIcon
=
()
=>
wrapper
.
find
(
GlLoadingIcon
);
const
findLoadingIcon
=
()
=>
wrapper
.
find
(
GlLoadingIcon
);
const
findSelectedLabelToken
=
()
=>
wrapper
.
find
(
'
[data-testid="selected-label"]
'
);
it
(
'
renders a loading icon
'
,
()
=>
{
it
(
'
renders a loading icon
'
,
()
=>
{
createComponent
({
config
:
{
...
defaultConfig
,
isLoading
:
true
},
value
:
{}
},
{
stubs
});
createComponent
({
config
:
{
...
defaultConfig
,
isLoading
:
true
},
value
:
{}
},
{
stubs
});
...
@@ -45,6 +47,22 @@ describe('LabelToken', () => {
...
@@ -45,6 +47,22 @@ describe('LabelToken', () => {
expect
(
findLoadingIcon
().
exists
()).
toBe
(
true
);
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
'
,
()
=>
{
describe
(
'
suggestions
'
,
()
=>
{
it
(
'
renders a suggestion for each item
'
,
()
=>
{
it
(
'
renders a suggestion for each item
'
,
()
=>
{
createComponent
();
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