2017-04-21 11:16:22 -04:00
|
|
|
<script>
|
2020-03-18 11:09:45 -04:00
|
|
|
/* eslint-disable @gitlab/vue-require-i18n-strings */
|
2020-12-09 10:10:12 -05:00
|
|
|
import { GlTooltipDirective, GlIcon, GlLink } from '@gitlab/ui';
|
2021-02-14 13:09:20 -05:00
|
|
|
import { isEmpty } from 'lodash';
|
2020-01-03 04:07:33 -05:00
|
|
|
import { convertObjectPropsToCamelCase } from '~/lib/utils/common_utils';
|
2021-02-14 13:09:20 -05:00
|
|
|
import { __, s__, sprintf } from '~/locale';
|
|
|
|
import CiIcon from '~/vue_shared/components/ci_icon.vue';
|
2020-01-03 04:07:33 -05:00
|
|
|
import CommitComponent from '~/vue_shared/components/commit.vue';
|
2019-11-26 04:08:36 -05:00
|
|
|
import TooltipOnTruncate from '~/vue_shared/components/tooltip_on_truncate.vue';
|
2021-02-14 13:09:20 -05:00
|
|
|
import UserAvatarLink from '~/vue_shared/components/user_avatar/user_avatar_link.vue';
|
|
|
|
import timeagoMixin from '~/vue_shared/mixins/timeago';
|
2020-01-03 04:07:33 -05:00
|
|
|
import eventHub from '../event_hub';
|
2018-07-10 04:11:04 -04:00
|
|
|
import ActionsComponent from './environment_actions.vue';
|
2021-02-14 13:09:20 -05:00
|
|
|
import DeleteComponent from './environment_delete.vue';
|
2018-07-10 04:11:04 -04:00
|
|
|
import ExternalUrlComponent from './environment_external_url.vue';
|
2020-01-03 04:07:33 -05:00
|
|
|
import MonitoringButtonComponent from './environment_monitoring.vue';
|
|
|
|
import PinComponent from './environment_pin.vue';
|
2020-03-25 05:08:11 -04:00
|
|
|
import RollbackComponent from './environment_rollback.vue';
|
2021-02-14 13:09:20 -05:00
|
|
|
import StopComponent from './environment_stop.vue';
|
2018-07-10 04:11:04 -04:00
|
|
|
import TerminalButtonComponent from './environment_terminal_button.vue';
|
|
|
|
|
|
|
|
/**
|
2018-10-30 06:53:01 -04:00
|
|
|
* Environment Item Component
|
2018-07-10 04:11:04 -04:00
|
|
|
*
|
|
|
|
* Renders a table row for each environment.
|
|
|
|
*/
|
|
|
|
|
|
|
|
export default {
|
|
|
|
components: {
|
|
|
|
ActionsComponent,
|
2020-01-03 04:07:33 -05:00
|
|
|
CommitComponent,
|
2018-07-10 04:11:04 -04:00
|
|
|
ExternalUrlComponent,
|
2020-08-24 11:10:11 -04:00
|
|
|
GlIcon,
|
2020-12-09 10:10:12 -05:00
|
|
|
GlLink,
|
2020-01-03 04:07:33 -05:00
|
|
|
MonitoringButtonComponent,
|
|
|
|
PinComponent,
|
2020-03-25 05:08:11 -04:00
|
|
|
DeleteComponent,
|
2018-07-10 04:11:04 -04:00
|
|
|
RollbackComponent,
|
2020-01-03 04:07:33 -05:00
|
|
|
StopComponent,
|
2018-07-10 04:11:04 -04:00
|
|
|
TerminalButtonComponent,
|
2019-11-26 04:08:36 -05:00
|
|
|
TooltipOnTruncate,
|
|
|
|
UserAvatarLink,
|
2020-12-09 10:10:12 -05:00
|
|
|
CiIcon,
|
2018-07-10 04:11:04 -04:00
|
|
|
},
|
|
|
|
directives: {
|
2018-11-08 10:02:49 -05:00
|
|
|
GlTooltip: GlTooltipDirective,
|
2018-07-10 04:11:04 -04:00
|
|
|
},
|
2020-04-24 14:09:46 -04:00
|
|
|
mixins: [timeagoMixin],
|
2018-07-10 04:11:04 -04:00
|
|
|
|
|
|
|
props: {
|
2019-11-29 16:06:13 -05:00
|
|
|
canReadEnvironment: {
|
|
|
|
type: Boolean,
|
|
|
|
required: false,
|
|
|
|
default: false,
|
|
|
|
},
|
|
|
|
|
2018-07-10 04:11:04 -04:00
|
|
|
model: {
|
|
|
|
type: Object,
|
|
|
|
required: true,
|
2020-01-03 04:07:33 -05:00
|
|
|
},
|
|
|
|
|
2019-11-29 16:06:13 -05:00
|
|
|
tableData: {
|
|
|
|
type: Object,
|
|
|
|
required: true,
|
2018-07-10 04:11:04 -04:00
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
computed: {
|
2020-04-24 14:09:46 -04:00
|
|
|
deployIconName() {
|
|
|
|
return this.model.isDeployBoardVisible ? 'chevron-down' : 'chevron-right';
|
|
|
|
},
|
2018-07-10 04:11:04 -04:00
|
|
|
/**
|
2018-10-30 06:53:01 -04:00
|
|
|
* Verifies if `last_deployment` key exists in the current Environment.
|
2018-07-10 04:11:04 -04:00
|
|
|
* This key is required to render most of the html - this method works has
|
|
|
|
* an helper.
|
|
|
|
*
|
|
|
|
* @returns {Boolean}
|
|
|
|
*/
|
|
|
|
hasLastDeploymentKey() {
|
2020-03-30 05:07:58 -04:00
|
|
|
if (this.model && this.model.last_deployment && !isEmpty(this.model.last_deployment)) {
|
2018-07-10 04:11:04 -04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
},
|
|
|
|
|
2020-12-09 10:10:12 -05:00
|
|
|
/**
|
|
|
|
* @returns {Object|Undefined} The `upcoming_deployment` object if it exists.
|
|
|
|
* Otherwise, `undefined`.
|
|
|
|
*/
|
|
|
|
upcomingDeployment() {
|
|
|
|
return this.model?.upcoming_deployment;
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @returns {String} Text that will be shown in the tooltip when
|
|
|
|
* the user hovers over the upcoming deployment's status icon.
|
|
|
|
*/
|
|
|
|
upcomingDeploymentTooltipText() {
|
|
|
|
return sprintf(s__('Environments|Deployment %{status}'), {
|
|
|
|
status: this.upcomingDeployment.deployable.status.text,
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2020-01-03 04:07:33 -05:00
|
|
|
/**
|
|
|
|
* Checkes whether the row displayed is a folder.
|
|
|
|
*
|
|
|
|
* @returns {Boolean}
|
|
|
|
*/
|
|
|
|
|
|
|
|
isFolder() {
|
|
|
|
return this.model.isFolder;
|
|
|
|
},
|
|
|
|
|
2018-08-03 16:25:56 -04:00
|
|
|
/**
|
|
|
|
* Checkes whether the environment is protected.
|
|
|
|
* (`is_protected` currently only set in EE)
|
|
|
|
*
|
|
|
|
* @returns {Boolean}
|
|
|
|
*/
|
|
|
|
isProtected() {
|
|
|
|
return this.model && this.model.is_protected;
|
|
|
|
},
|
|
|
|
|
2018-07-10 04:11:04 -04:00
|
|
|
/**
|
|
|
|
* Returns whether the environment can be stopped.
|
|
|
|
*
|
|
|
|
* @returns {Boolean}
|
|
|
|
*/
|
|
|
|
canStopEnvironment() {
|
|
|
|
return this.model && this.model.can_stop;
|
|
|
|
},
|
|
|
|
|
2020-03-25 05:08:11 -04:00
|
|
|
/**
|
|
|
|
* Returns whether the environment can be deleted.
|
|
|
|
*
|
|
|
|
* @returns {Boolean}
|
|
|
|
*/
|
|
|
|
canDeleteEnvironment() {
|
|
|
|
return Boolean(this.model && this.model.can_delete && this.model.delete_path);
|
|
|
|
},
|
|
|
|
|
2018-07-10 04:11:04 -04:00
|
|
|
/**
|
|
|
|
* Verifies if the `deployable` key is present in `last_deployment` key.
|
|
|
|
* Used to verify whether we should or not render the rollback partial.
|
|
|
|
*
|
|
|
|
* @returns {Boolean|Undefined}
|
|
|
|
*/
|
|
|
|
canRetry() {
|
|
|
|
return (
|
|
|
|
this.model &&
|
|
|
|
this.hasLastDeploymentKey &&
|
|
|
|
this.model.last_deployment &&
|
2018-08-06 18:21:39 -04:00
|
|
|
this.model.last_deployment.deployable &&
|
|
|
|
this.model.last_deployment.deployable.retry_path
|
2018-07-10 04:11:04 -04:00
|
|
|
);
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
2020-01-03 04:07:33 -05:00
|
|
|
* Verifies if the autostop date is present.
|
|
|
|
*
|
|
|
|
* @returns {Boolean}
|
|
|
|
*/
|
|
|
|
canShowAutoStopDate() {
|
|
|
|
if (!this.model.auto_stop_at) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
const autoStopDate = new Date(this.model.auto_stop_at);
|
|
|
|
const now = new Date();
|
|
|
|
|
|
|
|
return now < autoStopDate;
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Human readable deployment date.
|
|
|
|
*
|
|
|
|
* @returns {String}
|
|
|
|
*/
|
|
|
|
autoStopDate() {
|
|
|
|
if (this.canShowAutoStopDate) {
|
|
|
|
return {
|
|
|
|
formatted: this.timeFormatted(this.model.auto_stop_at),
|
|
|
|
tooltip: this.tooltipTitle(this.model.auto_stop_at),
|
|
|
|
};
|
|
|
|
}
|
|
|
|
return {
|
|
|
|
formatted: '',
|
|
|
|
tooltip: '',
|
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Verifies if the deployment date is present.
|
2018-07-10 04:11:04 -04:00
|
|
|
*
|
|
|
|
* @returns {Boolean|Undefined}
|
|
|
|
*/
|
2020-01-03 04:07:33 -05:00
|
|
|
canShowDeploymentDate() {
|
2019-08-21 14:58:04 -04:00
|
|
|
return this.model && this.model.last_deployment && this.model.last_deployment.deployed_at;
|
2018-07-10 04:11:04 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
2020-01-03 04:07:33 -05:00
|
|
|
* Human readable deployment date.
|
2018-07-10 04:11:04 -04:00
|
|
|
*
|
|
|
|
* @returns {String}
|
|
|
|
*/
|
2019-08-21 14:58:04 -04:00
|
|
|
deployedDate() {
|
2020-01-03 04:07:33 -05:00
|
|
|
if (this.canShowDeploymentDate) {
|
|
|
|
return {
|
|
|
|
formatted: this.timeFormatted(this.model.last_deployment.deployed_at),
|
|
|
|
tooltip: this.tooltipTitle(this.model.last_deployment.deployed_at),
|
|
|
|
};
|
2018-07-10 04:11:04 -04:00
|
|
|
}
|
2020-01-03 04:07:33 -05:00
|
|
|
return {
|
|
|
|
formatted: '',
|
|
|
|
tooltip: '',
|
|
|
|
};
|
2018-07-10 04:11:04 -04:00
|
|
|
},
|
|
|
|
|
2018-10-08 09:06:00 -04:00
|
|
|
actions() {
|
2019-02-08 07:53:35 -05:00
|
|
|
if (!this.model || !this.model.last_deployment) {
|
2018-10-08 09:06:00 -04:00
|
|
|
return [];
|
2018-07-10 04:11:04 -04:00
|
|
|
}
|
2018-10-08 09:06:00 -04:00
|
|
|
|
|
|
|
const { manualActions, scheduledActions } = convertObjectPropsToCamelCase(
|
|
|
|
this.model.last_deployment,
|
|
|
|
{ deep: true },
|
|
|
|
);
|
2018-10-22 15:45:45 -04:00
|
|
|
const combinedActions = (manualActions || []).concat(scheduledActions || []);
|
2020-12-23 16:10:24 -05:00
|
|
|
return combinedActions.map((action) => ({
|
2018-10-08 09:06:00 -04:00
|
|
|
...action,
|
2019-03-07 04:38:39 -05:00
|
|
|
name: action.name,
|
2018-10-08 09:06:00 -04:00
|
|
|
}));
|
2018-07-10 04:11:04 -04:00
|
|
|
},
|
|
|
|
|
2020-04-24 14:09:46 -04:00
|
|
|
shouldRenderDeployBoard() {
|
|
|
|
return this.model.hasDeployBoard;
|
|
|
|
},
|
|
|
|
|
2018-07-10 04:11:04 -04:00
|
|
|
/**
|
|
|
|
* Builds the string used in the user image alt attribute.
|
|
|
|
*
|
|
|
|
* @returns {String}
|
|
|
|
*/
|
|
|
|
userImageAltDescription() {
|
|
|
|
if (
|
|
|
|
this.model &&
|
|
|
|
this.model.last_deployment &&
|
|
|
|
this.model.last_deployment.user &&
|
|
|
|
this.model.last_deployment.user.username
|
|
|
|
) {
|
2019-07-01 16:24:59 -04:00
|
|
|
return sprintf(__("%{username}'s avatar"), {
|
|
|
|
username: this.model.last_deployment.user.username,
|
|
|
|
});
|
2018-07-10 04:11:04 -04:00
|
|
|
}
|
|
|
|
return '';
|
|
|
|
},
|
|
|
|
|
2020-12-09 10:10:12 -05:00
|
|
|
/**
|
|
|
|
* Same as `userImageAltDescription`, but for the
|
|
|
|
* upcoming deployment's user
|
|
|
|
*
|
|
|
|
* @returns {String}
|
|
|
|
*/
|
|
|
|
upcomingDeploymentUserImageAltDescription() {
|
|
|
|
return sprintf(__("%{username}'s avatar"), {
|
|
|
|
username: this.upcomingDeployment.user.username,
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2018-07-10 04:11:04 -04:00
|
|
|
/**
|
|
|
|
* If provided, returns the commit tag.
|
|
|
|
*
|
|
|
|
* @returns {String|Undefined}
|
|
|
|
*/
|
|
|
|
commitTag() {
|
|
|
|
if (this.model && this.model.last_deployment && this.model.last_deployment.tag) {
|
|
|
|
return this.model.last_deployment.tag;
|
|
|
|
}
|
|
|
|
return undefined;
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* If provided, returns the commit ref.
|
|
|
|
*
|
|
|
|
* @returns {Object|Undefined}
|
|
|
|
*/
|
|
|
|
commitRef() {
|
|
|
|
if (this.model && this.model.last_deployment && this.model.last_deployment.ref) {
|
|
|
|
return this.model.last_deployment.ref;
|
|
|
|
}
|
|
|
|
return undefined;
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* If provided, returns the commit url.
|
|
|
|
*
|
|
|
|
* @returns {String|Undefined}
|
|
|
|
*/
|
|
|
|
commitUrl() {
|
|
|
|
if (
|
|
|
|
this.model &&
|
|
|
|
this.model.last_deployment &&
|
|
|
|
this.model.last_deployment.commit &&
|
|
|
|
this.model.last_deployment.commit.commit_path
|
|
|
|
) {
|
|
|
|
return this.model.last_deployment.commit.commit_path;
|
|
|
|
}
|
|
|
|
return undefined;
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* If provided, returns the commit short sha.
|
|
|
|
*
|
|
|
|
* @returns {String|Undefined}
|
|
|
|
*/
|
|
|
|
commitShortSha() {
|
|
|
|
if (
|
|
|
|
this.model &&
|
|
|
|
this.model.last_deployment &&
|
|
|
|
this.model.last_deployment.commit &&
|
|
|
|
this.model.last_deployment.commit.short_id
|
|
|
|
) {
|
|
|
|
return this.model.last_deployment.commit.short_id;
|
|
|
|
}
|
|
|
|
return undefined;
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* If provided, returns the commit title.
|
|
|
|
*
|
|
|
|
* @returns {String|Undefined}
|
|
|
|
*/
|
|
|
|
commitTitle() {
|
|
|
|
if (
|
|
|
|
this.model &&
|
|
|
|
this.model.last_deployment &&
|
|
|
|
this.model.last_deployment.commit &&
|
|
|
|
this.model.last_deployment.commit.title
|
|
|
|
) {
|
|
|
|
return this.model.last_deployment.commit.title;
|
|
|
|
}
|
|
|
|
return undefined;
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* If provided, returns the commit tag.
|
|
|
|
*
|
|
|
|
* @returns {Object|Undefined}
|
|
|
|
*/
|
|
|
|
commitAuthor() {
|
|
|
|
if (
|
|
|
|
this.model &&
|
|
|
|
this.model.last_deployment &&
|
|
|
|
this.model.last_deployment.commit &&
|
|
|
|
this.model.last_deployment.commit.author
|
|
|
|
) {
|
|
|
|
return this.model.last_deployment.commit.author;
|
|
|
|
}
|
|
|
|
|
|
|
|
return undefined;
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Verifies if the `retry_path` key is present and returns its value.
|
|
|
|
*
|
|
|
|
* @returns {String|Undefined}
|
|
|
|
*/
|
|
|
|
retryUrl() {
|
|
|
|
if (
|
|
|
|
this.model &&
|
|
|
|
this.model.last_deployment &&
|
|
|
|
this.model.last_deployment.deployable &&
|
|
|
|
this.model.last_deployment.deployable.retry_path
|
|
|
|
) {
|
|
|
|
return this.model.last_deployment.deployable.retry_path;
|
|
|
|
}
|
|
|
|
return undefined;
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Verifies if the `last?` key is present and returns its value.
|
|
|
|
*
|
|
|
|
* @returns {Boolean|Undefined}
|
|
|
|
*/
|
|
|
|
isLastDeployment() {
|
2019-07-01 16:24:59 -04:00
|
|
|
// name: 'last?' is a false positive: https://gitlab.com/gitlab-org/frontend/eslint-plugin-i18n/issues/26#possible-false-positives
|
2019-09-18 10:02:45 -04:00
|
|
|
// Vue i18n ESLint rules issue: https://gitlab.com/gitlab-org/gitlab-foss/issues/63560
|
2020-03-18 11:09:45 -04:00
|
|
|
// eslint-disable-next-line @gitlab/require-i18n-strings
|
2018-07-10 04:11:04 -04:00
|
|
|
return this.model && this.model.last_deployment && this.model.last_deployment['last?'];
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Builds the name of the builds needed to display both the name and the id.
|
|
|
|
*
|
|
|
|
* @returns {String}
|
|
|
|
*/
|
|
|
|
buildName() {
|
|
|
|
if (this.model && this.model.last_deployment && this.model.last_deployment.deployable) {
|
|
|
|
const { deployable } = this.model.last_deployment;
|
|
|
|
return `${deployable.name} #${deployable.id}`;
|
|
|
|
}
|
|
|
|
return '';
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Builds the needed string to show the internal id.
|
|
|
|
*
|
|
|
|
* @returns {String}
|
|
|
|
*/
|
|
|
|
deploymentInternalId() {
|
|
|
|
if (this.model && this.model.last_deployment && this.model.last_deployment.iid) {
|
|
|
|
return `#${this.model.last_deployment.iid}`;
|
|
|
|
}
|
|
|
|
return '';
|
2017-02-09 06:52:22 -05:00
|
|
|
},
|
2016-10-26 11:00:16 -04:00
|
|
|
|
2020-12-09 10:10:12 -05:00
|
|
|
/**
|
|
|
|
* Same as `deploymentInternalId`, but for the upcoming deployment
|
|
|
|
*
|
|
|
|
* @returns {String}
|
|
|
|
*/
|
|
|
|
upcomingDeploymentInternalId() {
|
|
|
|
return `#${this.upcomingDeployment.iid}`;
|
|
|
|
},
|
|
|
|
|
2018-07-10 04:11:04 -04:00
|
|
|
/**
|
|
|
|
* Verifies if the user object is present under last_deployment object.
|
|
|
|
*
|
|
|
|
* @returns {Boolean}
|
|
|
|
*/
|
|
|
|
deploymentHasUser() {
|
|
|
|
return (
|
|
|
|
this.model &&
|
2020-03-30 05:07:58 -04:00
|
|
|
!isEmpty(this.model.last_deployment) &&
|
|
|
|
!isEmpty(this.model.last_deployment.user)
|
2018-07-10 04:11:04 -04:00
|
|
|
);
|
2017-02-09 06:52:22 -05:00
|
|
|
},
|
2016-11-09 05:55:00 -05:00
|
|
|
|
2018-07-10 04:11:04 -04:00
|
|
|
/**
|
|
|
|
* Returns the user object nested with the last_deployment object.
|
|
|
|
* Used to render the template.
|
|
|
|
*
|
|
|
|
* @returns {Object}
|
|
|
|
*/
|
|
|
|
deploymentUser() {
|
|
|
|
if (
|
|
|
|
this.model &&
|
2020-03-30 05:07:58 -04:00
|
|
|
!isEmpty(this.model.last_deployment) &&
|
|
|
|
!isEmpty(this.model.last_deployment.user)
|
2018-07-10 04:11:04 -04:00
|
|
|
) {
|
|
|
|
return this.model.last_deployment.user;
|
|
|
|
}
|
|
|
|
return {};
|
2017-02-09 06:52:22 -05:00
|
|
|
},
|
2018-07-10 04:11:04 -04:00
|
|
|
|
2020-01-03 04:07:33 -05:00
|
|
|
/**
|
|
|
|
* Checkes whether to display no deployment text.
|
|
|
|
*
|
|
|
|
* @returns {Boolean}
|
|
|
|
*/
|
|
|
|
showNoDeployments() {
|
|
|
|
return !this.hasLastDeploymentKey && !this.isFolder;
|
|
|
|
},
|
|
|
|
|
2018-07-10 04:11:04 -04:00
|
|
|
/**
|
|
|
|
* Verifies if the build name column should be rendered by verifing
|
|
|
|
* if all the information needed is present
|
|
|
|
* and if the environment is not a folder.
|
|
|
|
*
|
|
|
|
* @returns {Boolean}
|
|
|
|
*/
|
|
|
|
shouldRenderBuildName() {
|
|
|
|
return (
|
2020-01-03 04:07:33 -05:00
|
|
|
!this.isFolder &&
|
2020-03-30 05:07:58 -04:00
|
|
|
!isEmpty(this.model.last_deployment) &&
|
|
|
|
!isEmpty(this.model.last_deployment.deployable)
|
2018-07-10 04:11:04 -04:00
|
|
|
);
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Verifies the presence of all the keys needed to render the buil_path.
|
|
|
|
*
|
|
|
|
* @return {String}
|
|
|
|
*/
|
|
|
|
buildPath() {
|
|
|
|
if (
|
|
|
|
this.model &&
|
|
|
|
this.model.last_deployment &&
|
|
|
|
this.model.last_deployment.deployable &&
|
|
|
|
this.model.last_deployment.deployable.build_path
|
|
|
|
) {
|
|
|
|
return this.model.last_deployment.deployable.build_path;
|
|
|
|
}
|
|
|
|
|
|
|
|
return '';
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Verifies the presence of all the keys needed to render the external_url.
|
|
|
|
*
|
|
|
|
* @return {String}
|
|
|
|
*/
|
|
|
|
externalURL() {
|
2020-01-03 04:07:33 -05:00
|
|
|
return this.model.external_url || '';
|
2018-07-10 04:11:04 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Verifies if deplyment internal ID should be rendered by verifing
|
|
|
|
* if all the information needed is present
|
|
|
|
* and if the environment is not a folder.
|
|
|
|
*
|
|
|
|
* @returns {Boolean}
|
|
|
|
*/
|
|
|
|
shouldRenderDeploymentID() {
|
|
|
|
return (
|
2020-01-03 04:07:33 -05:00
|
|
|
!this.isFolder &&
|
2020-03-30 05:07:58 -04:00
|
|
|
!isEmpty(this.model.last_deployment) &&
|
2018-07-10 04:11:04 -04:00
|
|
|
this.model.last_deployment.iid !== undefined
|
|
|
|
);
|
|
|
|
},
|
|
|
|
|
|
|
|
environmentPath() {
|
2020-01-03 04:07:33 -05:00
|
|
|
return this.model.environment_path || '';
|
2018-07-10 04:11:04 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
monitoringUrl() {
|
2020-01-03 04:07:33 -05:00
|
|
|
return this.model.metrics_path || '';
|
|
|
|
},
|
2018-07-10 04:11:04 -04:00
|
|
|
|
2020-01-03 04:07:33 -05:00
|
|
|
autoStopUrl() {
|
|
|
|
return this.model.cancel_auto_stop_path || '';
|
2018-07-10 04:11:04 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
displayEnvironmentActions() {
|
|
|
|
return (
|
2018-11-05 03:37:09 -05:00
|
|
|
this.actions.length > 0 ||
|
2018-07-10 04:11:04 -04:00
|
|
|
this.externalURL ||
|
|
|
|
this.monitoringUrl ||
|
|
|
|
this.canStopEnvironment ||
|
2020-03-25 05:08:11 -04:00
|
|
|
this.canDeleteEnvironment ||
|
2018-07-10 04:11:04 -04:00
|
|
|
this.canRetry
|
|
|
|
);
|
|
|
|
},
|
2018-10-15 14:35:00 -04:00
|
|
|
|
|
|
|
folderIconName() {
|
|
|
|
return this.model.isOpen ? 'chevron-down' : 'chevron-right';
|
|
|
|
},
|
2020-12-09 10:10:12 -05:00
|
|
|
|
|
|
|
upcomingDeploymentCellClasses() {
|
|
|
|
return [
|
|
|
|
this.tableData.upcoming.spacing,
|
2021-01-25 10:09:00 -05:00
|
|
|
{ 'gl-display-none gl-md-display-block': !this.upcomingDeployment },
|
2020-12-09 10:10:12 -05:00
|
|
|
];
|
|
|
|
},
|
2018-07-10 04:11:04 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
2020-04-24 14:09:46 -04:00
|
|
|
toggleDeployBoard() {
|
|
|
|
eventHub.$emit('toggleDeployBoard', this.model);
|
|
|
|
},
|
2018-07-10 04:11:04 -04:00
|
|
|
onClickFolder() {
|
|
|
|
eventHub.$emit('toggleFolder', this.model);
|
|
|
|
},
|
2020-12-09 10:10:12 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the field title that will be shown in the field's row
|
|
|
|
* in the mobile view.
|
|
|
|
*
|
|
|
|
* @returns `field.mobileTitle` if present;
|
|
|
|
* if not, falls back to `field.title`.
|
|
|
|
*/
|
|
|
|
getMobileViewTitleForField(fieldName) {
|
|
|
|
const field = this.tableData[fieldName];
|
|
|
|
|
|
|
|
return field.mobileTitle || field.title;
|
|
|
|
},
|
2018-07-10 04:11:04 -04:00
|
|
|
},
|
|
|
|
};
|
2017-04-21 11:16:22 -04:00
|
|
|
</script>
|
|
|
|
<template>
|
2017-06-06 08:58:29 -04:00
|
|
|
<div
|
2017-11-02 02:54:08 -04:00
|
|
|
:class="{
|
|
|
|
'js-child-row environment-child-row': model.isChildren,
|
2020-01-03 04:07:33 -05:00
|
|
|
'folder-row': isFolder,
|
2017-11-02 02:54:08 -04:00
|
|
|
}"
|
2018-06-11 05:49:47 -04:00
|
|
|
class="gl-responsive-table-row"
|
2018-11-16 15:07:38 -05:00
|
|
|
role="row"
|
|
|
|
>
|
2019-11-29 16:06:13 -05:00
|
|
|
<div
|
|
|
|
class="table-section section-wrap text-truncate"
|
|
|
|
:class="tableData.name.spacing"
|
|
|
|
role="gridcell"
|
|
|
|
>
|
2020-01-03 04:07:33 -05:00
|
|
|
<div v-if="!isFolder" class="table-mobile-header" role="rowheader">
|
2020-12-09 10:10:12 -05:00
|
|
|
{{ getMobileViewTitleForField('name') }}
|
2017-06-06 08:58:29 -04:00
|
|
|
</div>
|
2019-03-08 09:26:04 -05:00
|
|
|
|
|
|
|
<span v-if="shouldRenderDeployBoard" class="deploy-board-icon" @click="toggleDeployBoard">
|
2020-08-24 11:10:11 -04:00
|
|
|
<gl-icon :name="deployIconName" />
|
2019-03-08 09:26:04 -05:00
|
|
|
</span>
|
|
|
|
|
2019-02-27 11:55:36 -05:00
|
|
|
<span
|
2020-01-03 04:07:33 -05:00
|
|
|
v-if="!isFolder"
|
2019-02-27 11:55:36 -05:00
|
|
|
v-gl-tooltip
|
|
|
|
:title="model.name"
|
|
|
|
class="environment-name table-mobile-content"
|
|
|
|
>
|
|
|
|
<a class="qa-environment-link" :href="environmentPath">
|
|
|
|
<span v-if="model.size === 1">{{ model.name }}</span>
|
|
|
|
<span v-else>{{ model.name_without_type }}</span>
|
|
|
|
</a>
|
2019-03-08 09:26:04 -05:00
|
|
|
<span v-if="isProtected" class="badge badge-success">
|
|
|
|
{{ s__('Environments|protected') }}
|
|
|
|
</span>
|
2018-08-03 16:25:56 -04:00
|
|
|
</span>
|
2019-02-27 11:55:36 -05:00
|
|
|
<span
|
|
|
|
v-else
|
|
|
|
v-gl-tooltip
|
|
|
|
:title="model.folderName"
|
|
|
|
class="folder-name"
|
|
|
|
role="button"
|
|
|
|
@click="onClickFolder"
|
|
|
|
>
|
2020-08-24 11:10:11 -04:00
|
|
|
<gl-icon :name="folderIconName" class="folder-icon" />
|
2017-02-09 06:52:22 -05:00
|
|
|
|
2020-08-24 11:10:11 -04:00
|
|
|
<gl-icon name="folder" class="folder-icon" />
|
2017-02-09 06:52:22 -05:00
|
|
|
|
2018-11-16 15:07:38 -05:00
|
|
|
<span> {{ model.folderName }} </span>
|
2017-02-09 06:52:22 -05:00
|
|
|
|
2018-11-16 15:07:38 -05:00
|
|
|
<span class="badge badge-pill"> {{ model.size }} </span>
|
2017-04-21 11:16:22 -04:00
|
|
|
</span>
|
2017-06-06 08:58:29 -04:00
|
|
|
</div>
|
2017-04-21 11:16:22 -04:00
|
|
|
|
2018-01-06 13:59:49 -05:00
|
|
|
<div
|
2020-10-14 14:08:47 -04:00
|
|
|
class="table-section deployment-column d-none d-md-block"
|
2019-11-29 16:06:13 -05:00
|
|
|
:class="tableData.deploy.spacing"
|
2018-01-06 13:59:49 -05:00
|
|
|
role="gridcell"
|
|
|
|
>
|
2019-04-08 11:22:01 -04:00
|
|
|
<span v-if="shouldRenderDeploymentID" class="text-break-word">
|
|
|
|
{{ deploymentInternalId }}
|
|
|
|
</span>
|
2017-04-21 11:16:22 -04:00
|
|
|
|
2020-01-03 04:07:33 -05:00
|
|
|
<span v-if="!isFolder && deploymentHasUser" class="text-break-word">
|
2017-04-21 11:16:22 -04:00
|
|
|
by
|
2017-04-15 19:38:07 -04:00
|
|
|
<user-avatar-link
|
|
|
|
:link-href="deploymentUser.web_url"
|
|
|
|
:img-src="deploymentUser.avatar_url"
|
|
|
|
:img-alt="userImageAltDescription"
|
|
|
|
:tooltip-text="deploymentUser.username"
|
2019-04-08 11:22:01 -04:00
|
|
|
class="js-deploy-user-container float-none"
|
2017-04-15 19:38:07 -04:00
|
|
|
/>
|
2017-04-21 11:16:22 -04:00
|
|
|
</span>
|
2020-01-03 04:07:33 -05:00
|
|
|
|
|
|
|
<div v-if="showNoDeployments" class="commit-title table-mobile-content">
|
|
|
|
{{ s__('Environments|No deployments yet') }}
|
|
|
|
</div>
|
2017-06-06 08:58:29 -04:00
|
|
|
</div>
|
2017-04-21 11:16:22 -04:00
|
|
|
|
2020-10-14 14:08:47 -04:00
|
|
|
<div class="table-section d-none d-md-block" :class="tableData.build.spacing" role="gridcell">
|
2019-11-26 04:08:36 -05:00
|
|
|
<a v-if="shouldRenderBuildName" :href="buildPath" class="build-link cgray">
|
|
|
|
<tooltip-on-truncate
|
|
|
|
:title="buildName"
|
|
|
|
truncate-target="child"
|
|
|
|
class="flex-truncate-parent"
|
|
|
|
>
|
|
|
|
<span class="flex-truncate-child">
|
|
|
|
{{ buildName }}
|
|
|
|
</span>
|
|
|
|
</tooltip-on-truncate>
|
2017-04-21 11:16:22 -04:00
|
|
|
</a>
|
2017-06-06 08:58:29 -04:00
|
|
|
</div>
|
2017-04-21 11:16:22 -04:00
|
|
|
|
2020-01-03 04:07:33 -05:00
|
|
|
<div v-if="!isFolder" class="table-section" :class="tableData.commit.spacing" role="gridcell">
|
2020-12-09 10:10:12 -05:00
|
|
|
<div role="rowheader" class="table-mobile-header">
|
|
|
|
{{ getMobileViewTitleForField('commit') }}
|
|
|
|
</div>
|
2018-11-16 15:07:38 -05:00
|
|
|
<div v-if="hasLastDeploymentKey" class="js-commit-component table-mobile-content">
|
2017-04-21 11:16:22 -04:00
|
|
|
<commit-component
|
|
|
|
:tag="commitTag"
|
|
|
|
:commit-ref="commitRef"
|
|
|
|
:commit-url="commitUrl"
|
|
|
|
:short-sha="commitShortSha"
|
|
|
|
:title="commitTitle"
|
2018-11-16 15:07:38 -05:00
|
|
|
:author="commitAuthor"
|
|
|
|
/>
|
2017-04-21 11:16:22 -04:00
|
|
|
</div>
|
2020-01-03 04:07:33 -05:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<div v-if="!isFolder" class="table-section" :class="tableData.date.spacing" role="gridcell">
|
2020-12-09 10:10:12 -05:00
|
|
|
<div role="rowheader" class="table-mobile-header">
|
|
|
|
{{ getMobileViewTitleForField('date') }}
|
|
|
|
</div>
|
2020-01-03 04:07:33 -05:00
|
|
|
<span
|
|
|
|
v-if="canShowDeploymentDate"
|
|
|
|
v-gl-tooltip
|
|
|
|
:title="deployedDate.tooltip"
|
|
|
|
class="environment-created-date-timeago table-mobile-content flex-truncate-parent"
|
|
|
|
>
|
|
|
|
<span class="flex-truncate-child">
|
|
|
|
{{ deployedDate.formatted }}
|
|
|
|
</span>
|
|
|
|
</span>
|
2017-06-06 08:58:29 -04:00
|
|
|
</div>
|
2017-04-21 11:16:22 -04:00
|
|
|
|
2020-12-09 10:10:12 -05:00
|
|
|
<div
|
|
|
|
v-if="!isFolder"
|
|
|
|
class="table-section"
|
|
|
|
:class="upcomingDeploymentCellClasses"
|
|
|
|
role="gridcell"
|
|
|
|
data-testid="upcoming-deployment"
|
|
|
|
>
|
|
|
|
<div role="rowheader" class="table-mobile-header">
|
|
|
|
{{ getMobileViewTitleForField('upcoming') }}
|
|
|
|
</div>
|
|
|
|
<div
|
|
|
|
v-if="upcomingDeployment"
|
|
|
|
class="gl-w-full gl-display-flex gl-flex-direction-row gl-md-flex-direction-column! gl-justify-content-end"
|
|
|
|
data-testid="upcoming-deployment-content"
|
|
|
|
>
|
|
|
|
<div class="gl-display-flex gl-align-items-center">
|
|
|
|
<span class="gl-mr-2">{{ upcomingDeploymentInternalId }}</span>
|
|
|
|
<gl-link
|
|
|
|
v-if="upcomingDeployment.deployable"
|
|
|
|
v-gl-tooltip
|
|
|
|
:href="upcomingDeployment.deployable.build_path"
|
|
|
|
:title="upcomingDeploymentTooltipText"
|
|
|
|
data-testid="upcoming-deployment-status-link"
|
|
|
|
>
|
|
|
|
<ci-icon class="gl-mr-2" :status="upcomingDeployment.deployable.status" />
|
|
|
|
</gl-link>
|
|
|
|
</div>
|
|
|
|
<div class="gl-display-flex">
|
|
|
|
<span v-if="upcomingDeployment.user" class="text-break-word">
|
|
|
|
by
|
|
|
|
<user-avatar-link
|
|
|
|
:link-href="upcomingDeployment.user.web_url"
|
|
|
|
:img-src="upcomingDeployment.user.avatar_url"
|
|
|
|
:img-alt="upcomingDeploymentUserImageAltDescription"
|
|
|
|
:tooltip-text="upcomingDeployment.user.username"
|
|
|
|
/>
|
|
|
|
</span>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
2020-04-14 11:09:44 -04:00
|
|
|
<div v-if="!isFolder" class="table-section" :class="tableData.autoStop.spacing" role="gridcell">
|
2020-12-09 10:10:12 -05:00
|
|
|
<div role="rowheader" class="table-mobile-header">
|
|
|
|
{{ getMobileViewTitleForField('autoStop') }}
|
|
|
|
</div>
|
2020-01-03 04:07:33 -05:00
|
|
|
<span
|
|
|
|
v-if="canShowAutoStopDate"
|
|
|
|
v-gl-tooltip
|
|
|
|
:title="autoStopDate.tooltip"
|
|
|
|
class="table-mobile-content flex-truncate-parent"
|
|
|
|
>
|
|
|
|
<span class="flex-truncate-child js-auto-stop">{{ autoStopDate.formatted }}</span>
|
2017-04-21 11:16:22 -04:00
|
|
|
</span>
|
2017-06-06 08:58:29 -04:00
|
|
|
</div>
|
2017-04-21 11:16:22 -04:00
|
|
|
|
2017-06-20 12:34:07 -04:00
|
|
|
<div
|
2020-01-03 04:07:33 -05:00
|
|
|
v-if="!isFolder && displayEnvironmentActions"
|
2019-11-29 16:06:13 -05:00
|
|
|
class="table-section table-button-footer"
|
|
|
|
:class="tableData.actions.spacing"
|
2018-11-16 15:07:38 -05:00
|
|
|
role="gridcell"
|
|
|
|
>
|
|
|
|
<div class="btn-group table-action-buttons" role="group">
|
2020-04-14 11:09:44 -04:00
|
|
|
<pin-component v-if="canShowAutoStopDate" :auto-stop-url="autoStopUrl" />
|
2020-01-03 04:07:33 -05:00
|
|
|
|
2017-04-21 11:16:22 -04:00
|
|
|
<external-url-component
|
|
|
|
v-if="externalURL && canReadEnvironment"
|
2017-05-03 10:23:12 -04:00
|
|
|
:external-url="externalURL"
|
2018-01-05 09:31:01 -05:00
|
|
|
/>
|
2017-04-21 11:16:22 -04:00
|
|
|
|
|
|
|
<monitoring-button-component
|
|
|
|
v-if="monitoringUrl && canReadEnvironment"
|
2017-05-03 10:23:12 -04:00
|
|
|
:monitoring-url="monitoringUrl"
|
2018-01-05 09:31:01 -05:00
|
|
|
/>
|
2017-04-21 11:16:22 -04:00
|
|
|
|
2018-11-16 15:07:38 -05:00
|
|
|
<actions-component v-if="actions.length > 0" :actions="actions" />
|
2018-07-10 04:11:04 -04:00
|
|
|
|
2017-04-21 11:16:22 -04:00
|
|
|
<terminal-button-component
|
|
|
|
v-if="model && model.terminal_path"
|
2017-05-03 10:23:12 -04:00
|
|
|
:terminal-path="model.terminal_path"
|
2018-01-05 09:31:01 -05:00
|
|
|
/>
|
2017-04-21 11:16:22 -04:00
|
|
|
|
|
|
|
<rollback-component
|
2019-02-08 07:53:35 -05:00
|
|
|
v-if="canRetry"
|
2019-03-05 13:33:10 -05:00
|
|
|
:environment="model"
|
2017-04-21 11:16:22 -04:00
|
|
|
:is-last-deployment="isLastDeployment"
|
|
|
|
:retry-url="retryUrl"
|
2018-01-05 09:31:01 -05:00
|
|
|
/>
|
2018-07-10 04:11:04 -04:00
|
|
|
|
2018-11-16 15:07:38 -05:00
|
|
|
<stop-component v-if="canStopEnvironment" :environment="model" />
|
2020-03-25 05:08:11 -04:00
|
|
|
|
|
|
|
<delete-component v-if="canDeleteEnvironment" :environment="model" />
|
2017-04-21 11:16:22 -04:00
|
|
|
</div>
|
2017-06-06 08:58:29 -04:00
|
|
|
</div>
|
|
|
|
</div>
|
2017-04-21 11:16:22 -04:00
|
|
|
</template>
|