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

workload_table.vue « components « kubernetes_dashboard « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 65cf00a3b85a6435a1336e22c1fb346d9d88b701 (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
69
70
71
72
73
74
75
76
77
<script>
import { GlTable, GlBadge, GlPagination } from '@gitlab/ui';
import {
  WORKLOAD_STATUS_BADGE_VARIANTS,
  PAGE_SIZE,
  TABLE_HEADING_CLASSES,
  DEFAULT_WORKLOAD_TABLE_FIELDS,
} from '../constants';

export default {
  components: {
    GlTable,
    GlBadge,
    GlPagination,
  },
  props: {
    items: {
      type: Array,
      required: true,
    },
    fields: {
      type: Array,
      default: () => DEFAULT_WORKLOAD_TABLE_FIELDS,
      required: false,
    },
  },
  data() {
    return {
      currentPage: 1,
    };
  },
  computed: {
    tableFields() {
      return this.fields.map((field) => {
        return {
          ...field,
          thClass: TABLE_HEADING_CLASSES,
          sortable: true,
        };
      });
    },
  },
  PAGE_SIZE,
  WORKLOAD_STATUS_BADGE_VARIANTS,
  TABLE_CELL_CLASSES: 'gl-p-2',
};
</script>

<template>
  <div class="gl-mt-8">
    <gl-table
      :items="items"
      :fields="tableFields"
      :per-page="$options.PAGE_SIZE"
      :current-page="currentPage"
      stacked="md"
      bordered
    >
      <template #cell(status)="{ item: { status } }">
        <gl-badge
          :variant="$options.WORKLOAD_STATUS_BADGE_VARIANTS[status]"
          size="sm"
          class="gl-ml-2"
          >{{ status }}</gl-badge
        >
      </template>
    </gl-table>

    <gl-pagination
      v-model="currentPage"
      :per-page="$options.PAGE_SIZE"
      :total-items="items.length"
      align="center"
      class="gl-mt-6"
    />
  </div>
</template>