Skip to content
Snippets Groups Projects
Commit 493e40e2 authored by Jonathan Eatherly's avatar Jonathan Eatherly
Browse files

Fix question url handling of query array values. Remove checkbox onChange prop function requirement

parent 5040ff87
No related branches found
No related tags found
No related merge requests found
......@@ -7,7 +7,7 @@ import { normal as defaultColors } from "metabase/lib/colors";
export default class CheckBox extends Component {
static propTypes = {
checked: PropTypes.bool,
onChange: PropTypes.func.isRequired,
onChange: PropTypes.func,
color: PropTypes.oneOf(defaultColors),
size: PropTypes.number, // TODO - this should probably be a concrete set of options
padding: PropTypes.number// TODO - the component should pad itself properly based on the size
......
......@@ -13,7 +13,7 @@ export function question(cardId, hash = "", query = "") {
query = Object.entries(query)
.map(kv => {
if (Array.isArray(kv[1])) {
return kv[1].map(v => `${kv[0]}=${v}`).join('&');
return kv[1].map(v => `${encodeURIComponent(kv[0])}=${encodeURIComponent(v)}`).join('&');
} else {
return kv.map(encodeURIComponent).join("=");
}
......
......@@ -130,7 +130,6 @@ export default class SelectPicker extends Component {
<label className="flex align-center cursor-pointer p1" onClick={() => this.selectValue(option.key, !checked.has(option.key))}>
<CheckBox
checked={checked.has(option.key)}
onChange={() => {}}
color='purple'
/>
<h4 className="ml1">{this.nameForOption(option)}</h4>
......
import { question } from "metabase/lib/urls";
describe("urls", () => {
describe("question", () => {
describe("with a query", () => {
it("returns the correct url", () => {
expect(question(null, "", {foo: 'bar'})).toEqual('/question?foo=bar');
expect(question(null, "", {foo: 'bar+bar'})).toEqual('/question?foo=bar%2Bbar');
expect(question(null, "", {foo: ['bar', 'baz']})).toEqual('/question?foo=bar&foo=baz');
expect(question(null, "", {foo: ['bar', 'baz+bay']})).toEqual('/question?foo=bar&foo=baz%2Bbay');
expect(question(null, "", {foo: ['bar', 'baz&bay']})).toEqual('/question?foo=bar&foo=baz%26bay');
});
});
});
});
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