This repository has been archived by the owner on Sep 28, 2020. It is now read-only.
forked from mattermost/mattermost-webapp
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
9 changed files
with
306 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
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,52 @@ | ||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. | ||
// See LICENSE.txt for license information. | ||
import PropTypes from 'prop-types'; | ||
import React from 'react'; | ||
import Select from 'react-select'; | ||
|
||
export default class TimePicker extends React.PureComponent { | ||
static proptypes = { | ||
keyValue: PropTypes.string, | ||
defaultValue: PropTypes.string, | ||
submit: PropTypes.func.isRequired, | ||
options: PropTypes.array.isRequired, | ||
}; | ||
|
||
constructor(props) { | ||
super(props); | ||
this.onSelectChange = this.onSelectChange.bind(this); | ||
this.state = { | ||
// eslint-disable-next-line react/prop-types | ||
selectedOption: {value: this.props.defaultValue, label: this.props.defaultValue}, | ||
}; | ||
} | ||
async onSelectChange(selectedOption) { | ||
this.setState({selectedOption}, async () => { | ||
// eslint-disable-next-line react/prop-types | ||
await this.props.submit(this.props.keyValue, selectedOption.label); | ||
}); | ||
} | ||
|
||
render() { | ||
// eslint-disable-next-line react/prop-types | ||
var options = this.props.options; | ||
return ( | ||
<Select | ||
value={this.state.selectedOption} | ||
styles={customStyles} | ||
onChange={this.onSelectChange} | ||
options={options} | ||
/> | ||
); | ||
} | ||
} | ||
|
||
const customStyles = { | ||
control: (base) => ({ | ||
...base, | ||
width: '150px', | ||
minHeight: '10px', | ||
textAlign: 'center', | ||
}), | ||
}; | ||
|
Oops, something went wrong.