Welcome to mirror list, hosted at ThFree Co, Russian Federation.

jobs_filtered_search.vue « filtered_search « components « jobs « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 67cdca6aa0a10e517b3ee6a437e7c4be9392cbe7 (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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<script>
import { GlFilteredSearch } from '@gitlab/ui';
import {
  OPERATORS_IS,
  TOKEN_TITLE_STATUS,
  TOKEN_TYPE_STATUS,
} from '~/vue_shared/components/filtered_search_bar/constants';
import JobStatusToken from './tokens/job_status_token.vue';

export default {
  components: {
    GlFilteredSearch,
  },
  props: {
    queryString: {
      type: Object,
      required: false,
      default: null,
    },
  },
  computed: {
    tokens() {
      return [
        {
          type: TOKEN_TYPE_STATUS,
          icon: 'status',
          title: TOKEN_TITLE_STATUS,
          unique: true,
          token: JobStatusToken,
          operators: OPERATORS_IS,
        },
      ];
    },
    filteredSearchValue() {
      if (this.queryString?.statuses) {
        return [
          {
            type: TOKEN_TYPE_STATUS,
            value: {
              data: this.queryString?.statuses,
              operator: '=',
            },
          },
        ];
      }
      return [];
    },
  },
  methods: {
    onSubmit(filters) {
      this.$emit('filterJobsBySearch', filters);
    },
  },
};
</script>

<template>
  <gl-filtered-search
    :placeholder="s__('Jobs|Filter jobs')"
    :available-tokens="tokens"
    :value="filteredSearchValue"
    @submit="onSubmit"
  />
</template>