github.com/argoproj/argo-cd/v2@v2.10.9/ui/src/app/applications/components/application-create-panel/set-finalizer-on-application.tsx (about)

     1  import {Checkbox, HelpIcon} from 'argo-ui';
     2  import * as React from 'react';
     3  import * as ReactForm from 'react-form';
     4  
     5  export const SetFinalizerOnApplication = ReactForm.FormField((props: {fieldApi: ReactForm.FieldApi}) => {
     6      const {
     7          fieldApi: {getValue, setValue}
     8      } = props;
     9      const finalizerVal = 'resources-finalizer.argocd.argoproj.io';
    10      const currentValue = getValue() || [];
    11      const index = currentValue.findIndex((item: string) => item === finalizerVal);
    12      const isChecked = index < 0 ? false : true;
    13      return (
    14          <div className='small-12 large-6' style={{borderBottom: '0'}}>
    15              <React.Fragment>
    16                  <Checkbox
    17                      id='set-finalizer'
    18                      checked={isChecked}
    19                      onChange={(state: boolean) => {
    20                          const value = getValue() || [];
    21                          if (!state) {
    22                              const i = value.findIndex((item: string) => item === finalizerVal);
    23                              if (i >= 0) {
    24                                  const tmp = value.slice();
    25                                  tmp.splice(i, 1);
    26                                  setValue(tmp);
    27                              }
    28                          } else {
    29                              const tmp = value.slice();
    30                              tmp.push(finalizerVal);
    31                              setValue(tmp);
    32                          }
    33                      }}
    34                  />
    35                  <label htmlFor={`set-finalizer`}>Set Deletion Finalizer</label>
    36                  <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.' />
    37              </React.Fragment>
    38          </div>
    39      );
    40  });