{{template "base/head" .}}
<div class="page-content organization teams">
	{{template "org/header" .}}
	<div class="ui container">
		{{template "base/alert" .}}
		<div class="ui grid">
			{{template "org/team/sidebar" .}}
			<div class="ui ten wide column">
				{{template "org/team/navbar" .}}
				{{$canAddRemove := and $.IsOrganizationOwner (not $.Team.IncludesAllRepositories)}}
				{{if $canAddRemove}}
					<div class="ui attached segment" id="repo-top-segment">
						<div class="inline ui field left">
							<form class="ui form ignore-dirty" id="add-repo-form" action="{{$.OrgLink}}/teams/{{$.Team.LowerName | PathEscape}}/action/repo/add" method="post">
								{{.CsrfTokenHtml}}
								<div class="inline field ui left">
									<div id="search-repo-box" data-uid="{{.Org.ID}}" class="ui search">
										<div class="ui input">
											<input class="prompt" name="repo_name" placeholder="{{.locale.Tr "org.teams.search_repo_placeholder"}}" autocomplete="off" required>
										</div>
									</div>
								</div>
								<button class="ui green button">{{.locale.Tr "add"}}</button>
							</form>
						</div>
						<div class="inline ui field right">
							<form class="ui form" id="repo-multiple-form" action="{{$.OrgLink}}/teams/{{$.Team.LowerName | PathEscape}}/repositories" method="post">
								<button class="ui red button delete-button right" data-url="{{$.OrgLink}}/teams/{{$.Team.LowerName | PathEscape}}/action/repo/removeall">{{.locale.Tr "remove_all"}}</button>
								<button class="ui green button add-all-button right" data-url="{{$.OrgLink}}/teams/{{$.Team.LowerName | PathEscape}}/action/repo/addall">{{.locale.Tr "add_all"}}</button>
							</form>
						</div>
					</div>
				{{end}}
				<div class="ui bottom attached table segment repositories">
					{{range .Team.Repos}}
						<div class="item">
							{{if $canAddRemove}}
								<form method="post" action="{{$.OrgLink}}/teams/{{$.Team.LowerName | PathEscape}}/action/repo/remove">
									{{$.CsrfTokenHtml}}
									<button type="submit" class="ui red small button right" name="repoid" value="{{.ID}}">{{$.locale.Tr "remove"}}</button>
								</form>
							{{end}}
							<a class="member" href="{{$.Org.HomeLink}}/{{.Name | PathEscape}}">
								{{if .IsPrivate}}
									{{svg "octicon-lock"}}
								{{else if .IsFork}}
									{{svg "octicon-repo-forked"}}
								{{else if .IsMirror}}
									{{svg "octicon-mirror"}}
								{{else}}
									{{svg "octicon-repo"}}
								{{end}}
								<strong>{{$.Org.Name}}/{{.Name}}</strong>
							</a>
						</div>
					{{else}}
						<div class="item">
							<span class="text grey italic">{{$.locale.Tr "org.teams.repos.none"}}</span>
						</div>
					{{end}}
				</div>
			</div>
		</div>
	</div>
</div>

<div class="ui small basic delete modal">
	<div class="ui icon header">
		{{svg "octicon-trash"}}
		{{.locale.Tr "org.teams.remove_all_repos_title"}}
	</div>
	<div class="content">
		<p>{{.locale.Tr "org.teams.remove_all_repos_desc"}}</p>
	</div>
	{{template "base/delete_modal_actions" .}}
</div>

<div class="ui small basic addall modal">
	<div class="ui icon header">
		<i class="globe icon"></i>
		{{.locale.Tr "org.teams.add_all_repos_title"}}
	</div>
	<div class="content">
		<p>{{.locale.Tr "org.teams.add_all_repos_desc"}}</p>
	</div>
	{{template "base/delete_modal_actions" .}}
</div>

{{template "base/footer" .}}