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

export default {
  components: {
    'environment-item': EnvironmentTableRowComponent,
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 37 38 39 40 41 42 43 44 45 46 47
  },

  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>
48 49
  <div class="ci-table" role="grid">
    <div class="gl-responsive-table-row table-row-header" role="row">
50
      <div class="table-section section-10 environments-name" role="columnheader">
51 52
        Environment
      </div>
53
      <div class="table-section section-10 environments-deploy" role="columnheader">
54 55
        Deployment
      </div>
56
      <div class="table-section section-15 environments-build" role="columnheader">
57 58
        Job
      </div>
59
      <div class="table-section section-25 environments-commit" role="columnheader">
60 61
        Commit
      </div>
62
      <div class="table-section section-10 environments-date" role="columnheader">
63 64 65 66 67 68 69 70 71 72 73 74
        Updated
      </div>
    </div>
    <template
      v-for="model in environments"
      v-bind:model="model">
      <div
        is="environment-item"
        :model="model"
        :can-create-deployment="canCreateDeployment"
        :can-read-environment="canReadEnvironment"
        />
75

76 77 78 79
      <template v-if="model.isFolder && model.isOpen && model.children && model.children.length > 0">
        <div v-if="isLoadingFolderContent">
          <loading-icon size="2" />
        </div>
80

81 82 83 84 85 86 87 88
        <template v-else>
          <div
            is="environment-item"
            v-for="children in model.children"
            :model="children"
            :can-create-deployment="canCreateDeployment"
            :can-read-environment="canReadEnvironment"
            />
89

90 91 92 93 94 95 96 97 98
          <div>
            <div class="text-center prepend-top-10">
              <a
                :href="folderUrl(model)"
                class="btn btn-default">
                Show all
              </a>
            </div>
          </div>
99 100
        </template>
      </template>
101 102
    </template>
  </div>
103
</template>