Skip to content
Snippets Groups Projects

Add UI components for Beyond Identity check exclusions by Projects

Merged Jacques Erasmus requested to merge 454372-beyond-identity-exclusions-ui into master
21 files
+ 1062
24
Compare changes
  • Side-by-side
  • Inline
Files
21
<script>
import { GlDrawer, GlButton } from '@gitlab/ui';
import { DRAWER_Z_INDEX } from '~/lib/utils/constants';
import { getContentWrapperHeight } from '~/lib/utils/dom_utils';
import { __ } from '~/locale';
import ListSelector from '~/vue_shared/components/list_selector/index.vue';
export default {
DRAWER_Z_INDEX,
components: {
GlDrawer,
GlButton,
ListSelector,
},
props: {
isOpen: {
type: Boolean,
required: true,
},
},
data() {
return {
isLoading: false,
exclusions: [],
};
},
computed: {
getDrawerHeaderHeight() {
return getContentWrapperHeight();
},
},
methods: {
handleSelectExclusion(exclusion) {
this.exclusions.push({ ...exclusion });
},
handleRemoveExclusion(id) {
const exclusionIndex = this.exclusions.findIndex((exclusion) => exclusion.id === id);
this.exclusions.splice(exclusionIndex, 1);
},
async handleAddExclusions() {
this.isLoading = true;
this.$emit('add', this.exclusions);
this.exclusions = [];
this.isLoading = false;
},
},
i18n: {
addExclusions: __('Add exclusions'),
},
};
</script>
<template>
<gl-drawer
:header-height="getDrawerHeaderHeight"
:z-index="$options.DRAWER_Z_INDEX"
:open="isOpen"
v-on="$listeners"
>
<template #title>
<h2 class="gl-font-size-h2 gl-mt-0" data-testid="title">{{ $options.i18n.addExclusions }}</h2>
</template>
<template #default>
<list-selector
type="projects"
class="gl-m-5 gl-p-0!"
:selected-items="exclusions"
@select="handleSelectExclusion"
@delete="handleRemoveExclusion"
/>
<gl-button
class="gl-ml-5"
variant="confirm"
:loading="isLoading"
data-testid="add-button"
@click="handleAddExclusions"
>
{{ $options.i18n.addExclusions }}
</gl-button>
</template>
</gl-drawer>
</template>
Loading