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
|
<script>
import { GlButton, GlLink, GlForm } from '@gitlab/ui';
// eslint-disable-next-line no-restricted-imports
import { mapActions, mapState, mapGetters } from 'vuex';
import Tracking from '~/tracking';
import {
HR_DEFAULT_CLASSES,
TRACKING_ACTION_CLICK,
TRACKING_LABEL_APPLY,
TRACKING_LABEL_RESET,
} from '../constants/index';
export default {
name: 'FiltersTemplate',
components: {
GlButton,
GlLink,
GlForm,
},
computed: {
...mapState(['sidebarDirty', 'useSidebarNavigation']),
...mapGetters(['currentScope']),
hrClasses() {
return [...HR_DEFAULT_CLASSES, 'gl-display-none', 'gl-md-display-block'];
},
},
methods: {
...mapActions(['applyQuery', 'resetQuery']),
applyQueryWithTracking() {
Tracking.event(TRACKING_ACTION_CLICK, TRACKING_LABEL_APPLY, {
label: this.currentScope,
});
this.applyQuery();
},
resetQueryWithTracking() {
Tracking.event(TRACKING_ACTION_CLICK, TRACKING_LABEL_RESET, {
label: this.currentScope,
});
this.resetQuery();
},
},
};
</script>
<template>
<gl-form class="issue-filters gl-px-5 gl-pt-0" @submit.prevent="applyQueryWithTracking">
<hr v-if="!useSidebarNavigation" :class="hrClasses" />
<slot></slot>
<hr v-if="!useSidebarNavigation" :class="hrClasses" />
<div class="gl-display-flex gl-align-items-center gl-mt-4">
<gl-button category="primary" variant="confirm" type="submit" :disabled="!sidebarDirty">
{{ __('Apply') }}
</gl-button>
<gl-link v-if="sidebarDirty" class="gl-ml-auto" @click="resetQueryWithTracking">{{
__('Reset filters')
}}</gl-link>
</div>
</gl-form>
</template>
|