Skip to content

Refactor dashboard/feed.tmpl #26956

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

Merged
merged 7 commits into from
Sep 7, 2023
Merged

Conversation

CaiCandong
Copy link
Member

@CaiCandong CaiCandong commented Sep 7, 2023

  • Refactor ActionType to models/activities/action_type.go
  • Replace the magic number in feed.tmlp with InAction

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Sep 7, 2023
@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Sep 7, 2023
@lunny lunny added the type/refactoring Existing code has been cleaned up. There should be no new functionality. label Sep 7, 2023
@pull-request-size pull-request-size bot added size/M and removed size/L labels Sep 7, 2023
@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Sep 7, 2023
@lunny lunny added the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Sep 7, 2023
@KN4CK3R KN4CK3R merged commit 30cea70 into go-gitea:main Sep 7, 2023
@GiteaBot GiteaBot added this to the 1.22.0 milestone Sep 7, 2023
@GiteaBot GiteaBot removed the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Sep 7, 2023
@techknowlogick techknowlogick modified the milestones: 1.22.0, 1.21.0 Sep 8, 2023
zjjhot added a commit to zjjhot/gitea that referenced this pull request Sep 8, 2023
* giteaofficial/main:
  Add `yamllint` (go-gitea#26965)
  Fix yaml quoting (go-gitea#26964)
  [skip ci] Updated translations via Crowdin
  Add `actions/labeler` (go-gitea#26962)
  Team invite url fix when registration disabled (go-gitea#26950)
  Refactor dashboard/feed.tmpl (go-gitea#26956)
  Improve hint when uploading a too large avatar (go-gitea#26935)
  Replace `util.SliceXxx`  with `slices.Xxx`  (go-gitea#26958)
  Add reverseproxy auth for API back with default disabled (go-gitea#26703)
  Add "dir=auto" for input/textarea elements by default (go-gitea#26735)
@silverwind
Copy link
Member

Dashboard fails to load for me with 500 on my local instance after this:

Render failed, failed to render template: user/dashboard/dashboard, error: template error: builtin(static):user/dashboard/feeds:14:20 : executing "user/dashboard/feeds" at <.GetOpType.InActions>: can't evaluate field InActions in type activities.ActionType
----------------------------------------------------------------------
					{{if .GetOpType.InActions "create_repo"}}
					               ^

@CaiCandong
Copy link
Member Author

CaiCandong commented Sep 8, 2023

Let me check It.
@silverwind
Is your source code consistent with main branch ? This function exists.

func (at ActionType) InActions(actions ...string) bool {
for _, action := range actions {
if action == at.String() {
return true
}
}
return false
}

@silverwind
Copy link
Member

Yes, I'm at bafe133.

@CaiCandong
Copy link
Member Author

CaiCandong commented Sep 8, 2023

Yes, I'm at bafe133.

Thanks, indeed this function was missing.

{{if gt .ActUser.ID 0}}
<a href="{{AppSubUrl}}/{{.GetActUserName | PathEscape}}" title="{{.GetDisplayNameTitle}}">{{.GetDisplayName}}</a>
{{else}}
{{.ShortActUserName}}
{{end}}
{{if eq .GetOpType 1}}
{{$.locale.Tr "action.create_repo" (.GetRepoLink|Escape) (.ShortRepoPath|Escape) | Str2html}}
{{else if eq .GetOpType 2}}
{{$.locale.Tr "action.rename_repo" (.GetContent|Escape) (.GetRepoLink|Escape) (.ShortRepoPath|Escape) | Str2html}}
{{else if eq .GetOpType 5}}
{{if .Content}}
{{$.locale.Tr "action.commit_repo" (.GetRepoLink|Escape) (.GetRefLink|Escape) (Escape .GetBranch) (.ShortRepoPath|Escape) | Str2html}}
{{else}}
{{$.locale.Tr "action.create_branch" (.GetRepoLink|Escape) (.GetRefLink|Escape) (Escape .GetBranch) (.ShortRepoPath|Escape) | Str2html}}
{{end}}
{{else if eq .GetOpType 6}}
{{$index := index .GetIssueInfos 0}}
{{$.locale.Tr "action.create_issue" ((printf "%s/issues/%s" .GetRepoLink $index) |Escape) $index (.ShortRepoPath|Escape) | Str2html}}
{{else if eq .GetOpType 7}}

Your feeds.tmpl template doesn't seem to be aligned with action.go?
This PR was not released in 1.20.

@silverwind
Copy link
Member

Must be something else. I defintely got 30cea70 on my main branch that exactly matches the remote.

@CaiCandong
Copy link
Member Author

func (at ActionType) InActions(actions ...string) bool {
for _, action := range actions {
if action == at.String() {
return true
}
}
return false
}

Does this code exist locally? It's kind of weird.

@silverwind
Copy link
Member

silverwind commented Sep 8, 2023

Yes, it's there. Maybe I will dive deeper later, unless you find it first. You should be able to reproduce this hopefully. maybe it's something weird about my database (mysql).

@wxiaoguang
Copy link
Contributor

It can't be related to database.

Have you re-compiled and restarted the Gitea instance? Or could you try to do it manually in case it's the air bug?

@silverwind
Copy link
Member

I ran make clean-all build and that seems to have fixed it. Bad cache somewhere I assume.

@CaiCandong CaiCandong deleted the refactor/dashboard branch October 3, 2023 03:22
@go-gitea go-gitea locked as resolved and limited conversation to collaborators Dec 6, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. type/refactoring Existing code has been cleaned up. There should be no new functionality.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants