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
c9b4762e
Commit
c9b4762e
authored
Apr 26, 2018
by
Kushal Pandya
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reveal labels dropdown when labels icon is clicked on collapsed sidebar
parent
61edf8d2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
58 additions
and
7 deletions
+58
-7
ee/app/assets/javascripts/epics/sidebar/components/sidebar_app.vue
...sets/javascripts/epics/sidebar/components/sidebar_app.vue
+34
-7
spec/javascripts/epics/sidebar/components/sidebar_app_spec.js
.../javascripts/epics/sidebar/components/sidebar_app_spec.js
+24
-0
No files found.
ee/app/assets/javascripts/epics/sidebar/components/sidebar_app.vue
View file @
c9b4762e
<
script
>
<
script
>
/* global ListLabel */
/* eslint-disable vue/require-default-prop */
/* eslint-disable vue/require-default-prop */
import
_
from
'
underscore
'
;
import
Cookies
from
'
js-cookie
'
;
import
Cookies
from
'
js-cookie
'
;
import
Flash
from
'
~/flash
'
;
import
Flash
from
'
~/flash
'
;
import
{
capitalizeFirstCharacter
}
from
'
~/lib/utils/text_utility
'
;
import
{
capitalizeFirstCharacter
}
from
'
~/lib/utils/text_utility
'
;
import
ListLabel
from
'
~/vue_shared/models/label
'
;
import
SidebarDatePicker
from
'
~/vue_shared/components/sidebar/date_picker.vue
'
;
import
SidebarDatePicker
from
'
~/vue_shared/components/sidebar/date_picker.vue
'
;
import
SidebarCollapsedGroupedDatePicker
from
'
~/vue_shared/components/sidebar/collapsed_grouped_date_picker.vue
'
;
import
SidebarCollapsedGroupedDatePicker
from
'
~/vue_shared/components/sidebar/collapsed_grouped_date_picker.vue
'
;
import
ToggleSidebar
from
'
~/vue_shared/components/sidebar/toggle_sidebar.vue
'
;
import
ToggleSidebar
from
'
~/vue_shared/components/sidebar/toggle_sidebar.vue
'
;
...
@@ -73,6 +74,7 @@
...
@@ -73,6 +74,7 @@
store
,
store
,
// Backend will pass the appropriate css class for the contentContainer
// Backend will pass the appropriate css class for the contentContainer
collapsed
:
Cookies
.
get
(
'
collapsed_gutter
'
)
===
'
true
'
,
collapsed
:
Cookies
.
get
(
'
collapsed_gutter
'
)
===
'
true
'
,
autoExpanded
:
false
,
savingStartDate
:
false
,
savingStartDate
:
false
,
savingEndDate
:
false
,
savingEndDate
:
false
,
service
:
new
SidebarService
(
this
.
endpoint
),
service
:
new
SidebarService
(
this
.
endpoint
),
...
@@ -91,6 +93,21 @@
...
@@ -91,6 +93,21 @@
Cookies
.
set
(
'
collapsed_gutter
'
,
this
.
collapsed
);
Cookies
.
set
(
'
collapsed_gutter
'
,
this
.
collapsed
);
},
},
toggleSidebarRevealLabelsDropdown
()
{
const
contentContainer
=
this
.
$el
.
closest
(
'
.page-with-contextual-sidebar
'
);
this
.
toggleSidebar
();
// When sidebar is expanded, we need to wait
// for rendering to finish before opening
// dropdown as otherwise it causes `calc()`
// used in CSS to miscalculate collapsed
// sidebar size.
_
.
debounce
(()
=>
{
this
.
autoExpanded
=
true
;
contentContainer
.
querySelector
(
'
.js-sidebar-dropdown-toggle
'
)
.
dispatchEvent
(
new
Event
(
'
click
'
,
{
bubbles
:
true
,
cancelable
:
false
}));
},
100
)();
},
saveDate
(
dateType
=
'
start
'
,
newDate
)
{
saveDate
(
dateType
=
'
start
'
,
newDate
)
{
const
type
=
dateType
===
'
start
'
?
dateType
:
'
end
'
;
const
type
=
dateType
===
'
start
'
?
dateType
:
'
end
'
;
const
capitalizedType
=
capitalizeFirstCharacter
(
type
);
const
capitalizedType
=
capitalizeFirstCharacter
(
type
);
...
@@ -122,17 +139,25 @@
...
@@ -122,17 +139,25 @@
const
labelIndex
=
this
.
epicContext
.
labels
.
findIndex
(
l
=>
l
.
id
===
label
.
id
);
const
labelIndex
=
this
.
epicContext
.
labels
.
findIndex
(
l
=>
l
.
id
===
label
.
id
);
if
(
labelIndex
===
-
1
)
{
if
(
labelIndex
===
-
1
)
{
this
.
epicContext
.
labels
.
push
(
new
ListLabel
({
this
.
epicContext
.
labels
.
push
(
id
:
label
.
id
,
new
ListLabel
({
title
:
label
.
title
,
id
:
label
.
id
,
color
:
label
.
color
[
0
],
title
:
label
.
title
,
textColor
:
label
.
text_color
,
color
:
label
.
color
[
0
],
}));
textColor
:
label
.
text_color
,
}),
);
}
else
{
}
else
{
this
.
epicContext
.
labels
.
splice
(
labelIndex
,
1
);
this
.
epicContext
.
labels
.
splice
(
labelIndex
,
1
);
}
}
}
}
},
},
handleDropdownClose
()
{
if
(
this
.
autoExpanded
)
{
this
.
autoExpanded
=
false
;
this
.
toggleSidebar
();
}
},
},
},
};
};
</
script
>
</
script
>
...
@@ -192,6 +217,8 @@
...
@@ -192,6 +217,8 @@
:can-edit=
"editable"
:can-edit=
"editable"
:show-create=
"true"
:show-create=
"true"
@
onLabelClick=
"handleLabelClick"
@
onLabelClick=
"handleLabelClick"
@
onDropdownClose=
"handleDropdownClose"
@
toggleCollapse=
"toggleSidebarRevealLabelsDropdown"
>
>
{{
__
(
'
None
'
)
}}
{{
__
(
'
None
'
)
}}
</sidebar-labels-select>
</sidebar-labels-select>
...
...
spec/javascripts/epics/sidebar/components/sidebar_app_spec.js
View file @
c9b4762e
...
@@ -112,6 +112,10 @@ describe('epicSidebar', () => {
...
@@ -112,6 +112,10 @@ describe('epicSidebar', () => {
it
(
'
should render collapsed grouped date picker
'
,
()
=>
{
it
(
'
should render collapsed grouped date picker
'
,
()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
.sidebar-collapsed-icon span
'
).
innerText
.
trim
()).
toEqual
(
'
From Jan 1 2017
'
);
expect
(
vm
.
$el
.
querySelector
(
'
.sidebar-collapsed-icon span
'
).
innerText
.
trim
()).
toEqual
(
'
From Jan 1 2017
'
);
});
});
it
(
'
should render collapsed labels picker
'
,
()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
.js-labels-block .sidebar-collapsed-icon span
'
).
innerText
.
trim
()).
toEqual
(
'
1
'
);
});
});
});
describe
(
'
toggleSidebar
'
,
()
=>
{
describe
(
'
toggleSidebar
'
,
()
=>
{
...
@@ -217,6 +221,26 @@ describe('epicSidebar', () => {
...
@@ -217,6 +221,26 @@ describe('epicSidebar', () => {
});
});
});
});
describe
(
'
handleDropdownClose
'
,
()
=>
{
it
(
'
calls toggleSidebar when `autoExpanded` prop is true
'
,
()
=>
{
spyOn
(
vm
,
'
toggleSidebar
'
);
vm
.
autoExpanded
=
true
;
vm
.
handleDropdownClose
();
expect
(
vm
.
autoExpanded
).
toBe
(
false
);
expect
(
vm
.
toggleSidebar
).
toHaveBeenCalled
();
});
it
(
'
does not call toggleSidebar when `autoExpanded` prop is false
'
,
()
=>
{
spyOn
(
vm
,
'
toggleSidebar
'
);
vm
.
autoExpanded
=
false
;
vm
.
handleDropdownClose
();
expect
(
vm
.
autoExpanded
).
toBe
(
false
);
expect
(
vm
.
toggleSidebar
).
not
.
toHaveBeenCalled
();
});
});
describe
(
'
saveDate error
'
,
()
=>
{
describe
(
'
saveDate error
'
,
()
=>
{
let
interceptor
;
let
interceptor
;
let
component
;
let
component
;
...
...
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