-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor devicelist page #435
Merged
Merged
Changes from 18 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
7dc4b04
rename VerticalTabs to tabs & simplify props
arejayelle 11c086c
Simplify TabPanel component
arejayelle 66b46a5
Sikmplify wrapping of DevicesTable
arejayelle 0be6cf1
lint & cleanup imports
arejayelle 3813b60
Create DeviceListPageContents.jsx
arejayelle d2d0876
Create DeviceTableTitle component to allow selecting view type
arejayelle 2c7dc34
Replace DLTabTable with DLPageContents and cleanup files & imports
arejayelle fd4979b
update tests
arejayelle b6d962f
revertchanges (will be handled in another PR)
arejayelle 569602b
STYLE THE TABLE TITLE :fire:
arejayelle bdb144d
🦀🦀🦀 Add test for DeviceListPageContents 🦀🦀🦀
arejayelle 734bfda
lint
arejayelle 1e1f32c
Create DeviceTableTitle.test.jsx
arejayelle 0cb931a
lint and add afterEach block
arejayelle 7e0a40e
add test for handleChange
arejayelle 2125f4d
setState tests
arejayelle 416203e
fix DevicesTable props validation to accept nodes
arejayelle 0c23e63
lint
arejayelle 7f2c348
Update DeviceListPageContents.test.jsx to test return type
arejayelle 0ac2f25
lint
arejayelle 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import React from "react"; | ||
|
||
import { getSenders, getReceivers } from "../api/DeviceApi"; | ||
import DeviceTableTitle from "./DeviceTableTitle"; | ||
import DevicesTable from "./DevicesTable"; | ||
|
||
export default class DeviceListPageContents extends React.Component { | ||
constructor(props) { | ||
super(props); | ||
this.state = { | ||
selected: 0, | ||
senders: [], | ||
receivers: [] | ||
}; | ||
|
||
this.handleChange = this.handleChange.bind(this); | ||
this.handleSendersChange = this.handleSendersChange.bind(this); | ||
this.handleReceiversChange = this.handleReceiversChange.bind(this); | ||
} | ||
|
||
componentDidMount() { | ||
getSenders(this.handleSendersChange); | ||
getReceivers(this.handleReceiversChange); | ||
} | ||
|
||
handleChange(value) { | ||
this.setState({ | ||
selected: value | ||
}); | ||
} | ||
|
||
handleSendersChange(senders) { | ||
this.setState({ | ||
senders | ||
}); | ||
} | ||
|
||
handleReceiversChange(receivers) { | ||
this.setState({ | ||
receivers | ||
}); | ||
} | ||
|
||
getDevices() { | ||
const { receivers, senders, selected } = this.state; | ||
switch (selected) { | ||
case 1: | ||
return senders; | ||
case 2: | ||
return receivers; | ||
default: | ||
return senders.concat(receivers); | ||
} | ||
} | ||
|
||
getTitle() { | ||
const { selected } = this.state; | ||
return ( | ||
<DeviceTableTitle index={selected} handleChange={this.handleChange} /> | ||
); | ||
} | ||
|
||
render() { | ||
return <DevicesTable devices={this.getDevices()} title={this.getTitle()} />; | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
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,38 @@ | ||
import React from "react"; | ||
import PropTypes from "prop-types"; | ||
import { MenuItem, Select } from "@material-ui/core"; | ||
import StyledInput from "./StyledInput"; | ||
|
||
export default class DeviceTableTitle extends React.Component { | ||
constructor(props) { | ||
super(props); | ||
|
||
this.handleChange = this.handleChange.bind(this); | ||
} | ||
|
||
handleChange(event) { | ||
const { handleChange } = this.props; | ||
handleChange(event.target.value); | ||
} | ||
|
||
render() { | ||
const { index } = this.props; | ||
return ( | ||
<Select | ||
id="device-table-title-select" | ||
value={index} | ||
onChange={this.handleChange} | ||
input={<StyledInput />} | ||
> | ||
<MenuItem value={0}>All Devices</MenuItem> | ||
<MenuItem value={1}>Senders</MenuItem> | ||
<MenuItem value={2}>Receivers</MenuItem> | ||
</Select> | ||
); | ||
} | ||
} | ||
|
||
DeviceTableTitle.propTypes = { | ||
index: PropTypes.number.isRequired, | ||
handleChange: PropTypes.func.isRequired | ||
}; |
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 |
---|---|---|
|
@@ -149,6 +149,6 @@ export default function DevicesTable(props) { | |
} | ||
|
||
DevicesTable.propTypes = { | ||
title: PropTypes.string.isRequired, | ||
title: PropTypes.node.isRequired, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. VERY SEXY that all you had to change in this file was this!!! \o/ |
||
devices: PropTypes.arrayOf(PropTypes.instanceOf(DeviceInfo)).isRequired | ||
}; |
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,18 @@ | ||
import { InputBase, withStyles } from "@material-ui/core"; | ||
|
||
export default withStyles({ | ||
input: { | ||
borderRadius: 4, | ||
position: "relative", | ||
fontWeight: 500, | ||
letterSpacing: "0.0075em", | ||
lineHeight: "1.6", | ||
fontSize: "1.25rem", | ||
padding: "10px 26px 10px 12px", | ||
"&:focus": { | ||
borderRadius: 4, | ||
borderColor: "#80bdff", | ||
boxShadow: "0 0 0 0.2rem rgba(0,123,255,.25)" | ||
} | ||
} | ||
})(InputBase); |
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.
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.
Why did you choose to inject the entire title component into
DevicesTable
rather than just have it in DevicesTable?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.
this makes it read cleaner and is easier to test