fix: hide some disallowed actions that lead to 404 errors in archived repos (#12773)

This
1. hides the “New issue” button, which currently leads to a 404 page, because it is not useful to have it, e.g., here: https://code.forgejo.org/forgejo/act/issues/169
2. removes the UI ability on projects in archived repos to move around issues and project columns. When a user performs such an action, currently it is shown as it were successful, but actually all requests lead to 404s without warning.
3. hides the hints for synching a fork or creating a pull request for recently pushed branches (which again would lead to 404s)
4. hides the branch selector (only shows the branch) on single issue/PR pages, which is disfunctional on archived repos

Thus, both these changes do not change anything related to what happens to issues or projects in archived repos, but only reduces 404 errors.

I don’t think this needs to be tested more than manually.

## Test

Create first a repository with at least **one issue** in **one project** and edit a file by creating a **new branch**. Then, perform following actions, once in the state where the repository is normal and once when it is archived:

action|unarchived|archived
---|---|---
\1. go to the issue|“New issue” button functional|“New issue” button removed
\2. click on the branch selector|menu opens|menu is now disabled and shows the branch
\3. go to the project|“New issue” button functional|“New issue” button removed
\4. try to move around columns|modifies columns|not possible anymore
\5. try to move around the issue|modifies issue location|not possible anymore
\6. go to the code view|see hint "You pushed …"|do not see this hint anymore

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/12773
Reviewed-by: Gusted <gusted@noreply.codeberg.org>
This commit is contained in:
Robert Wolff 2026-05-30 14:02:33 +02:00 committed by Gusted
commit ef44b777f4
5 changed files with 14 additions and 9 deletions

View file

@ -63,7 +63,7 @@
</div>
<div id="project-board">
<div class="board {{if .CanWriteProjects}}sortable{{end}}"{{if .CanWriteProjects}} data-url="{{$.Link}}/move"{{end}}>
<div class="board {{if $canWriteProject}}sortable{{end}}"{{if $canWriteProject}} data-url="{{$.Link}}/move"{{end}}>
{{range .Columns}}
<div class="project-column"{{if .Color}} style="background: {{.Color}} !important; color: {{ContrastColor .Color}} !important"{{end}} data-id="{{.ID}}" data-sorting="{{.Sorting}}" data-url="{{$.Link}}/{{.ID}}">
<div class="project-column-header{{if $canWriteProject}} tw-cursor-grab{{end}}">
@ -165,7 +165,7 @@
</div>
</div>
{{if .CanWriteProjects}}
{{if $canWriteProject}}
<div class="ui g-modal-confirm delete modal" id="delete-project">
<div class="header">
{{svg "octicon-trash"}}

View file

@ -147,8 +147,10 @@
</div>
</div>
{{template "repo/code/recently_pushed_new_branches" .}}
{{template "repo/code/fork_sync_message" .}}
{{if (not .Repository.IsArchived)}}
{{template "repo/code/recently_pushed_new_branches" .}}
{{template "repo/code/fork_sync_message" .}}
{{end}}
{{if .IsViewFile}}
{{template "repo/view_file" .}}

View file

@ -1,13 +1,14 @@
{{if and (not .Issue.IsPull) (not .PageIsComparePull)}}
{{$hasIssuesOrPullsWritePermission := and .HasIssuesOrPullsWritePermission (not .Repository.IsArchived)}}
<input id="ref_selector" name="ref" type="hidden" value="{{.Reference}}">
<input id="editing_mode" name="edit_mode" type="hidden" value="{{(or .IsIssueWriter .HasIssuesOrPullsWritePermission)}}">
<input id="editing_mode" name="edit_mode" type="hidden" value="{{$hasIssuesOrPullsWritePermission}}">
<form method="post" action="{{$.RepoLink}}/issues/{{.Issue.Index}}/ref" id="update_issueref_form">
</form>
{{/* TODO: share this branch selector dropdown with the same in repo page */}}
<div class="ui {{if not .HasIssuesOrPullsWritePermission}}disabled{{end}} floating filter select-branch dropdown tw-max-w-full" data-no-results="{{ctx.Locale.Tr "repo.pulls.no_results"}}">
<div class="ui {{if not $hasIssuesOrPullsWritePermission}}disabled{{end}} floating filter select-branch dropdown tw-max-w-full" data-no-results="{{ctx.Locale.Tr "repo.pulls.no_results"}}">
<div class="ui basic small button">
<span class="text branch-name gt-ellipsis">{{if .Reference}}{{$.RefEndName}}{{else}}{{ctx.Locale.Tr "repo.issues.no_ref"}}{{end}}</span>
{{if .HasIssuesOrPullsWritePermission}}{{svg "octicon-triangle-down" 14 "dropdown icon"}}{{end}}
{{if $hasIssuesOrPullsWritePermission}}{{svg "octicon-triangle-down" 14 "dropdown icon"}}{{end}}
</div>
<div class="menu">
<div class="ui icon search input">

View file

@ -13,7 +13,7 @@
{{if $canEditIssueTitle}}
<button id="issue-title-edit-show" class="ui small basic button">{{ctx.Locale.Tr "repo.issues.edit"}}</button>
{{end}}
{{if not .Issue.IsPull}}
{{if and (not .Issue.IsPull) (not .Repository.IsArchived)}}
<a role="button" class="ui small primary button" href="{{.RepoLink}}/issues/new{{if .NewIssueChooseTemplate}}/choose{{end}}">{{ctx.Locale.Tr "repo.issues.new"}}</a>
{{end}}
</div>

View file

@ -4,7 +4,9 @@
<div class="ui container padded">
<div class="tw-flex tw-justify-between tw-items-center tw-mb-4">
{{template "repo/issue/navbar" .}}
<a class="ui small primary button" href="{{.RepoLink}}/issues/new/choose?project={{.Project.ID}}">{{ctx.Locale.Tr "repo.issues.new"}}</a>
{{if (not $.Repository.IsArchived)}}
<a class="ui small primary button" href="{{.RepoLink}}/issues/new/choose?project={{.Project.ID}}">{{ctx.Locale.Tr "repo.issues.new"}}</a>
{{end}}
</div>
</div>
<div class="ui container fluid padded">