Skip to content

Commit fdb1516

Browse files
committed
just display ghost team
1 parent 99fc8d2 commit fdb1516

File tree

4 files changed

+2
-57
lines changed

4 files changed

+2
-57
lines changed

models/issues/comment.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -313,11 +313,6 @@ type PushActionContent struct {
313313
CommitIDs []string `json:"commit_ids"`
314314
}
315315

316-
// RequestTeamReviewActionContent is content of requesting or cancelling request a team to review a PR
317-
type RequestTeamReviewActionContent struct {
318-
TeamName string `json:"team_name"`
319-
}
320-
321316
// LoadIssue loads the issue reference for the comment
322317
func (c *Comment) LoadIssue(ctx context.Context) (err error) {
323318
if c.Issue != nil {

models/issues/review.go

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ package issues
55

66
import (
77
"context"
8-
"encoding/json"
98
"fmt"
109
"strings"
1110

@@ -816,14 +815,6 @@ func AddTeamReviewRequest(issue *Issue, reviewer *organization.Team, doer *user_
816815
}
817816
}
818817

819-
// record the name of team in case that we cannot get the name of team after it is deleted.
820-
var content RequestTeamReviewActionContent
821-
content.TeamName = reviewer.Name
822-
contentJSON, err := json.Marshal(content)
823-
if err != nil {
824-
return nil, err
825-
}
826-
827818
comment, err := CreateComment(ctx, &CreateCommentOptions{
828819
Type: CommentTypeReviewRequest,
829820
Doer: doer,
@@ -832,7 +823,6 @@ func AddTeamReviewRequest(issue *Issue, reviewer *organization.Team, doer *user_
832823
RemovedAssignee: false, // Use RemovedAssignee as !isRequest
833824
AssigneeTeamID: reviewer.ID, // Use AssigneeTeamID as reviewer team ID
834825
ReviewID: review.ID,
835-
Content: string(contentJSON),
836826
})
837827
if err != nil {
838828
return nil, fmt.Errorf("CreateComment(): %w", err)
@@ -885,22 +875,13 @@ func RemoveTeamReviewRequest(issue *Issue, reviewer *organization.Team, doer *us
885875
return nil, committer.Commit()
886876
}
887877

888-
// record the name of team in case that we cannot get the name of team after it is deleted.
889-
var content RequestTeamReviewActionContent
890-
content.TeamName = reviewer.Name
891-
contentJSON, err := json.Marshal(content)
892-
if err != nil {
893-
return nil, err
894-
}
895-
896878
comment, err := CreateComment(ctx, &CreateCommentOptions{
897879
Type: CommentTypeReviewRequest,
898880
Doer: doer,
899881
Repo: issue.Repo,
900882
Issue: issue,
901883
RemovedAssignee: true, // Use RemovedAssignee as !isRequest
902884
AssigneeTeamID: reviewer.ID, // Use AssigneeTeamID as reviewer team ID
903-
Content: string(contentJSON),
904885
})
905886
if err != nil {
906887
return nil, fmt.Errorf("CreateComment(): %w", err)

modules/templates/helper.go

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,6 @@ func NewFuncMap() []template.FuncMap {
363363
curBranch,
364364
)
365365
},
366-
"GetRequestReviewTeamName": GetRequestReviewTeamName,
367366
}}
368367
}
369368

@@ -800,19 +799,3 @@ func Eval(tokens ...any) (any, error) {
800799
n, err := eval.Expr(tokens...)
801800
return n.Value, err
802801
}
803-
804-
// If the value of commnet type is 27 and assigne_team_id not equal 0, this is a request review for a team.
805-
// So, we can use this func to parse the name of the team from `content` of the comment when the team is deleted.
806-
func GetRequestReviewTeamName(content string) string {
807-
if content == "" {
808-
return content
809-
}
810-
811-
var data issues_model.RequestTeamReviewActionContent
812-
if err := json.Unmarshal([]byte(content), &data); err != nil {
813-
log.Error("json.Unmarshal: %s, error: %v", content, err)
814-
return ""
815-
}
816-
817-
return data.TeamName
818-
}

templates/repo/issue/view_content/comments.tmpl

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -688,25 +688,11 @@
688688
{{$.locale.Tr "repo.issues.review.add_review_request" (.Assignee.GetDisplayName|Escape) $createdStr | Safe}}
689689
{{end}}
690690
{{else}}
691-
<!--
692-
- For new comments, the name of the team which is requested review is stored in the `content` column of the comment
693-
If the team was deleted, we can parse the name from the `content` column.
694-
Of course, if the team has not been deleted, we can get the name from `.AssigneeTeam` directly.
695-
696-
- For comments that already exist and the row of the team has been deleted,
697-
because we didn't save the name of the team in the `cotent` column of the comment before,
698-
So we can only display "Unknown Team" here.
699-
-->
700-
{{$teamName := "Unknown Team"}}
691+
<!-- If the assigned team is deleted, just displaying "Ghost Team" in the comment -->
692+
{{$teamName := "Ghost Team"}}
701693
{{if .AssigneeTeam}}
702694
{{$teamName = .AssigneeTeam.Name}}
703-
{{else if .Content}}
704-
{{$teamNameFromContent := GetRequestReviewTeamName .Content}}
705-
{{if not (eq $teamNameFromContent "")}}
706-
{{$teamName = $teamNameFromContent}}
707-
{{end}}
708695
{{end}}
709-
710696
{{if .RemovedAssignee}}
711697
{{$.locale.Tr "repo.issues.review.remove_review_request" ($teamName|Escape) $createdStr | Safe}}
712698
{{else}}

0 commit comments

Comments
 (0)