-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[dashboard] adding an option to duplicate slices when "Saving AS" (#3391
- Loading branch information
1 parent
3b4cd81
commit e53f303
Showing
10 changed files
with
135 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
|
||
const propTypes = { | ||
checked: PropTypes.bool.isRequired, | ||
onChange: PropTypes.func.isRequired, | ||
style: PropTypes.object, | ||
}; | ||
|
||
export default function Checkbox({ checked, onChange, style }) { | ||
return ( | ||
<span style={style}> | ||
<i | ||
className={`fa fa-check ${checked ? 'text-primary' : 'text-transparent'}`} | ||
onClick={onChange.bind(!checked)} | ||
style={{ | ||
border: '1px solid #aaa', | ||
borderRadius: '2px', | ||
cursor: 'pointer', | ||
}} | ||
/> | ||
</span>); | ||
} | ||
Checkbox.propTypes = propTypes; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
superset/assets/spec/javascripts/components/Checkbox_spec.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import React from 'react'; | ||
import { expect } from 'chai'; | ||
import { describe, it } from 'mocha'; | ||
import sinon from 'sinon'; | ||
import { shallow } from 'enzyme'; | ||
|
||
import Checkbox from '../../../javascripts/components/Checkbox'; | ||
|
||
describe('Checkbox', () => { | ||
const defaultProps = { | ||
checked: true, | ||
onChange: sinon.spy(), | ||
}; | ||
|
||
let wrapper; | ||
const factory = (o) => { | ||
const props = Object.assign({}, defaultProps, o); | ||
return shallow(<Checkbox {...props} />); | ||
}; | ||
beforeEach(() => { | ||
wrapper = factory({}); | ||
}); | ||
it('is a valid element', () => { | ||
expect(React.isValidElement(<Checkbox {...defaultProps} />)).to.equal(true); | ||
}); | ||
it('inits checked when checked', () => { | ||
expect(wrapper.find('i.fa-check.text-primary')).to.have.length(1); | ||
}); | ||
it('inits unchecked when not checked', () => { | ||
const el = factory({ checked: false }); | ||
expect(el.find('i.fa-check.text-primary')).to.have.length(0); | ||
expect(el.find('i.fa-check.text-transparent')).to.have.length(1); | ||
}); | ||
it('unchecks when clicked', () => { | ||
expect(wrapper.find('i.fa-check.text-transparent')).to.have.length(0); | ||
wrapper.find('i').first().simulate('click'); | ||
expect(defaultProps.onChange.calledOnce).to.equal(true); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters