summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/sidebar/components/time_tracking/sidebar_time_tracking.vue
diff options
context:
space:
mode:
authorGeorge Tsiolis <tsiolis.g@gmail.com>2018-05-02 01:44:48 +0300
committerGeorge Tsiolis <tsiolis.g@gmail.com>2018-05-02 12:43:46 +0300
commit751302a16e2adc85fe0647f51df5fad24e1f12b0 (patch)
treefce5bf4ecdd41915f38e474bd382a90cfdc2da43 /app/assets/javascripts/sidebar/components/time_tracking/sidebar_time_tracking.vue
parentb8a848304edc50ec4d4dfbb895dc3c16896c8e10 (diff)
downloadgitlab-ce-751302a16e2adc85fe0647f51df5fad24e1f12b0.tar.gz
Move SidebarTimeTracking vue component
Diffstat (limited to 'app/assets/javascripts/sidebar/components/time_tracking/sidebar_time_tracking.vue')
-rw-r--r--app/assets/javascripts/sidebar/components/time_tracking/sidebar_time_tracking.vue61
1 files changed, 61 insertions, 0 deletions
diff --git a/app/assets/javascripts/sidebar/components/time_tracking/sidebar_time_tracking.vue b/app/assets/javascripts/sidebar/components/time_tracking/sidebar_time_tracking.vue
new file mode 100644
index 00000000000..2e1d6e9643a
--- /dev/null
+++ b/app/assets/javascripts/sidebar/components/time_tracking/sidebar_time_tracking.vue
@@ -0,0 +1,61 @@
+<script>
+import $ from 'jquery';
+import _ from 'underscore';
+
+import '~/smart_interval';
+
+import IssuableTimeTracker from './time_tracker.vue';
+
+import Store from '../../stores/sidebar_store';
+import Mediator from '../../sidebar_mediator';
+import eventHub from '../../event_hub';
+
+export default {
+ components: {
+ IssuableTimeTracker,
+ },
+ data() {
+ return {
+ mediator: new Mediator(),
+ store: new Store(),
+ };
+ },
+ mounted() {
+ this.listenForQuickActions();
+ },
+ methods: {
+ listenForQuickActions() {
+ $(document).on('ajax:success', '.gfm-form', this.quickActionListened);
+ eventHub.$on('timeTrackingUpdated', (data) => {
+ this.quickActionListened(null, data);
+ });
+ },
+ quickActionListened(e, data) {
+ const subscribedCommands = ['spend_time', 'time_estimate'];
+ let changedCommands;
+ if (data !== undefined) {
+ changedCommands = data.commands_changes
+ ? Object.keys(data.commands_changes)
+ : [];
+ } else {
+ changedCommands = [];
+ }
+ if (changedCommands && _.intersection(subscribedCommands, changedCommands).length) {
+ this.mediator.fetch();
+ }
+ },
+ },
+};
+</script>
+
+<template>
+ <div class="block">
+ <issuable-time-tracker
+ :time_estimate="store.timeEstimate"
+ :time_spent="store.totalTimeSpent"
+ :human_time_estimate="store.humanTimeEstimate"
+ :human_time_spent="store.humanTotalTimeSpent"
+ :root-path="store.rootPath"
+ />
+ </div>
+</template>