-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
🪟 🎉 Add column selection UI to new stream table #21058
Conversation
const onToggleFieldSelected = useCallback( | ||
(fieldPath: string[], isSelected: boolean) => { | ||
if (!config) { | ||
return; | ||
} | ||
const updatedConfig = updateFieldSelected({ config, fields, fieldPath, isSelected, numberOfFieldsInStream }); | ||
updateStreamWithConfig(updatedConfig); | ||
}, | ||
[config, fields, numberOfFieldsInStream, updateStreamWithConfig] | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This has been extracted to streamConfigHelpers
to make unit testing easier (see streamConfigHelpers.test.ts
)
const FIELD_ONE: SyncSchemaField = { | ||
path: ["field_one"], | ||
cleanedName: "field_one", | ||
key: "field_one", | ||
type: "string", | ||
}; | ||
const FIELD_TWO: SyncSchemaField = { | ||
path: ["field_two"], | ||
cleanedName: "field_two", | ||
key: "field_two", | ||
type: "string", | ||
}; | ||
const FIELD_THREE: SyncSchemaField = { | ||
cleanedName: "field_three", | ||
type: "todo", | ||
key: "field_three", | ||
path: ["field_three"], | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I redefined FIELD_ONE
, FIELD_TWO
and FIELD_THREE
in this file, which is one of the reasons for the large diff.
const fields = useMemo(() => { | ||
const traversedFields = traverseSchemaToField(stream?.jsonSchema, stream?.name); | ||
return traversedFields.sort(naturalComparatorBy((field) => field.cleanedName)); | ||
}, [stream?.jsonSchema, stream?.name]); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This has just been moved up in the file, not changed!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code looks good but there were a few issues I noticed during testing.
Can you follow up with Nico about the "Sync" column? I'm not sure if that is outdated design so I'm not sure what exactly is the intent there (previous designs had a switch instead of checkbox)
The field count needs to appear in the main table. Is this intended to be done separately?
I tried just unselecting my primary key and saving and got an error. But the error is a little vague. It works for one stream, but what about multiple streams? One option is to invalidate the selected primary key immediately so that the user has to update the key right away (Probably can be addressed separately.)
After you delete a connection and go back to it (we call this readonly mode), you can still check and uncheck the checkboxes:
When I check and uncheck the boxes, the save changes button is enabled instead of going back to being disabled:
Let me know which ones you want to address in this PR and which will be addressed separately.
...nents/connection/CatalogTree/next/StreamDetailsPanel/StreamFieldsTable/StreamFieldsTable.tsx
Show resolved
Hide resolved
<CheckBox | ||
checkboxSize="sm" | ||
checked={isFieldSelected} | ||
onChange={() => handleFieldToggle(field.path, !isFieldSelected)} | ||
/> | ||
)} | ||
{isDisabled && ( | ||
<Tooltip control={<CheckBox checkboxSize="sm" disabled checked={isFieldSelected} readOnly />}> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: I'm always in favor of rendering the same component instead of splitting the logic into two render calls. Meaning that an alternative would be to create the CheckBox in a variable with all the possible fields, then if disabled, wrap it in a tooltip.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I understand, and I think I generally agree when there's a lot of JSX, but I'm not sure if it would be any clearer in this instance. This component's render function basically does one thing only: checks the boolean isDisabled
and returns one or the other bit of JSX. If I split that into another variable, wouldn't that same logic be repeated in the variable? What would the benefit be?
selectedFields: [], | ||
fieldSelectionEnabled: false, | ||
}); | ||
}); | ||
}); | ||
}); | ||
|
||
describe(`${updateFieldSelected.name}`, () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've been using this convention:
Function: #${myFunction.name}
Component: <${MyComponent.name} />
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure I quite follow here - are you suggesting that I put a #
before the function name in the test title? Something like this?
describe(`#${updateFieldSelected.name}`, () => {
I can't find any other usage like this in the codebase, so I think I'm misunderstanding here.
Thanks for the review! I'll address the comments today/tomorrow.
Yes, this is missing and I think I will actually leave it out for the moment to keep this PR as small as possible. It should be an easy follow-up PR: #21772 |
Good catch, this one is because the backend does not return Edit: following up, looks like we will need to do this validation client-side. So we'll have to conditionally delete |
Thanks for catching this! I did not have |
This has been fixed here: 427a3b6 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dizel852 thank you for pointing that out, it looks like a backend error that we're looking into 👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did some testing and noticed something 👀
...ection/CatalogTree/next/StreamDetailsPanel/StreamFieldsTable/SyncFieldCell/SyncFieldCell.tsx
Show resolved
Hide resolved
@josephkmh i'm trying to test this feature on the latest version (0.44.0) but i don't find the way to select columns. I'm using postgres src and dest. am i missing something? |
@edoang this is indeed only available in Airbyte cloud currently. It will be coming to OSS, but we don't have a timeline for that just yet! |
What
Closes #20584
Adds column selection UI to the new stream table design.
field.selection.in.new.table.mov
How
StreamFieldsTable
for a "Sync" checkbox for each top-level fieldsyncMode
anddestinationSyncMode
- primary keys and cursors in these modes should not be deselected