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

83.33% Statements 15/18
60% Branches 6/10
100% Functions 9/9
83.33% Lines 15/18

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                  7x               44x     22x     18x                       22x     33x 33x             33x         2x       2x         2x 1x     1x           18x 11x              
<script>
import BoardListHeaderFoss from '~/boards/components/board_list_header.vue';
import { fetchPolicies } from '~/lib/graphql';
import { n__, __, sprintf } from '~/locale';
import { setError } from '~/boards/graphql/cache_updates';
import { listsDeferredQuery } from '../constants';
 
// This is a false violation of @gitlab/no-runtime-template-compiler, since it
// extends a valid Vue single file component.
// eslint-disable-next-line @gitlab/no-runtime-template-compiler
export default {
  extends: BoardListHeaderFoss,
  inject: ['weightFeatureAvailable', 'isEpicBoard'],
  apollo: {
    boardList: {
      fetchPolicy: fetchPolicies.CACHE_AND_NETWORK,
      query() {
        return listsDeferredQuery[this.issuableType].query;
      },
      variables() {
        return this.countQueryVariables;
      },
      update(data) {
        return this.isEpicBoard ? data.epicBoardList : data.boardList;
      },
      error(error) {
        setError({
          error,
          message: this.$options.i18n.fetchError,
        });
      },
    },
  },
  computed: {
    countIcon() {
      return this.isEpicBoard ? 'epic' : 'issues';
    },
    itemsTooltipLabel() {
      const { maxIssueCount } = this.list;
      Iif (maxIssueCount > 0) {
        return sprintf(__('%{itemsCount} issues with a limit of %{maxIssueCount}'), {
          itemsCount: this.itemsCount,
          maxIssueCount,
        });
      }
 
      return this.isEpicBoard
        ? n__(`%d epic`, `%d epics`, this.itemsCount)
        : n__(`%d issue`, `%d issues`, this.itemsCount);
    },
    weightCountToolTip() {
      Iif (!this.weightFeatureAvailable) {
        return null;
      }
 
      return sprintf(__('%{totalIssueWeight} total weight'), {
        totalIssueWeight: this.totalIssueWeight,
      });
    },
    totalIssueWeight() {
      if (this.isEpicBoard) {
        return this.boardList?.metadata?.totalWeight || 0;
      }
 
      return this.boardList?.totalIssueWeight;
    },
  },
  watch: {
    boardList: {
      handler() {
        if (!this.isEpicBoard) {
          this.$emit('setTotalIssuesCount', this.boardList?.id, this.boardList?.issuesCount ?? 0);
        }
      },
    },
  },
};
</script>