All files / ee/app/assets/javascripts/license_compliance/components detected_licenses_table.vue

100% Statements 8/8
100% Branches 5/5
100% Functions 3/3
100% Lines 8/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  2x 2x 2x 2x                     37x 37x           1x           117x                        
<script>
import { mapActions, mapState } from 'vuex';
import Pagination from '~/vue_shared/components/pagination_links.vue';
import { LICENSE_LIST } from '../store/constants';
import LicensesTable from './licenses_table.vue';
 
export default {
  name: 'DetectedLicensesTable',
  components: {
    LicensesTable,
    Pagination,
  },
  computed: {
    ...mapState(LICENSE_LIST, ['licenses', 'isLoading', 'initialized', 'pageInfo']),
    shouldShowPagination() {
      const { initialized, pageInfo } = this;
      return Boolean(initialized && pageInfo && pageInfo.total);
    },
  },
  methods: {
    ...mapActions(LICENSE_LIST, ['fetchLicenses']),
    fetchPage(page) {
      return this.fetchLicenses({ page });
    },
  },
};
</script>
 
<template>
  <div>
    <licenses-table :licenses="licenses" :is-loading="isLoading" />
 
    <pagination
      v-if="shouldShowPagination"
      :change="fetchPage"
      :page-info="pageInfo"
      class="justify-content-center mt-3"
    />
  </div>
</template>