-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Implement the feature that close issuse as archived/merged/resolved #23522
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
Closed
Closed
Changes from all commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
57cb23d
button & dropdown
sillyguodong 13a5e3d
fix style of button & dropdown
sillyguodong 1eb8b18
dropdown item add click event
sillyguodong b7ab794
dropdown js
sillyguodong 96cca04
dropdown use fomanticUI component
sillyguodong 9516184
complete ui
sillyguodong 4a9e672
implement basically
sillyguodong 4af0bcd
fix lint
sillyguodong ba8b08b
Merge branch 'main' into feature/issue_22793
sillyguodong 71c03a5
keep active
sillyguodong baf2ab7
mark the comobox with classname 'js-aria-comobox'
sillyguodong a12c386
Merge branch 'main' into feature/issue_22793
sillyguodong 7b68c3f
use svg instead of fomantic icon
sillyguodong b625d55
use selected
sillyguodong 2de28aa
use selected in dropdown
sillyguodong 1c6365e
demo
wxiaoguang d7db875
fix
sillyguodong f1ff475
fix
sillyguodong d0ce23f
fix lint
sillyguodong 42cc712
fix
sillyguodong 466fcb3
fix lint
sillyguodong 69d46a9
rename closed status
sillyguodong 4c092df
Merge branch 'main' into feature/issue_22793
sillyguodong cb2accb
add migration
sillyguodong f117aa0
fix and add tooltip
sillyguodong 099fd27
Merge branch 'main' into feature/issue_22793
sillyguodong 04e98a0
lint
sillyguodong 3ce31c8
Merge branch 'main' into feature/issue_22793
sillyguodong f8b80f0
fix css format
sillyguodong File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -125,6 +125,7 @@ type Issue struct { | |
IsRead bool `xorm:"-"` | ||
IsPull bool `xorm:"INDEX"` // Indicates whether is a pull request or not. | ||
PullRequest *PullRequest `xorm:"-"` | ||
ClosedStatus IssueClosedStatus | ||
NumComments int | ||
Ref string | ||
|
||
|
@@ -643,15 +644,15 @@ func UpdateIssueCols(ctx context.Context, issue *Issue, cols ...string) error { | |
return nil | ||
} | ||
|
||
func changeIssueStatus(ctx context.Context, issue *Issue, doer *user_model.User, isClosed, isMergePull bool) (*Comment, error) { | ||
func changeIssueStatus(ctx context.Context, issue *Issue, doer *user_model.User, isClosed, isMergePull bool, status IssueClosedStatus) (*Comment, error) { | ||
// Reload the issue | ||
currentIssue, err := GetIssueByID(ctx, issue.ID) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
// Nothing should be performed if current status is same as target status | ||
if currentIssue.IsClosed == isClosed { | ||
if currentIssue.IsClosed == isClosed && (!issue.IsPull && issue.ClosedStatus == status) { | ||
if !issue.IsPull { | ||
return nil, ErrIssueWasClosed{ | ||
ID: issue.ID, | ||
|
@@ -663,6 +664,9 @@ func changeIssueStatus(ctx context.Context, issue *Issue, doer *user_model.User, | |
} | ||
|
||
issue.IsClosed = isClosed | ||
if !issue.IsPull { | ||
issue.ClosedStatus = status | ||
} | ||
return doChangeIssueStatus(ctx, issue, doer, isMergePull) | ||
} | ||
|
||
|
@@ -686,7 +690,7 @@ func doChangeIssueStatus(ctx context.Context, issue *Issue, doer *user_model.Use | |
issue.ClosedUnix = 0 | ||
} | ||
|
||
if err := UpdateIssueCols(ctx, issue, "is_closed", "closed_unix"); err != nil { | ||
if err := UpdateIssueCols(ctx, issue, "is_closed", "closed_status", "closed_unix"); err != nil { | ||
return nil, err | ||
} | ||
|
||
|
@@ -713,11 +717,24 @@ func doChangeIssueStatus(ctx context.Context, issue *Issue, doer *user_model.Use | |
} | ||
|
||
// New action comment | ||
cmtType := CommentTypeClose | ||
if !issue.IsClosed { | ||
cmtType = CommentTypeReopen | ||
} else if isMergePull { | ||
cmtType := CommentTypeUnknown | ||
if isMergePull { | ||
cmtType = CommentTypeMergePull | ||
} else if !issue.IsClosed { | ||
cmtType = CommentTypeReopen | ||
} else if issue.IsPull { | ||
cmtType = CommentTypeClose | ||
} else { | ||
switch issue.ClosedStatus { | ||
case IssueClosedStatusCommonClosed: | ||
cmtType = CommentTypeClose | ||
case IssueClosedStatusArchived: | ||
cmtType = CommentTypeCloseAsArchived | ||
case IssueClosedStatusResolved: | ||
cmtType = CommentTypeCloseAsResolved | ||
case IssueClosedStatusMerged: | ||
cmtType = CommentTypeCloseAsMerged | ||
} | ||
} | ||
|
||
return CreateComment(ctx, &CreateCommentOptions{ | ||
|
@@ -729,15 +746,15 @@ func doChangeIssueStatus(ctx context.Context, issue *Issue, doer *user_model.Use | |
} | ||
|
||
// ChangeIssueStatus changes issue status to open or closed. | ||
func ChangeIssueStatus(ctx context.Context, issue *Issue, doer *user_model.User, isClosed bool) (*Comment, error) { | ||
func ChangeIssueStatus(ctx context.Context, issue *Issue, doer *user_model.User, isClosed bool, status IssueClosedStatus) (*Comment, error) { | ||
if err := issue.LoadRepo(ctx); err != nil { | ||
return nil, err | ||
} | ||
if err := issue.LoadPoster(ctx); err != nil { | ||
return nil, err | ||
} | ||
|
||
return changeIssueStatus(ctx, issue, doer, isClosed, false) | ||
return changeIssueStatus(ctx, issue, doer, isClosed, false, status) | ||
} | ||
|
||
// ChangeIssueTitle changes the title of this issue, as the given user. | ||
|
@@ -2051,6 +2068,10 @@ func UpdateIssueByAPI(issue *Issue, doer *user_model.User) (statusChangeComment | |
} | ||
|
||
if currentIssue.IsClosed != issue.IsClosed { | ||
issue.ClosedStatus = IssueClosedStatusOpen | ||
if issue.IsClosed { | ||
issue.ClosedStatus = IssueClosedStatusCommonClosed | ||
} | ||
statusChangeComment, err = doChangeIssueStatus(ctx, issue, doer, false) | ||
if err != nil { | ||
return nil, false, err | ||
|
@@ -2498,3 +2519,20 @@ func DeleteOrphanedIssues(ctx context.Context) error { | |
func (issue *Issue) HasOriginalAuthor() bool { | ||
return issue.OriginalAuthor != "" && issue.OriginalAuthorID != 0 | ||
} | ||
|
||
type IssueClosedStatus int64 | ||
|
||
const IssueClosedStatusUndefined = -1 | ||
|
||
const ( | ||
// IssueClosedStatusOpen | ||
IssueClosedStatusOpen IssueClosedStatus = iota | ||
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. looks meanless, can check it by |
||
// IssueClosedStatusCommonClosed | ||
IssueClosedStatusCommonClosed | ||
// IssueClosedStatusArchived | ||
IssueClosedStatusArchived | ||
// IssueClosedStatusResolved | ||
IssueClosedStatusResolved | ||
// IssueClosedStatusMerged | ||
IssueClosedStatusMerged | ||
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. how about add |
||
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// Copyright 2023 The Gitea Authors. All rights reserved. | ||
// SPDX-License-Identifier: MIT | ||
|
||
package v1_20 //nolint | ||
|
||
import ( | ||
"xorm.io/xorm" | ||
) | ||
|
||
func AddClosedStatusToIssue(x *xorm.Engine) error { | ||
type Issue struct { | ||
ClosedStatus int8 | ||
} | ||
|
||
if err := x.Sync(new(Issue)); err != nil { | ||
return err | ||
} | ||
|
||
// TODO: TBD Whether to use issues_model.IssueClosedStatusUndefined (-1) | ||
if _, err := x.Exec("UPDATE issue SET closed_status = ? WHERE closed_status IS NULL and is_pull = false AND is_closed = true", 1); err != nil { | ||
return err | ||
} | ||
|
||
_, err := x.Exec("UPDATE issue SET closed_status = ? WHERE closed_status IS NULL and is_pull = false AND is_closed = false", 0) | ||
return err | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I guess it's better to extend the
CommentTypeClose
, instead of adding too many new comment types.