-
Notifications
You must be signed in to change notification settings - Fork 710
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #25 from prydonius/2.0-chart-install
add ChartDeployButton component for deploying charts
- Loading branch information
Showing
10 changed files
with
195 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
import * as React from 'react'; | ||
import { Chart } from '../store/types'; | ||
import { RouterAction } from 'react-router-redux'; | ||
import * as Modal from 'react-modal'; | ||
|
||
interface Props { | ||
chart: Chart; | ||
deployChart: (chart: Chart, releaseName: string, namespace: string) => Promise<{}>; | ||
push: (location: string) => RouterAction; | ||
} | ||
|
||
interface State { | ||
isDeploying: boolean; | ||
modalIsOpen: boolean; | ||
// deployment options | ||
releaseName: string; | ||
namespace: string; | ||
error: string | null; | ||
} | ||
|
||
class ChartDeployButton extends React.Component<Props> { | ||
state: State = { | ||
isDeploying: false, | ||
modalIsOpen: false, | ||
releaseName: '', | ||
namespace: 'default', | ||
error: null, | ||
}; | ||
|
||
render() { | ||
return ( | ||
<div className="ChartDeployButton"> | ||
{this.state.isDeploying && | ||
<div>Deploying...</div> | ||
} | ||
<button | ||
className="button button-primary" | ||
onClick={this.openModel} | ||
disabled={this.state.isDeploying} | ||
> | ||
Deploy | ||
</button> | ||
<Modal | ||
isOpen={this.state.modalIsOpen} | ||
onRequestClose={this.closeModal} | ||
contentLabel="Modal" | ||
> | ||
{this.state.error && | ||
<div className="container padding-v-bigger bg-action"> | ||
{this.state.error} | ||
</div>} | ||
<form onSubmit={this.handleDeploy}> | ||
<div> | ||
<label htmlFor="releaseName">Name</label> | ||
<input | ||
id="releaseName" | ||
onChange={this.handleReleaseNameChange} | ||
value={this.state.releaseName} | ||
required={true} | ||
/> | ||
</div> | ||
<div> | ||
<label htmlFor="namespace">Namespace</label> | ||
<input | ||
name="namespace" | ||
onChange={this.handleNamespaceChange} | ||
value={this.state.namespace} | ||
/> | ||
</div> | ||
<div> | ||
<button className="button button-primary" type="submit">Submit</button> | ||
<button className="button" onClick={this.closeModal}>Cancel</button> | ||
</div> | ||
</form> | ||
</Modal> | ||
</div> | ||
); | ||
} | ||
|
||
openModel = () => { | ||
this.setState({ | ||
modalIsOpen: true | ||
}); | ||
} | ||
|
||
closeModal = () => { | ||
this.setState({ | ||
modalIsOpen: false | ||
}); | ||
} | ||
|
||
handleDeploy = (e: React.FormEvent<HTMLFormElement>) => { | ||
e.preventDefault(); | ||
const { chart, deployChart, push } = this.props; | ||
this.setState({isDeploying: true}); | ||
const { releaseName, namespace } = this.state; | ||
deployChart(chart, releaseName, namespace) | ||
.then(() => push(`/apps/${releaseName}`)) | ||
.catch(err => this.setState({isDeploying: false, error: err.toString()})); | ||
} | ||
|
||
handleReleaseNameChange = (e: React.FormEvent<HTMLInputElement>) => { | ||
this.setState({ releaseName: e.currentTarget.value }); | ||
} | ||
handleNamespaceChange = (e: React.FormEvent<HTMLInputElement>) => { | ||
this.setState({ namespace: e.currentTarget.value }); | ||
} | ||
} | ||
|
||
export default ChartDeployButton; |
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