summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/logs/components/log_simple_filters.vue
blob: 55bdd5f00884aaa93850fa098308f07672c2890e (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
65
66
67
68
<script>
import { GlDropdown, GlDropdownSectionHeader, GlDropdownItem } from '@gitlab/ui';
import { mapActions, mapState } from 'vuex';
import { s__ } from '~/locale';

export default {
  components: {
    GlDropdown,
    GlDropdownSectionHeader,
    GlDropdownItem,
  },
  props: {
    disabled: {
      type: Boolean,
      required: false,
      default: false,
    },
  },
  data() {
    return {
      searchQuery: '',
    };
  },
  computed: {
    ...mapState('environmentLogs', ['pods']),

    podDropdownText() {
      return this.pods.current || s__('Environments|No pod selected');
    },
  },
  methods: {
    ...mapActions('environmentLogs', ['showPodLogs']),
    isCurrentPod(podName) {
      return podName === this.pods.current;
    },
  },
};
</script>
<template>
  <div>
    <gl-dropdown
      ref="podsDropdown"
      :text="podDropdownText"
      :disabled="disabled"
      class="gl-mr-3 gl-mb-3 gl-display-flex gl-md-display-block qa-pods-dropdown"
    >
      <gl-dropdown-section-header>
        {{ s__('Environments|Select pod') }}
      </gl-dropdown-section-header>

      <gl-dropdown-item v-if="!pods.options.length" disabled>
        <span ref="noPodsMsg" class="text-muted">
          {{ s__('Environments|No pods to display') }}
        </span>
      </gl-dropdown-item>
      <gl-dropdown-item
        v-for="podName in pods.options"
        :key="podName"
        :is-check-item="true"
        :is-checked="isCurrentPod(podName)"
        class="text-nowrap"
        @click="showPodLogs(podName)"
      >
        {{ podName }}
      </gl-dropdown-item>
    </gl-dropdown>
  </div>
</template>