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
d2665707
Commit
d2665707
authored
May 03, 2018
by
Kushal Pandya
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Emit `toggleSubscription`, `toggleSidebar` events on component
parent
b2e1b709
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
1 deletion
+40
-1
app/assets/javascripts/sidebar/components/subscriptions/subscriptions.vue
...cripts/sidebar/components/subscriptions/subscriptions.vue
+21
-1
spec/javascripts/sidebar/subscriptions_spec.js
spec/javascripts/sidebar/subscriptions_spec.js
+19
-0
No files found.
app/assets/javascripts/sidebar/components/subscriptions/subscriptions.vue
View file @
d2665707
...
@@ -47,8 +47,25 @@
...
@@ -47,8 +47,25 @@
},
},
},
},
methods
:
{
methods
:
{
/**
* We need to emit this event on both component & eventHub
* for 2 dependencies;
*
* 1. eventHub: This component is used in Issue Boards sidebar
* where component template is part of HAML
* and event listeners are tied to app's eventHub.
* 2. Component: This compone is also used in Epics in EE
* where listeners are tied to component event.
*/
toggleSubscription
()
{
toggleSubscription
()
{
// App's eventHub event emission.
eventHub
.
$emit
(
'
toggleSubscription
'
,
this
.
id
);
eventHub
.
$emit
(
'
toggleSubscription
'
,
this
.
id
);
// Component event emission.
this
.
$emit
(
'
toggleSubscription
'
,
this
.
id
);
},
onClickCollapsedIcon
()
{
this
.
$emit
(
'
toggleSidebar
'
);
},
},
},
},
};
};
...
@@ -56,7 +73,10 @@
...
@@ -56,7 +73,10 @@
<
template
>
<
template
>
<div>
<div>
<div
class=
"sidebar-collapsed-icon"
>
<div
class=
"sidebar-collapsed-icon"
@
click=
"onClickCollapsedIcon"
>
<span
<span
v-tooltip
v-tooltip
:title=
"notificationTooltip"
:title=
"notificationTooltip"
...
...
spec/javascripts/sidebar/subscriptions_spec.js
View file @
d2665707
import
Vue
from
'
vue
'
;
import
Vue
from
'
vue
'
;
import
subscriptions
from
'
~/sidebar/components/subscriptions/subscriptions.vue
'
;
import
subscriptions
from
'
~/sidebar/components/subscriptions/subscriptions.vue
'
;
import
eventHub
from
'
~/sidebar/event_hub
'
;
import
mountComponent
from
'
spec/helpers/vue_mount_component_helper
'
;
import
mountComponent
from
'
spec/helpers/vue_mount_component_helper
'
;
describe
(
'
Subscriptions
'
,
function
()
{
describe
(
'
Subscriptions
'
,
function
()
{
...
@@ -39,4 +40,22 @@ describe('Subscriptions', function () {
...
@@ -39,4 +40,22 @@ describe('Subscriptions', function () {
expect
(
vm
.
$refs
.
toggleButton
.
$el
.
querySelector
(
'
.project-feature-toggle
'
)).
toHaveClass
(
'
is-checked
'
);
expect
(
vm
.
$refs
.
toggleButton
.
$el
.
querySelector
(
'
.project-feature-toggle
'
)).
toHaveClass
(
'
is-checked
'
);
});
});
it
(
'
toggleSubscription method emits `toggleSubscription` event on eventHub and Component
'
,
()
=>
{
vm
=
mountComponent
(
Subscriptions
,
{
subscribed
:
true
});
spyOn
(
eventHub
,
'
$emit
'
);
spyOn
(
vm
,
'
$emit
'
);
vm
.
toggleSubscription
();
expect
(
eventHub
.
$emit
).
toHaveBeenCalledWith
(
'
toggleSubscription
'
,
jasmine
.
any
(
Object
));
expect
(
vm
.
$emit
).
toHaveBeenCalledWith
(
'
toggleSubscription
'
,
jasmine
.
any
(
Object
));
});
it
(
'
onClickCollapsedIcon method emits `toggleSidebar` event on component
'
,
()
=>
{
vm
=
mountComponent
(
Subscriptions
,
{
subscribed
:
true
});
spyOn
(
vm
,
'
$emit
'
);
vm
.
onClickCollapsedIcon
();
expect
(
vm
.
$emit
).
toHaveBeenCalledWith
(
'
toggleSidebar
'
);
});
});
});
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