fix: resolve three tech-debt FIXME/TODO items
- fix(blame): set HasSourceRenderedToggle for renderable files so that permalinks include ?display=source for correct line-number linking - fix(settings): translate team permission strings using data-locale attributes instead of raw API values - fix(dropzone): use relative path for non-image attachment markdown links for consistency with image attachments Refs #318, #334 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -2920,6 +2920,7 @@
|
||||
"org.teams.write_access_helper": "Members can read and push to team repositories.",
|
||||
"org.teams.admin_access": "Administrator Access",
|
||||
"org.teams.admin_access_helper": "Members can pull and push to team repositories and add collaborators to them.",
|
||||
"org.teams.owner_access": "Owner",
|
||||
"org.teams.no_desc": "This team has no description",
|
||||
"org.teams.settings": "Settings",
|
||||
"org.teams.owners_permission_desc": "Owners have full access to <strong>all repositories</strong> and have <strong>administrator access</strong> to the organization.",
|
||||
|
||||
@@ -20,6 +20,7 @@ import (
|
||||
"git.mokoconsulting.tech/MokoConsulting/MokoGitea/modules/gitrepo"
|
||||
"git.mokoconsulting.tech/MokoConsulting/MokoGitea/modules/highlight"
|
||||
"git.mokoconsulting.tech/MokoConsulting/MokoGitea/modules/log"
|
||||
"git.mokoconsulting.tech/MokoConsulting/MokoGitea/modules/markup"
|
||||
"git.mokoconsulting.tech/MokoConsulting/MokoGitea/modules/setting"
|
||||
"git.mokoconsulting.tech/MokoConsulting/MokoGitea/modules/templates"
|
||||
"git.mokoconsulting.tech/MokoConsulting/MokoGitea/modules/util"
|
||||
@@ -73,6 +74,12 @@ func RefBlame(ctx *context.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
// Set HasSourceRenderedToggle if the file has a known markup renderer,
|
||||
// so that permalinks include ?display=source for correct line-number linking.
|
||||
if markup.DetectRendererTypeByFilename(ctx.Repo.TreePath) != nil {
|
||||
ctx.Data["HasSourceRenderedToggle"] = true
|
||||
}
|
||||
|
||||
ctx.Data["NumLines"], err = blob.GetBlobLineCount(nil)
|
||||
if err != nil {
|
||||
ctx.NotFound(err)
|
||||
|
||||
@@ -76,8 +76,6 @@
|
||||
</table>
|
||||
{{end}}{{/* end if .IsFileTooLarge */}}
|
||||
<div class="code-line-menu tippy-target">
|
||||
{{/*FIXME: the "HasSourceRenderedToggle" is never set on blame page, it should mean "whether the file is renderable".
|
||||
If the file is renderable, then it must has the "display=source" parameter to make sure the file view page shows the source code, then line number works. */}}
|
||||
{{if $.Permission.CanRead ctx.Consts.RepoUnitTypeIssues}}
|
||||
<a class="item ref-in-new-issue" role="menuitem" data-url-issue-new="{{.RepoLink}}/issues/new" data-url-param-body-link="{{.Repository.Link}}/src/commit/{{PathEscape .CommitID}}/{{PathEscapeSegments .TreePath}}{{if $.HasSourceRenderedToggle}}?display=source{{end}}" rel="nofollow noindex">{{ctx.Locale.Tr "repo.issues.context.reference_issue"}}</a>
|
||||
{{end}}
|
||||
|
||||
@@ -107,7 +107,12 @@
|
||||
<div class="ui bottom attached segment">
|
||||
{{if $allowedToChangeTeams}}
|
||||
<form class="ui form" id="repo-collab-team-form" action="{{.Link}}/team" method="post">
|
||||
<div id="search-team-box" class="ui search input tw-align-middle" data-org-name="{{.OrgName}}">
|
||||
<div id="search-team-box" class="ui search input tw-align-middle" data-org-name="{{.OrgName}}"
|
||||
data-locale-permission-none="{{ctx.Locale.Tr "org.teams.none_access"}}"
|
||||
data-locale-permission-read="{{ctx.Locale.Tr "org.teams.read_access"}}"
|
||||
data-locale-permission-write="{{ctx.Locale.Tr "org.teams.write_access"}}"
|
||||
data-locale-permission-admin="{{ctx.Locale.Tr "org.teams.admin_access"}}"
|
||||
data-locale-permission-owner="{{ctx.Locale.Tr "org.teams.owner_access"}}">
|
||||
<input class="prompt" name="team" placeholder="{{ctx.Locale.Tr "search.team_kind"}}" autocomplete="off" required>
|
||||
</div>
|
||||
<button class="ui primary button">{{ctx.Locale.Tr "repo.settings.add_team"}}</button>
|
||||
|
||||
@@ -34,9 +34,8 @@ export function generateMarkdownLinkForAttachment(file: Partial<CustomDropzoneFi
|
||||
// Make the image link relative to the repo path, then the final URL is "/sub-path/owner/repo/attachments/{uuid}"
|
||||
fileMarkdown = html`<img width="${Math.round(width / dppx)}" alt="${file.name}" src="attachments/${file.uuid}">`;
|
||||
} else {
|
||||
// Markdown always renders the image with a relative path, so the final URL is "/sub-path/owner/repo/attachments/{uuid}"
|
||||
// TODO: it should also use relative path for consistency, because absolute is ambiguous for "/sub-path/attachments" or "/attachments"
|
||||
fileMarkdown = ``;
|
||||
// Use relative path for consistency with the image tag above
|
||||
fileMarkdown = ``;
|
||||
}
|
||||
} else if (isVideoFile(file)) {
|
||||
fileMarkdown = html`<video src="attachments/${file.uuid}" title="${file.name}" controls></video>`;
|
||||
|
||||
@@ -59,9 +59,10 @@ function initRepoSettingsSearchTeamBox() {
|
||||
onResponse(response: any) {
|
||||
const items: Array<Record<string, any>> = [];
|
||||
for (const item of response.data) {
|
||||
const localizedPermission = searchTeamBox.getAttribute(`data-locale-permission-${item.permission}`) || `${item.permission} access`;
|
||||
items.push({
|
||||
title: item.name,
|
||||
description: `${item.permission} access`, // TODO: translate this string
|
||||
description: localizedPermission,
|
||||
});
|
||||
}
|
||||
return {results: items};
|
||||
|
||||
Reference in New Issue
Block a user