All files / ee/app/assets/javascripts/boards/components board_scope.vue

62.5% Statements 5/8
0% Branches 0/4
71.42% Functions 5/7
62.5% Lines 5/8

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 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122              3x                                                                 9x             2x     9x                     1x                                                                                                                        
<script>
import { GlButton } from '@gitlab/ui';
import { __ } from '~/locale';
import AssigneeSelect from './assignee_select.vue';
import BoardLabelsSelect from './labels_select.vue';
import BoardIterationSelect from './iteration_select.vue';
import BoardMilestoneSelect from './milestone_select.vue';
import BoardWeightSelect from './weight_select.vue';
 
export default {
  components: {
    GlButton,
    AssigneeSelect,
    BoardLabelsSelect,
    BoardIterationSelect,
    BoardMilestoneSelect,
    BoardWeightSelect,
  },
  inject: ['isIssueBoard'],
  props: {
    collapseScope: {
      type: Boolean,
      required: true,
    },
    canAdminBoard: {
      type: Boolean,
      required: true,
    },
    board: {
      type: Object,
      required: true,
    },
    weights: {
      type: Array,
      required: false,
      default: () => [],
    },
  },
 
  data() {
    return {
      expanded: false,
    };
  },
 
  computed: {
    expandButtonText() {
      return this.expanded ? __('Collapse') : __('Expand');
    },
    scopeText() {
      return this.isIssueBoard
        ? __('Board scope affects which issues are displayed for anyone who visits this board')
        : __('Board scope affects which epics are displayed for anyone who visits this board');
    },
    iterationId() {
      return this.board.iteration?.id;
    },
  },
 
  methods: {
    handleLabelClick(labels) {
      this.$emit('set-board-labels', labels);
    },
    handleLabelRemove(labelId) {
      const labelToRemove = [{ id: labelId, set: false }];
      this.handleLabelClick(labelToRemove);
    },
  },
};
</script>
 
<template>
  <div data-testid="board-scope-modal">
    <div v-if="canAdminBoard" class="media">
      <label class="label-bold gl-font-lg media-body">{{ __('Scope') }}</label>
      <gl-button v-if="collapseScope" @click="expanded = !expanded">
        {{ expandButtonText }}
      </gl-button>
    </div>
    <p class="text-secondary gl-mb-3">
      {{ scopeText }}
    </p>
    <div v-if="!collapseScope || expanded">
      <board-milestone-select
        v-if="isIssueBoard"
        :board="board"
        :can-edit="canAdminBoard"
        @set-milestone="$emit('set-milestone', $event)"
      />
 
      <board-iteration-select
        v-if="isIssueBoard"
        :board="board"
        :can-edit="canAdminBoard"
        @set-iteration="$emit('set-iteration', $event)"
      />
 
      <board-labels-select
        :board="board"
        :can-edit="canAdminBoard"
        @onLabelRemove="handleLabelRemove"
        @set-labels="handleLabelClick"
      />
 
      <assignee-select
        v-if="isIssueBoard"
        :board="board"
        :can-edit="canAdminBoard"
        @set-assignee="$emit('set-assignee', $event)"
      />
 
      <board-weight-select
        v-if="isIssueBoard"
        :board="board"
        :weights="weights"
        :can-edit="canAdminBoard"
        @set-weight="$emit('set-weight', $event)"
      />
    </div>
  </div>
</template>