forked from argoproj/argo-cd
-
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.
feat: Added option for cascading deletion while creation of app (argo…
…proj#8645) * feat: Added option to set finalizer while creation of app for cascading deletion. Signed-off-by: rishabh625 <[email protected]> * Fixed UI to be aligned with Yaml,fixed linting docs Signed-off-by: rishabh625 <[email protected]> * moved React component SetFinalizerOnApplication into new file, as per keiths suggestion Signed-off-by: rishabh625 <[email protected]> * changed class name to remove some spaces,moved HelpIcon to right of text Signed-off-by: rishabh625 <[email protected]> * changed variable into camelCase,fixed to pass PR check Signed-off-by: rishabh625 <[email protected]> * Made finalizer to be appended into array instead of replacing Signed-off-by: rishabh625 <[email protected]> * Changed Variable names Signed-off-by: rishabh625 <[email protected]> * renamed file as per suggestions Signed-off-by: rishabh625 <[email protected]> * Added comment changes Signed-off-by: rishabh625 [email protected] Signed-off-by: rishabh625 <[email protected]>
- Loading branch information
1 parent
697636e
commit 185e580
Showing
4 changed files
with
56 additions
and
7 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
40 changes: 40 additions & 0 deletions
40
ui/src/app/applications/components/application-create-panel/set-finalizer-on-application.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,40 @@ | ||
import {Checkbox, HelpIcon} from 'argo-ui'; | ||
import * as React from 'react'; | ||
import * as ReactForm from 'react-form'; | ||
|
||
export const SetFinalizerOnApplication = ReactForm.FormField((props: {fieldApi: ReactForm.FieldApi}) => { | ||
const { | ||
fieldApi: {getValue, setValue} | ||
} = props; | ||
const finalizerVal = 'resources-finalizer.argocd.argoproj.io'; | ||
const currentValue = getValue() || []; | ||
const index = currentValue.findIndex((item: string) => item === finalizerVal); | ||
const isChecked = index < 0 ? false : true; | ||
return ( | ||
<div className='small-12 large-6' style={{borderBottom: '0'}}> | ||
<React.Fragment> | ||
<Checkbox | ||
id='set-finalizer' | ||
checked={isChecked} | ||
onChange={(state: boolean) => { | ||
const value = getValue() || []; | ||
if (!state) { | ||
const i = value.findIndex((item: string) => item === finalizerVal); | ||
if (i >= 0) { | ||
const tmp = value.slice(); | ||
tmp.splice(i, 1); | ||
setValue(tmp); | ||
} | ||
} else { | ||
const tmp = value.slice(); | ||
tmp.push(finalizerVal); | ||
setValue(tmp); | ||
} | ||
}} | ||
/> | ||
<label htmlFor={`set-finalizer`}>Set Deletion Finalizer</label> | ||
<HelpIcon title='If checked, the resources deletion finalizer will be set on the application. Potentially destructive, refer to the documentation for more information on the effects of the finalizer.' /> | ||
</React.Fragment> | ||
</div> | ||
); | ||
}); |