NO-JIRA: feat: add cancel button when graph is loading.#225
NO-JIRA: feat: add cancel button when graph is loading.#225alanconway wants to merge 1 commit intoopenshift:mainfrom
Conversation
While the graph is loading, replace the "sync" button with a "cancel" button to cancel the fetch.
|
@alanconway: This pull request explicitly references no jira issue. DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
WalkthroughThe pull request implements a fetch cancellation mechanism for the troubleshooting panel, refactors UI terminology from "Cancel" to "Close" for consistency, extends the Result type with optional error and messaging fields, and updates corresponding localization strings. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes ✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
Comment |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: alanconway The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
@alanconway: all tests passed! Full PR test history. Your PR dashboard. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here. |
|
/cc @PeterYurkovich |
| setCancel(null); | ||
| fetch.cancel(); | ||
| }; | ||
| setCancel(() => doCancel); |
There was a problem hiding this comment.
I'm finding the doCancel closure a bit tricky to follow. Would you be open to using a ref for the cancel handle and separate isLoading state instead? Something like:
const cancelRef = React.useRef<(() => void) | null>(null);
const [isLoading, setIsLoading] = React.useState(false);
React.useEffect(() => {
// Cancel previous
cancelRef.current?.();
cancelRef.current = null;
// ...
setIsLoading(true);
const fetch = getGoalsGraph({ start, goals: [search.goal] });
cancelRef.current = () => fetch.cancel();
fetch
.then(/* ... */)
.catch(/* ... */)
.finally(() => {
cancelRef.current = null;
setIsLoading(false);
});
return () => cancelRef.current?.();
}, [/* deps */]);
While the graph is loading, replace the "sync" button with a "cancel" button to cancel the fetch.