debian-mirror-gitlab/app/assets/javascripts/members/components/modals/remove_member_modal.vue

115 lines
3.3 KiB
Vue
Raw Normal View History

2020-07-28 23:09:34 +05:30
<script>
import { GlFormCheckbox, GlModal } from '@gitlab/ui';
2021-10-27 15:23:28 +05:30
import { mapActions, mapState } from 'vuex';
2020-07-28 23:09:34 +05:30
import csrf from '~/lib/utils/csrf';
2021-04-29 21:17:54 +05:30
import { s__, __ } from '~/locale';
2021-11-18 22:05:49 +05:30
import UserDeletionObstaclesList from '~/vue_shared/components/user_deletion_obstacles/user_deletion_obstacles_list.vue';
2020-07-28 23:09:34 +05:30
export default {
actionCancel: {
text: __('Cancel'),
},
csrf,
components: {
GlFormCheckbox,
GlModal,
2021-11-18 22:05:49 +05:30
UserDeletionObstaclesList,
2020-07-28 23:09:34 +05:30
},
2021-10-27 15:23:28 +05:30
inject: ['namespace'],
2020-07-28 23:09:34 +05:30
computed: {
2021-10-27 15:23:28 +05:30
...mapState({
isAccessRequest(state) {
return state[this.namespace].removeMemberModalData.isAccessRequest;
},
isInvite(state) {
return state[this.namespace].removeMemberModalData.isInvite;
},
memberPath(state) {
return state[this.namespace].removeMemberModalData.memberPath;
},
memberType(state) {
return state[this.namespace].removeMemberModalData.memberType;
},
message(state) {
return state[this.namespace].removeMemberModalData.message;
},
2021-11-18 22:05:49 +05:30
userDeletionObstacles(state) {
return state[this.namespace].removeMemberModalData.userDeletionObstacles ?? {};
2021-10-27 15:23:28 +05:30
},
removeMemberModalVisible(state) {
return state[this.namespace].removeMemberModalVisible;
},
}),
2021-04-29 21:17:54 +05:30
isGroupMember() {
2021-10-27 15:23:28 +05:30
return this.memberType === 'GroupMember';
2021-04-29 21:17:54 +05:30
},
2020-07-28 23:09:34 +05:30
actionText() {
2021-04-29 21:17:54 +05:30
if (this.isAccessRequest) {
return __('Deny access request');
} else if (this.isInvite) {
return s__('Member|Revoke invite');
}
return __('Remove member');
2020-07-28 23:09:34 +05:30
},
actionPrimary() {
return {
text: this.actionText,
attributes: {
variant: 'danger',
},
};
},
2021-11-18 22:05:49 +05:30
hasWorkspaceAccess() {
2021-04-29 21:17:54 +05:30
return !this.isAccessRequest && !this.isInvite;
},
2021-11-18 22:05:49 +05:30
hasObstaclesToUserDeletion() {
return this.hasWorkspaceAccess && this.userDeletionObstacles.obstacles?.length;
2021-04-29 21:17:54 +05:30
},
2020-07-28 23:09:34 +05:30
},
methods: {
2021-10-27 15:23:28 +05:30
...mapActions({
hideRemoveMemberModal(dispatch) {
return dispatch(`${this.namespace}/hideRemoveMemberModal`);
},
}),
2020-07-28 23:09:34 +05:30
submitForm() {
this.$refs.form.submit();
},
},
};
</script>
<template>
<gl-modal
ref="modal"
modal-id="remove-member-modal"
:action-cancel="$options.actionCancel"
:action-primary="actionPrimary"
:title="actionText"
2021-10-27 15:23:28 +05:30
:visible="removeMemberModalVisible"
2020-07-28 23:09:34 +05:30
data-qa-selector="remove_member_modal_content"
@primary="submitForm"
2021-10-27 15:23:28 +05:30
@hide="hideRemoveMemberModal"
2020-07-28 23:09:34 +05:30
>
2021-10-27 15:23:28 +05:30
<form ref="form" :action="memberPath" method="post">
<p>{{ message }}</p>
2020-07-28 23:09:34 +05:30
2021-11-18 22:05:49 +05:30
<user-deletion-obstacles-list
v-if="hasObstaclesToUserDeletion"
:obstacles="userDeletionObstacles.obstacles"
:user-name="userDeletionObstacles.name"
2021-04-29 21:17:54 +05:30
/>
2020-07-28 23:09:34 +05:30
<input ref="method" type="hidden" name="_method" value="delete" />
<input :value="$options.csrf.token" type="hidden" name="authenticity_token" />
2021-04-29 21:17:54 +05:30
<gl-form-checkbox v-if="isGroupMember" name="remove_sub_memberships">
{{ __('Also remove direct user membership from subgroups and projects') }}
</gl-form-checkbox>
2021-11-18 22:05:49 +05:30
<gl-form-checkbox v-if="hasWorkspaceAccess" name="unassign_issuables">
2020-07-28 23:09:34 +05:30
{{ __('Also unassign this user from related issues and merge requests') }}
</gl-form-checkbox>
</form>
</gl-modal>
</template>