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

🪟 🐛 Fix loading state of "Launch" button in connection table #22002

Merged
merged 10 commits into from
Jan 31, 2023

Conversation

josephkmh
Copy link
Contributor

@josephkmh josephkmh commented Jan 27, 2023

What

Fixes the loading state of the manual sync button on the connection table.

Closes #20729

Before, there was no feedback for the user when clicking "Launch" on a manual sync, requiring the user to refresh the page to see that the sync started:

Screen.Recording.2023-01-28.at.11.10.40.AM.mov

Now there is a loading state, the sync changes to "In progress" and its status is updated every 60 seconds (in this video it updates after 10 seconds to illustrate):

sync.progress.mov

There is also error handling if the manual sync request fails:

manual.sync.error.mov

How

  • Refactors the code a bit to avoid prop drilling and repeated definition of the onSync callback
  • Adds a loading state from the mutation
  • Refreshes/invalidates the connection list after the manual sync is triggered
  • Adds a 60-second refresh interval to the connection table, so a user doesn't have to refresh the page to see the sync
    status update
  • Changed the button text from "Launch" to "Start sync", which matches what we do on the connection page (we don't use "Launch" anywhere else in the app).

Recommended reading order

  1. StatusCellControl.tsx and useConnectionHook.tsx have the main changes to logic
  2. The rest

@octavia-squidington-iv octavia-squidington-iv added the area/frontend Related to the Airbyte webapp label Jan 27, 2023
return useSuspenseQuery(
connectionsKeys.lists(payload.destinationId ?? payload.sourceId),
() => service.list({ ...payload, workspaceId: workspace.workspaceId }),
{ refetchInterval: REFETCH_CONNECTION_LIST_INTERVAL }
Copy link
Contributor Author

@josephkmh josephkmh Jan 27, 2023

Choose a reason for hiding this comment

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

Re-fetching the connections every 60 seconds lets us show updated progress in the connection table. That way syncs don't stay "pending" until you refresh the page. p99 latency for this endpoint is under 100ms, so I don't think it's a performance problem.

Comment on lines +32 to +39
const onRunManualSync = (event: React.SyntheticEvent) => {
event.stopPropagation();

const connection = connections.find((c) => c.connectionId === id);
if (connection) {
syncConnection(connection);
}
};
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 function was basically constructed in three places before (SourceConnectionTable, DestinationConnectionTable and ConnectionTable) and drilled down as prop called onSync. Instead we can just create the function here and remove all that intermediate code.

@josephkmh josephkmh marked this pull request as ready for review January 28, 2023 11:13
@josephkmh josephkmh changed the title [DRAFT] 🪟 🐛 Fix loading state of "Launch" button in connection table 🪟 🐛 Fix loading state of "Launch" button in connection table Jan 28, 2023
@josephkmh josephkmh requested a review from a team January 30, 2023 10:29
@edmundito
Copy link
Contributor

From watching the video, the only feedback I have is to make sure that the Enabled column is fixed so that when the button is pressed it doesn't reflow the table. However, #21759 will do some table cleanup.

@josephkmh
Copy link
Contributor Author

josephkmh commented Jan 30, 2023

From watching the video, the only feedback I have is to make sure that the Enabled column is fixed so that when the button is pressed it doesn't reflow the table. However, #21759 will do some table cleanup.

@edmundito yeah there is some reflow of the table, but I think it's rather due to the "Last sync" column (see video below at 9-12 seconds). I'd rather keep that in a separate PR (probably the one you linked?) since the behavior of the columns should be fixed holistically.

Screen.Recording.2023-01-30.at.4.45.33.PM.mov

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.

Code looking good, tested locally and noticed one detail.

@@ -0,0 +1,5 @@
.inProgressLabel {
height: 32px; /** Needs to match our Button height to avoid jumping around */
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we make this a variable? I've also had another occasion where I needed the button height

Copy link
Contributor Author

@josephkmh josephkmh Jan 31, 2023

Choose a reason for hiding this comment

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

The reason I didn't is that IMO we should not really need to pass around the height of the button. The table row should have an appropriate (larger) height so that it's not reflowing depending on the content. But of course that's a little out of scope. On second thought, a variable is at least better than a comment like this, so I'll add the button heights to _variables.scss

aeb9344

});
},
onSuccess: async () => {
webConnectionService
Copy link
Contributor

Choose a reason for hiding this comment

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

We may need to await here. I noticed that the button goes into a non-loading state for the time the list is loading.

Copy link
Contributor Author

@josephkmh josephkmh Jan 31, 2023

Choose a reason for hiding this comment

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

good point! fixed ✅ 5dcaf69

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.

Re-tested and looks good. Just maybe one nit that should be fixed to stay consistent, but no need for re-approval.

airbyte-webapp/src/scss/_variables.scss Outdated Show resolved Hide resolved
@josephkmh josephkmh enabled auto-merge (squash) January 31, 2023 15:45
@josephkmh josephkmh merged commit 7f28751 into master Jan 31, 2023
@josephkmh josephkmh deleted the joey/launch-button-loading-state branch January 31, 2023 16:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/frontend Related to the Airbyte webapp team/compose type/bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

No feedback after launching the sync manually from Connections tab
3 participants