Skip to content
Snippets Groups Projects
Commit 87a2a7a2 authored by Clement Ho's avatar Clement Ho Committed by 🤖 GitLab Bot 🤖
Browse files

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 04b37e42)

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
parent 66abd260
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -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();
},
Loading
Loading
---
title: Fix for embedded metrics undefined params
merge_request: 31975
author:
type: fixed
Loading
Loading
@@ -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
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment