-
Notifications
You must be signed in to change notification settings - Fork 900
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(application): reactify delete application section (#7501)
- Loading branch information
Jammy Louie
committed
Oct 8, 2019
1 parent
b8207c4
commit babbe88
Showing
7 changed files
with
80 additions
and
79 deletions.
There are no files selected for viewing
58 changes: 58 additions & 0 deletions
58
app/scripts/modules/core/src/application/config/DeleteApplicationSection.tsx
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,58 @@ | ||
import * as React from 'react'; | ||
|
||
import { Application, ApplicationWriter } from 'core/application'; | ||
import { ReactInjector } from 'core/reactShims'; | ||
import { FirewallLabel } from 'core/securityGroup/label'; | ||
|
||
export interface IDeleteApplicationSection { | ||
application: Application; | ||
} | ||
|
||
export function DeleteApplicationSection(props: IDeleteApplicationSection) { | ||
const { application } = props; | ||
const deleteApplication = (): void => { | ||
const taskMonitor = { | ||
application, | ||
title: `Deleting ${application.name}`, | ||
hasKatoTask: false, | ||
onTaskComplete: () => { | ||
ReactInjector.$state.go('home.infrastructure'); | ||
}, | ||
}; | ||
|
||
ReactInjector.confirmationModalService.confirm({ | ||
header: `Really delete ${application.name} ?`, | ||
buttonText: `Delete ${application.name}`, | ||
provider: 'aws', | ||
taskMonitorConfig: taskMonitor, | ||
submitMethod: () => ApplicationWriter.deleteApplication(application.attributes), | ||
}); | ||
}; | ||
|
||
if (application.notFound) { | ||
return ( | ||
<> | ||
<p>Application not found.</p> | ||
</> | ||
); | ||
} else { | ||
return Boolean(application.serverGroups.data.length) ? ( | ||
<> | ||
<p>You cannot delete this application because it has server groups.</p> | ||
</> | ||
) : ( | ||
<> | ||
<p> | ||
Deleting the application only removes the associated metadata around the application. It will{' '} | ||
<strong>not</strong> delete any <FirewallLabel label="firewalls" />, load balancers, or pipeline | ||
configurations you may have created. | ||
</p> | ||
<button className="btn btn-link clickable" onClick={deleteApplication}> | ||
<span> | ||
<span className="glyphicon glyphicon-trash" /> Delete Application | ||
</span> | ||
</button> | ||
</> | ||
); | ||
} | ||
} |
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
13 changes: 0 additions & 13 deletions
13
app/scripts/modules/core/src/application/config/deleteApplicationSection.directive.html
This file was deleted.
Oops, something went wrong.
65 changes: 0 additions & 65 deletions
65
app/scripts/modules/core/src/application/config/deleteApplicationSection.directive.js
This file was deleted.
Oops, something went wrong.
8 changes: 8 additions & 0 deletions
8
app/scripts/modules/core/src/application/config/deleteApplicationSection.module.ts
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,8 @@ | ||
import { module } from 'angular'; | ||
import { react2angular } from 'react2angular'; | ||
import { DeleteApplicationSection } from './DeleteApplicationSection'; | ||
export const DELETE_APPLICATION_SECTION = 'spinnaker.core.application.config.delete.directive'; | ||
module(DELETE_APPLICATION_SECTION, []).component( | ||
'deleteApplicationSection', | ||
react2angular(DeleteApplicationSection, ['application']), | ||
); |
11 changes: 11 additions & 0 deletions
11
app/scripts/modules/core/src/securityGroup/label/FirewallLabel.tsx
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,11 @@ | ||
import * as React from 'react'; | ||
|
||
import { FirewallLabels } from './FirewallLabels'; | ||
|
||
export interface IFirewallLabel { | ||
label: string; | ||
} | ||
|
||
export function FirewallLabel(props: IFirewallLabel) { | ||
return <span>{FirewallLabels.get(props.label)}</span>; | ||
} |
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 |
---|---|---|
@@ -1 +1,2 @@ | ||
export * from './FirewallLabel'; | ||
export * from './FirewallLabels'; |