import React from 'react'; import type { Application } from '../application.model'; import { ConfirmationModalService } from '../../confirmationModal'; import { ReactInjector } from '../../reactShims'; import { FirewallLabel } from '../../securityGroup/label'; import { ApplicationWriter } from '../service/ApplicationWriter'; export interface IDeleteApplicationSection { application: Application; } export function DeleteApplicationSection(props: IDeleteApplicationSection) { const { application } = props; const deleteApplication = (): void => { const taskMonitor = { application, title: `Deleting ${application.name}`, onTaskComplete: () => { ReactInjector.$state.go('home.infrastructure'); }, }; ConfirmationModalService.confirm({ header: `Really delete ${application.name} ?`, buttonText: `Delete ${application.name}`, taskMonitorConfig: taskMonitor, submitMethod: () => ApplicationWriter.deleteApplication(application.attributes), }); }; if (application.notFound) { return ( <>
Application not found.
> ); } else if (application.hasError) { return ( <>Something went wrong loading {application.name}.
> ); } else { return Boolean(application.serverGroups.data.length) ? ( <>You cannot delete this application because it has server groups.
> ) : ( <>
Deleting the application only removes the associated metadata around the application. It will{' '}
not delete any