Skip to content

feat: show api call status when adding insights to dashboards #9817

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

Merged
merged 7 commits into from
May 19, 2022

Conversation

pauldambra
Copy link
Member

Problem

API calls are slower in production than local dev and the modal to add insights to dashboards gives no user feedback 🤦

Changes

Updates UI so the user knows what is happening

adding

How did you test this code?

running it locally

@pauldambra pauldambra requested a review from mariusandra May 17, 2022 13:06
Copy link
Collaborator

@mariusandra mariusandra left a comment

Choose a reason for hiding this comment

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

I normally use this as an example of an anti-pattern in the kea docs 🙃.

In the spirit of minimalism, at first sight, for sure at least the *Started events can be omitted, and the reducers can be set to true on the addToDashboard and removeFromDashboard events directly. Perhaps there's some other action that also always dispatches when the loading is done.

Also, what if there is more than one row? 🤔

2022-05-18 21 49 58

@pauldambra
Copy link
Member Author

2022-05-18 21 31 30

disabled buttons rather than allow and track multiple API calls at the same time

@pauldambra pauldambra requested a review from mariusandra May 18, 2022 20:42
Copy link
Collaborator

@mariusandra mariusandra left a comment

Choose a reason for hiding this comment

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

It seems possible to also remove both adding and removing, and just rely on dashboardWithActiveAPICall


return (
<div style={style} className={clsx('modal-row', isHighlighted && 'highlighted')}>
<Link to={urls.dashboard(dashboard.id)}>{dashboard.name || 'Untitled'}</Link>
<LemonButton
type={isAlreadyOnDashboard ? 'primary' : 'secondary'}
loading={dashboardWithActiveAPICall === dashboard.id}
disabled={adding || removing}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is it worth tracking these separately anymore?

false,
{
removeFromDashboard: () => true,
reportRemovedInsightFromDashboard: () => false,
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't know why, but this feels dirty somehow -> depending on some auxiliary reporting action to fire, and updating an internal state because of that. But I'm too tired to nit any more 🙃

Copy link
Member Author

Choose a reason for hiding this comment

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

💡

Comment on lines 70 to 80
buttonLabel: [
(s) => [s.adding, s.dashboardWithActiveAPICall],
(adding: boolean, dashboardWithActiveAPICall: number | null) =>
(dashboardId: number, isAlreadyOnDashboard: boolean) => {
if (dashboardWithActiveAPICall === dashboardId) {
return adding ? 'Adding' : 'Removing'
} else {
return isAlreadyOnDashboard ? 'Added' : 'Add to dashboard'
}
},
],
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can't we derive whether the adding/removing action is being performed from isAlreadyOnDashboard?

Copy link
Member Author

Choose a reason for hiding this comment

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

Doh!

@pauldambra
Copy link
Member Author

2022-05-18 22 14 13

on a fast network the changing label was an annoying brief flash... and on a slow network no better than the loading state... yanked it

@mariusandra
Copy link
Collaborator

"Perfection is achieved not when there's nothing more to add, but when there's nothing more to take away"
-- some profound quote from the internet

However, if I read the situation well, a git push is still one more thing to add? 🫠

@pauldambra
Copy link
Member Author

Always leave them wanting more.“ - P.T. Barnum.

😆

@pauldambra pauldambra requested a review from mariusandra May 19, 2022 14:15
@mariusandra mariusandra merged commit bb7e496 into master May 19, 2022
@mariusandra mariusandra deleted the dashboard_adding_status branch May 19, 2022 16:45
fuziontech added a commit that referenced this pull request May 19, 2022
* master:
  refactor(ingestion): Make `KAFKA_ENABLED` true by default and set `KAFKA_HOSTS` default (#9844)
  feat(apps): transpile frontend.tsx (#9828)
  feat: show api call status when adding insights to dashboards (#9817)
  feat: track metrics on zapier hook firings (#9866)
  fix(onboarding): instrumentation (#9845)
  feat(whitelabel-shared-dashboard): Hide branding on shared dashboards paid (#9849)
  fix(apps): plugin source quickfix (#9862)
  refactor(plugin-server): Remove `ts-jest`, use `jest.mocked` (#9861)
  refactor(plugin-server): Trigger public jobs with graphile insted of celery queue (#9811)
  chore: upgrade pip tools (#9859)
  feat(apps): plugin source in its own model, part 2 (#9854)
  chore: Update sprint_planning_retro.md (#9791)
  feat(apps): plugin source in its own model, part 1 (#9853)
  feat(matrix): Add option to save `simulate_matrix` like `setup_dev` (#9836)
  fix(cohort): add mapping from event to person (#9841)
  feat(person-on-events): Enable CI to run using both old and new queries (#9814)
alexkim205 pushed a commit that referenced this pull request May 23, 2022
* show api call status when adding insights to dashboards

* so the linter doesn't care about the PR name

* homer-into-the-hedge.gif

* don't track adding and removing separately

* further into the hedge

* respond to error as well

* connect an action before using it
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants