Skip to content

fix: auto-refresh job and queue list after successful creation#247

Open
gautamsidhwani29 wants to merge 2 commits into
volcano-sh:mainfrom
gautamsidhwani29:fix/auto-refresh-after-job-queue-creation
Open

fix: auto-refresh job and queue list after successful creation#247
gautamsidhwani29 wants to merge 2 commits into
volcano-sh:mainfrom
gautamsidhwani29:fix/auto-refresh-after-job-queue-creation

Conversation

@gautamsidhwani29
Copy link
Copy Markdown

Problem

When a user creates a new Job or Queue via the dashboard UI, the data grid does not automatically refresh to show the newly created resource. The user must manually click the "Refresh" button.

Fixes:

#236

Fix

  • Added fetchJobs() call after successful job creation in Jobs.jsx
  • Added fetchQueues() call after successful queue creation in Queues.jsx

Testing

  • Created a Job via the dashboard list refreshes automatically
  • Created a Queue via the dashboard list refreshes automatically

Signed-off-by: gautamsidhwani29 <gautamsidhwani405@gmail.com>
@volcano-sh-bot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign jessestutler for approval. For more information see the Kubernetes Code Review Process.

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

Details 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

@volcano-sh-bot
Copy link
Copy Markdown
Contributor

Welcome @gautamsidhwani29! It looks like this is your first PR to volcano-sh/dashboard 🎉

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request ensures that the UI stays in sync by triggering data refreshes after successfully creating jobs or queues. Feedback suggests awaiting the asynchronous fetch calls to prevent premature loading state termination, resetting pagination to the first page for better visibility of new items, and cleaning up a trailing space.

Comment thread frontend/src/components/jobs/Jobs.jsx Outdated
}

alert("Job created successfully!");
fetchJobs();
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

To ensure the newly created job is visible to the user, it's recommended to reset the pagination to the first page (assuming the default sort is newest first). Additionally, there is a trailing space on this line that should be removed.

            setPagination((prev) => ({ ...prev, page: 1 }));
            fetchJobs();

}

alert("Queue created successfully!");
fetchQueues();
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The fetchQueues() call should be awaited. Currently, because it is an asynchronous call and not awaited, the finally block at line 80 will execute immediately after the fetch starts, setting loading to false while the data is still being retrieved. This causes the loading indicator to disappear prematurely. Additionally, resetting the pagination to the first page ensures the user sees the newly created queue.

Suggested change
fetchQueues();
setPagination((prev) => ({ ...prev, page: 1 }));
await fetchQueues();

Signed-off-by: gautamsidhwani29 <gautamsidhwani405@gmail.com>
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.

2 participants