All files / ee/app/assets/javascripts/members/components/ldap ldap_dropdown_item.vue

100% Statements 8/8
100% Branches 0/0
80% Functions 4/5
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 42 43  2x 2x 2x                             2x     2x 2x   2x                   15x                
<script>
import { GlDropdownItem, GlDropdownDivider } from '@gitlab/ui';
import { mapActions } from 'vuex';
import { s__ } from '~/locale';
 
export default {
  name: 'LdapDropdownItem',
  components: { GlDropdownItem, GlDropdownDivider },
  inject: ['namespace'],
  props: {
    memberId: {
      type: Number,
      required: true,
    },
  },
  methods: {
    ...mapActions({
      updateLdapOverride(dispatch, payload) {
        return dispatch(`${this.namespace}/updateLdapOverride`, payload);
      },
    }),
    handleClick() {
      this.updateLdapOverride({ memberId: this.memberId, override: false })
        .then(() => {
          this.$toast.show(s__('Members|Reverted to LDAP group sync settings.'));
        })
        .catch(() => {
          // Do nothing, error handled in `updateLdapOverride` Vuex action
        });
    },
  },
};
</script>
 
<template>
  <span>
    <gl-dropdown-divider />
    <gl-dropdown-item is-check-item @click="handleClick">
      {{ s__('Members|Revert to LDAP group sync settings') }}
    </gl-dropdown-item>
  </span>
</template>