Commit 15528c75 authored by Filipa Lacerda's avatar Filipa Lacerda

Merge branch...

Merge branch '55925-if-there-is-only-one-changed-page-in-review-app-go-directly-there' into 'master'

If there is one changed page in review app, link to it

Closes #55925

See merge request gitlab-org/gitlab-ce!25048
parents 09adc0f6 ccdb8906
...@@ -54,6 +54,12 @@ export default { ...@@ -54,6 +54,12 @@ export default {
deployTimeago() { deployTimeago() {
return this.timeFormated(this.deployment.deployed_at); return this.timeFormated(this.deployment.deployed_at);
}, },
deploymentExternalUrl() {
if (this.deployment.changes && this.deployment.changes.length === 1) {
return this.deployment.changes[0].external_url;
}
return this.deployment.external_url;
},
hasExternalUrls() { hasExternalUrls() {
return !!(this.deployment.external_url && this.deployment.external_url_formatted); return !!(this.deployment.external_url && this.deployment.external_url_formatted);
}, },
...@@ -78,7 +84,7 @@ export default { ...@@ -78,7 +84,7 @@ export default {
: ''; : '';
}, },
shouldRenderDropdown() { shouldRenderDropdown() {
return this.deployment.changes && this.deployment.changes.length > 0; return this.deployment.changes && this.deployment.changes.length > 1;
}, },
showMemoryUsage() { showMemoryUsage() {
return this.hasMetrics && this.showMetrics; return this.hasMetrics && this.showMetrics;
...@@ -154,12 +160,12 @@ export default { ...@@ -154,12 +160,12 @@ export default {
v-if="shouldRenderDropdown" v-if="shouldRenderDropdown"
class="js-mr-wigdet-deployment-dropdown inline" class="js-mr-wigdet-deployment-dropdown inline"
:items="deployment.changes" :items="deployment.changes"
:main-action-link="deployment.external_url" :main-action-link="deploymentExternalUrl"
filter-key="path" filter-key="path"
> >
<template slot="mainAction" slot-scope="slotProps"> <template slot="mainAction" slot-scope="slotProps">
<review-app-link <review-app-link
:link="deployment.external_url" :link="deploymentExternalUrl"
:css-class="`deploy-link js-deploy-url inline ${slotProps.className}`" :css-class="`deploy-link js-deploy-url inline ${slotProps.className}`"
/> />
</template> </template>
...@@ -183,7 +189,7 @@ export default { ...@@ -183,7 +189,7 @@ export default {
</filtered-search-dropdown> </filtered-search-dropdown>
<review-app-link <review-app-link
v-else v-else
:link="deployment.external_url" :link="deploymentExternalUrl"
css-class="js-deploy-url js-deploy-url-feature-flag deploy-link btn btn-default btn-sm inlin" css-class="js-deploy-url js-deploy-url-feature-flag deploy-link btn btn-default btn-sm inlin"
/> />
</template> </template>
......
---
title: Review App Link to Changed Page if Only One Change Present
merge_request: 25048
author:
type: changed
...@@ -6,32 +6,36 @@ import mountComponent from '../../helpers/vue_mount_component_helper'; ...@@ -6,32 +6,36 @@ import mountComponent from '../../helpers/vue_mount_component_helper';
describe('Deployment component', () => { describe('Deployment component', () => {
const Component = Vue.extend(deploymentComponent); const Component = Vue.extend(deploymentComponent);
const deploymentMockData = { let deploymentMockData;
id: 15,
name: 'review/diplo', beforeEach(() => {
url: '/root/review-apps/environments/15', deploymentMockData = {
stop_url: '/root/review-apps/environments/15/stop', id: 15,
metrics_url: '/root/review-apps/environments/15/deployments/1/metrics', name: 'review/diplo',
metrics_monitoring_url: '/root/review-apps/environments/15/metrics', url: '/root/review-apps/environments/15',
external_url: 'http://gitlab.com.', stop_url: '/root/review-apps/environments/15/stop',
external_url_formatted: 'gitlab', metrics_url: '/root/review-apps/environments/15/deployments/1/metrics',
deployed_at: '2017-03-22T22:44:42.258Z', metrics_monitoring_url: '/root/review-apps/environments/15/metrics',
deployed_at_formatted: 'Mar 22, 2017 10:44pm', external_url: 'http://gitlab.com.',
changes: [ external_url_formatted: 'gitlab',
{ deployed_at: '2017-03-22T22:44:42.258Z',
path: 'index.html', deployed_at_formatted: 'Mar 22, 2017 10:44pm',
external_url: 'http://root-master-patch-91341.volatile-watch.surge.sh/index.html', changes: [
}, {
{ path: 'index.html',
path: 'imgs/gallery.html', external_url: 'http://root-master-patch-91341.volatile-watch.surge.sh/index.html',
external_url: 'http://root-master-patch-91341.volatile-watch.surge.sh/imgs/gallery.html', },
}, {
{ path: 'imgs/gallery.html',
path: 'about/', external_url: 'http://root-master-patch-91341.volatile-watch.surge.sh/imgs/gallery.html',
external_url: 'http://root-master-patch-91341.volatile-watch.surge.sh/about/', },
}, {
], path: 'about/',
}; external_url: 'http://root-master-patch-91341.volatile-watch.surge.sh/about/',
},
],
};
});
let vm; let vm;
...@@ -207,6 +211,31 @@ describe('Deployment component', () => { ...@@ -207,6 +211,31 @@ describe('Deployment component', () => {
}); });
}); });
describe('with a single change', () => {
beforeEach(() => {
deploymentMockData.changes = deploymentMockData.changes.slice(0, 1);
vm = mountComponent(Component, {
deployment: { ...deploymentMockData },
showMetrics: true,
});
});
it('renders the link to the review app without dropdown', () => {
expect(vm.$el.querySelector('.js-mr-wigdet-deployment-dropdown')).toBeNull();
expect(vm.$el.querySelector('.js-deploy-url-feature-flag')).not.toBeNull();
});
it('renders the link to the review app linked to to the first change', () => {
const expectedUrl = deploymentMockData.changes[0].external_url;
const deployUrl = vm.$el.querySelector('.js-deploy-url-feature-flag');
expect(vm.$el.querySelector('.js-mr-wigdet-deployment-dropdown')).toBeNull();
expect(deployUrl).not.toBeNull();
expect(deployUrl.href).toEqual(expectedUrl);
});
});
describe('deployment status', () => { describe('deployment status', () => {
describe('running', () => { describe('running', () => {
beforeEach(() => { beforeEach(() => {
......
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