-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Add file tree to file view page #32721
base: main
Are you sure you want to change the base?
Add file tree to file view page #32721
Conversation
7229b60
to
59e46d4
Compare
e45940d
to
c4e7f0c
Compare
…-file-view-page' into add-file-tree-to-file-view-page
…2/gitea into kerwin612-add-file-tree-to-file-view-page
{{template "repo/branch_dropdown" dict | ||
"Repository" .ctxData.Repository | ||
"ShowTabBranches" true | ||
"ShowTabTags" true | ||
"CurrentRefType" .ctxData.RefType | ||
"CurrentRefShortName" .ctxData.RefShortName | ||
"CurrentTreePath" .ctxData.TreePath | ||
"RefLinkTemplate" "{RepoLink}/src/{RefType}/{RefShortName}/{TreePath}" | ||
"AllowCreateNewRef" .ctxData.CanCreateBranch | ||
"ShowViewAllRefsEntry" true | ||
"ContainerClasses" .containerClasses | ||
}} |
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 file is not right (the merge was wrong)
Maybe not wrong but it should not be like that IMO
ctx.Data["RefShortName"] = util.Iif(refType == RepoRefCommit, base.ShortSha(ctx.Repo.RefName), ctx.Repo.RefName) | ||
ctx.Data["RefType"] = RefTypeName(refType) |
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 shouldn't do that (keep adding more variables to global template data)
If you'd like to refactor it, it needs a separate PR, mixing everything together would make this PR unmaintainable and possible to lose code.
-> Refactor context repository #33202
ref := ctx.FormTrim("ref") | ||
recursive := ctx.FormBool("recursive") | ||
|
||
gitRepo, closer, err := gitrepo.RepositoryFromContextOrOpen(ctx, ctx.Repo.Repository) |
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.
There is ctx.Repo.GitRepo
} | ||
defer closer.Close() | ||
|
||
refName := gitRepo.UnstableGuessRefByShortName(ref) |
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.
@@ -743,6 +744,21 @@ const ( | |||
RepoRefBlob | |||
) | |||
|
|||
func RefTypeName(refType RepoRefType) string { |
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.
It duplicates with BranchNameSubURL
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as resolved.
This comment was marked as resolved.
It seems that PDF file will broken. a good test repo: https://gitea.com/silverwind/symlink-test/src/branch/master/pdf/bitcoin.pdf Reproduce:
Edited: |
This comment was marked as outdated.
This comment was marked as outdated.
resolved |
resolved |
My mouse has a |
http://host/owner/symlink-test/src/tag/0.0.1/file-symlink file-symlink not work. |
@@ -118,3 +122,363 @@ func GetTreeBySHA(ctx context.Context, repo *repo_model.Repository, gitRepo *git | |||
} | |||
return tree, nil | |||
} | |||
|
|||
type TreeEntry struct { |
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 think we shouldn't call it TreeEntry
again since there are already some TreeEntry
structs in code.
|
||
type TreeEntry struct { | ||
Name string `json:"name"` | ||
IsFile bool `json:"isFile"` |
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.
Besides "file" / "dir", it could also be something like "submodule"
// There are many "cancel button" elements in modal dialogs, Fomantic UI expects they are button-like elements but never submit a form. | ||
// However, Gitea misuses the modal dialog and put the cancel buttons inside forms, so we must prevent the form submission. | ||
// There are a few cancel buttons in non-modal forms, and there are some dynamically created forms (eg: the "Edit Issue Content") | ||
addDelegatedEventListener(document, 'click', 'form button.ui.cancel.button', (_ /* el */, e) => e.preventDefault()); | ||
addDelegatedEventListener(target, 'click', 'form button.ui.cancel.button', (_ /* el */, e) => e.preventDefault()); |
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.
addDelegatedEventListener
means the event listener has been added to the "document" globally, it works for all nodes (including newly added ones), the listener shouldn't be added to any children elements anymore.
To make things clear, we need this first: Refactor context repository #33202 |
This pull request introduces a file tree on the left side when reviewing files of a repository.