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
|
<script>
import { GlFormCheckboxGroup, GlFormCheckbox } from '@gitlab/ui';
// eslint-disable-next-line no-restricted-imports
import { mapState, mapActions } from 'vuex';
import Tracking from '~/tracking';
import { parseBoolean } from '~/lib/utils/common_utils';
import { archivedFilterData, TRACKING_NAMESPACE, TRACKING_LABEL_CHECKBOX } from './data';
export default {
name: 'ArchivedFilter',
components: {
GlFormCheckboxGroup,
GlFormCheckbox,
},
computed: {
...mapState(['urlQuery']),
selectedFilter: {
get() {
return [parseBoolean(this.urlQuery?.include_archived)];
},
set(value) {
const newValue = value?.pop() ?? false;
this.setQuery({ key: archivedFilterData.filterParam, value: newValue?.toString() });
this.trackSelectCheckbox(newValue);
},
},
},
methods: {
...mapActions(['setQuery']),
trackSelectCheckbox(value) {
Tracking.event(TRACKING_NAMESPACE, TRACKING_LABEL_CHECKBOX, {
label: archivedFilterData.checkboxLabel,
property: value,
});
},
},
archivedFilterData,
};
</script>
<template>
<gl-form-checkbox-group v-model="selectedFilter">
<h5>{{ $options.archivedFilterData.headerLabel }}</h5>
<gl-form-checkbox
class="gl-flex-grow-1 gl-display-inline-flex gl-justify-content-space-between gl-w-full"
:class="$options.LABEL_DEFAULT_CLASSES"
:value="true"
>
<span data-testid="label">
{{ $options.archivedFilterData.checkboxLabel }}
</span>
</gl-form-checkbox>
</gl-form-checkbox-group>
</template>
|