forked from vmware-tanzu/kubeapps
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add service catalog deprovision button (vmware-tanzu#60)
* add deprovision * delete selfLink instead of params * remove delete url * readability
- Loading branch information
Showing
5 changed files
with
76 additions
and
2 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,50 @@ | ||
import * as React from "react"; | ||
import { IServiceInstance } from "../../shared/ServiceCatalog"; | ||
|
||
interface IDeprovisionButtonProps { | ||
instance: IServiceInstance; | ||
deprovision: (instance: IServiceInstance) => Promise<{}>; | ||
} | ||
|
||
interface IDeprovisionButtonState { | ||
error: string | undefined; | ||
instance: IServiceInstance | undefined; | ||
isDeprovisioning: boolean; | ||
} | ||
|
||
class DeprovisionButton extends React.Component<IDeprovisionButtonProps, IDeprovisionButtonState> { | ||
public state: IDeprovisionButtonState = { | ||
error: undefined, | ||
instance: this.props.instance, | ||
isDeprovisioning: false, | ||
}; | ||
|
||
public handleDeprovision = async () => { | ||
const { deprovision, instance } = this.props; | ||
this.setState({ isDeprovisioning: true }); | ||
|
||
try { | ||
await deprovision(instance); | ||
this.setState({ isDeprovisioning: false }); | ||
} catch (err) { | ||
this.setState({ isDeprovisioning: false, error: err.toString() }); | ||
} | ||
}; | ||
|
||
public render() { | ||
return ( | ||
<div className="DeprovisionButton"> | ||
{this.state.isDeprovisioning && <div>Deprovisioning...</div>} | ||
<button | ||
className="button button-primary" | ||
disabled={this.state.isDeprovisioning} | ||
onClick={this.handleDeprovision} | ||
> | ||
Deprovision | ||
</button> | ||
</div> | ||
); | ||
} | ||
} | ||
|
||
export default DeprovisionButton; |
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