function Main()

in s3-artifact-storage-ui/src/App/App.tsx [165:210]


function Main() {
  const config = useAppContext();
  // console.log(config);
  const resetUI = useJspContainer(
    '#storageParamsInner table.runnerFormTable, #saveButtons'
  );
  const formMethods = useS3Form();
  const storageOptions = useStorageOptions();

  const doReset = useCallback(
    (option: Option | null) => {
      resetUI();
      let ind = 0;
      if (option) {
        ind = storageOptions.findIndex((e) => e.key === option.key);
        ind = ind < 0 ? 0 : ind;
      }
      // @ts-ignore
      $('editStorageForm').storageType.selectedIndex = ind;
      // @ts-ignore
      $('editStorageForm')['-ufd-teamcity-ui-storageType'].value =
        option?.label || storageOptions[0].label;
      // @ts-ignore
      $('storageParams').updateContainer();
    },
    [resetUI, storageOptions]
  );

  const close = useCallback(() => {
    document.location.href = `${utils.resolveRelativeURL(
      '/admin/editProject.html'
    )}?projectId=${config.projectId}&tab=artifactsStorage`;
  }, [config.projectId]);

  return (
    <FormProvider {...formMethods}>
      <ControlsHeightContext.Provider value={ControlsHeight.S}>
        <BucketsContextProvider>
          <MainFormComponent onReset={doReset} onClose={close} />
          <StorageTypeChangedWarningDialog />
          {/*<DevTool control={formMethods.control} />*/}
        </BucketsContextProvider>
      </ControlsHeightContext.Provider>
    </FormProvider>
  );
}