{{template "base/head" .}}
<div role="main" aria-label="{{.Title}}" class="page-content organization members">
	{{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="./teams">{{ctx.Locale.Tr "org.teams.manage_team_member"}}</a>
			</div>
			<div class="divider"></div>
		{{end}}
		<div class="flex-divided-list items-with-main">
			{{range .Members}}
				{{$isPublic := index $.MembersIsPublicMember .ID}}
				<div class="item {{if $.PublicOnly}}tw-items-center{{end}}">
					<div class="item-leading">
						<a href="{{.HomeLink}}">{{ctx.AvatarUtils.Avatar . 48}}</a>
					</div>
					<div class="item-main">
						<div class="item-title">
							{{template "shared/user/name" .}}
							{{if not $isPublic}}
								<span class="ui basic small label">{{ctx.Locale.Tr "org.members.private"}}</span>
							{{end}}
						</div>
						<div class="tw-flex tw-flex-col tw-gap-1">
							{{if not $.PublicOnly}}
							<div>
								{{ctx.Locale.Tr "org.members.member_role"}}
								<strong class="flex-text-inline">{{if index $.MembersIsUserOrgOwner .ID}}{{svg "octicon-shield-lock"}} {{ctx.Locale.Tr "org.members.owner"}}{{else}}{{ctx.Locale.Tr "org.members.member"}}{{end}}</strong>
							</div>
							{{end}}
							{{if $.IsOrganizationOwner}}
							<div>
								{{ctx.Locale.Tr "admin.users.2fa"}}:
								{{if index $.MembersTwoFaStatus .ID}}
									<span class="tw-text-green tw-flex">{{svg "octicon-check"}}</span>
								{{else}}
									{{svg "octicon-x"}}
								{{end}}
							</div>
							{{end}}
						</div>
					</div>
					<div class="item-trailing">
						{{if or (eq $.SignedUser.ID .ID) $.IsOrganizationOwner}}
							{{if $isPublic}}
								<a class="ui tiny button link-action" href data-url="{{$.OrgLink}}/members/action/private?uid={{.ID}}">{{svg "octicon-eye-closed" 12 "icon"}}{{ctx.Locale.Tr "org.members.public_helper"}}</a>
							{{else}}
								<a class="ui tiny button link-action" href data-url="{{$.OrgLink}}/members/action/public?uid={{.ID}}">{{svg "octicon-eye" 12 "icon"}}{{ctx.Locale.Tr "org.members.private_helper"}}</a>
							{{end}}
						{{end}}
						{{if eq $.SignedUser.ID .ID}}
							<button class="ui red tiny button link-action"
								data-url="{{$.OrgLink}}/members/action/leave?uid={{.ID}}"
								data-modal-confirm-header="{{ctx.Locale.Tr "org.members.leave"}}"
								data-modal-confirm-content="{{ctx.Locale.Tr "org.members.leave.detail" $.Org.DisplayName}}"
								>{{ctx.Locale.Tr "org.members.leave"}}</button>
						{{else if $.IsOrganizationOwner}}
							<button class="ui red tiny button link-action"
								data-url="{{$.OrgLink}}/members/action/remove?uid={{.ID}}"
								data-modal-confirm-header="{{ctx.Locale.Tr "org.members.remove"}}"
								data-modal-confirm-content="{{ctx.Locale.Tr "org.members.remove.detail" .DisplayName $.Org.DisplayName}}"
							>{{ctx.Locale.Tr "org.members.remove"}}</button>
						{{end}}
					</div>
				</div>
			{{end}}
		</div>
		{{template "base/paginate" .}}
	</div>
</div>
{{template "base/footer" .}}
