{{template "base/head" .}}
<div role="main" aria-label="{{.Title}}" class="page-content organization teams">
	{{template "org/header" .}}
	<div class="ui container">
		{{template "base/alert" .}}
		{{if .IsOrganizationOwner}}
			<div class="flex-text-block">
				<div class="tw-flex-1">{{ctx.Locale.Tr "org.teams.manage_team_member_prompt"}}</div>
				<a class="ui primary button" href="{{.OrgLink}}/teams/new">{{svg "octicon-plus"}} {{ctx.Locale.Tr "org.create_new_team"}}</a>
			</div>
		{{end}}

		<form class="ui form ignore-dirty tw-my-4" method="get" action="{{$.Link}}">
			<div class="ui fluid action input">
				<input type="search" name="q" value="{{$.Keyword}}" placeholder="{{ctx.Locale.Tr "search.team_kind"}}" maxlength="255" spellcheck="false">
				<button class="ui button" type="submit">{{svg "octicon-search"}}</button>
			</div>
		</form>

		<div class="ui two column stackable grid">
			{{range $team := $.OrgListTeams}}
				<div class="column team-item-box">
					<div class="ui top attached header muted-links flex-left-right team-item-header">
						<div class="flex-text-inline">
							<a href="{{$.OrgLink}}/teams/{{.LowerName | PathEscape}}"><strong>{{.Name}}</strong></a>
							{{if .IsPrivate}}
								<span class="ui mini label" data-tooltip-content="{{ctx.Locale.Tr "org.teams.visibility_private_helper"}}">{{ctx.Locale.Tr "org.teams.visibility_private"}}</span>
							{{else if .IsLimited}}
								<span class="ui mini label" data-tooltip-content="{{ctx.Locale.Tr "org.teams.visibility_limited_helper"}}">{{ctx.Locale.Tr "org.teams.visibility_limited"}}</span>
							{{else if .IsPublic}}
								<span class="ui mini label" data-tooltip-content="{{ctx.Locale.Tr "org.teams.visibility_public_helper"}}">{{ctx.Locale.Tr "org.teams.visibility_public"}}</span>
							{{end}}
						</div>
						<div class="flex-text-block tw-flex-wrap">
							<a href="{{$.OrgLink}}/teams/{{.LowerName | PathEscape}}">{{.NumMembers}} {{ctx.Locale.Tr "org.lower_members"}}</a>
							·
							<a href="{{$.OrgLink}}/teams/{{.LowerName | PathEscape}}/repositories">{{.NumRepos}} {{ctx.Locale.Tr "org.lower_repositories"}}</a>
							{{if .IsMember ctx $.SignedUser.ID}}
								<button class="ui red mini compact button show-modal" data-modal="#org-member-leave-team"
									data-modal-form.action="{{$.OrgLink}}/teams/{{.LowerName | PathEscape}}/action/leave?uid={{$.SignedUser.ID}}"
									data-modal-to-leave-team-name="{{.Name}}"
								>{{ctx.Locale.Tr "org.teams.leave"}}</button>
							{{end}}
						</div>
					</div>
					{{if $team.Description}}
					<div class="ui attached header team-item-description">
						{{if $team.Description}}{{$team.Description}}{{end}}
					</div>
					{{end}}
					<div class="ui attached segment">
						<div class="flex-text-block tw-flex-wrap">
							{{range .Members}}
								{{template "shared/user/avatarlink" dict "user" . "size" 32 "tooltip" true}}
							{{else}}
								<a class="flex-text-inline tw-h-[32px]" href="{{$.OrgLink}}/teams/{{$team.LowerName | PathEscape}}">{{ctx.Locale.Tr "org.teams.add_team_member"}}</a>
							{{end}}
						</div>
					</div>
				</div>
			{{end}}
		</div>
	{{template "base/paginate" .}}
	</div>
</div>
<div class="ui mini modal" id="org-member-leave-team">
	<div class="header">
		{{ctx.Locale.Tr "org.teams.leave"}}
	</div>
	<form class="content ui form form-fetch-action" method="post">
		<p>{{ctx.Locale.Tr "org.teams.leave.detail" (HTMLFormat `<span class="%s"></span>` "to-leave-team-name")}}</p>
		{{template "base/modal_actions_confirm" .}}
	</form>
</div>
{{template "base/footer" .}}
