Commit 034b8d17 authored by Andrew Fontaine's avatar Andrew Fontaine

Display Deployment Details Without Deployable

A Deployment can be created via the API and has no deployable, but most
of the details still exist, and we should show those off.
parent d2bef057
<script> <script>
import _ from 'underscore'; import _ from 'underscore';
import { GlTooltipDirective, GlLink } from '@gitlab/ui'; import { GlTooltipDirective, GlLink, GlBadge } from '@gitlab/ui';
import { s__, __, sprintf } from '~/locale'; import { s__, __, sprintf } from '~/locale';
import Icon from '~/vue_shared/components/icon.vue'; import Icon from '~/vue_shared/components/icon.vue';
import timeagoMixin from '~/vue_shared/mixins/timeago'; import timeagoMixin from '~/vue_shared/mixins/timeago';
...@@ -8,7 +8,7 @@ import UserAvatarLink from '~/vue_shared/components/user_avatar/user_avatar_link ...@@ -8,7 +8,7 @@ import UserAvatarLink from '~/vue_shared/components/user_avatar/user_avatar_link
import Commit from '~/vue_shared/components/commit.vue'; import Commit from '~/vue_shared/components/commit.vue';
import Alerts from 'ee/vue_shared/dashboards/components/alerts.vue'; import Alerts from 'ee/vue_shared/dashboards/components/alerts.vue';
import TimeAgo from 'ee/vue_shared/dashboards/components/time_ago.vue'; import TimeAgo from 'ee/vue_shared/dashboards/components/time_ago.vue';
import { STATUS_FAILED, STATUS_RUNNING } from 'ee/vue_shared/dashboards/constants'; import { STATUS_FAILED } from 'ee/vue_shared/dashboards/constants';
import ProjectPipeline from 'ee/vue_shared/dashboards/components/project_pipeline.vue'; import ProjectPipeline from 'ee/vue_shared/dashboards/components/project_pipeline.vue';
import EnvironmentHeader from './environment_header.vue'; import EnvironmentHeader from './environment_header.vue';
...@@ -17,6 +17,7 @@ export default { ...@@ -17,6 +17,7 @@ export default {
EnvironmentHeader, EnvironmentHeader,
UserAvatarLink, UserAvatarLink,
GlLink, GlLink,
GlBadge,
Commit, Commit,
Alerts, Alerts,
ProjectPipeline, ProjectPipeline,
...@@ -56,7 +57,7 @@ export default { ...@@ -56,7 +57,7 @@ export default {
'dashboard-card-body-warning': !this.hasPipelineFailed && this.hasPipelineErrors, 'dashboard-card-body-warning': !this.hasPipelineFailed && this.hasPipelineErrors,
'dashboard-card-body-failed': this.hasPipelineFailed, 'dashboard-card-body-failed': this.hasPipelineFailed,
'bg-secondary': !this.hasPipelineFailed && !this.hasPipelineErrors, 'bg-secondary': !this.hasPipelineFailed && !this.hasPipelineErrors,
'd-flex flex-column justify-content-center align-items-center': !this.deployable, 'd-flex flex-column justify-content-center align-items-center': !this.lastDeployment,
}; };
}, },
user() { user() {
...@@ -77,7 +78,9 @@ export default { ...@@ -77,7 +78,9 @@ export default {
return !_.isEmpty(this.lastDeployment.commit) ? this.lastDeployment.commit : {}; return !_.isEmpty(this.lastDeployment.commit) ? this.lastDeployment.commit : {};
}, },
jobTooltip() { jobTooltip() {
return sprintf(this.$options.tooltips.job, { job: this.buildName }); return this.deployable
? sprintf(this.$options.tooltips.job, { job: this.buildName })
: s__('EnvironmentDashboard|Created through the Deployment API');
}, },
commitRef() { commitRef() {
return this.lastDeployment && !_.isEmpty(this.lastDeployment.commit) return this.lastDeployment && !_.isEmpty(this.lastDeployment.commit)
...@@ -98,21 +101,18 @@ export default { ...@@ -98,21 +101,18 @@ export default {
); );
}, },
finishedTime() { finishedTime() {
return this.deployable.updated_at; return this.lastDeployment.deployed_at;
}, },
finishedTimeTitle() { finishedTimeTitle() {
return this.tooltipTitle(this.finishedTime); return this.tooltipTitle(this.finishedTime);
}, },
shouldShowTimeAgo() { shouldShowTimeAgo() {
return ( return Boolean(this.finishedTime);
this.deployable &&
this.deployable.status &&
this.deployable.status.group !== STATUS_RUNNING &&
this.finishedTime
);
}, },
buildName() { buildName() {
return this.deployable ? `${this.deployable.name} #${this.deployable.id}` : ''; return this.deployable
? `${this.deployable.name} #${this.deployable.id}`
: s__('EnvironmentDashboard|API');
}, },
}, },
}; };
...@@ -126,7 +126,7 @@ export default { ...@@ -126,7 +126,7 @@ export default {
/> />
<div :class="cardClasses" class="dashboard-card-body card-body"> <div :class="cardClasses" class="dashboard-card-body card-body">
<div v-if="deployable" class="row"> <div v-if="lastDeployment" class="row">
<div class="col-1 align-self-center"> <div class="col-1 align-self-center">
<user-avatar-link <user-avatar-link
v-if="user" v-if="user"
...@@ -140,9 +140,15 @@ export default { ...@@ -140,9 +140,15 @@ export default {
<div class="col-10 col-sm-7 pr-0 pl-5 align-self-center align-middle ci-table"> <div class="col-10 col-sm-7 pr-0 pl-5 align-self-center align-middle ci-table">
<div class="branch-commit"> <div class="branch-commit">
<icon name="work" /> <icon name="work" />
<gl-link v-gl-tooltip="jobTooltip" :href="deployable.build_path" class="str-truncated"> <gl-link
v-if="deployable"
v-gl-tooltip="jobTooltip"
:href="deployable.build_path"
class="str-truncated"
>
{{ buildName }} {{ buildName }}
</gl-link> </gl-link>
<gl-badge v-else v-gl-tooltip="jobTooltip" variant="primary">{{ buildName }}</gl-badge>
</div> </div>
<commit <commit
:tag="lastDeployment.tag" :tag="lastDeployment.tag"
......
...@@ -116,6 +116,6 @@ describe('Environment', () => { ...@@ -116,6 +116,6 @@ describe('Environment', () => {
propsData, propsData,
}); });
expect(wrapper.text()).toContain('This environment has no deployments yet.'); expect(wrapper.text()).toContain('API');
}); });
}); });
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
"id": 227, "id": 227,
"iid": 50, "iid": 50,
"sha": "63492726c2264a0277141d6a6573c3d22ecd7de3", "sha": "63492726c2264a0277141d6a6573c3d22ecd7de3",
"deployed_at": "2019-02-20T16:15:40.122Z",
"ref": { "ref": {
"name": "master", "name": "master",
"ref_path": "/root/minimal-ruby-app/tree/master", "ref_path": "/root/minimal-ruby-app/tree/master",
......
...@@ -6230,6 +6230,12 @@ msgstr "" ...@@ -6230,6 +6230,12 @@ msgstr ""
msgid "Environment:" msgid "Environment:"
msgstr "" msgstr ""
msgid "EnvironmentDashboard|API"
msgstr ""
msgid "EnvironmentDashboard|Created through the Deployment API"
msgstr ""
msgid "Environments" msgid "Environments"
msgstr "" msgstr ""
......
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