-
Notifications
You must be signed in to change notification settings - Fork 253
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2423 from target/ts-conversion-CreateAlertDialog
ui/alerts: convert CreateAlertDialog, CreateAlertForm, and useCreateAlerts to ts
- Loading branch information
Showing
6 changed files
with
98 additions
and
63 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
39 changes: 0 additions & 39 deletions
39
web/src/app/alerts/CreateAlertDialog/StepContent/CreateAlertForm.js
This file was deleted.
Oops, something went wrong.
50 changes: 50 additions & 0 deletions
50
web/src/app/alerts/CreateAlertDialog/StepContent/CreateAlertForm.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,50 @@ | ||
import React from 'react' | ||
import { FormContainer, FormField } from '../../../forms' | ||
import { CreateAlertInfo } from './CreateAlertInfo' | ||
import { CreateAlertServiceSelect } from './CreateAlertServiceSelect' | ||
import { CreateAlertConfirm } from './CreateAlertConfirm' | ||
import { Value } from '../CreateAlertDialog' | ||
|
||
// TODO: extend FormContainer once that file has been converted to typescript | ||
interface CreateAlertFormProps { | ||
activeStep: number | ||
value: Value | ||
|
||
errors: Error[] | ||
|
||
onChange?: (newValue: Value) => void | ||
disabled?: boolean | ||
|
||
mapValue?: () => void | ||
mapOnChangeValue?: () => void | ||
|
||
// Enables functionality to remove an incoming value at it's index from | ||
// an array field if the new value is falsey. | ||
removeFalseyIdxs?: boolean | ||
} | ||
|
||
// TODO: remove this interface once FormContainer.js has been converted to TS | ||
interface Error { | ||
message: string | ||
field: string | ||
helpLink?: string | ||
} | ||
|
||
export function CreateAlertForm({ | ||
activeStep, | ||
...otherProps | ||
}: CreateAlertFormProps): JSX.Element { | ||
return ( | ||
<FormContainer optionalLabels {...otherProps}> | ||
{activeStep === 0 && <CreateAlertInfo />} | ||
{activeStep === 1 && ( | ||
<FormField | ||
required | ||
render={(props) => <CreateAlertServiceSelect {...props} />} | ||
name='serviceIDs' | ||
/> | ||
)} | ||
{activeStep === 2 && <CreateAlertConfirm />} | ||
</FormContainer> | ||
) | ||
} |
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