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 useFetchState & rework all modern calls #1036

Merged

Conversation

andrewballantyne
Copy link
Member

@andrewballantyne andrewballantyne commented Mar 21, 2023

Closes: #885

Description

Added a generic useFetchState hook that will stand as the generic way to fetch data.

  • Handles standard boilerplate to fetch and store data, loaded state and error
  • Handles refresh function as a promise -- so actions can await a refresh before actioning
  • Handles not invoking when you have partial props
  • Handles lazy setting state, if you want to provide initial data while fetching or to provide some nested refresh (get NotebookStates need this)
  • Implemented signals -- we now can cancel requests! (did not implement this across all calls, so handled the old ignore response way too)

How Has This Been Tested?

Tested the app -- all new areas, projects & model serving.

Test Impact

There are no tests for this -- we don't have a good infra to test generic fetch utilities like this.

cc @Gkrumbach07 keep me honest here -- is there a way we can test this?

Request review criteria:

  • The commits have meaningful messages (squashes happen on merge by the bot).
  • Included any necessary screenshots or gifs if it was a UI change.
  • Included tags to the UX team if it was a UI/UX change.
  • Testing instructions have been added in the PR body (for PRs involving changes that are not immediately obvious).
  • The developer has manually tested the changes and verified that the changes work
  • The developer has added tests or explained why testing cannot be added (unit tests & storybook for related changes)

@andrewballantyne andrewballantyne mentioned this pull request Mar 21, 2023
6 tasks
@Gkrumbach07
Copy link
Member

/lgtm

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Mar 21, 2023

[APPROVALNOTIFIER] This PR is APPROVED

Approval requirements bypassed by manually added approval.

This pull-request has been approved by:

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-merge-robot openshift-merge-robot merged commit 8378419 into opendatahub-io:main Mar 21, 2023
bartoszmajsak pushed a commit to maistra/odh-dashboard that referenced this pull request Mar 30, 2023
bartoszmajsak pushed a commit to maistra/odh-dashboard that referenced this pull request Mar 30, 2023
@andrewballantyne andrewballantyne deleted the add-fetch-state branch April 28, 2023 15:43
strangiato pushed a commit to strangiato/odh-dashboard that referenced this pull request Oct 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Architecture]: Create useNetworkCall Hook for Standard Data Fetch Calls
3 participants