summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/packages/list/components/package_search.vue
blob: cd61d323d8341fa1fe3503d804b0e5109085e9ba (plain)
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
<script>
import { mapState, mapActions } from 'vuex';
import { __, s__ } from '~/locale';
import RegistrySearch from '~/vue_shared/components/registry/registry_search.vue';
import getTableHeaders from '../utils';
import PackageTypeToken from './tokens/package_type_token.vue';

export default {
  tokens: [
    {
      type: 'type',
      icon: 'package',
      title: s__('PackageRegistry|Type'),
      unique: true,
      token: PackageTypeToken,
      operators: [{ value: '=', description: __('is'), default: 'true' }],
    },
  ],
  components: { RegistrySearch },
  computed: {
    ...mapState({
      isGroupPage: (state) => state.config.isGroupPage,
      sorting: (state) => state.sorting,
      filter: (state) => state.filter,
    }),
    sortableFields() {
      return getTableHeaders(this.isGroupPage);
    },
  },
  methods: {
    ...mapActions(['setSorting', 'setFilter']),
    updateSorting(newValue) {
      this.setSorting(newValue);
      this.$emit('update');
    },
  },
};
</script>

<template>
  <registry-search
    :filter="filter"
    :sorting="sorting"
    :tokens="$options.tokens"
    :sortable-fields="sortableFields"
    @sorting:changed="updateSorting"
    @filter:changed="setFilter"
    @filter:submit="$emit('update')"
  />
</template>