From d85f72b10bfbaf202ae3329509b45b82362f2ec6 Mon Sep 17 00:00:00 2001 From: Clement Ho Date: Fri, 12 Jan 2018 12:48:28 -0600 Subject: Refactor into init_labels --- app/assets/javascripts/init_labels.js | 18 ++++++++++++++++++ .../javascripts/pages/projects/labels/index/index.js | 19 ++----------------- 2 files changed, 20 insertions(+), 17 deletions(-) create mode 100644 app/assets/javascripts/init_labels.js diff --git a/app/assets/javascripts/init_labels.js b/app/assets/javascripts/init_labels.js new file mode 100644 index 00000000000..5f20055510f --- /dev/null +++ b/app/assets/javascripts/init_labels.js @@ -0,0 +1,18 @@ +import LabelManager from './label_manager'; +import GroupLabelSubscription from './group_label_subscription'; +import ProjectLabelSubscription from './project_label_subscription'; + +export default () => { + if ($('.prioritized-labels').length) { + new LabelManager(); // eslint-disable-line no-new + } + $('.label-subscription').each((i, el) => { + const $el = $(el); + + if ($el.find('.dropdown-group-label').length) { + new GroupLabelSubscription($el); // eslint-disable-line no-new + } else { + new ProjectLabelSubscription($el); // eslint-disable-line no-new + } + }); +}; diff --git a/app/assets/javascripts/pages/projects/labels/index/index.js b/app/assets/javascripts/pages/projects/labels/index/index.js index 82a5b4d0760..018345fa112 100644 --- a/app/assets/javascripts/pages/projects/labels/index/index.js +++ b/app/assets/javascripts/pages/projects/labels/index/index.js @@ -1,18 +1,3 @@ -import LabelManager from '~/label_manager'; -import GroupLabelSubscription from '~/group_label_subscription'; -import ProjectLabelSubscription from '~/project_label_subscription'; +import initLabels from '~/init_labels'; -export default () => { - if ($('.prioritized-labels').length) { - new LabelManager(); // eslint-disable-line no-new - } - $('.label-subscription').each((i, el) => { - const $el = $(el); - - if ($el.find('.dropdown-group-label').length) { - new GroupLabelSubscription($el); // eslint-disable-line no-new - } else { - new ProjectLabelSubscription($el); // eslint-disable-line no-new - } - }); -}; +export default initLabels; -- cgit v1.2.1