-
Notifications
You must be signed in to change notification settings - Fork 267
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🪟 🔧 [Form Migration][Part 1] New
react-hook-form
components for `<C…
…onnectionTransformationPage />` and refactored the old ones (#7967)
- Loading branch information
Showing
23 changed files
with
519 additions
and
104 deletions.
There are no files selected for viewing
6 changes: 1 addition & 5 deletions
6
airbyte-webapp/src/components/ArrayOfObjectsEditor/ArrayOfObjectsEditor.module.scss
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 |
---|---|---|
@@ -1,11 +1,7 @@ | ||
@use "scss/colors"; | ||
@use "scss/variables"; | ||
|
||
.container { | ||
margin-bottom: variables.$spacing-xl; | ||
} | ||
|
||
.list { | ||
background-color: colors.$grey-50; | ||
border-radius: variables.$border-radius-xs; | ||
overflow: hidden; | ||
} |
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
69 changes: 69 additions & 0 deletions
69
airbyte-webapp/src/components/ArrayOfObjectsEditor/ArrayOfObjectsHookFormEditor.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,69 @@ | ||
import React from "react"; | ||
import { FieldArrayWithId } from "react-hook-form"; | ||
|
||
import { Box } from "components/ui/Box"; | ||
import { FlexContainer } from "components/ui/Flex"; | ||
|
||
import styles from "./ArrayOfObjectsEditor.module.scss"; | ||
import { EditorHeader } from "./components/EditorHeader"; | ||
import { EditorRow } from "./components/EditorRow"; | ||
|
||
export interface ArrayOfObjectsHookFormEditorProps<T> { | ||
fields: T[]; | ||
mainTitle?: React.ReactNode; | ||
addButtonText?: React.ReactNode; | ||
renderItemName?: (item: T, index: number) => React.ReactNode | undefined; | ||
renderItemDescription?: (item: T, index: number) => React.ReactNode | undefined; | ||
onAddItem: () => void; | ||
onStartEdit: (n: number) => void; | ||
onRemove: (index: number) => void; | ||
} | ||
|
||
/** | ||
* The component is used to render a list of react-hook-form FieldArray items with the ability to add, edit and remove items. | ||
* It's a react-hook-form version of the ArrayOfObjectsEditor component and will replace it in the future. | ||
* @see ArrayOfObjectsEditor | ||
* @param fields | ||
* @param mainTitle | ||
* @param addButtonText | ||
* @param onAddItem | ||
* @param renderItemName | ||
* @param renderItemDescription | ||
* @param onStartEdit | ||
* @param onRemove | ||
* @param mode | ||
* @constructor | ||
*/ | ||
export const ArrayOfObjectsHookFormEditor = <T extends FieldArrayWithId>({ | ||
fields, | ||
mainTitle, | ||
addButtonText, | ||
onAddItem, | ||
renderItemName, | ||
renderItemDescription, | ||
onStartEdit, | ||
onRemove, | ||
}: ArrayOfObjectsHookFormEditorProps<T>) => ( | ||
<Box mb="xl"> | ||
<EditorHeader | ||
mainTitle={mainTitle} | ||
itemsCount={fields.length} | ||
addButtonText={addButtonText} | ||
onAddItem={onAddItem} | ||
/> | ||
{fields.length ? ( | ||
<FlexContainer direction="column" gap="xs" className={styles.list}> | ||
{fields.map((field, index) => ( | ||
<EditorRow | ||
key={field.id} | ||
name={renderItemName?.(field, index)} | ||
description={renderItemDescription?.(field, index)} | ||
id={index} | ||
onEdit={onStartEdit} | ||
onRemove={onRemove} | ||
/> | ||
))} | ||
</FlexContainer> | ||
) : null} | ||
</Box> | ||
); |
14 changes: 0 additions & 14 deletions
14
airbyte-webapp/src/components/ArrayOfObjectsEditor/components/EditorHeader.module.scss
This file was deleted.
Oops, something went wrong.
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
18 changes: 3 additions & 15 deletions
18
airbyte-webapp/src/components/ArrayOfObjectsEditor/components/EditorRow.module.scss
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 |
---|---|---|
@@ -1,30 +1,18 @@ | ||
@use "scss/colors"; | ||
@use "scss/variables"; | ||
|
||
.container + .container { | ||
.container { | ||
border-top: 1px solid colors.$foreground; | ||
background-color: colors.$grey-50; | ||
} | ||
|
||
.body { | ||
display: flex; | ||
justify-content: space-between; | ||
align-items: center; | ||
flex-direction: row; | ||
color: colors.$dark-blue; | ||
font-weight: 400; | ||
font-size: variables.$font-size-sm; | ||
line-height: 1.4; | ||
padding: variables.$spacing-xs variables.$spacing-xs variables.$spacing-xs variables.$spacing-md; | ||
gap: variables.$spacing-xs; | ||
padding: variables.$spacing-xs variables.$spacing-md; | ||
} | ||
|
||
.name { | ||
overflow: hidden; | ||
text-overflow: ellipsis; | ||
white-space: nowrap; | ||
} | ||
|
||
.actions { | ||
display: flex; | ||
flex-direction: row; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,2 @@ | ||
import { ArrayOfObjectsEditor } from "./ArrayOfObjectsEditor"; | ||
|
||
export default ArrayOfObjectsEditor; | ||
export { ArrayOfObjectsEditor }; | ||
export { ArrayOfObjectsEditor } from "./ArrayOfObjectsEditor"; | ||
export { ArrayOfObjectsHookFormEditor } from "./ArrayOfObjectsHookFormEditor"; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,2 @@ | ||
import LabeledRadioButton from "./LabeledRadioButton"; | ||
|
||
export default LabeledRadioButton; | ||
export { LabeledRadioButton }; | ||
export { LabeledRadioButton } from "./LabeledRadioButton"; | ||
export type { LabeledRadioButtonProps } from "./LabeledRadioButton"; |
Oops, something went wrong.