-
Notifications
You must be signed in to change notification settings - Fork 25
feat(dashboard): show "Ready for review" CTA on draft PRs #180
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6402,6 +6402,35 @@ export const mergePullRequest = createServerFn({ method: "POST" }) | |
| } | ||
| }); | ||
|
|
||
| export type ReadyForReviewInput = PullFromRepoInput & { | ||
| /** GraphQL node id of the pull request (e.g. `PR_kwD...`). */ | ||
| pullId: string; | ||
| }; | ||
|
|
||
| export const markPullReadyForReview = createServerFn({ method: "POST" }) | ||
| .inputValidator(identityValidator<ReadyForReviewInput>) | ||
| .handler(async ({ data }): Promise<MutationResult> => { | ||
| const context = await getGitHubUserContextForRepository(data); | ||
| if (!context) { | ||
| return { ok: false, error: "Not authenticated" }; | ||
| } | ||
|
|
||
| try { | ||
| await context.octokit.graphql( | ||
| `mutation($pullRequestId: ID!) { | ||
| markPullRequestReadyForReview(input: { pullRequestId: $pullRequestId }) { | ||
| pullRequest { isDraft } | ||
| } | ||
| }`, | ||
| { pullRequestId: data.pullId }, | ||
| ); | ||
| await bustPullDetailCaches(context.session.user.id, data); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bust At Line 6304, 💡 Proposed fixasync function bustPullDetailCaches(userId: string, params: PullCacheParams) {
await Promise.all([
+ bustGitHubCache(userId, "pulls.pageData.graphql.v2", params),
bustGitHubCache(userId, "pulls.detail.raw", params),
bustGitHubCache(userId, "pulls.status.raw", params),
bustGitHubCache(userId, "pulls.status.v1", params),
bustGitHubCache(userId, "pulls.status.v2", params),
bustGitHubCache(userId, "pulls.status.v3", params),
]);
}🤖 Prompt for AI Agents |
||
| return { ok: true }; | ||
| } catch (error) { | ||
| return toMutationError("mark pull request as ready for review", error); | ||
| } | ||
| }); | ||
|
|
||
| export const deleteBranch = createServerFn({ method: "POST" }) | ||
| .inputValidator( | ||
| identityValidator<{ | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reset loading state on success to prevent a permanently disabled CTA.
isMarkingis never cleared on the success path. If the refetch/invalidation does not transition the view immediately, the button can stay disabled with a stuck spinner.💡 Suggested fix
const handleMarkReady = async () => { if (!pullId) { toast.error("Missing pull request id"); return; } setIsMarking(true); try { const result = await markPullReadyForReview({ data: { owner, repo, pullNumber, pullId }, }); if (result.ok) { await queryClient.invalidateQueries({ queryKey: ["github"] }); } else { toast.error(result.error); checkPermissionWarning(result, `${owner}/${repo}`); - setIsMarking(false); + return; } } catch { toast.error("Failed to mark as ready for review"); - setIsMarking(false); + } finally { + setIsMarking(false); } };📝 Committable suggestion
🤖 Prompt for AI Agents