-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Allow icon and color props for ActionButton * Add ChannelPause button * Add actions to pause a channel
- Loading branch information
Showing
14 changed files
with
118 additions
and
26 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
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,42 @@ | ||
import React, { PropTypes } from "react" | ||
import { bindActionCreators } from "redux" | ||
import { connect } from "react-redux" | ||
import { translate } from "react-i18next" | ||
import { ActionButton } from "../ui" | ||
import * as actions from "../../actions/channel" | ||
|
||
const ChannelPause = ({ channel, t, actions }) => { | ||
if (!channel) return null | ||
const { statusInfo } = channel | ||
const paused = statusInfo != null && statusInfo.status == "paused" | ||
const text = paused ? t("Unpause channel") : t("Pause channel") | ||
const icon = paused ? "play_arrow" : "pause" | ||
const color = paused ? "green" : "red" | ||
|
||
const pauseChannel = (channel, pause) => { | ||
console.log(`About to ${pause ? "pause" : "unpause"} channel ${channel.id}`) | ||
if (pause) { | ||
actions.pause(channel) | ||
} else { | ||
actions.unpause(channel) | ||
} | ||
} | ||
|
||
return ActionButton({ text, onClick: (e) => pauseChannel(channel, !paused), icon, color }) | ||
} | ||
|
||
ChannelPause.propTypes = { | ||
t: PropTypes.func, | ||
channel: PropTypes.object, | ||
actions: PropTypes.object.isRequired, | ||
} | ||
|
||
const mapStateToProps = (state, ownProps) => ({ | ||
channel: state.channel.data, | ||
}) | ||
|
||
const mapDispatchToProps = (dispatch) => ({ | ||
actions: bindActionCreators(actions, dispatch), | ||
}) | ||
|
||
export default translate()(connect(mapStateToProps, mapDispatchToProps)(ChannelPause)) |
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
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