{{template "base/head" .}}
<div role="main" aria-label="{{.Title}}" class="page-content organization teams">
	{{template "org/header" .}}
	<div class="ui container">
		{{template "base/alert" .}}
		<div class="ui stackable grid">
			{{template "org/team/sidebar" .}}
			<div class="ui ten wide column">
				{{template "org/team/navbar" .}}
				{{if .IsOrganizationOwner}}
					<div class="ui attached segment">
						<form class="ui form ignore-dirty gt-df gt-fw gt-gap-3" action="{{$.OrgLink}}/teams/{{$.Team.LowerName | PathEscape}}/action/add" method="post">
							{{.CsrfTokenHtml}}
							<input type="hidden" name="uid" value="{{.SignedUser.ID}}">
							<div id="search-user-box" class="ui search gt-mr-3"{{if .IsEmailInviteEnabled}} data-allow-email="true" data-allow-email-description="{{.locale.Tr "org.teams.invite_team_member" $.Team.Name}}"{{end}}>
								<div class="ui input">
									<input class="prompt" name="uname" placeholder="{{.locale.Tr "repo.settings.search_user_placeholder"}}" autocomplete="off" required>
								</div>
							</div>
							<button class="ui green button">{{.locale.Tr "org.teams.add_team_member"}}</button>
						</form>
					</div>
				{{end}}
				<div class="ui attached segment">
					<div class="flex-list">
						{{range .Team.Members}}
							<div class="flex-item flex-item-center">
								<div class="flex-item-leading">
									<a href="{{.HomeLink}}">{{avatar $.Context . 32}}</a>
								</div>
								<div class="flex-item-main">
									<div class="flex-item-title">
										{{template "shared/user/name" .}}
									</div>
								</div>
								<div class="flex-item-trailing">
									{{if and $.IsOrganizationOwner (not (and ($.Team.IsOwnerTeam) (eq (len $.Team.Members) 1)))}}
										<form>
											<button class="ui red button delete-button" data-modal-id="remove-team-member"
												data-url="{{$.OrgLink}}/teams/{{$.Team.LowerName | PathEscape}}/action/remove" data-datauid="{{.ID}}"
												data-name="{{.DisplayName}}"
												data-data-team-name="{{$.Team.Name}}">{{$.locale.Tr "org.members.remove"}}</button>
										</form>
									{{end}}
								</div>
							</div>
						{{else}}
							<div class="flex-item">
								<span class="text grey italic">{{$.locale.Tr "org.teams.members.none"}}</span>
							</div>
						{{end}}
					</div>
				</div>
				{{if and .Invites $.IsOrganizationOwner}}
				<h4 class="ui top attached header">{{$.locale.Tr "org.teams.invite_team_member.list"}}</h4>
				<div class="ui bottom attached table segment members">
					{{range .Invites}}
						<div class="item gt-df gt-ac gt-fw">
							<span class="gt-f1">{{.Email}}</span>
							<form action="{{$.OrgLink}}/teams/{{$.Team.LowerName | PathEscape}}/action/remove_invite" method="post">
								{{$.CsrfTokenHtml}}
								<input type="hidden" name="iid" value="{{.ID}}">
								<button class="ui red button">{{$.locale.Tr "org.members.remove"}}</button>
							</form>
						</div>
					{{end}}
				</div>
				{{end}}
			</div>
		</div>
	</div>
</div>
<div class="ui g-modal-confirm delete modal" id="remove-team-member">
	<div class="header">
		{{$.locale.Tr "org.members.remove"}}
	</div>
	<div class="content">
		<p>{{$.locale.Tr "org.members.remove.detail" `<span class="name"></span>` `<span class="dataTeamName"></span>` | Safe}}</p>
	</div>
	{{template "base/modal_actions_confirm" .}}
</div>
{{template "base/footer" .}}