2017-04-21 11:16:22 -04:00
|
|
|
<script>
|
|
|
|
/**
|
|
|
|
* Render environments table.
|
|
|
|
*/
|
2018-11-16 14:29:11 -05:00
|
|
|
import { GlLoadingIcon } from '@gitlab/ui';
|
2020-03-30 05:07:58 -04:00
|
|
|
import { flow, reverse, sortBy } from 'lodash/fp';
|
2019-12-09 07:07:58 -05:00
|
|
|
import { s__ } from '~/locale';
|
2021-01-05 13:10:25 -05:00
|
|
|
import CanaryUpdateModal from './canary_update_modal.vue';
|
2021-02-14 13:09:20 -05:00
|
|
|
import DeployBoard from './deploy_board.vue';
|
|
|
|
import EnvironmentItem from './environment_item.vue';
|
2017-04-21 11:16:22 -04:00
|
|
|
|
|
|
|
export default {
|
|
|
|
components: {
|
2019-03-08 05:01:46 -05:00
|
|
|
EnvironmentItem,
|
2018-11-07 05:06:15 -05:00
|
|
|
GlLoadingIcon,
|
2021-01-05 13:10:25 -05:00
|
|
|
DeployBoard,
|
2020-09-04 17:08:41 -04:00
|
|
|
EnvironmentAlert: () => import('ee_component/environments/components/environment_alert.vue'),
|
2021-01-05 13:10:25 -05:00
|
|
|
CanaryUpdateModal,
|
2017-04-21 11:16:22 -04:00
|
|
|
},
|
|
|
|
props: {
|
|
|
|
environments: {
|
|
|
|
type: Array,
|
|
|
|
required: true,
|
2018-08-03 16:25:56 -04:00
|
|
|
default: () => [],
|
2017-04-21 11:16:22 -04:00
|
|
|
},
|
|
|
|
},
|
2020-12-15 16:09:53 -05:00
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
canaryWeight: 0,
|
|
|
|
environmentToChange: null,
|
|
|
|
};
|
|
|
|
},
|
Sort Environments in Table by Last Updated
Ensure folders push to the top, if both have no last update, sort by
name.
The sorting algorithm should sort in the following priorities:
1. folders first,
2. last updated descending,
3. by name ascending,
the sorting algorithm must:
1. Sort by name ascending,
2. Reverse (sort by name descending),
3. Sort by last deployment ascending,
4. Reverse (last deployment descending, name ascending),
5. Put folders first.
It is done this way, as `underscore`'s sort API is very basic: simple
comparisons, sorting by ascending only.
2019-02-11 10:25:10 -05:00
|
|
|
computed: {
|
|
|
|
sortedEnvironments() {
|
2020-12-23 16:10:24 -05:00
|
|
|
return this.sortEnvironments(this.environments).map((env) =>
|
Sort Environments in Table by Last Updated
Ensure folders push to the top, if both have no last update, sort by
name.
The sorting algorithm should sort in the following priorities:
1. folders first,
2. last updated descending,
3. by name ascending,
the sorting algorithm must:
1. Sort by name ascending,
2. Reverse (sort by name descending),
3. Sort by last deployment ascending,
4. Reverse (last deployment descending, name ascending),
5. Put folders first.
It is done this way, as `underscore`'s sort API is very basic: simple
comparisons, sorting by ascending only.
2019-02-11 10:25:10 -05:00
|
|
|
this.shouldRenderFolderContent(env)
|
|
|
|
? { ...env, children: this.sortEnvironments(env.children) }
|
|
|
|
: env,
|
|
|
|
);
|
|
|
|
},
|
2019-11-29 16:06:13 -05:00
|
|
|
tableData() {
|
|
|
|
return {
|
|
|
|
// percent spacing for cols, should add up to 100
|
|
|
|
name: {
|
|
|
|
title: s__('Environments|Environment'),
|
2020-12-09 10:10:12 -05:00
|
|
|
spacing: 'section-10',
|
2019-11-29 16:06:13 -05:00
|
|
|
},
|
|
|
|
deploy: {
|
|
|
|
title: s__('Environments|Deployment'),
|
|
|
|
spacing: 'section-10',
|
|
|
|
},
|
|
|
|
build: {
|
|
|
|
title: s__('Environments|Job'),
|
|
|
|
spacing: 'section-15',
|
|
|
|
},
|
|
|
|
commit: {
|
|
|
|
title: s__('Environments|Commit'),
|
2020-12-09 10:10:12 -05:00
|
|
|
spacing: 'section-15',
|
2019-11-29 16:06:13 -05:00
|
|
|
},
|
|
|
|
date: {
|
|
|
|
title: s__('Environments|Updated'),
|
|
|
|
spacing: 'section-10',
|
|
|
|
},
|
2020-12-09 10:10:12 -05:00
|
|
|
upcoming: {
|
|
|
|
title: s__('Environments|Upcoming'),
|
|
|
|
mobileTitle: s__('Environments|Upcoming deployment'),
|
|
|
|
spacing: 'section-10',
|
|
|
|
},
|
2020-01-03 04:07:33 -05:00
|
|
|
autoStop: {
|
2021-10-12 20:09:55 -04:00
|
|
|
title: s__('Environments|Auto stop'),
|
2020-12-09 10:10:12 -05:00
|
|
|
spacing: 'section-10',
|
2020-01-03 04:07:33 -05:00
|
|
|
},
|
2019-11-29 16:06:13 -05:00
|
|
|
actions: {
|
2020-12-09 10:10:12 -05:00
|
|
|
spacing: 'section-20',
|
2019-11-29 16:06:13 -05:00
|
|
|
},
|
|
|
|
};
|
|
|
|
},
|
Sort Environments in Table by Last Updated
Ensure folders push to the top, if both have no last update, sort by
name.
The sorting algorithm should sort in the following priorities:
1. folders first,
2. last updated descending,
3. by name ascending,
the sorting algorithm must:
1. Sort by name ascending,
2. Reverse (sort by name descending),
3. Sort by last deployment ascending,
4. Reverse (last deployment descending, name ascending),
5. Put folders first.
It is done this way, as `underscore`'s sort API is very basic: simple
comparisons, sorting by ascending only.
2019-02-11 10:25:10 -05:00
|
|
|
},
|
2017-04-21 11:16:22 -04:00
|
|
|
methods: {
|
|
|
|
folderUrl(model) {
|
|
|
|
return `${window.location.pathname}/folders/${model.folderName}`;
|
|
|
|
},
|
2020-04-24 14:09:46 -04:00
|
|
|
shouldRenderDeployBoard(model) {
|
|
|
|
return model.hasDeployBoard && model.isDeployBoardVisible;
|
|
|
|
},
|
2018-01-08 15:01:49 -05:00
|
|
|
shouldRenderFolderContent(env) {
|
2018-08-03 16:25:56 -04:00
|
|
|
return env.isFolder && env.isOpen && env.children && env.children.length > 0;
|
2018-01-08 15:01:49 -05:00
|
|
|
},
|
2020-09-04 17:08:41 -04:00
|
|
|
shouldRenderAlert(env) {
|
|
|
|
return env?.has_opened_alert;
|
|
|
|
},
|
Sort Environments in Table by Last Updated
Ensure folders push to the top, if both have no last update, sort by
name.
The sorting algorithm should sort in the following priorities:
1. folders first,
2. last updated descending,
3. by name ascending,
the sorting algorithm must:
1. Sort by name ascending,
2. Reverse (sort by name descending),
3. Sort by last deployment ascending,
4. Reverse (last deployment descending, name ascending),
5. Put folders first.
It is done this way, as `underscore`'s sort API is very basic: simple
comparisons, sorting by ascending only.
2019-02-11 10:25:10 -05:00
|
|
|
sortEnvironments(environments) {
|
|
|
|
/*
|
|
|
|
* The sorting algorithm should sort in the following priorities:
|
|
|
|
*
|
|
|
|
* 1. folders first,
|
|
|
|
* 2. last updated descending,
|
|
|
|
* 3. by name ascending,
|
|
|
|
*
|
|
|
|
* the sorting algorithm must:
|
|
|
|
*
|
|
|
|
* 1. Sort by name ascending,
|
|
|
|
* 2. Reverse (sort by name descending),
|
|
|
|
* 3. Sort by last deployment ascending,
|
|
|
|
* 4. Reverse (last deployment descending, name ascending),
|
|
|
|
* 5. Put folders first.
|
|
|
|
*/
|
2020-03-30 05:07:58 -04:00
|
|
|
return flow(
|
2020-12-23 16:10:24 -05:00
|
|
|
sortBy((env) => (env.isFolder ? env.folderName : env.name)),
|
2020-03-30 05:07:58 -04:00
|
|
|
reverse,
|
2020-12-23 16:10:24 -05:00
|
|
|
sortBy((env) => (env.last_deployment ? env.last_deployment.created_at : '0000')),
|
2020-03-30 05:07:58 -04:00
|
|
|
reverse,
|
2020-12-23 16:10:24 -05:00
|
|
|
sortBy((env) => (env.isFolder ? -1 : 1)),
|
2020-03-30 05:07:58 -04:00
|
|
|
)(environments);
|
Sort Environments in Table by Last Updated
Ensure folders push to the top, if both have no last update, sort by
name.
The sorting algorithm should sort in the following priorities:
1. folders first,
2. last updated descending,
3. by name ascending,
the sorting algorithm must:
1. Sort by name ascending,
2. Reverse (sort by name descending),
3. Sort by last deployment ascending,
4. Reverse (last deployment descending, name ascending),
5. Put folders first.
It is done this way, as `underscore`'s sort API is very basic: simple
comparisons, sorting by ascending only.
2019-02-11 10:25:10 -05:00
|
|
|
},
|
2020-12-15 16:09:53 -05:00
|
|
|
changeCanaryWeight(model, weight) {
|
|
|
|
this.environmentToChange = model;
|
|
|
|
this.canaryWeight = weight;
|
|
|
|
},
|
2017-04-21 11:16:22 -04:00
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
<template>
|
2018-11-16 15:07:38 -05:00
|
|
|
<div class="ci-table" role="grid">
|
2020-12-15 16:09:53 -05:00
|
|
|
<canary-update-modal :environment="environmentToChange" :weight="canaryWeight" />
|
2018-11-16 15:07:38 -05:00
|
|
|
<div class="gl-responsive-table-row table-row-header" role="row">
|
2019-11-29 16:06:13 -05:00
|
|
|
<div class="table-section" :class="tableData.name.spacing" role="columnheader">
|
|
|
|
{{ tableData.name.title }}
|
2017-06-06 08:58:29 -04:00
|
|
|
</div>
|
2019-11-29 16:06:13 -05:00
|
|
|
<div class="table-section" :class="tableData.deploy.spacing" role="columnheader">
|
|
|
|
{{ tableData.deploy.title }}
|
2017-06-06 08:58:29 -04:00
|
|
|
</div>
|
2019-11-29 16:06:13 -05:00
|
|
|
<div class="table-section" :class="tableData.build.spacing" role="columnheader">
|
|
|
|
{{ tableData.build.title }}
|
2017-06-06 08:58:29 -04:00
|
|
|
</div>
|
2019-11-29 16:06:13 -05:00
|
|
|
<div class="table-section" :class="tableData.commit.spacing" role="columnheader">
|
|
|
|
{{ tableData.commit.title }}
|
2017-06-06 08:58:29 -04:00
|
|
|
</div>
|
2019-11-29 16:06:13 -05:00
|
|
|
<div class="table-section" :class="tableData.date.spacing" role="columnheader">
|
|
|
|
{{ tableData.date.title }}
|
2017-06-06 08:58:29 -04:00
|
|
|
</div>
|
2020-12-09 10:10:12 -05:00
|
|
|
<div class="table-section" :class="tableData.upcoming.spacing" role="columnheader">
|
|
|
|
{{ tableData.upcoming.title }}
|
|
|
|
</div>
|
2020-04-14 11:09:44 -04:00
|
|
|
<div class="table-section" :class="tableData.autoStop.spacing" role="columnheader">
|
2020-01-03 04:07:33 -05:00
|
|
|
{{ tableData.autoStop.title }}
|
|
|
|
</div>
|
2017-06-06 08:58:29 -04:00
|
|
|
</div>
|
Sort Environments in Table by Last Updated
Ensure folders push to the top, if both have no last update, sort by
name.
The sorting algorithm should sort in the following priorities:
1. folders first,
2. last updated descending,
3. by name ascending,
the sorting algorithm must:
1. Sort by name ascending,
2. Reverse (sort by name descending),
3. Sort by last deployment ascending,
4. Reverse (last deployment descending, name ascending),
5. Put folders first.
It is done this way, as `underscore`'s sort API is very basic: simple
comparisons, sorting by ascending only.
2019-02-11 10:25:10 -05:00
|
|
|
<template v-for="(model, i) in sortedEnvironments" :model="model">
|
2021-06-28 11:08:03 -04:00
|
|
|
<environment-item
|
2018-09-20 02:13:50 -04:00
|
|
|
:key="`environment-item-${i}`"
|
2017-06-06 08:58:29 -04:00
|
|
|
:model="model"
|
2019-11-29 16:06:13 -05:00
|
|
|
:table-data="tableData"
|
2020-12-15 16:09:53 -05:00
|
|
|
data-qa-selector="environment_item"
|
2018-01-06 13:59:49 -05:00
|
|
|
/>
|
2017-04-21 11:16:22 -04:00
|
|
|
|
2019-03-08 05:01:46 -05:00
|
|
|
<div
|
2019-03-27 07:50:08 -04:00
|
|
|
v-if="shouldRenderDeployBoard(model)"
|
2019-03-08 05:01:46 -05:00
|
|
|
:key="`deploy-board-row-${i}`"
|
|
|
|
class="js-deploy-board-row"
|
|
|
|
>
|
|
|
|
<div class="deploy-board-container">
|
|
|
|
<deploy-board
|
|
|
|
:deploy-board-data="model.deployBoardData"
|
|
|
|
:is-loading="model.isLoadingDeployBoard"
|
|
|
|
:is-empty="model.isEmptyDeployBoard"
|
2020-02-13 10:08:52 -05:00
|
|
|
:logs-path="model.logs_path"
|
2020-12-15 16:09:53 -05:00
|
|
|
@changeCanaryWeight="changeCanaryWeight(model, $event)"
|
2019-03-08 05:01:46 -05:00
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</div>
|
2020-09-04 17:08:41 -04:00
|
|
|
<environment-alert
|
|
|
|
v-if="shouldRenderAlert(model)"
|
|
|
|
:key="`alert-row-${i}`"
|
|
|
|
:environment="model"
|
|
|
|
/>
|
2019-03-08 05:01:46 -05:00
|
|
|
|
2018-11-16 15:07:38 -05:00
|
|
|
<template v-if="shouldRenderFolderContent(model)">
|
|
|
|
<div v-if="model.isLoadingFolderContent" :key="`loading-item-${i}`">
|
2020-06-29 11:08:56 -04:00
|
|
|
<gl-loading-icon size="md" class="gl-mt-5" />
|
2017-06-06 08:58:29 -04:00
|
|
|
</div>
|
2017-04-21 11:16:22 -04:00
|
|
|
|
2017-06-06 08:58:29 -04:00
|
|
|
<template v-else>
|
2021-04-30 17:10:23 -04:00
|
|
|
<template v-for="(child, index) in model.children">
|
2021-06-28 11:08:03 -04:00
|
|
|
<environment-item
|
2021-04-30 17:10:23 -04:00
|
|
|
:key="`environment-row-${i}-${index}`"
|
|
|
|
:model="child"
|
|
|
|
:table-data="tableData"
|
|
|
|
data-qa-selector="environment_item"
|
|
|
|
/>
|
|
|
|
|
|
|
|
<div
|
|
|
|
v-if="shouldRenderDeployBoard(child)"
|
|
|
|
:key="`deploy-board-row-${i}-${index}`"
|
|
|
|
class="js-deploy-board-row"
|
|
|
|
>
|
|
|
|
<div class="deploy-board-container">
|
|
|
|
<deploy-board
|
|
|
|
:deploy-board-data="child.deployBoardData"
|
|
|
|
:is-loading="child.isLoadingDeployBoard"
|
|
|
|
:is-empty="child.isEmptyDeployBoard"
|
|
|
|
:logs-path="child.logs_path"
|
|
|
|
@changeCanaryWeight="changeCanaryWeight(child, $event)"
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<environment-alert
|
|
|
|
v-if="shouldRenderAlert(model)"
|
|
|
|
:key="`alert-row-${i}-${index}`"
|
|
|
|
:environment="child"
|
|
|
|
/>
|
|
|
|
</template>
|
2017-04-21 11:16:22 -04:00
|
|
|
|
2018-01-23 04:37:07 -05:00
|
|
|
<div :key="`sub-div-${i}`">
|
2020-07-27 17:09:16 -04:00
|
|
|
<div class="text-center gl-mt-3">
|
2019-03-08 05:01:46 -05:00
|
|
|
<a :href="folderUrl(model)" class="btn btn-default">
|
|
|
|
{{ s__('Environments|Show all') }}
|
|
|
|
</a>
|
2017-06-06 08:58:29 -04:00
|
|
|
</div>
|
|
|
|
</div>
|
2017-04-21 11:16:22 -04:00
|
|
|
</template>
|
|
|
|
</template>
|
2017-06-06 08:58:29 -04:00
|
|
|
</template>
|
|
|
|
</div>
|
2017-04-21 11:16:22 -04:00
|
|
|
</template>
|