| 
									
										
										
										
											2018-12-20 23:55:02 +08:00
										 |  |  | import React from 'react'; | 
					
						
							| 
									
										
										
										
											2019-01-11 20:53:04 +08:00
										 |  |  | import StackdriverDatasource from '../datasource'; | 
					
						
							| 
									
										
										
										
											2018-12-20 23:55:02 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | export interface Props { | 
					
						
							| 
									
										
										
										
											2019-01-11 20:53:04 +08:00
										 |  |  |   datasource: StackdriverDatasource; | 
					
						
							| 
									
										
										
										
											2018-12-20 23:55:02 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | interface State { | 
					
						
							|  |  |  |   projectName: string; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | export class Project extends React.Component<Props, State> { | 
					
						
							|  |  |  |   state: State = { | 
					
						
							|  |  |  |     projectName: 'Loading project...', | 
					
						
							|  |  |  |   }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   async componentDidMount() { | 
					
						
							|  |  |  |     const projectName = await this.props.datasource.getDefaultProject(); | 
					
						
							|  |  |  |     this.setState({ projectName }); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   render() { | 
					
						
							|  |  |  |     const { projectName } = this.state; | 
					
						
							|  |  |  |     return ( | 
					
						
							|  |  |  |       <div className="gf-form"> | 
					
						
							|  |  |  |         <span className="gf-form-label width-9 query-keyword">Project</span> | 
					
						
							|  |  |  |         <input className="gf-form-input width-15" disabled type="text" value={projectName} /> | 
					
						
							|  |  |  |       </div> | 
					
						
							|  |  |  |     ); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | } |