2022-01-10 19:13:53 -05:00
|
|
|
<script>
|
|
|
|
import {
|
|
|
|
GlCollapse,
|
|
|
|
GlDropdown,
|
|
|
|
GlButton,
|
|
|
|
GlLink,
|
2022-01-25 01:16:04 -05:00
|
|
|
GlSprintf,
|
2022-01-10 19:13:53 -05:00
|
|
|
GlTooltipDirective as GlTooltip,
|
|
|
|
} from '@gitlab/ui';
|
2022-01-25 01:16:04 -05:00
|
|
|
import { __, s__ } from '~/locale';
|
2022-01-10 19:13:53 -05:00
|
|
|
import { truncate } from '~/lib/utils/text_utility';
|
2022-01-28 13:14:12 -05:00
|
|
|
import TimeAgoTooltip from '~/vue_shared/components/time_ago_tooltip.vue';
|
2022-01-10 19:13:53 -05:00
|
|
|
import isLastDeployment from '../graphql/queries/is_last_deployment.query.graphql';
|
|
|
|
import ExternalUrl from './environment_external_url.vue';
|
|
|
|
import Actions from './environment_actions.vue';
|
|
|
|
import StopComponent from './environment_stop.vue';
|
|
|
|
import Rollback from './environment_rollback.vue';
|
|
|
|
import Pin from './environment_pin.vue';
|
|
|
|
import Monitoring from './environment_monitoring.vue';
|
|
|
|
import Terminal from './environment_terminal_button.vue';
|
|
|
|
import Delete from './environment_delete.vue';
|
2022-01-13 22:16:05 -05:00
|
|
|
import Deployment from './deployment.vue';
|
2022-01-10 19:13:53 -05:00
|
|
|
|
|
|
|
export default {
|
|
|
|
components: {
|
|
|
|
GlCollapse,
|
|
|
|
GlDropdown,
|
|
|
|
GlButton,
|
|
|
|
GlLink,
|
2022-01-25 01:16:04 -05:00
|
|
|
GlSprintf,
|
2022-01-10 19:13:53 -05:00
|
|
|
Actions,
|
2022-01-13 22:16:05 -05:00
|
|
|
Deployment,
|
2022-01-10 19:13:53 -05:00
|
|
|
ExternalUrl,
|
|
|
|
StopComponent,
|
|
|
|
Rollback,
|
|
|
|
Monitoring,
|
|
|
|
Pin,
|
|
|
|
Terminal,
|
2022-01-28 13:14:12 -05:00
|
|
|
TimeAgoTooltip,
|
2022-01-10 19:13:53 -05:00
|
|
|
Delete,
|
|
|
|
},
|
|
|
|
directives: {
|
|
|
|
GlTooltip,
|
|
|
|
},
|
2022-01-25 01:16:04 -05:00
|
|
|
inject: ['helpPagePath'],
|
2022-01-10 19:13:53 -05:00
|
|
|
props: {
|
|
|
|
environment: {
|
|
|
|
required: true,
|
|
|
|
type: Object,
|
|
|
|
},
|
|
|
|
inFolder: {
|
|
|
|
required: false,
|
|
|
|
default: false,
|
|
|
|
type: Boolean,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
apollo: {
|
|
|
|
isLastDeployment: {
|
|
|
|
query: isLastDeployment,
|
|
|
|
variables() {
|
|
|
|
return { environment: this.environment };
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
i18n: {
|
|
|
|
collapse: __('Collapse'),
|
|
|
|
expand: __('Expand'),
|
2022-01-25 01:16:04 -05:00
|
|
|
emptyState: s__(
|
|
|
|
'Environments|There are no deployments for this environment yet. %{linkStart}Learn more about setting up deployments.%{linkEnd}',
|
|
|
|
),
|
2022-01-28 13:14:12 -05:00
|
|
|
autoStopIn: s__('Environment|Auto stop %{time}'),
|
2022-01-10 19:13:53 -05:00
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return { visible: false };
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
icon() {
|
|
|
|
return this.visible ? 'angle-down' : 'angle-right';
|
|
|
|
},
|
|
|
|
externalUrl() {
|
|
|
|
return this.environment.externalUrl;
|
|
|
|
},
|
|
|
|
name() {
|
|
|
|
return this.inFolder ? this.environment.nameWithoutType : this.environment.name;
|
|
|
|
},
|
|
|
|
label() {
|
|
|
|
return this.visible ? this.$options.i18n.collapse : this.$options.i18n.expand;
|
|
|
|
},
|
2022-01-13 22:16:05 -05:00
|
|
|
lastDeployment() {
|
|
|
|
return this.environment?.lastDeployment;
|
|
|
|
},
|
|
|
|
upcomingDeployment() {
|
|
|
|
return this.environment?.upcomingDeployment;
|
|
|
|
},
|
2022-01-25 01:16:04 -05:00
|
|
|
hasDeployment() {
|
|
|
|
return Boolean(this.environment?.upcomingDeployment || this.environment?.lastDeployment);
|
|
|
|
},
|
2022-01-10 19:13:53 -05:00
|
|
|
actions() {
|
2022-01-13 22:16:05 -05:00
|
|
|
if (!this.lastDeployment) {
|
2022-01-10 19:13:53 -05:00
|
|
|
return [];
|
|
|
|
}
|
2022-01-13 22:16:05 -05:00
|
|
|
const { manualActions = [], scheduledActions = [] } = this.lastDeployment;
|
2022-01-10 19:13:53 -05:00
|
|
|
const combinedActions = [...manualActions, ...scheduledActions];
|
|
|
|
return combinedActions.map((action) => ({
|
|
|
|
...action,
|
|
|
|
}));
|
|
|
|
},
|
|
|
|
canStop() {
|
|
|
|
return this.environment?.canStop;
|
|
|
|
},
|
|
|
|
retryPath() {
|
2022-01-13 22:16:05 -05:00
|
|
|
return this.lastDeployment?.deployable?.retryPath;
|
2022-01-10 19:13:53 -05:00
|
|
|
},
|
|
|
|
hasExtraActions() {
|
|
|
|
return Boolean(
|
|
|
|
this.retryPath ||
|
|
|
|
this.canShowAutoStopDate ||
|
|
|
|
this.metricsPath ||
|
|
|
|
this.terminalPath ||
|
|
|
|
this.canDeleteEnvironment,
|
|
|
|
);
|
|
|
|
},
|
|
|
|
canShowAutoStopDate() {
|
|
|
|
if (!this.environment?.autoStopAt) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
const autoStopDate = new Date(this.environment?.autoStopAt);
|
|
|
|
const now = new Date();
|
|
|
|
|
|
|
|
return now < autoStopDate;
|
|
|
|
},
|
|
|
|
autoStopPath() {
|
|
|
|
return this.environment?.cancelAutoStopPath ?? '';
|
|
|
|
},
|
|
|
|
metricsPath() {
|
|
|
|
return this.environment?.metricsPath ?? '';
|
|
|
|
},
|
|
|
|
terminalPath() {
|
|
|
|
return this.environment?.terminalPath ?? '';
|
|
|
|
},
|
|
|
|
canDeleteEnvironment() {
|
|
|
|
return Boolean(this.environment?.canDelete && this.environment?.deletePath);
|
|
|
|
},
|
|
|
|
displayName() {
|
|
|
|
return truncate(this.name, 80);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
toggleCollapse() {
|
|
|
|
this.visible = !this.visible;
|
|
|
|
},
|
|
|
|
},
|
2022-01-13 22:16:05 -05:00
|
|
|
deploymentClasses: [
|
|
|
|
'gl-border-gray-100',
|
|
|
|
'gl-border-t-solid',
|
|
|
|
'gl-border-1',
|
|
|
|
'gl-py-5',
|
2022-01-20 10:11:58 -05:00
|
|
|
'gl-md-pl-7',
|
2022-01-13 22:16:05 -05:00
|
|
|
'gl-bg-gray-10',
|
|
|
|
],
|
2022-01-10 19:13:53 -05:00
|
|
|
};
|
|
|
|
</script>
|
|
|
|
<template>
|
|
|
|
<div>
|
|
|
|
<div
|
|
|
|
class="gl-px-3 gl-pt-3 gl-pb-5 gl-display-flex gl-justify-content-space-between gl-align-items-center"
|
|
|
|
>
|
2022-01-13 22:16:05 -05:00
|
|
|
<div
|
|
|
|
:class="{ 'gl-ml-7': inFolder }"
|
|
|
|
class="gl-min-w-0 gl-mr-4 gl-display-flex gl-align-items-center"
|
|
|
|
>
|
2022-01-10 19:13:53 -05:00
|
|
|
<gl-button
|
|
|
|
class="gl-mr-4 gl-min-w-fit-content"
|
|
|
|
:icon="icon"
|
|
|
|
:aria-label="label"
|
|
|
|
size="small"
|
|
|
|
category="tertiary"
|
|
|
|
@click="toggleCollapse"
|
|
|
|
/>
|
|
|
|
<gl-link
|
|
|
|
v-gl-tooltip
|
|
|
|
:href="environment.environmentPath"
|
|
|
|
class="gl-text-blue-500 gl-text-truncate"
|
|
|
|
:class="{ 'gl-font-weight-bold': visible }"
|
|
|
|
:title="name"
|
|
|
|
>
|
|
|
|
{{ displayName }}
|
|
|
|
</gl-link>
|
|
|
|
</div>
|
2022-01-28 13:14:12 -05:00
|
|
|
<div class="gl-display-flex gl-align-items-center">
|
|
|
|
<p v-if="canShowAutoStopDate" class="gl-font-sm gl-text-gray-700 gl-mr-5 gl-mb-0">
|
|
|
|
<gl-sprintf :message="$options.i18n.autoStopIn">
|
|
|
|
<template #time>
|
|
|
|
<time-ago-tooltip :time="environment.autoStopAt" css-class="gl-font-weight-bold" />
|
|
|
|
</template>
|
|
|
|
</gl-sprintf>
|
|
|
|
</p>
|
2022-01-10 19:13:53 -05:00
|
|
|
<div class="btn-group table-action-buttons" role="group">
|
|
|
|
<external-url
|
|
|
|
v-if="externalUrl"
|
|
|
|
:external-url="externalUrl"
|
|
|
|
data-track-action="click_button"
|
|
|
|
data-track-label="environment_url"
|
|
|
|
/>
|
|
|
|
|
|
|
|
<actions
|
|
|
|
v-if="actions.length > 0"
|
|
|
|
:actions="actions"
|
|
|
|
data-track-action="click_dropdown"
|
|
|
|
data-track-label="environment_actions"
|
|
|
|
graphql
|
|
|
|
/>
|
|
|
|
|
|
|
|
<stop-component
|
|
|
|
v-if="canStop"
|
|
|
|
:environment="environment"
|
|
|
|
class="gl-z-index-2"
|
|
|
|
data-track-action="click_button"
|
|
|
|
data-track-label="environment_stop"
|
|
|
|
graphql
|
|
|
|
/>
|
|
|
|
|
|
|
|
<gl-dropdown
|
|
|
|
v-if="hasExtraActions"
|
|
|
|
icon="ellipsis_v"
|
|
|
|
text-sr-only
|
|
|
|
:text="__('More actions')"
|
|
|
|
category="secondary"
|
|
|
|
no-caret
|
|
|
|
right
|
|
|
|
>
|
|
|
|
<rollback
|
|
|
|
v-if="retryPath"
|
|
|
|
:environment="environment"
|
|
|
|
:is-last-deployment="isLastDeployment"
|
|
|
|
:retry-url="retryPath"
|
|
|
|
graphql
|
|
|
|
data-track-action="click_button"
|
|
|
|
data-track-label="environment_rollback"
|
|
|
|
/>
|
|
|
|
|
|
|
|
<pin
|
|
|
|
v-if="canShowAutoStopDate"
|
|
|
|
:auto-stop-url="autoStopPath"
|
|
|
|
data-track-action="click_button"
|
|
|
|
data-track-label="environment_pin"
|
|
|
|
/>
|
|
|
|
|
|
|
|
<monitoring
|
|
|
|
v-if="metricsPath"
|
|
|
|
:monitoring-url="metricsPath"
|
|
|
|
data-track-action="click_button"
|
|
|
|
data-track-label="environment_monitoring"
|
|
|
|
/>
|
|
|
|
|
|
|
|
<terminal
|
|
|
|
v-if="terminalPath"
|
|
|
|
:terminal-path="terminalPath"
|
|
|
|
data-track-action="click_button"
|
|
|
|
data-track-label="environment_terminal"
|
|
|
|
/>
|
|
|
|
|
|
|
|
<delete
|
|
|
|
v-if="canDeleteEnvironment"
|
|
|
|
:environment="environment"
|
|
|
|
data-track-action="click_button"
|
|
|
|
data-track-label="environment_delete"
|
|
|
|
graphql
|
|
|
|
/>
|
|
|
|
</gl-dropdown>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
2022-01-13 22:16:05 -05:00
|
|
|
<gl-collapse :visible="visible">
|
2022-01-25 01:16:04 -05:00
|
|
|
<template v-if="hasDeployment">
|
|
|
|
<div v-if="lastDeployment" :class="$options.deploymentClasses">
|
|
|
|
<deployment
|
|
|
|
:deployment="lastDeployment"
|
|
|
|
:class="{ 'gl-ml-7': inFolder }"
|
|
|
|
latest
|
|
|
|
class="gl-pl-4"
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
<div v-if="upcomingDeployment" :class="$options.deploymentClasses">
|
|
|
|
<deployment
|
|
|
|
:deployment="upcomingDeployment"
|
|
|
|
:class="{ 'gl-ml-7': inFolder }"
|
|
|
|
class="gl-pl-4"
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
<div v-else :class="$options.deploymentClasses">
|
|
|
|
<gl-sprintf :message="$options.i18n.emptyState">
|
|
|
|
<template #link="{ content }">
|
|
|
|
<gl-link :href="helpPagePath">{{ content }}</gl-link>
|
|
|
|
</template>
|
|
|
|
</gl-sprintf>
|
2022-01-13 22:16:05 -05:00
|
|
|
</div>
|
|
|
|
</gl-collapse>
|
2022-01-10 19:13:53 -05:00
|
|
|
</div>
|
|
|
|
</template>
|