-
Notifications
You must be signed in to change notification settings - Fork 16
DM-7803: add time series launch capability to suit app. #325
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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 hidden or 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 hidden or 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,78 @@ | ||
/* | ||
* License information at https://github.com/Caltech-IPAC/firefly/blob/master/License.txt | ||
*/ | ||
|
||
import React, {Component,PropTypes} from 'react'; | ||
import sCompare from 'react-addons-shallow-compare'; | ||
|
||
import {flux} from '../../Firefly.js'; | ||
import {getTblInfoById, getActiveTableId} from '../TableUtil.js'; | ||
|
||
/** | ||
* This button will track the highlighted row of the given tbl_id or of the active table of the given tbl_grp. | ||
* There are 2 callbacks available as props. | ||
* onClick: This function is called when a user click on this button. | ||
* onChange({tbl_id, highlightedRow}): This function is called when highlightedRow changes. | ||
* The returned object of this function will be set into state. | ||
* Props like show or title can be changed via this function. | ||
*/ | ||
export class ActiveTableButton extends Component { | ||
|
||
constructor(props) { | ||
super(props); | ||
this.state = {...props}; | ||
this.onClick = this.onClick.bind(this); | ||
} | ||
|
||
componentDidMount() { | ||
this.removeListener= flux.addListener(() => this.storeUpdate()); | ||
} | ||
|
||
componentWillUnmount() { | ||
this.removeListener && this.removeListener(); | ||
this.isUnmounted = true; | ||
} | ||
|
||
storeUpdate() { | ||
if (!this.isUnmounted) { | ||
var {tbl_id, tbl_grp, onChange} = this.props; | ||
tbl_id = tbl_id || getActiveTableId(tbl_grp); | ||
const {highlightedRow} = getTblInfoById(tbl_id); | ||
|
||
if (sCompare(this, this.props, Object.assign({}, this.state, {tbl_id, highlightedRow}))) { | ||
this.setState({tbl_id, highlightedRow}); | ||
onChange && this.setState(onChange({tbl_id, highlightedRow})); | ||
} | ||
} | ||
} | ||
|
||
onClick() { | ||
const {onClick} = this.props; | ||
const {tbl_id, highlightedRow} = this.state; | ||
onClick && onClick({tbl_id, highlightedRow}); | ||
} | ||
|
||
render() { | ||
const {show=true, title, style, type='standard'} = this.state; | ||
const astyle = Object.assign({textOverflow: 'ellipsis', maxWidth: 200, overflow: 'hidden'}, style); | ||
const className = type === 'standard' ? 'button std' : 'button std hl'; | ||
return show && ( | ||
<button type = 'button' className={className} onClick = {this.onClick}> | ||
<div title={title} style={astyle}>{title}</div> | ||
</button> | ||
); | ||
} | ||
} | ||
|
||
|
||
ActiveTableButton.propTypes = { | ||
tbl_id : PropTypes.string, | ||
tbl_grp : PropTypes.string, | ||
show : PropTypes.bool, | ||
title : PropTypes.string, | ||
type : PropTypes.oneOf(['standard', 'highlight']), | ||
style : PropTypes.object, | ||
onChange : PropTypes.func, | ||
onClick : PropTypes.func | ||
}; | ||
|
This file contains hidden or 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 hidden or 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 hidden or 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.
I had a little trouble figuring out how this all worked. The key is the onChanges function that takes a table_id and a highlighted row and return a boolean and a title. I think this should be documented.