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

Fix PR's target branch dropdown #33589

Merged
merged 1 commit into from
Feb 14, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 16 additions & 8 deletions routers/web/repo/issue_page_meta.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,27 +79,35 @@ func retrieveRepoIssueMetaData(ctx *context.Context, repo *repo_model.Repository
return data
}

data.CanModifyIssueOrPull = ctx.Repo.CanWriteIssuesOrPulls(isPull) && !ctx.Repo.Repository.IsArchived
if !data.CanModifyIssueOrPull {
// it sets "Branches" template data,
// it is used to render the "edit PR target branches" dropdown, and the "branch selector" in the issue's sidebar.
PrepareBranchList(ctx)
if ctx.Written() {
return data
}

data.retrieveAssigneesDataForIssueWriter(ctx)
// it sets the "Assignees" template data, and the data is also used to "mention" users.
data.retrieveAssigneesData(ctx)
if ctx.Written() {
return data
}

data.retrieveMilestonesDataForIssueWriter(ctx)
if ctx.Written() {
// TODO: the issue/pull permissions are quite complex and unclear
// A reader could create an issue/PR with setting some meta (eg: assignees from issue template, reviewers, target branch)
// A reader(creator) could update some meta (eg: target branch), but can't change assignees anymore.
// For non-creator users, only writers could update some meta (eg: assignees, milestone, project)
// Need to clarify the logic and add some tests in the future
data.CanModifyIssueOrPull = ctx.Repo.CanWriteIssuesOrPulls(isPull) && !ctx.Repo.Repository.IsArchived
if !data.CanModifyIssueOrPull {
return data
}

data.retrieveProjectsDataForIssueWriter(ctx)
data.retrieveMilestonesDataForIssueWriter(ctx)
if ctx.Written() {
return data
}

PrepareBranchList(ctx)
data.retrieveProjectsDataForIssueWriter(ctx)
if ctx.Written() {
return data
}
Expand Down Expand Up @@ -131,7 +139,7 @@ func (d *IssuePageMetaData) retrieveMilestonesDataForIssueWriter(ctx *context.Co
}
}

func (d *IssuePageMetaData) retrieveAssigneesDataForIssueWriter(ctx *context.Context) {
func (d *IssuePageMetaData) retrieveAssigneesData(ctx *context.Context) {
var err error
d.AssigneesData.CandidateAssignees, err = repo_model.GetRepoAssignees(ctx, d.Repository)
if err != nil {
Expand Down
Loading