Commit a3edfab1 authored by jakeburden's avatar jakeburden

Show correct deployment date for a manual job

Only display time if the job has deployed

Update JS tests for displaying job deployment time

Simplify boolean check in deployedDate
parent ef0f1509
...@@ -111,12 +111,7 @@ export default { ...@@ -111,12 +111,7 @@ export default {
* @returns {Boolean|Undefined} * @returns {Boolean|Undefined}
*/ */
canShowDate() { canShowDate() {
return ( return this.model && this.model.last_deployment && this.model.last_deployment.deployed_at;
this.model &&
this.model.last_deployment &&
this.model.last_deployment.deployable &&
this.model.last_deployment.deployable !== undefined
);
}, },
/** /**
...@@ -124,14 +119,9 @@ export default { ...@@ -124,14 +119,9 @@ export default {
* *
* @returns {String} * @returns {String}
*/ */
createdDate() { deployedDate() {
if ( if (this.canShowDate) {
this.model && return timeagoInstance.format(this.model.last_deployment.deployed_at);
this.model.last_deployment &&
this.model.last_deployment.deployable &&
this.model.last_deployment.deployable.created_at
) {
return timeagoInstance.format(this.model.last_deployment.deployable.created_at);
} }
return ''; return '';
}, },
...@@ -547,7 +537,7 @@ export default { ...@@ -547,7 +537,7 @@ export default {
<div v-if="!model.isFolder" class="table-section section-10" role="gridcell"> <div v-if="!model.isFolder" class="table-section section-10" role="gridcell">
<div role="rowheader" class="table-mobile-header">{{ s__('Environments|Updated') }}</div> <div role="rowheader" class="table-mobile-header">{{ s__('Environments|Updated') }}</div>
<span v-if="canShowDate" class="environment-created-date-timeago table-mobile-content"> <span v-if="canShowDate" class="environment-created-date-timeago table-mobile-content">
{{ createdDate }} {{ deployedDate }}
</span> </span>
</div> </div>
......
...@@ -22,7 +22,8 @@ ...@@ -22,7 +22,8 @@
.table-section.section-15{ role: 'gridcell' } .table-section.section-15{ role: 'gridcell' }
.table-mobile-header{ role: 'rowheader' }= _("Created") .table-mobile-header{ role: 'rowheader' }= _("Created")
%span.table-mobile-content= time_ago_with_tooltip(deployment.created_at) - if deployment.deployed_at
%span.table-mobile-content= time_ago_with_tooltip(deployment.deployed_at)
.table-section.section-20.table-button-footer{ role: 'gridcell' } .table-section.section-20.table-button-footer{ role: 'gridcell' }
.btn-group.table-action-buttons .btn-group.table-action-buttons
......
---
title: Update the timestamp in Operations > Environments to show correct deployment
date for manual deploy jobs
merge_request: 32072
author:
type: fixed
...@@ -106,6 +106,7 @@ describe('Environment item', () => { ...@@ -106,6 +106,7 @@ describe('Environment item', () => {
play_path: '/play', play_path: '/play',
}, },
], ],
deployed_at: '2016-11-29T18:11:58.430Z',
}, },
has_stop_action: true, has_stop_action: true,
environment_path: 'root/ci-folders/environments/31', environment_path: 'root/ci-folders/environments/31',
...@@ -139,9 +140,7 @@ describe('Environment item', () => { ...@@ -139,9 +140,7 @@ describe('Environment item', () => {
it('should render last deployment date', () => { it('should render last deployment date', () => {
const timeagoInstance = new timeago(); // eslint-disable-line const timeagoInstance = new timeago(); // eslint-disable-line
const formatedDate = timeagoInstance.format( const formatedDate = timeagoInstance.format(environment.last_deployment.deployed_at);
environment.last_deployment.deployable.created_at,
);
expect( expect(
component.$el.querySelector('.environment-created-date-timeago').textContent, component.$el.querySelector('.environment-created-date-timeago').textContent,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment