BigW Consortium Gitlab

environments_table.vue 2.96 KB
Newer Older
1 2 3 4
<script>
/**
 * Render environments table.
 */
5
import environmentItem from './environment_item.vue';
6
import loadingIcon from '../../vue_shared/components/loading_icon.vue';
7 8 9

export default {
  components: {
10
    environmentItem,
11
    loadingIcon,
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
  },

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

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

    canCreateDeployment: {
      type: Boolean,
      required: false,
      default: false,
    },
  },
  methods: {
    folderUrl(model) {
      return `${window.location.pathname}/folders/${model.folderName}`;
    },
Filipa Lacerda committed
37 38 39 40 41 42
    shouldRenderFolderContent(env) {
      return env.isFolder &&
        env.isOpen &&
        env.children &&
        env.children.length > 0;
    },
43 44 45 46
  },
};
</script>
<template>
47 48 49 50 51 52 53 54 55 56 57 58 59
  <div
    class="ci-table"
    role="grid"
  >
    <div
      class="gl-responsive-table-row table-row-header"
      role="row"
    >
      <div
        class="table-section section-10 environments-name"
        role="columnheader"
      >
        {{ s__("Environments|Environment") }}
60
      </div>
61 62 63 64 65
      <div
        class="table-section section-10 environments-deploy"
        role="columnheader"
      >
        {{ s__("Environments|Deployment") }}
66
      </div>
67 68 69 70 71
      <div
        class="table-section section-15 environments-build"
        role="columnheader"
      >
        {{ s__("Environments|Job") }}
72
      </div>
73 74 75 76 77
      <div
        class="table-section section-25 environments-commit"
        role="columnheader"
      >
        {{ s__("Environments|Commit") }}
78
      </div>
79 80 81 82 83
      <div
        class="table-section section-10 environments-date"
        role="columnheader"
      >
        {{ s__("Environments|Updated") }}
84 85 86
      </div>
    </div>
    <template
87 88
      v-for="(model, i) in environments"
      :model="model">
89 90 91 92 93
      <div
        is="environment-item"
        :model="model"
        :can-create-deployment="canCreateDeployment"
        :can-read-environment="canReadEnvironment"
94
        :key="i"
95
      />
96

97
      <template
Filipa Lacerda committed
98
        v-if="shouldRenderFolderContent(model)"
99 100 101
      >
        <div
          v-if="model.isLoadingFolderContent"
102
          :key="`loading-item-${i}`">
103 104
          <loading-icon size="2" />
        </div>
105

106 107 108
        <template v-else>
          <div
            is="environment-item"
Filipa Lacerda committed
109
            v-for="(children, index) in model.children"
110 111 112
            :model="children"
            :can-create-deployment="canCreateDeployment"
            :can-read-environment="canReadEnvironment"
113
            :key="`env-item-${i}-${index}`"
114
          />
115

116
          <div :key="`sub-div-${i}`">
117 118 119
            <div class="text-center prepend-top-10">
              <a
                :href="folderUrl(model)"
120 121 122
                class="btn btn-default"
              >
                {{ s__("Environments|Show all") }}
123 124 125
              </a>
            </div>
          </div>
126 127
        </template>
      </template>
128 129
    </template>
  </div>
130
</template>