summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/environments/components/environments_table.vue
blob: 5148a2ae79b69d72c76d1a47bc70b1d449117646 (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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
<script>
/**
 * Render environments table.
 */
import EnvironmentTableRowComponent from './environment_item.vue';
import loadingIcon from '../../vue_shared/components/loading_icon.vue';

export default {
  components: {
    'environment-item': EnvironmentTableRowComponent,
    loadingIcon,
  },

  props: {
    environments: {
      type: Array,
      required: true,
      default: () => ([]),
    },

    canReadEnvironment: {
      type: Boolean,
      required: false,
      default: false,
    },

    canCreateDeployment: {
      type: Boolean,
      required: false,
      default: false,
    },

    isLoadingFolderContent: {
      type: Boolean,
      required: false,
      default: false,
    },
  },

  methods: {
    folderUrl(model) {
      return `${window.location.pathname}/folders/${model.folderName}`;
    },
  },
};
</script>
<template>
  <table class="table ci-table">
    <thead>
      <tr>
        <th class="environments-name">
          Environment
        </th>
        <th class="environments-deploy">
          Last deployment
        </th>
        <th class="environments-build">
          Job
        </th>
        <th class="environments-commit">
          Commit
        </th>
        <th class="environments-date">
          Updated
        </th>
        <th class="environments-actions"></th>
      </tr>
    </thead>
    <tbody>
      <template
        v-for="model in environments"
        v-bind:model="model">
        <tr
          is="environment-item"
          :model="model"
          :can-create-deployment="canCreateDeployment"
          :can-read-environment="canReadEnvironment"
          />

        <template v-if="model.isFolder && model.isOpen && model.children && model.children.length > 0">
          <tr v-if="isLoadingFolderContent">
            <td colspan="6">
              <loading-icon size="2" />
            </td>
          </tr>

          <template v-else>
            <tr
              is="environment-item"
              v-for="children in model.children"
              :model="children"
              :can-create-deployment="canCreateDeployment"
              :can-read-environment="canReadEnvironment"
              />

            <tr>
              <td
                colspan="6"
                class="text-center">
                <a
                  :href="folderUrl(model)"
                  class="btn btn-default">
                  Show all
                </a>
              </td>
            </tr>
          </template>
        </template>
      </template>
    </tbody>
  </table>
</template>