Skip to content
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 loading state to switch, convert to scss modules #12790

Merged
merged 21 commits into from
May 25, 2022
Merged

Conversation

krishnaglick
Copy link
Contributor

@krishnaglick krishnaglick commented May 11, 2022

Closes #12530

  1. Update the switch component to support the loading state
    a. Rename component from Toggle to Switch
    b. Migrate from styled components to sass

Renamed, has a loading state, and uses sass modules.

  1. Identify areas where the loading state is supported
    a. Search in code for the Toggle component and figure out which ones need to have the loading state

Arguably done. Many places this component is used actually cause sync actions that trigger async updates so we don't have a way to track when to start/stop loading. I could code something up, like using a key to track loading state, but I'd argue the problem views (connections list, destinations list, and sources list) merit a refactor that would make this way easier.

  1. Update layout around toggle to include error messages when the request fails

Error states are arguably outside the scope of this work. The mocks place them below the label, not the switch itself, and there are several components that implement Switch. Additionally error states are bubbled up to Error Boundaries more often than not so I'm unsure how much value this gets us.
Merits discussion.

@krishnaglick krishnaglick requested a review from a team as a code owner May 11, 2022 20:31
@github-actions github-actions bot added area/frontend area/platform issues related to the platform labels May 11, 2022

&.small:before {
transform: translateX(10px);
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doing &:before { &.small {} } did not work.

@@ -103,7 +103,7 @@ export const BulkHeader: React.FC<BulkHeaderProps> = ({ destinationSupportedSync
<CheckboxCell />
<ArrowCell />
<HeaderCell flex={0.4}>
<Toggle small checked={options.selected} onChange={() => onChangeOption({ selected: !options.selected })} />
<Switch small checked={options.selected} onChange={() => onChangeOption({ selected: !options.selected })} />
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an example of an async effect caused by a sync option. Hard to know what Switch triggered things.

Copy link
Contributor

@edmundito edmundito left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good so far, comments below.

@timroes
Copy link
Contributor

timroes commented May 12, 2022

Could we as part of this PR also add the Switch component to storybook, just to make sure we're having the SASS setup working in storybook as well?

Copy link
Contributor

@edmundito edmundito left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great!

@krishnaglick
Copy link
Contributor Author

@timroes Unsure how you wanted to implement a11y features into this. It's at least labeled correctly.

Comment on lines 38 to 40
// Getting the loading state down here may be difficult.
// ConnectionsTable.tsx#28
// The data is invalidated, then re-loaded. There's no specific action flow for loading.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@edmundito I think this should rather just be a coment on the PR not in the code. Could we remove this before merging this?

@edmundito edmundito requested review from timroes and teallarson May 20, 2022 19:23
@edmundito edmundito self-assigned this May 20, 2022
@edmundito edmundito merged commit c04f6e8 into master May 25, 2022
@edmundito edmundito deleted the kc/better-switch branch May 25, 2022 16:54
jscottpolevault pushed a commit to jscottpolevault/airbyte that referenced this pull request Jun 1, 2022
* Adding sass

* Rename Toggle -> Switch

* Loading state test works

* Mostly working styles

* Smooth

* cleanup

* Added loading where available

* Switch to classnames, move svg's, code review bits, move theme content into scss.

* Added switch to storybook

* Better

* LabeledToggle -> LabeledSwitch

* Edmundo CR

* Import variables from SASS in TS

* Minor adjustments

* Refactor code

* Adjust styling to discussion with Nico

* invalidate connection on source and destination item pages when updating status

* Fix switch loading status in NotificationForm

* Update classnames in package-lock

* While updating the connection, disable reset and sync buttons

* Disable switch while loading

Co-authored-by: Tim Roes <tim@airbyte.io>
Co-authored-by: Edmundo Ruiz Ghanem <edmundo@airbyte.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update loading state of the switch component
5 participants