Commit 834bd36c authored by Kushal Pandya's avatar Kushal Pandya

Merge branch '49479-hide-unmerged-env-perf-stats' into 'master'

Don't show memory usage graph for unmerged MRs

Closes #49479

See merge request gitlab-org/gitlab-ce!22673
parents 8dd89f03 dfd1d6c4
...@@ -33,6 +33,10 @@ export default { ...@@ -33,6 +33,10 @@ export default {
type: Object, type: Object,
required: true, required: true,
}, },
showMetrics: {
type: Boolean,
required: true,
},
}, },
deployedTextMap: { deployedTextMap: {
running: __('Deploying to'), running: __('Deploying to'),
...@@ -74,6 +78,9 @@ export default { ...@@ -74,6 +78,9 @@ export default {
shouldRenderDropdown() { shouldRenderDropdown() {
return this.deployment.changes && this.deployment.changes.length > 0; return this.deployment.changes && this.deployment.changes.length > 0;
}, },
showMemoryUsage() {
return this.hasMetrics && this.showMetrics;
},
}, },
methods: { methods: {
stopEnvironment() { stopEnvironment() {
...@@ -136,7 +143,7 @@ export default { ...@@ -136,7 +143,7 @@ export default {
{{ deployTimeago }} {{ deployTimeago }}
</span> </span>
<memory-usage <memory-usage
v-if="hasMetrics" v-if="showMemoryUsage"
:metrics-url="deployment.metrics_url" :metrics-url="deployment.metrics_url"
:metrics-monitoring-url="deployment.metrics_monitoring_url" :metrics-monitoring-url="deployment.metrics_monitoring_url"
/> />
......
...@@ -312,6 +312,7 @@ export default { ...@@ -312,6 +312,7 @@ export default {
:key="`pre-merge-deploy-${deployment.id}`" :key="`pre-merge-deploy-${deployment.id}`"
class="js-pre-merge-deploy" class="js-pre-merge-deploy"
:deployment="deployment" :deployment="deployment"
:show-metrics="false"
/> />
<div class="mr-section-container"> <div class="mr-section-container">
<grouped-test-reports-app <grouped-test-reports-app
...@@ -366,6 +367,7 @@ export default { ...@@ -366,6 +367,7 @@ export default {
v-for="postMergeDeployment in mr.postMergeDeployments" v-for="postMergeDeployment in mr.postMergeDeployments"
:key="`post-merge-deploy-${postMergeDeployment.id}`" :key="`post-merge-deploy-${postMergeDeployment.id}`"
:deployment="postMergeDeployment" :deployment="postMergeDeployment"
:show-metrics="true"
class="js-post-deployment" class="js-post-deployment"
/> />
</template> </template>
......
---
title: Don't show Memory Usage for unmerged MRs
merge_request:
author:
type: changed
...@@ -41,7 +41,7 @@ describe('Deployment component', () => { ...@@ -41,7 +41,7 @@ describe('Deployment component', () => {
describe('', () => { describe('', () => {
beforeEach(() => { beforeEach(() => {
vm = mountComponent(Component, { deployment: { ...deploymentMockData } }); vm = mountComponent(Component, { deployment: { ...deploymentMockData }, showMetrics: true });
}); });
describe('deployTimeago', () => { describe('deployTimeago', () => {
...@@ -174,11 +174,31 @@ describe('Deployment component', () => { ...@@ -174,11 +174,31 @@ describe('Deployment component', () => {
}); });
}); });
describe('with showMetrics enabled', () => {
beforeEach(() => {
vm = mountComponent(Component, { deployment: { ...deploymentMockData }, showMetrics: true });
});
it('shows metrics', () => {
expect(vm.$el).toContainElement('.js-mr-memory-usage');
});
});
describe('with showMetrics disabled', () => {
beforeEach(() => {
vm = mountComponent(Component, { deployment: { ...deploymentMockData }, showMetrics: false });
});
it('hides metrics', () => {
expect(vm.$el).not.toContainElement('.js-mr-memory-usage');
});
});
describe('without changes', () => { describe('without changes', () => {
beforeEach(() => { beforeEach(() => {
delete deploymentMockData.changes; delete deploymentMockData.changes;
vm = mountComponent(Component, { deployment: { ...deploymentMockData } }); vm = mountComponent(Component, { deployment: { ...deploymentMockData }, showMetrics: true });
}); });
it('renders the link to the review app without dropdown', () => { it('renders the link to the review app without dropdown', () => {
...@@ -192,6 +212,7 @@ describe('Deployment component', () => { ...@@ -192,6 +212,7 @@ describe('Deployment component', () => {
beforeEach(() => { beforeEach(() => {
vm = mountComponent(Component, { vm = mountComponent(Component, {
deployment: Object.assign({}, deploymentMockData, { status: 'running' }), deployment: Object.assign({}, deploymentMockData, { status: 'running' }),
showMetrics: true,
}); });
}); });
...@@ -208,6 +229,7 @@ describe('Deployment component', () => { ...@@ -208,6 +229,7 @@ describe('Deployment component', () => {
beforeEach(() => { beforeEach(() => {
vm = mountComponent(Component, { vm = mountComponent(Component, {
deployment: Object.assign({}, deploymentMockData, { status: 'success' }), deployment: Object.assign({}, deploymentMockData, { status: 'success' }),
showMetrics: true,
}); });
}); });
...@@ -220,6 +242,7 @@ describe('Deployment component', () => { ...@@ -220,6 +242,7 @@ describe('Deployment component', () => {
beforeEach(() => { beforeEach(() => {
vm = mountComponent(Component, { vm = mountComponent(Component, {
deployment: Object.assign({}, deploymentMockData, { status: 'failed' }), deployment: Object.assign({}, deploymentMockData, { status: 'failed' }),
showMetrics: true,
}); });
}); });
......
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