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

PRfd - Merge PR and change PR status #8209

Merged
merged 26 commits into from
Sep 24, 2024
Merged

PRfd - Merge PR and change PR status #8209

merged 26 commits into from
Sep 24, 2024

Conversation

itaigilo
Copy link
Contributor

Closes #8176.

Change Description

Wire the "Merge PR" button to the API.
Wire the "Close PR" button to the API, and add a "Re-open PR" button.

Also, show PR details in Markdown.


Screenshot 2024-09-23 at 12 27 43

@itaigilo itaigilo added exclude-changelog PR description should not be included in next release changelog pull-requests labels Sep 23, 2024
@itaigilo itaigilo requested review from N-o-Z and a team September 23, 2024 09:28
Copy link

E2E Test Results - DynamoDB Local - Local Block Adapter

13 passed

Copy link

E2E Test Results - Quickstart

10 passed

@itaigilo itaigilo changed the base branch from master to feature/prfd-create-pr-page September 23, 2024 10:52
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Some extra UI stuff for the List page,
Got into this PR, in order not to create another one in the PRs chain.

@N-o-Z
Copy link
Member

N-o-Z commented Sep 23, 2024

@itaigilo Per discussion on the PRD - we do not support re-open ATM. This should be removed

@itaigilo
Copy link
Contributor Author

@itaigilo Per discussion on the PRD - we do not support re-open ATM. This should be removed

Yeah I saw that -
But it felt weird, that after closing all the buttons disappear.

I don't mind removing it, but it's small piece of code that's already implemented.
Any good reason to not release it?

Copy link
Member

@N-o-Z N-o-Z left a comment

Choose a reason for hiding this comment

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

Thanks!!
Please see comments

let [error, setError] = useState(null);

const mergePullRequest = async () => {
// TODO: this is not ideal - this should be handled in an atomic way
Copy link
Member

Choose a reason for hiding this comment

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

Let's open an issue for this and remove the comment as this is probably not something we're going to handle in the near future

Copy link
Contributor Author

Choose a reason for hiding this comment

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

await pullsAPI.update(repo.id, pull.id, {status: PullStatus.merged});
window.location.reload(); // TODO: replace with a more elegant solution
} catch (error) {
setError(`Failed to update pull-request status: ${error.message}`);
Copy link
Member

Choose a reason for hiding this comment

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

We should do something here - this is an inconsistent state which can lead to strange behavior

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah you're right.

I think we should:

  1. Log this error somehow and monitor it, so we can see how often this occurs.
  2. Have two extra retries.

Does this make sense, or do you have other suggestions?

setLoading(true);
try {
await pullsAPI.update(repo.id, pull.id, {status});
window.location.reload(); // TODO: replace with a more elegant solution
Copy link
Member

Choose a reason for hiding this comment

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

Same as previous comment (also please use our TODO convention)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Why this is an inconsistent state?

}
</Button>
}
{isPullOpen() &&
Copy link
Member

Choose a reason for hiding this comment

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

This condition is not enough - Merge should be also disabled if no changes (due to modifications of the branches, or if any of them no longer exists)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

True -
Will be handled in a separate PR (or deferred).

onClick={changePullStatus(isPullOpen() ? PullStatus.closed : PullStatus.open)}>
{loading ?
<span className="spinner-border spinner-border-sm text-light" role="status"/> :
<>{isPullOpen() ? "Close" : "Re-open"} pull request</>
Copy link
Member

Choose a reason for hiding this comment

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

We don't support re-open

Copy link
Member

Choose a reason for hiding this comment

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

And also we shouldn't have a re-open button for Merged PRs

@N-o-Z
Copy link
Member

N-o-Z commented Sep 23, 2024

@itaigilo Per discussion on the PRD - we do not support re-open ATM. This should be removed

Yeah I saw that - But it felt weird, that after closing all the buttons disappear.

I don't mind removing it, but it's small piece of code that's already implemented. Any good reason to not release it?

Yes - it complicates the state machine of the PRs. We want to reduce the scope as much as possible.
I think we can be good with graying out the buttons - we don't have to remove them
Whatever makes more sense to you

@itaigilo itaigilo requested a review from N-o-Z September 23, 2024 18:00
Copy link
Member

@N-o-Z N-o-Z left a comment

Choose a reason for hiding this comment

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

Approved to unblock but please make sure to fix all comments before merging!

} catch (error) {
setError(`Failed to update pull-request status: ${error.message}`);
setLoading(false);
for (let i = 0; i < RETRIES_COUNT; i++) {
Copy link
Member

Choose a reason for hiding this comment

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

We are already importing https://www.npmjs.com/package/exponential-backoff so lets use it

Base automatically changed from feature/prfd-create-pr-page to master September 24, 2024 09:27
This reverts commit a5566fa.
# Conflicts:
#	webui/src/lib/api/index.js
#	webui/src/pages/repositories/repository/pulls/pullDetails.jsx
@itaigilo
Copy link
Contributor Author

All handled,
Except for the comments related to empty diffs, which will be handled in a separate PR.
Merging.

@itaigilo itaigilo enabled auto-merge (squash) September 24, 2024 09:47
@itaigilo itaigilo merged commit 06cd860 into master Sep 24, 2024
38 checks passed
@itaigilo itaigilo deleted the prfd-merge-and-edit-pr branch September 24, 2024 09:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
exclude-changelog PR description should not be included in next release changelog pull-requests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

PRfD - WebUI - Edit PR
2 participants