This repository has been archived by the owner on Apr 15, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 60
Implement custom alert dialogs in React - Closes #515 #526
Merged
Merged
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
5be5289
Implement Alert dialogs
slaweet 6243f3a
Add alert dialog stories
slaweet 96900e5
Use alert dialogs in send dialog
slaweet 7ea3bfb
Add unit tests for alert dialogs
slaweet a4acdd7
Replace relative flexboxgrid imports with absolute
slaweet File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import React from 'react'; | ||
import Button from 'react-toolbox/lib/button'; | ||
import grid from '../../../node_modules/flexboxgrid/dist/flexboxgrid.css'; | ||
|
||
|
||
const Alert = props => ( | ||
<div> | ||
<p>{props.text}</p> | ||
<br /> | ||
<section className={`${grid.row} ${grid['between-xs']}`}> | ||
<span /> | ||
<Button label='Ok' onClick={props.closeDialog}/> | ||
</section> | ||
</div> | ||
); | ||
|
||
export default Alert; |
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,34 @@ | ||
import React from 'react'; | ||
import chai, { expect } from 'chai'; | ||
import { mount } from 'enzyme'; | ||
import sinon from 'sinon'; | ||
import sinonChai from 'sinon-chai'; | ||
import chaiEnzyme from 'chai-enzyme'; | ||
import Alert from './alert'; | ||
|
||
chai.use(sinonChai); | ||
chai.use(chaiEnzyme()); // Note the invocation at the end | ||
|
||
describe('Alert', () => { | ||
let wrapper; | ||
let closeSpy; | ||
const text = 'some random text'; | ||
|
||
beforeEach(() => { | ||
closeSpy = sinon.spy(); | ||
wrapper = mount(<Alert text={text} closeDialog={closeSpy} />); | ||
}); | ||
|
||
it('renders paragraph with props.text', () => { | ||
expect(wrapper.find('p').text()).to.equal(text); | ||
}); | ||
|
||
it('renders "Ok" Button', () => { | ||
expect(wrapper.find('Button').text()).to.equal('Ok'); | ||
}); | ||
|
||
it('renders "Ok" Button that calls props.closeDialog on click', () => { | ||
wrapper.find('Button').simulate('click'); | ||
expect(closeSpy).to.have.been.calledWith(); | ||
}); | ||
}); |
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 |
---|---|---|
|
@@ -38,3 +38,11 @@ | |
} | ||
} | ||
} | ||
|
||
.error { | ||
background-color: #c62828; | ||
} | ||
|
||
.success { | ||
background-color: #7cb342; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,16 @@ | ||
import { connect } from 'react-redux'; | ||
import Send from './send'; | ||
import { successAlertDialogDisplayed, errorAlertDialogDisplayed } from '../../actions/dialog'; | ||
|
||
const mapStateToProps = state => ({ | ||
account: state.account, | ||
activePeer: state.peers.data, | ||
}); | ||
|
||
export default connect(mapStateToProps)(Send); | ||
const mapDispatchToProps = dispatch => ({ | ||
showSuccessAlert: data => dispatch(successAlertDialogDisplayed(data)), | ||
showErrorAlert: data => dispatch(errorAlertDialogDisplayed(data)), | ||
}); | ||
|
||
export default connect(mapStateToProps, mapDispatchToProps)(Send); | ||
|
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For importing from npm modules, there's not need to use relative path.
flexboxgrid/dist/flexboxgrid.css';
would work fine.