-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Add more Links to Comments #25049
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
base: main
Are you sure you want to change the base?
Add more Links to Comments #25049
Conversation
if comment.Milestone != nil && comment.Milestone.ID != -1 { | ||
err = comment.Milestone.LoadRepo(ctx) | ||
if err != nil { | ||
ctx.ServerError("LoadMilestoneRepo", err) | ||
return | ||
} | ||
} | ||
if comment.OldMilestone != nil && comment.OldMilestone.ID != -1 { | ||
err = comment.OldMilestone.LoadRepo(ctx) | ||
if err != nil { | ||
ctx.ServerError("LoadMilestoneRepo", err) | ||
return | ||
} | ||
} |
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 recommend two separate methods Comment#LoadMilestone
and Comment#LoadOldMilestone
|
||
// Link returns the milestone Link | ||
func (m *Milestone) Link() string { | ||
return fmt.Sprintf("%s/milestone/%d", m.Repo.HTMLURL(), m.ID) |
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.
You want m.Repo.Link
here.
HTMLURL
is absolute while Link
should be relative.
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.
return fmt.Sprintf("%s/milestone/%d", m.Repo.HTMLURL(), m.ID) | |
return fmt.Sprintf("%s/milestone/%d", m.Repo.Link(), m.ID) |
@@ -209,7 +217,7 @@ | |||
{{if eq .Poster.ID .Assignee.ID}} | |||
{{$.locale.Tr "repo.issues.remove_self_assignment" $createdStr | Safe}} | |||
{{else}} | |||
{{$.locale.Tr "repo.issues.remove_assignee_at" (.Poster.GetDisplayName|Escape) $createdStr | Safe}} | |||
{{$.locale.Tr "repo.issues.remove_assignee_at" (printf `<a href="%s">%s</a>` .Poster.HomeLink (.Poster.GetDisplayName|Escape)) $createdStr | Safe}} |
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.
We are adding the same exact call that many times that we should perhaps extract it into a separate function.
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.
This is only used in this template. Do we really need a own function for for every object something that is used in a single template a few times?
The events in the Comment history have now Links. e.g. If foo added this to the bar milestone, appears in the Comments, bar is now a Link to the bar Milestone. On the UI Side nothing changed. Everything looks the same.