All files / app/assets/javascripts/members/components app.vue

87.5% Statements 7/8
100% Branches 1/1
100% Functions 6/6
87.5% Lines 7/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    5x                     16x                                   19x     5x           3x 1x                 1x                                
<script>
import { GlAlert } from '@gitlab/ui';
// eslint-disable-next-line no-restricted-imports
import { mapState, mapMutations } from 'vuex';
import { scrollToElement } from '~/lib/utils/common_utils';
import { HIDE_ERROR } from '../store/mutation_types';
import FilterSortContainer from './filter_sort/filter_sort_container.vue';
import MembersTable from './table/members_table.vue';
 
export default {
  name: 'MembersApp',
  components: { MembersTable, FilterSortContainer, GlAlert },
  provide() {
    return {
      namespace: this.namespace,
    };
  },
  props: {
    namespace: {
      type: String,
      required: true,
    },
    tabQueryParamValue: {
      type: String,
      required: false,
      default: '',
    },
  },
  computed: {
    ...mapState({
      showError(state) {
        return state[this.namespace].showError;
      },
      errorMessage(state) {
        return state[this.namespace].errorMessage;
      },
    }),
  },
  watch: {
    showError(value) {
      if (value) {
        this.$nextTick(() => {
          scrollToElement(this.$refs.errorAlert.$el);
        });
      }
    },
  },
  methods: {
    ...mapMutations({
      hideError(commit) {
        return commit(`${this.namespace}/${HIDE_ERROR}`);
      },
    }),
  },
};
</script>
 
<template>
  <div>
    <gl-alert v-if="showError" ref="errorAlert" variant="danger" @dismiss="hideError">{{
      errorMessage
    }}</gl-alert>
    <filter-sort-container />
    <members-table :tab-query-param-value="tabQueryParamValue" />
  </div>
</template>