diff options
author | Eric Eastwood <contact@ericeastwood.com> | 2017-11-14 00:01:46 -0600 |
---|---|---|
committer | Eric Eastwood <contact@ericeastwood.com> | 2017-11-15 06:10:14 -0600 |
commit | 8ac71372a19b8b27492a95e20a3101c446952953 (patch) | |
tree | b09f494dfba1aaa0e8368f6fe582f52e69862f33 | |
parent | 27c9e83573df07799f5d77ccf4cafe96a2d43ee5 (diff) | |
download | gitlab-ce-39594-use-single-mediator-for-sidebar.tar.gz |
Use shared mediator with sidebar subscriptions39594-use-single-mediator-for-sidebar
Part of https://gitlab.com/gitlab-org/gitlab-ce/issues/39594
3 files changed, 17 insertions, 13 deletions
diff --git a/app/assets/javascripts/init_issuable_sidebar.js b/app/assets/javascripts/init_issuable_sidebar.js index 1191e0b895e..ada693afc46 100644 --- a/app/assets/javascripts/init_issuable_sidebar.js +++ b/app/assets/javascripts/init_issuable_sidebar.js @@ -14,7 +14,6 @@ export default () => { }); new LabelsSelect(); new IssuableContext(sidebarOptions.currentUser); - gl.Subscription.bindAll('.subscription'); new DueDateSelectors(); window.sidebar = new Sidebar(); }; diff --git a/app/assets/javascripts/sidebar/components/subscriptions/sidebar_subscriptions.vue b/app/assets/javascripts/sidebar/components/subscriptions/sidebar_subscriptions.vue index 4ad3d469f25..2282f5cc934 100644 --- a/app/assets/javascripts/sidebar/components/subscriptions/sidebar_subscriptions.vue +++ b/app/assets/javascripts/sidebar/components/subscriptions/sidebar_subscriptions.vue @@ -1,16 +1,17 @@ <script> -import Store from '../../stores/sidebar_store'; -import Mediator from '../../sidebar_mediator'; import eventHub from '../../event_hub'; import Flash from '../../../flash'; import subscriptions from './subscriptions.vue'; export default { - data() { - return { - mediator: new Mediator(), - store: new Store(), - }; + props: { + mediator: { + required: true, + type: Object, + validator(mediatorObject) { + return mediatorObject.toggleSubscription && mediatorObject.store; + }, + }, }, components: { @@ -39,7 +40,7 @@ export default { <template> <div class="block subscriptions"> <subscriptions - :loading="store.isFetching.subscriptions" - :subscribed="store.subscribed" /> + :loading="mediator.store.isFetching.subscriptions" + :subscribed="mediator.store.subscribed" /> </div> </template> diff --git a/app/assets/javascripts/sidebar/sidebar_bundle.js b/app/assets/javascripts/sidebar/sidebar_bundle.js index 2650bb725d4..a76dc53a17b 100644 --- a/app/assets/javascripts/sidebar/sidebar_bundle.js +++ b/app/assets/javascripts/sidebar/sidebar_bundle.js @@ -66,7 +66,7 @@ function mountParticipantsComponent() { }); } -function mountSubscriptionsComponent() { +function mountSubscriptionsComponent(mediator) { const el = document.querySelector('.js-sidebar-subscriptions-entry-point'); if (!el) return; @@ -77,7 +77,11 @@ function mountSubscriptionsComponent() { components: { sidebarSubscriptions, }, - render: createElement => createElement('sidebar-subscriptions', {}), + render: createElement => createElement('sidebar-subscriptions', { + props: { + mediator, + }, + }), }); } @@ -96,7 +100,7 @@ function domContentLoaded() { mountConfidentialComponent(mediator); mountLockComponent(mediator); mountParticipantsComponent(); - mountSubscriptionsComponent(); + mountSubscriptionsComponent(mediator); new SidebarMoveIssue( mediator, |