All files / app/assets/javascripts/sidebar/components/time_tracking sidebar_time_tracking.vue

8.33% Statements 1/12
0% Branches 0/6
0% Functions 0/4
8.33% Lines 1/12

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85              1x                                                                                                                                                          
<script>
import $ from 'jquery';
import { intersection } from 'lodash';
 
import '~/smart_interval';
 
import eventHub from '../../event_hub';
import IssuableTimeTracker from './time_tracker.vue';
 
export default {
  components: {
    IssuableTimeTracker,
  },
  props: {
    fullPath: {
      type: String,
      required: false,
      default: '',
    },
    issuableId: {
      type: String,
      required: true,
    },
    issuableIid: {
      type: String,
      required: true,
    },
    limitToHours: {
      type: Boolean,
      required: false,
      default: false,
    },
    canAddTimeEntries: {
      type: Boolean,
      required: false,
      default: true,
    },
    canSetTimeEstimate: {
      type: Boolean,
      required: false,
      default: false,
    },
  },
  mounted() {
    this.listenForQuickActions();
  },
  methods: {
    listenForQuickActions() {
      $(document).on('ajax:success', '.gfm-form', this.quickActionListened);
 
      eventHub.$on('timeTrackingUpdated', (data) => {
        this.quickActionListened({ detail: [data] });
      });
    },
    quickActionListened(e) {
      const data = e.detail[0];
 
      const subscribedCommands = ['spend_time', 'time_estimate'];
      let changedCommands;
      if (data !== undefined) {
        changedCommands = data.commands_changes ? Object.keys(data.commands_changes) : [];
      } else {
        changedCommands = [];
      }
      Iif (changedCommands && intersection(subscribedCommands, changedCommands).length) {
        eventHub.$emit('timeTracker:refresh');
      }
    },
  },
};
</script>
 
<template>
  <div class="block time-tracking">
    <issuable-time-tracker
      :full-path="fullPath"
      :issuable-id="issuableId"
      :issuable-iid="issuableIid"
      :limit-to-hours="limitToHours"
      :can-add-time-entries="canAddTimeEntries"
      :can-set-time-estimate="canSetTimeEstimate"
    />
  </div>
</template>