summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClement Ho <408677-ClemMakesApps@users.noreply.gitlab.com>2019-08-20 14:51:31 +0000
committerGitLab Release Tools Bot <delivery-team+release-tools@gitlab.com>2019-08-23 10:08:41 +0000
commit8d6156cd60589ffe8baa1df4dab4b61a40949114 (patch)
treefb957c7bce8cb09b5c912c42402f04611feaf072
parent0aed49db1ef9b2df99cf1b1602a33a473d741cc3 (diff)
downloadgitlab-ce-8d6156cd60589ffe8baa1df4dab4b61a40949114.tar.gz
Merge branch 'tr-param-undefined-fix' into 'master'
Embed metrics undefined param fix Closes #66177 See merge request gitlab-org/gitlab-ce!31975 (cherry picked from commit 04b37e429466c9ec750936067c0a9c326e57a1c4) 1ebc87e9 Remove dashboard param when undefined 8122a21a Insert additional assertion 2c4e17f9 Ensure all params have the option to be dropped when falsy 3812e4f3 Use isNil check 5ed2c263 Add tests and null check 2ebe1715 Add change log entry
-rw-r--r--app/assets/javascripts/monitoring/components/dashboard.vue4
-rw-r--r--changelogs/unreleased/tr-param-undefined-fix.yml5
-rw-r--r--spec/javascripts/monitoring/dashboard_spec.js20
3 files changed, 27 insertions, 2 deletions
diff --git a/app/assets/javascripts/monitoring/components/dashboard.vue b/app/assets/javascripts/monitoring/components/dashboard.vue
index dfeeba238ca..c414c26ca61 100644
--- a/app/assets/javascripts/monitoring/components/dashboard.vue
+++ b/app/assets/javascripts/monitoring/components/dashboard.vue
@@ -264,12 +264,12 @@ export default {
showToast() {
this.$toast.show(__('Link copied to clipboard'));
},
+ // TODO: END
generateLink(group, title, yLabel) {
const dashboard = this.currentDashboard || this.firstDashboard.path;
- const params = { dashboard, group, title, y_label: yLabel };
+ const params = _.pick({ dashboard, group, title, y_label: yLabel }, value => value != null);
return mergeUrlParams(params, window.location.href);
},
- // TODO: END
hideAddMetricModal() {
this.$refs.addMetricModal.hide();
},
diff --git a/changelogs/unreleased/tr-param-undefined-fix.yml b/changelogs/unreleased/tr-param-undefined-fix.yml
new file mode 100644
index 00000000000..0a9051485bd
--- /dev/null
+++ b/changelogs/unreleased/tr-param-undefined-fix.yml
@@ -0,0 +1,5 @@
+---
+title: Fix for embedded metrics undefined params
+merge_request: 31975
+author:
+type: fixed
diff --git a/spec/javascripts/monitoring/dashboard_spec.js b/spec/javascripts/monitoring/dashboard_spec.js
index 624d8b14c8f..02c3f303912 100644
--- a/spec/javascripts/monitoring/dashboard_spec.js
+++ b/spec/javascripts/monitoring/dashboard_spec.js
@@ -414,6 +414,26 @@ describe('Dashboard', () => {
expect(clipboardText()).toContain(`y_label=`);
});
+ it('undefined parameter is stripped', done => {
+ wrapper.setProps({ currentDashboard: undefined });
+
+ wrapper.vm.$nextTick(() => {
+ expect(clipboardText()).not.toContain(`dashboard=`);
+ expect(clipboardText()).toContain(`y_label=`);
+ done();
+ });
+ });
+
+ it('null parameter is stripped', done => {
+ wrapper.setProps({ currentDashboard: null });
+
+ wrapper.vm.$nextTick(() => {
+ expect(clipboardText()).not.toContain(`dashboard=`);
+ expect(clipboardText()).toContain(`y_label=`);
+ done();
+ });
+ });
+
it('creates a toast when clicked', () => {
spyOn(wrapper.vm.$toast, 'show').and.stub();