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
0
Merge Requests
0
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
Boxiang Sun
gitlab-ce
Commits
52309322
Commit
52309322
authored
Mar 05, 2018
by
Kushal Pandya
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
LabelsSelect DropdownCreateLabel Component
parent
5c885486
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
168 additions
and
0 deletions
+168
-0
app/assets/javascripts/vue_shared/components/sidebar/labels_select/dropdown_create_label.vue
...omponents/sidebar/labels_select/dropdown_create_label.vue
+84
-0
spec/javascripts/vue_shared/components/sidebar/labels_select/dropdown_create_label_spec.js
...nents/sidebar/labels_select/dropdown_create_label_spec.js
+84
-0
No files found.
app/assets/javascripts/vue_shared/components/sidebar/labels_select/dropdown_create_label.vue
0 → 100644
View file @
52309322
<
script
>
export
default
{
created
()
{
this
.
suggestedColors
=
gon
.
suggested_label_colors
;
},
};
</
script
>
<
template
>
<div
class=
"dropdown-page-two dropdown-new-label"
>
<div
class=
"dropdown-title"
>
<button
type=
"button"
class=
"dropdown-title-button dropdown-menu-back"
:aria-label=
"__('Go back')"
>
<i
aria-hidden=
"true"
class=
"fa fa-arrow-left"
data-hidden=
"true"
>
</i>
</button>
{{
__
(
'
Create new label
'
)
}}
<button
type=
"button"
class=
"dropdown-title-button dropdown-menu-close"
:aria-label=
"__('Close')"
>
<i
aria-hidden=
"true"
class=
"fa fa-times dropdown-menu-close-icon"
data-hidden=
"true"
>
</i>
</button>
</div>
<div
class=
"dropdown-content"
>
<div
class=
"dropdown-labels-error js-label-error"
></div>
<input
id=
"new_label_name"
type=
"text"
class=
"default-dropdown-input"
:placeholder=
"__('Name new label')"
/>
<div
class=
"suggest-colors suggest-colors-dropdown"
>
<a
v-for=
"(color, index) in suggestedColors"
href=
"#"
:key=
"index"
:data-color=
"color"
:style=
"
{
backgroundColor: color,
}"
>
</a>
</div>
<div
class=
"dropdown-label-color-input"
>
<div
class=
"dropdown-label-color-preview js-dropdown-label-color-preview"
></div>
<input
id=
"new_label_color"
type=
"text"
class=
"default-dropdown-input"
:placeholder=
"__('Assign custom color like #FF0000')"
/>
</div>
<div
class=
"clearfix"
>
<button
type=
"button"
class=
"btn btn-primary pull-left js-new-label-btn disabled"
>
{{
__
(
'
Create
'
)
}}
</button>
<button
type=
"button"
class=
"btn btn-default pull-right js-cancel-label-btn"
>
{{
__
(
'
Cancel
'
)
}}
</button>
</div>
</div>
</div>
</
template
>
spec/javascripts/vue_shared/components/sidebar/labels_select/dropdown_create_label_spec.js
0 → 100644
View file @
52309322
import
Vue
from
'
vue
'
;
import
dropdownCreateLabelComponent
from
'
~/vue_shared/components/sidebar/labels_select/dropdown_create_label.vue
'
;
import
{
mockSuggestedColors
}
from
'
./mock_data
'
;
import
mountComponent
from
'
../../../../helpers/vue_mount_component_helper
'
;
const
createComponent
=
()
=>
{
const
Component
=
Vue
.
extend
(
dropdownCreateLabelComponent
);
return
mountComponent
(
Component
);
};
describe
(
'
DropdownCreateLabelComponent
'
,
()
=>
{
let
vm
;
beforeEach
(()
=>
{
gon
.
suggested_label_colors
=
mockSuggestedColors
;
vm
=
createComponent
();
});
afterEach
(()
=>
{
vm
.
$destroy
();
});
describe
(
'
created
'
,
()
=>
{
it
(
'
initializes `suggestedColors` prop on component from `gon.suggested_color_labels` object
'
,
()
=>
{
expect
(
vm
.
suggestedColors
.
length
).
toBe
(
mockSuggestedColors
.
length
);
});
});
describe
(
'
template
'
,
()
=>
{
it
(
'
renders component container element with classes `dropdown-page-two dropdown-new-label`
'
,
()
=>
{
expect
(
vm
.
$el
.
classList
.
contains
(
'
dropdown-page-two
'
,
'
dropdown-new-label
'
)).
toBe
(
true
);
});
it
(
'
renders `Go back` button on component header
'
,
()
=>
{
const
backButtonEl
=
vm
.
$el
.
querySelector
(
'
.dropdown-title button.dropdown-title-button.dropdown-menu-back
'
);
expect
(
backButtonEl
).
not
.
toBe
(
null
);
expect
(
backButtonEl
.
querySelector
(
'
.fa-arrow-left
'
)).
not
.
toBe
(
null
);
});
it
(
'
renders component header element
'
,
()
=>
{
const
headerEl
=
vm
.
$el
.
querySelector
(
'
.dropdown-title
'
);
expect
(
headerEl
.
innerText
.
trim
()).
toContain
(
'
Create new label
'
);
});
it
(
'
renders `Close` button on component header
'
,
()
=>
{
const
closeButtonEl
=
vm
.
$el
.
querySelector
(
'
.dropdown-title button.dropdown-title-button.dropdown-menu-close
'
);
expect
(
closeButtonEl
).
not
.
toBe
(
null
);
expect
(
closeButtonEl
.
querySelector
(
'
.fa-times.dropdown-menu-close-icon
'
)).
not
.
toBe
(
null
);
});
it
(
'
renders `Name new label` input element
'
,
()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
.dropdown-labels-error.js-label-error
'
)).
not
.
toBe
(
null
);
expect
(
vm
.
$el
.
querySelector
(
'
input#new_label_name.default-dropdown-input
'
)).
not
.
toBe
(
null
);
});
it
(
'
renders suggested colors list elements
'
,
()
=>
{
const
colorsListContainerEl
=
vm
.
$el
.
querySelector
(
'
.suggest-colors.suggest-colors-dropdown
'
);
expect
(
colorsListContainerEl
).
not
.
toBe
(
null
);
expect
(
colorsListContainerEl
.
querySelectorAll
(
'
a
'
).
length
).
toBe
(
mockSuggestedColors
.
length
);
const
colorItemEl
=
colorsListContainerEl
.
querySelectorAll
(
'
a
'
)[
0
];
expect
(
colorItemEl
.
dataset
.
color
).
toBe
(
vm
.
suggestedColors
[
0
]);
expect
(
colorItemEl
.
getAttribute
(
'
style
'
)).
toBe
(
'
background-color: rgb(0, 51, 204);
'
);
});
it
(
'
renders color input element
'
,
()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
.dropdown-label-color-input
'
)).
not
.
toBe
(
null
);
expect
(
vm
.
$el
.
querySelector
(
'
.dropdown-label-color-preview.js-dropdown-label-color-preview
'
)).
not
.
toBe
(
null
);
expect
(
vm
.
$el
.
querySelector
(
'
input#new_label_color.default-dropdown-input
'
)).
not
.
toBe
(
null
);
});
it
(
'
renders component action buttons
'
,
()
=>
{
const
createBtnEl
=
vm
.
$el
.
querySelector
(
'
button.js-new-label-btn
'
);
const
cancelBtnEl
=
vm
.
$el
.
querySelector
(
'
button.js-cancel-label-btn
'
);
expect
(
createBtnEl
).
not
.
toBe
(
null
);
expect
(
createBtnEl
.
innerText
.
trim
()).
toBe
(
'
Create
'
);
expect
(
cancelBtnEl
.
innerText
.
trim
()).
toBe
(
'
Cancel
'
);
});
});
});
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