Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorJacob Schatz <jschatz@gitlab.com>2017-05-06 00:26:37 +0300
committerJacob Schatz <jschatz@gitlab.com>2017-05-06 00:26:37 +0300
commit59a85c6b8222bf8d8534aa3babf1f60ce9bfdc5a (patch)
tree0a2f178b5636cd4ca736c4741bf9618161c6bdb3 /app
parent86e75ae09238c7f73347c0e310c47f6070c005b9 (diff)
parentf1d48c25a2fa53995ed9fa491a72193bfc83be32 (diff)
Merge branch 'add-sidebar-specs' into 'master'
Add sidebar specs See merge request !11132
Diffstat (limited to 'app')
-rw-r--r--app/assets/javascripts/sidebar/components/time_tracking/sidebar_time_tracking.js20
-rw-r--r--app/assets/javascripts/sidebar/sidebar_bundle.js7
-rw-r--r--app/assets/javascripts/sidebar/sidebar_mediator.js4
-rw-r--r--app/assets/javascripts/sidebar/stores/sidebar_store.js4
4 files changed, 22 insertions, 13 deletions
diff --git a/app/assets/javascripts/sidebar/components/time_tracking/sidebar_time_tracking.js b/app/assets/javascripts/sidebar/components/time_tracking/sidebar_time_tracking.js
index e2dba1fb0c2..244b67b3ad9 100644
--- a/app/assets/javascripts/sidebar/components/time_tracking/sidebar_time_tracking.js
+++ b/app/assets/javascripts/sidebar/components/time_tracking/sidebar_time_tracking.js
@@ -17,15 +17,21 @@ export default {
},
methods: {
listenForSlashCommands() {
- $(document).on('ajax:success', '.gfm-form', (e, data) => {
- const subscribedCommands = ['spend_time', 'time_estimate'];
- const changedCommands = data.commands_changes
+ $(document).on('ajax:success', '.gfm-form', this.slashCommandListened);
+ },
+ slashCommandListened(e, data) {
+ const subscribedCommands = ['spend_time', 'time_estimate'];
+ let changedCommands;
+ if (data !== undefined) {
+ changedCommands = data.commands_changes
? Object.keys(data.commands_changes)
: [];
- if (changedCommands && _.intersection(subscribedCommands, changedCommands).length) {
- this.mediator.fetch();
- }
- });
+ } else {
+ changedCommands = [];
+ }
+ if (changedCommands && _.intersection(subscribedCommands, changedCommands).length) {
+ this.mediator.fetch();
+ }
},
},
mounted() {
diff --git a/app/assets/javascripts/sidebar/sidebar_bundle.js b/app/assets/javascripts/sidebar/sidebar_bundle.js
index 2ce53c2ed30..2b02af87d8a 100644
--- a/app/assets/javascripts/sidebar/sidebar_bundle.js
+++ b/app/assets/javascripts/sidebar/sidebar_bundle.js
@@ -4,7 +4,7 @@ import sidebarAssignees from './components/assignees/sidebar_assignees';
import Mediator from './sidebar_mediator';
-document.addEventListener('DOMContentLoaded', () => {
+function domContentLoaded() {
const mediator = new Mediator(gl.sidebarOptions);
mediator.fetch();
@@ -17,5 +17,8 @@ document.addEventListener('DOMContentLoaded', () => {
}
new Vue(sidebarTimeTracking).$mount('#issuable-time-tracker');
-});
+}
+document.addEventListener('DOMContentLoaded', domContentLoaded);
+
+export default domContentLoaded;
diff --git a/app/assets/javascripts/sidebar/sidebar_mediator.js b/app/assets/javascripts/sidebar/sidebar_mediator.js
index c13f3391f0d..5ccfb4ee9c1 100644
--- a/app/assets/javascripts/sidebar/sidebar_mediator.js
+++ b/app/assets/javascripts/sidebar/sidebar_mediator.js
@@ -30,8 +30,8 @@ export default class SidebarMediator {
this.service.get()
.then((response) => {
const data = response.json();
- this.store.processAssigneeData(data);
- this.store.processTimeTrackingData(data);
+ this.store.setAssigneeData(data);
+ this.store.setTimeTrackingData(data);
})
.catch(() => new Flash('Error occured when fetching sidebar data'));
}
diff --git a/app/assets/javascripts/sidebar/stores/sidebar_store.js b/app/assets/javascripts/sidebar/stores/sidebar_store.js
index 94408c4d715..2d44c05bb8d 100644
--- a/app/assets/javascripts/sidebar/stores/sidebar_store.js
+++ b/app/assets/javascripts/sidebar/stores/sidebar_store.js
@@ -17,13 +17,13 @@ export default class SidebarStore {
return SidebarStore.singleton;
}
- processAssigneeData(data) {
+ setAssigneeData(data) {
if (data.assignees) {
this.assignees = data.assignees;
}
}
- processTimeTrackingData(data) {
+ setTimeTrackingData(data) {
this.timeEstimate = data.time_estimate;
this.totalTimeSpent = data.total_time_spent;
this.humanTimeEstimate = data.human_time_estimate;