57 lines
1.5 KiB
JavaScript
57 lines
1.5 KiB
JavaScript
import React, { Component } from "react";
|
|
import { connect } from "react-redux";
|
|
import { RemoteService } from "../../remote";
|
|
import Device from "./devices/Device";
|
|
import NewSceneDevice from "./NewSceneDevice";
|
|
import { Grid } from "semantic-ui-react";
|
|
|
|
class ScenesPanel extends Component {
|
|
constructor(props) {
|
|
super(props);
|
|
}
|
|
|
|
render() {
|
|
return (
|
|
<Grid doubling columns={2} divided="vertically">
|
|
{!this.props.isActiveDefaultScene
|
|
? this.props.sceneStates.map((e, i) => {
|
|
return (
|
|
<Grid.Column key={i}>
|
|
<Device tab={this.props.tab} id={e} />
|
|
</Grid.Column>
|
|
);
|
|
})
|
|
: null}
|
|
{!this.props.isActiveDefaultScene ? (
|
|
<Grid.Column>
|
|
<NewSceneDevice />
|
|
</Grid.Column>
|
|
) : (
|
|
<Grid.Column>Welcome to the Scene View, you add a Scene</Grid.Column>
|
|
)}
|
|
</Grid>
|
|
);
|
|
}
|
|
}
|
|
|
|
const mapStateToProps = (state, _) => ({
|
|
get sceneStates() {
|
|
if (state.active.activeScene !== -1) {
|
|
const stateArray = [
|
|
...state.scenes[state.active.activeScene].sceneStates,
|
|
].sort();
|
|
return stateArray.map((id) => state.sceneStates[id]);
|
|
} else {
|
|
return [];
|
|
}
|
|
},
|
|
get isActiveDefaultScene() {
|
|
return state.active.activeScene === -1;
|
|
},
|
|
activeScene: state.active.activeScene,
|
|
});
|
|
const ScenesPanelContainer = connect(
|
|
mapStateToProps,
|
|
RemoteService
|
|
)(ScenesPanel);
|
|
export default ScenesPanelContainer;
|