Skip to content

Commit a04eeb2

Browse files
authored
Show edit/close/delete button on organization wide repositories (#23388)
A part of #22865
1 parent e72290f commit a04eeb2

File tree

4 files changed

+12
-12
lines changed

4 files changed

+12
-12
lines changed

routers/web/repo/projects.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ func Projects(ctx *context.Context) {
113113
pager.AddParam(ctx, "state", "State")
114114
ctx.Data["Page"] = pager
115115

116-
ctx.Data["CanWriteProjects"] = true
116+
ctx.Data["CanWriteProjects"] = ctx.Repo.Permission.CanWrite(unit.TypeProjects)
117117
ctx.Data["IsShowClosed"] = isShowClosed
118118
ctx.Data["IsProjectsPage"] = true
119119
ctx.Data["SortType"] = sortType

templates/projects/list.tmpl

+3-3
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,15 @@
5151
{{JsPrettyNumber .NumClosedIssues}} {{$.locale.Tr "repo.issues.closed_title"}}
5252
</span>
5353
</div>
54-
{{if and (or $.CanWriteIssues $.CanWritePulls) (not $.Repository.IsArchived)}}
54+
{{if and $.CanWriteProjects (not $.Repository.IsArchived)}}
5555
<div class="ui right operate">
5656
<a href="{{$.Link}}/{{.ID}}/edit" data-id={{.ID}} data-title={{.Title}}>{{svg "octicon-pencil"}} {{$.locale.Tr "repo.issues.label_edit"}}</a>
5757
{{if .IsClosed}}
5858
<a class="link-action" href data-url="{{$.Link}}/{{.ID}}/open">{{svg "octicon-check"}} {{$.locale.Tr "repo.projects.open"}}</a>
5959
{{else}}
6060
<a class="link-action" href data-url="{{$.Link}}/{{.ID}}/close">{{svg "octicon-skip"}} {{$.locale.Tr "repo.projects.close"}}</a>
6161
{{end}}
62-
<a class="delete-button" href="#" data-url="{{$.RepoLink}}/projects/{{.ID}}/delete" data-id="{{.ID}}">{{svg "octicon-trash"}} {{$.locale.Tr "repo.issues.label_delete"}}</a>
62+
<a class="delete-button" href="#" data-url="{{$.Link}}/{{.ID}}/delete" data-id="{{.ID}}">{{svg "octicon-trash"}} {{$.locale.Tr "repo.issues.label_delete"}}</a>
6363
</div>
6464
{{end}}
6565
{{if .Description}}
@@ -75,7 +75,7 @@
7575
</div>
7676
</div>
7777

78-
{{if or .CanWriteIssues .CanWritePulls}}
78+
{{if $.CanWriteProjects}}
7979
<div class="ui small basic delete modal">
8080
<div class="ui icon header">
8181
{{svg "octicon-trash"}}

templates/projects/view.tmpl

+2-2
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
<h2 class="project-title">{{$.Project.Title}}</h2>
4444
<div class="content project-description">{{$.Project.RenderedContent|Str2html}}</div>
4545
</div>
46-
{{if or $.CanWriteIssues $.CanWritePulls}}
46+
{{if $.CanWriteProjects}}
4747
<div class="column right aligned">
4848
<div class="ui compact right small menu">
4949
<a class="item" href="{{$.Link}}/edit?redirect=project" data-id={{$.Project.ID}} data-title={{$.Project.Title}}>
@@ -256,7 +256,7 @@
256256

257257
</div>
258258

259-
{{if or .CanWriteIssues .CanWritePulls}}
259+
{{if .CanWriteProjects}}
260260
<div class="ui small basic delete modal">
261261
<div class="ui icon header">
262262
{{svg "octicon-trash"}}

templates/repo/projects/list.tmpl

+6-6
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,15 @@
5353
{{JsPrettyNumber .NumClosedIssues}}&nbsp;{{$.locale.Tr "repo.issues.closed_title"}}
5454
</span>
5555
</div>
56-
{{if and (or $.CanWriteIssues $.CanWritePulls) (not $.Repository.IsArchived)}}
56+
{{if and $.CanWriteProjects (not $.Repository.IsArchived)}}
5757
<div class="ui right operate">
58-
<a href="{{$.Link}}/{{.ID}}/edit" data-id={{.ID}} data-title={{.Title}}>{{svg "octicon-pencil"}} {{$.locale.Tr "repo.issues.label_edit"}}</a>
58+
<a href="{{.Link}}/edit" data-id={{.ID}} data-title={{.Title}}>{{svg "octicon-pencil"}} {{$.locale.Tr "repo.issues.label_edit"}}</a>
5959
{{if .IsClosed}}
60-
<a class="link-action" href data-url="{{$.Link}}/{{.ID}}/open">{{svg "octicon-check"}} {{$.locale.Tr "repo.projects.open"}}</a>
60+
<a class="link-action" href data-url="{{.Link}}/open">{{svg "octicon-check"}} {{$.locale.Tr "repo.projects.open"}}</a>
6161
{{else}}
62-
<a class="link-action" href data-url="{{$.Link}}/{{.ID}}/close">{{svg "octicon-skip"}} {{$.locale.Tr "repo.projects.close"}}</a>
62+
<a class="link-action" href data-url="{{.Link}}/close">{{svg "octicon-skip"}} {{$.locale.Tr "repo.projects.close"}}</a>
6363
{{end}}
64-
<a class="delete-button" href="#" data-url="{{$.RepoLink}}/projects/{{.ID}}/delete" data-id="{{.ID}}">{{svg "octicon-trash"}} {{$.locale.Tr "repo.issues.label_delete"}}</a>
64+
<a class="delete-button" href="#" data-url="{{.Link}}/delete" data-id="{{.ID}}">{{svg "octicon-trash"}} {{$.locale.Tr "repo.issues.label_delete"}}</a>
6565
</div>
6666
{{end}}
6767
{{if .Description}}
@@ -77,7 +77,7 @@
7777
</div>
7878
</div>
7979

80-
{{if or .CanWriteIssues .CanWritePulls}}
80+
{{if .CanWriteProjects}}
8181
<div class="ui small basic delete modal">
8282
<div class="ui icon header">
8383
{{svg "octicon-trash"}}

0 commit comments

Comments
 (0)