All files / modules/75-ce/components/COAccessPointList AzureAccessPointForm.tsx

77.94% Statements 106/136
74.29% Branches 315/424
55% Functions 22/40
82.17% Lines 106/129

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629              10x 10x 10x 10x 10x 10x                     10x 10x 10x 10x 10x                     10x 10x                                                   10x             10x       10x                           10x 9x 9x 9x 9x         9x   9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x         9x         9x   9x                       9x                       9x                             9x                               9x                               9x                       9x 3x 1x 1x       1x       9x 3x       3x 3x         3x 3x 3x     9x 3x       3x 3x         3x   3x   3x     9x 5x 1x 1x       9x 3x       3x 3x         3x 3x 3x     9x 3x       3x 3x         3x     9x 3x       3x 3x         3x     9x 3x       3x 3x         3x     9x 6x 1x                 1x                       9x                                                                   9x 12x                     9x       9x       9x                         9x       9x       9x 50x       9x                                                   12x               1x                                     1x                                                                                                                         1x                                                                                                                                                                                           10x  
/*
 * Copyright 2021 Harness Inc. All rights reserved.
 * Use of this source code is governed by the PolyForm Shield 1.0.0 license
 * that can be found in the licenses directory at the root of this repository, also available at
 * https://polyformproject.org/wp-content/uploads/2020/06/PolyForm-Shield-1.0.0.txt.
 */
 
import React, { useEffect, useState } from 'react'
import { useParams } from 'react-router-dom'
import * as Yup from 'yup'
import cx from 'classnames'
import { isEmpty as _isEmpty } from 'lodash-es'
import {
  Button,
  Container,
  Formik,
  FormikForm,
  FormInput,
  Icon,
  Layout,
  SelectOption,
  Text
} from '@wings-software/uicore'
import { useModalHook } from '@harness/use-modal'
import { Color } from '@harness/design-system'
import { Dialog } from '@blueprintjs/core'
import { useToaster } from '@common/exports'
import {
  AccessPoint,
  useAllRegions,
  useAllResourceGroups,
  useAllVPCs,
  useAllSubnets,
  useAllPublicIps,
  useAllCertificates,
  CertificateData
} from 'services/lw'
import type { AccessPointScreenMode } from '@ce/types'
import CertificateUpload from './CertificateUploadScreen'
import css from '../COGatewayAccess/COGatewayAccess.module.scss'
 
export interface AzureApFormVal {
  ip?: string
  region: string
  resourceGroup: string
  sku: string
  subnet?: string
  virtualNetwork: string
  certificate: string
  newCertificate?: CertificateData
  fe_ip_name?: string
  subnet_name?: string
  func_region: string
}
 
interface AzureAccessPointFormProps {
  onSave: (savedAp: AccessPoint) => void
  cloudAccountId: string
  handlePreviousClick: (values: AzureApFormVal) => void
  lbCreationInProgress: boolean
  handleFormSubmit: (val: AzureApFormVal) => void
  loadBalancer: AccessPoint
  mode: AccessPointScreenMode
}
 
const SKUItems: SelectOption[] = [
  { label: 'SKU 1, Small', value: 'sku1_small' },
  { label: 'SKU 1, Medium', value: 'sku1_medium' },
  { label: 'SKU 1, Large', value: 'sku1_large' },
  { label: 'SKU2', value: 'sku2' }
]
 
const DEFAULT_FUNC_REGION = 'westus2'
 
type AllFieldsKey = keyof AzureApFormVal & keyof CertificateData
 
const lbFieldToFormFieldMap: Record<string, keyof AllFieldsKey> = {
  'metadata.fe_ip_id': 'ip',
  region: 'region',
  'metadata.resource_group': 'resourceGroup',
  'metadata.size': 'sku',
  'metadata.subnet_id': 'subnet',
  vpc: 'virtualNetwork',
  'metadata.certificate_id': 'certificate',
  'metadata.certificate.name': 'name',
  'metadata.certificate.password': 'password',
  'metadata.certificate.content': 'content',
  'metadata.func_region': 'func_region'
}
 
const AzureAccessPointForm: React.FC<AzureAccessPointFormProps> = props => {
  const { cloudAccountId, lbCreationInProgress, loadBalancer, mode } = props
  const isCreateMode = mode === 'create'
  const isEditMode = mode === 'edit'
  const { accountId } = useParams<{
    accountId: string
    orgIdentifier: string
    projectIdentifier: string
  }>()
  const { showSuccess } = useToaster()
 
  const [regionsOptions, setRegionsOptions] = useState<SelectOption[]>([])
  const [resourceGroupsOptions, setResourceGroupsOptions] = useState<SelectOption[]>([])
  const [vpcOptions, setVpcOptions] = useState<SelectOption[]>([])
  const [subnetsOptions, setSubnetsOptions] = useState<SelectOption[]>([])
  const [publicIpsOptions, setPublicIpsOptions] = useState<SelectOption[]>([])
  const [certificatesOptions, setCertificatesOptions] = useState<SelectOption[]>([])
  const [selectedRegion, setSelectedRegion] = useState<SelectOption>()
  const [selectedVpc, setSelectedVpc] = useState<SelectOption>()
  const [selectedResourceGroup, setSelectedResourceGroup] = useState<SelectOption>()
  const [newCertificate, setNewCertificate] = useState<CertificateData | undefined>(loadBalancer.metadata?.certificate)
  const [newFrontendIp, setNewFrontendIp] = useState<SelectOption | undefined>(
    loadBalancer.metadata?.fe_ip_name
      ? { label: loadBalancer.metadata.fe_ip_name, value: loadBalancer.metadata.fe_ip_name }
      : undefined
  )
  const [newSubnet, setNewSubnet] = useState<SelectOption | undefined>(
    loadBalancer.metadata?.subnet_name
      ? { label: loadBalancer.metadata.subnet_name, value: loadBalancer.metadata.subnet_name }
      : undefined
  )
  const [editableFieldsMap, setEditableFieldsMap] = useState<Record<string, boolean>>({})
 
  const { data: regions, loading: regionsLoading } = useAllRegions({
    account_id: accountId, // eslint-disable-line
    queryParams: {
      cloud_account_id: cloudAccountId, // eslint-disable-line
      accountIdentifier: accountId
    }
  })
 
  const {
    data: resourceGroups,
    loading: resourceGroupsLoading,
    refetch: refetchResourceGroups
  } = useAllResourceGroups({
    account_id: accountId, // eslint-disable-line
    queryParams: {
      cloud_account_id: cloudAccountId, // eslint-disable-line
      accountIdentifier: accountId
    }
  })
 
  const {
    data: vpcs,
    loading: vpcsLoading,
    refetch: vpcsReload
  } = useAllVPCs({
    account_id: accountId, // eslint-disable-line
    queryParams: {
      cloud_account_id: cloudAccountId,
      region: (selectedRegion?.value || loadBalancer.region) as string,
      resource_group_name: (selectedResourceGroup?.value || loadBalancer.metadata?.resource_group) as string,
      accountIdentifier: accountId
    },
    lazy: true
  })
 
  const {
    data: subnets,
    loading: subnetsLoading,
    refetch: subnetsReload
  } = useAllSubnets({
    account_id: accountId, // eslint-disable-line
    queryParams: {
      cloud_account_id: cloudAccountId,
      region: (selectedRegion?.value || loadBalancer.region) as string,
      vpc: (selectedVpc?.label || loadBalancer.vpc) as string,
      resource_group_name: (selectedResourceGroup?.value || loadBalancer.metadata?.resource_group) as string,
      accountIdentifier: accountId
    },
    lazy: true
  })
 
  const {
    data: publicIps,
    loading: publicIpsLoading,
    refetch: publicIpsReload
  } = useAllPublicIps({
    account_id: accountId, // eslint-disable-line
    queryParams: {
      cloud_account_id: cloudAccountId,
      region: (selectedRegion?.value || loadBalancer.region) as string,
      vpc: (selectedVpc?.label || loadBalancer.vpc) as string,
      resource_group_name: (selectedResourceGroup?.value || loadBalancer.metadata?.resource_group) as string,
      accountIdentifier: accountId
    },
    lazy: true
  })
 
  const {
    data: certificates,
    loading: certificatesLoading,
    refetch: certificatesReload
  } = useAllCertificates({
    account_id: accountId, // eslint-disable-line
    queryParams: {
      cloud_account_id: cloudAccountId,
      region: (selectedRegion?.value || loadBalancer.region) as string,
      resource_group_name: (selectedResourceGroup?.value || loadBalancer.metadata?.resource_group) as string,
      accountIdentifier: accountId,
      ...(loadBalancer.metadata?.app_gateway_id && { app_gateway_id: loadBalancer.metadata?.app_gateway_id })
    },
    lazy: true
  })
 
  useEffect(() => {
    if (mode !== 'create') {
      const editMap: Record<string, boolean> = {}
      loadBalancer.editables?.forEach(field => {
        const key = lbFieldToFormFieldMap[field]
        editMap[key as string] = true
      })
      setEditableFieldsMap(editMap)
    }
  }, [])
 
  useEffect(() => {
    Iif (regions?.response?.length == 0) {
      return
    }
    const loaded: SelectOption[] =
      regions?.response?.map(r => {
        return {
          label: r.label as string,
          value: r.name as string
        }
      }) || []
    setRegionsOptions(loaded)
    const savedRegion = loadBalancer.region && loaded.find(_option => _option.value === loadBalancer.region)
    Iif (savedRegion) setSelectedRegion(savedRegion)
  }, [regions, loadBalancer.region])
 
  useEffect(() => {
    Iif (resourceGroups?.response?.length == 0) {
      return
    }
    const loaded: SelectOption[] =
      resourceGroups?.response?.map(r => {
        return {
          label: r.name as string,
          value: r.name as string
        }
      }) || []
    setResourceGroupsOptions(loaded)
    const savedResourceGroup =
      loadBalancer.metadata?.resource_group &&
      loaded.find(_option => _option.value === loadBalancer.metadata?.resource_group)
    Iif (savedResourceGroup) setSelectedResourceGroup(savedResourceGroup)
  }, [resourceGroups, loadBalancer.metadata?.resource_group])
 
  useEffect(() => {
    if (selectedRegion?.value && selectedResourceGroup?.value) {
      vpcsReload()
      certificatesReload()
    }
  }, [selectedRegion, selectedResourceGroup])
 
  useEffect(() => {
    Iif (vpcs?.response?.length == 0) {
      return
    }
    const loaded: SelectOption[] =
      vpcs?.response?.map(r => {
        return {
          label: r.name as string,
          value: r.id as string
        }
      }) || []
    setVpcOptions(loaded)
    const savedVpc = loadBalancer.vpc && loaded.find(_option => _option.value === loadBalancer.vpc)
    Iif (savedVpc) setSelectedVpc(savedVpc)
  }, [vpcs, loadBalancer.vpc])
 
  useEffect(() => {
    Iif (subnets?.response?.length == 0) {
      return
    }
    const loaded: SelectOption[] =
      subnets?.response?.map(r => {
        return {
          label: r.name as string,
          value: r.id as string
        }
      }) || []
    setSubnetsOptions(loaded)
  }, [subnets])
 
  useEffect(() => {
    Iif (publicIps?.response?.length == 0) {
      return
    }
    const loaded: SelectOption[] =
      publicIps?.response?.map(r => {
        return {
          label: r.name as string,
          value: r.id as string
        }
      }) || []
    setPublicIpsOptions(loaded)
  }, [publicIps])
 
  useEffect(() => {
    Iif (certificates?.response?.length == 0) {
      return
    }
    const loaded: SelectOption[] =
      certificates?.response?.map(r => {
        return {
          label: r.name as string,
          value: r.id as string
        }
      }) || []
    setCertificatesOptions(loaded)
  }, [certificates])
 
  useEffect(() => {
    if (selectedRegion?.value && selectedVpc?.label && selectedResourceGroup?.value) {
      subnetsReload({
        queryParams: {
          cloud_account_id: cloudAccountId,
          region: selectedRegion?.value as string,
          vpc: selectedVpc?.label as string,
          resource_group_name: selectedResourceGroup?.value as string,
          accountIdentifier: accountId
        }
      })
      publicIpsReload({
        queryParams: {
          cloud_account_id: cloudAccountId,
          region: selectedRegion?.value as string,
          vpc: selectedVpc?.label as string,
          resource_group_name: selectedResourceGroup?.value as string,
          accountIdentifier: accountId
        }
      })
    }
  }, [selectedRegion, selectedResourceGroup, selectedVpc])
 
  const [openUploadCertiModal, closeUploadCertiModal] = useModalHook(() => {
    return (
      <Dialog
        onClose={closeUploadCertiModal}
        isOpen={true}
        style={{
          width: 650,
          padding: 40,
          position: 'relative',
          minHeight: 300
        }}
        enforceFocus={false}
      >
        <CertificateUpload
          editableFieldsMap={editableFieldsMap}
          mode={props.mode}
          onSubmit={_certificateDetails => {
            showSuccess(`Added ${_certificateDetails.name} successfully`)
            setNewCertificate(_certificateDetails)
            closeUploadCertiModal()
          }}
        />
        <Button
          minimal
          icon="cross"
          iconProps={{ size: 18 }}
          onClick={closeUploadCertiModal}
          style={{ position: 'absolute', right: 'var(--spacing-large)', top: 'var(--spacing-large)' }}
          data-testid={'close-certi-upload-modal'}
        />
      </Dialog>
    )
  }, [editableFieldsMap])
 
  const isFormValid = (validStatus: boolean) => {
    return (
      validStatus ||
      (loadBalancer.region &&
        loadBalancer.vpc &&
        loadBalancer.metadata?.resource_group &&
        (loadBalancer.metadata.subnet_id || loadBalancer.metadata.subnet_name) &&
        (loadBalancer.metadata.fe_ip_id || loadBalancer.metadata.fe_ip_name) &&
        loadBalancer.metadata.size)
    )
  }
 
  const isNewSubnetAdded = (subnetVal?: string) => {
    return _isEmpty(subnetsOptions.find(option => option.value === subnetVal))
  }
 
  const isNewFeIpAdded = (feIpVal?: string) => {
    return _isEmpty(publicIpsOptions.find(option => option.value === feIpVal))
  }
 
  const getValuesToSave = (values: AzureApFormVal): AzureApFormVal => {
    return {
      ...values,
      newCertificate,
      ...(isNewSubnetAdded(values.subnet)
        ? { subnet_name: values.subnet as string, subnet: undefined }
        : { subnet_name: undefined, subnet: values.subnet }),
      ...(isNewFeIpAdded(values.ip)
        ? { fe_ip_name: values.ip as string, ip: undefined }
        : { fe_ip_name: undefined, ip: values.ip })
    }
  }
 
  const handleSubmit = (values: AzureApFormVal) => {
    props.handleFormSubmit(getValuesToSave(values))
  }
 
  const handleBackClick = (values: AzureApFormVal) => {
    props.handlePreviousClick(getValuesToSave(values))
  }
 
  const renderRefreshButton = (cb: () => any, enforceRefresh?: boolean) =>
    (isCreateMode || enforceRefresh) && (
      <Button intent="none" text="Refresh" onClick={_ => cb()} minimal icon="refresh" />
    )
 
  return (
    <Container>
      <Formik
        initialValues={{
          ip: newFrontendIp ? (newFrontendIp.value as string) : loadBalancer.metadata?.fe_ip_id || '',
          region: loadBalancer.region || '',
          resourceGroup: loadBalancer.metadata?.resource_group || '',
          sku: loadBalancer.metadata?.size || '',
          subnet: newSubnet ? (newSubnet.value as string) : loadBalancer.metadata?.subnet_id || '',
          virtualNetwork: loadBalancer.vpc || '',
          certificate: loadBalancer.metadata?.certificate_id || '',
          func_region: loadBalancer.metadata?.func_region || DEFAULT_FUNC_REGION
        }}
        formName="azureAccessPt"
        onSubmit={handleSubmit}
        validationSchema={Yup.object().shape({
          ip: Yup.string().required(),
          region: Yup.string().required(),
          resourceGroup: Yup.string().required(),
          sku: Yup.string().required(),
          subnet: Yup.string().required(),
          virtualNetwork: Yup.string().required(),
          func_region: Yup.string().required()
        })}
      >
        {({ submitForm, isValid, values }) => (
          <FormikForm>
            <div className={css.formFieldRow}>
              <FormInput.Select
                label={'Region*'}
                placeholder={'Select region'}
                name="region"
                items={regionsOptions}
                onChange={regionItem => {
                  setSelectedRegion(regionItem)
                }}
                disabled={isEditMode ? !editableFieldsMap['region'] : !_isEmpty(values.region) ? false : regionsLoading}
              />
            </div>
            <div className={cx(css.formFieldRow, css.flexRow)}>
              <FormInput.Select
                label={'Resource Group*'}
                placeholder={'Select resource group'}
                name="resourceGroup"
                items={resourceGroupsOptions}
                disabled={
                  isEditMode
                    ? !editableFieldsMap['resourceGroup']
                    : !_isEmpty(values.resourceGroup)
                    ? false
                    : resourceGroupsLoading
                }
                onChange={resourceItem => {
                  setSelectedResourceGroup(resourceItem)
                }}
              />
              {renderRefreshButton(refetchResourceGroups)}
            </div>
            <div className={css.formFieldRow}>
              {!isCreateMode && (
                <div className={css.flexRow}>
                  <FormInput.Select
                    label={'Certificate (optional)'}
                    placeholder={'Select certificate'}
                    name={'certificate'}
                    selectProps={{
                      allowCreatingNewItems: true
                    }}
                    items={certificatesOptions}
                    disabled={
                      isEditMode
                        ? !editableFieldsMap['certificate']
                        : !_isEmpty(values.certificate)
                        ? false
                        : certificatesLoading || !selectedRegion || !selectedResourceGroup
                    }
                  />
                  {renderRefreshButton(certificatesReload, true)}
                </div>
              )}
              {isCreateMode && <label className={css.certiLabel}>{'Certificate (optional)'}</label>}
              <div className={css.uploadCtaContainer}>
                <span onClick={openUploadCertiModal} className={css.uploadText}>
                  + Upload a certificate
                </span>
                {newCertificate && (
                  <Layout.Horizontal flex={{ justifyContent: 'space-between' }}>
                    <Text>
                      <Icon name={'command-artifact-check'} /> {newCertificate?.name}
                    </Text>
                    <Icon
                      name={'trash'}
                      color={Color.RED_700}
                      onClick={() => setNewCertificate(undefined)}
                      title={'delete'}
                    />
                  </Layout.Horizontal>
                )}
              </div>
            </div>
            <div className={cx(css.formFieldRow, css.flexRow)}>
              <FormInput.Select
                label={'Virtual Network*'}
                placeholder={'Select virtual network'}
                name="virtualNetwork"
                items={vpcOptions}
                disabled={
                  isEditMode
                    ? !editableFieldsMap['virtualNetwork']
                    : !_isEmpty(values.virtualNetwork)
                    ? false
                    : vpcsLoading || !selectedRegion
                }
                onChange={vpcItem => {
                  setSelectedVpc(vpcItem)
                }}
              />
              {renderRefreshButton(vpcsReload)}
            </div>
            <div className={cx(css.formFieldRow, css.flexRow)}>
              <FormInput.Select
                label={'Subnet*'}
                placeholder={'Select subnet'}
                name="subnet"
                items={subnetsOptions}
                value={newSubnet}
                onChange={_subnet => setNewSubnet(_subnet)}
                selectProps={{
                  allowCreatingNewItems: true
                }}
                disabled={
                  isEditMode
                    ? !editableFieldsMap['subnet']
                    : !_isEmpty(values.subnet)
                    ? false
                    : subnetsLoading || !selectedVpc
                }
              />
              {renderRefreshButton(subnetsReload)}
            </div>
            <div className={cx(css.formFieldRow, css.flexRow)}>
              <FormInput.Select
                label={'Frontend IP*'}
                placeholder={'Select IP'}
                name="ip"
                items={publicIpsOptions}
                selectProps={{
                  allowCreatingNewItems: true
                }}
                value={newFrontendIp}
                onChange={_ip => setNewFrontendIp(_ip)}
                disabled={
                  isEditMode
                    ? !editableFieldsMap['ip']
                    : !_isEmpty(values.ip)
                    ? false
                    : publicIpsLoading || !selectedRegion || !selectedVpc || !selectedResourceGroup
                }
              />
              {renderRefreshButton(publicIpsReload)}
            </div>
            <div className={css.formFieldRow}>
              <FormInput.Select
                label={'SKU*'}
                placeholder={'Select SKU'}
                name="sku"
                items={SKUItems}
                disabled={isEditMode && !editableFieldsMap['sku']}
              />
            </div>
            <div className={css.formFieldRow}>
              <FormInput.Select
                label={'Azure Function Region*'}
                placeholder={'Select region'}
                name="func_region"
                items={regionsOptions}
                // onChange={regionItem => {
                //   setSelectedRegion(regionItem)
                // }}
                disabled={
                  isEditMode
                    ? !editableFieldsMap['func_region']
                    : !_isEmpty(values.func_region)
                    ? false
                    : regionsLoading
                }
              />
            </div>
            <Layout.Horizontal style={{ marginTop: 100 }}>
              <Button minimal icon={'chevron-left'} onClick={() => handleBackClick(values)}>
                Back
              </Button>
              {!lbCreationInProgress && (
                <Button intent={'primary'} onClick={submitForm} disabled={!isFormValid(isValid)}>
                  Save
                </Button>
              )}
              {lbCreationInProgress && (
                <Icon name="spinner" size={24} color="blue500" style={{ alignSelf: 'center' }} />
              )}
            </Layout.Horizontal>
          </FormikForm>
        )}
      </Formik>
    </Container>
  )
}
 
export default AzureAccessPointForm