{{$canReadReleases := $.Permission.CanRead $.UnitTypeReleases}}
{{$canReadCode := $.Permission.CanRead $.UnitTypeCode}}

{{if $canReadReleases}}
	<div class="tw-flex">
		<div class="tw-flex-1 tw-flex tw-items-center">
			<h2 class="ui compact small menu small-menu-items">
				<a class="{{if and .PageIsReleaseList (not .PageIsSingleTag)}}active {{end}}item" href="{{.RepoLink}}/releases{{if .Keyword}}?q={{.Keyword}}{{end}}">{{ctx.Locale.TrN .NumReleases "repo.n_release_one" "repo.n_release_few" (ctx.Locale.PrettyNumber .NumReleases)}}</a>
				{{if $canReadCode}}
					<a class="{{if or .PageIsTagList .PageIsSingleTag}}active {{end}}item" href="{{.RepoLink}}/tags{{if .Keyword}}?q={{.Keyword}}{{end}}">{{ctx.Locale.TrN .NumTags "repo.n_tag_one" "repo.n_tag_few" (ctx.Locale.PrettyNumber .NumTags)}}</a>
				{{end}}
			</h2>
		</div>
		{{if .ShowReleaseSearch}}
			<form class="ignore-dirty tw-w-1/5 tw-mr-3" method="get">
				{{template "shared/search/combo" dict "Value" .Keyword}}
			</form>
		{{end}}
		<div class="button-row">
			{{if .EnableFeed}}
				<a class="ui small button tw-h-full" href="{{.RepoLink}}/{{if .PageIsTagList}}tags{{else}}releases{{end}}.rss">
					{{svg "octicon-rss" 16}} {{ctx.Locale.Tr "rss_feed"}}
				</a>
			{{end}}
			{{if and (not .PageIsTagList) .CanCreateRelease}}
				<a class="ui small primary button" href="{{$.RepoLink}}/releases/new">
					{{ctx.Locale.Tr "repo.release.new_release"}}
				</a>
			{{end}}
		</div>
	</div>
	<div class="divider"></div>
{{else if $canReadCode}}
	{{/* if the "repo.releases" unit is disabled, only show the "commits / branches / tags" sub menu */}}
	{{template "repo/sub_menu" .}}
{{end}}
