Skip to content

Commit

Permalink
Behold the glory of an anonymous component
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Merenbach committed Jul 10, 2018
1 parent da1223a commit 92125c5
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions src/app/applications/components/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,24 @@ import { services } from '../../shared/services';

export async function deleteApplication(appName: string, context: AppContext, success: () => void) {
let cascade = false;
const confirmed = await context.apis.popup.confirm('Delete application', () => (
<div>
<p>Are you sure you want to delete the application "{appName}"?</p>
<p><Checkbox checked={false} onChange={(val) => { cascade = val ? true : false }} /> Cascade</p>
</div>
));
const confirmationForm = class extends React.Component<{}, { cascade: boolean } > {
constructor(props: any) {
super(props);
this.state = {cascade: false};
}
public render() {
return (
<div>
<p>Are you sure you want to delete the application "{appName}"?</p>
<p><Checkbox checked={this.state.cascade} onChange={(val) => this.setState({ cascade: val })} /> Cascade</p>
</div>
)
}
componentWillUnmount() {
cascade = this.state.cascade;
}
};
const confirmed = await context.apis.popup.confirm('Delete application', confirmationForm);
if (confirmed) {
try {
await services.applications.delete(appName, cascade);
Expand Down

0 comments on commit 92125c5

Please sign in to comment.