Embed metrics undefined param fix
This commit is contained in:
parent
b483598b1e
commit
a6319d1726
|
@ -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();
|
||||
},
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
title: Fix for embedded metrics undefined params
|
||||
merge_request: 31975
|
||||
author:
|
||||
type: fixed
|
|
@ -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();
|
||||
|
||||
|
|
Loading…
Reference in New Issue