-
Notifications
You must be signed in to change notification settings - Fork 356
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added flash messages to rbac user module.
- Loading branch information
1 parent
29bf2b5
commit 10a95b7
Showing
11 changed files
with
120 additions
and
15 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
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,15 @@ | ||
// TO-DO move this to separate file after we have css in webpack | ||
|
||
@keyframes FadeAnimation { | ||
0% { | ||
opacity: 1; | ||
} | ||
100% { | ||
opacity: 0; | ||
visibility: hidden; | ||
} | ||
} | ||
|
||
.react-fading-flash { | ||
animation: FadeAnimation 1s ease-out 4s forwards; | ||
} |
40 changes: 40 additions & 0 deletions
40
app/javascript/components/rbac-user-module/components/flash-messages.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,40 @@ | ||
import React, { Component } from 'react'; | ||
import { bindActionCreators } from 'redux'; | ||
import { connect } from 'react-redux'; | ||
import { Alert } from 'patternfly-react'; | ||
import { removeFlashMessage } from '../redux/actions'; | ||
|
||
class FlashMessage extends Component { | ||
componentDidMount() { | ||
const { message, onDismiss } = this.props; | ||
if (message.type !== 'error') { | ||
setTimeout(() => { | ||
onDismiss(message); | ||
}, 5000); | ||
} | ||
} | ||
render() { | ||
const { message: { text, type }, onDismiss } = this.props; | ||
return ( | ||
<div className={type !== 'error' ? 'react-fading-flash' : ''}> | ||
<Alert type={type} onDismiss={() => onDismiss(this.props.message)}> | ||
{text} | ||
</Alert> | ||
</div> | ||
); | ||
} | ||
} | ||
|
||
const FlashMessages = ({ flashMessages, removeFlashMessage }) => | ||
flashMessages.map(message => | ||
<FlashMessage key={message.flashId} message={message} onDismiss={removeFlashMessage}/>); | ||
|
||
const mapStateToProps = ({ usersReducer: { flashMessages } }) => ({ | ||
flashMessages, | ||
}); | ||
|
||
const mapDispatchToProps = dispatch => bindActionCreators({ | ||
removeFlashMessage, | ||
}, dispatch) | ||
|
||
export default connect(mapStateToProps, mapDispatchToProps)(FlashMessages); |
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
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