{{template "base/head" .}}
<div class="admin edit user">
	<div class="ui container">
		<div class="ui grid">
			{{template "admin/navbar" .}}
			<div class="twelve wide column content">
				{{template "base/alert" .}}
				<h4 class="ui top attached header">
					Edit Account 🖊
				</h4>
				<div class="ui attached segment">
					<form class="ui form" action="{{.Link}}" method="post">
						{{.CSRFTokenHTML}}
						<div class="inline field {{if .Err_UserName}}error{{end}}">
							<label for="user_name">Username</label>
							<a class="ui image label {{if .User.Suspended}}red{{end}}" href="{{AppURL}}{{.User.Name}}" target="_blank">
								<img src="{{AppendAvatarSize .User.RelAvatarLink 40}}"> {{.User.Name}}
							</a>
							<div class="ui label">
								Followers <div class="detail">{{.User.NumFollowers}}</div>
							</div>
							<div class="ui label">
								Following <div class="detail">{{.User.NumFollowing}}</div>
							</div>
						</div>
						<!-- Types and name -->
						<div class="inline required field {{if .Err_LoginType}}error{{end}}">
							<label>Authentication Source</label>
							<div class="ui selection type dropdown">
								<input type="hidden" id="login_type" name="login_type" value="{{.LoginSource.Type}}-{{.LoginSource.ID}}" required>
								<div class="text">Local</div>
								<i class="dropdown icon"></i>
								<div class="menu">
									<div class="item" data-value="0-0">Local</div>
									{{range .Sources}}
										<div class="item" data-value="{{.Type}}-{{.ID}}">{{.Name}}</div>
									{{end}}
								</div>
							</div>
						</div>
						<div class="required non-local field {{if .Err_LoginName}}error{{end}} {{if eq .User.LoginSource 0}}hide{{end}}">
							<label for="login_name">Authentication Login Name</label>
							<input id="login_name" name="login_name" value="{{.User.LoginName}}" autofocus>
						</div>
						<div class="field {{if .Err_FullName}}error{{end}}">
							<label for="full_name">Full Name</label>
							<input id="full_name" name="full_name" value="{{.User.FullName}}">
						</div>
						<div class="field {{if .Err_Description}}error{{end}}">
							<label for="description">Description</label>
							<textarea id="description" name="description" rows="2">{{.User.Description}}</textarea>
						</div>
						<div class="field {{if .Err_Company}}error{{end}}">
							<label for="company">Company</label>
							<input id="company" name="company" value="{{.User.Company}}">
						</div>
						<div class="required field {{if .Err_Email}}error{{end}}">
							<label for="email">Email</label>
							<input id="email" name="email" type="email" value="{{.User.Email}}" autofocus required>
						</div>
						<input class="fake" type="password">
						<div class="local field {{if .Err_Password}}error{{end}} {{if not (eq .User.LoginSource 0)}}hide{{end}}">
							<label for="password">Password</label>
							<input id="password" name="password" type="password">
							<p class="help">Leave it empty to remain unchanged.</p>
						</div>
						<div class="field {{if .Err_Website}}error{{end}}">
							<label for="website">Website</label>
							<input id="website" name="website" type="url" value="{{.User.Website}}" placeholder="e.g. https://mydomain.com">
						</div>
						<div class="field {{if .Err_Location}}error{{end}}">
							<label for="location">Location</label>
							<input id="location" name="location" value="{{.User.Location}}">
						</div>
						<div class="field {{if .Err_Twitter}}error{{end}}">
							<label for="twitter">Twitter</label>
							<input id="twitter" name="twitter" value="{{.User.Twitter}}">
						</div>
						<div class="field {{if .Err_Linkedin}}error{{end}}">
							<label for="linkedin">Linkedin</label>
							<input id="linkedin" name="linkedin" value="{{.User.Linkedin}}">
						</div>
						<div class="field {{if .Err_Github}}error{{end}}">
							<label for="github">GitHub</label>
							<input id="github" name="github" value="{{.User.Github}}">
						</div>
						<div class="field {{if .Err_Gitlab}}error{{end}}">
							<label for="gitlab">GitLab</label>
							<input id="gitlab" name="gitlab" value="{{.User.Gitlab}}">
						</div>
						<div class="field {{if .Err_Stackoverflow}}error{{end}}">
							<label for="stackoverflow">Stackoverflow</label>
							<input id="stackoverflow" name="stackoverflow" value="{{.User.Stackoverflow}}">
						</div>
						<div class="field {{if .Err_Telegram}}error{{end}}">
							<label for="telegram">Telegram</label>
							<input id="telegram" name="telegram" value="{{.User.Telegram}}">
						</div>
						<div class="field {{if .Err_Codepen}}error{{end}}">
							<label for="codepen">Codepen</label>
							<input id="codepen" name="codepen" value="{{.User.Codepen}}">
						</div>
						<div class="field {{if .Err_Notes}}error{{end}}">
							<label for="staff_notes">Staff Notes</label>
							<textarea id="staff_notes" name="staff_notes" rows="2">{{.User.StaffNotes}}</textarea>
							<p class="help">Take notes about <b>{{.User.Name}}</b> for future purpose.</p>
							<p class="help"><b>Note:</b> This will displayed as <b>reason</b> on prohibited page</p>
						</div>

						<div class="ui divider"></div>

						<div class="inline field {{if .Err_MaxRepoCreation}}error{{end}}">
							<label for="max_repo_creation">Maximum Repository Creation Limit</label>
							<input id="max_repo_creation" name="max_repo_creation" type="number" value="{{.User.MaxRepoCreation}}">
							<p class="help">(Set -1 to use global default limit)</p>
						</div>

						<div class="ui divider"></div>

						<div class="inline field">
							<div class="ui checkbox">
								<label><strong>This account is activated</strong></label>
								<input name="active" type="checkbox" {{if .User.IsActive}}checked{{end}}>
							</div>
						</div>
						<div class="inline field">
							<div class="ui checkbox">
								<label><strong>This account is verified</strong> <i class="verified octicon octicon-verified"></i></label>
								<input name="is_verified" type="checkbox" {{if .User.IsVerified}}checked{{end}}>
							</div>
						</div>
						<div class="inline field">
							<div class="ui checkbox">
								<label><strong>This account is staff</strong> <i class="isstaff octicon octicon-tools"></i></label>
								<input name="is_staff" type="checkbox" {{if .User.IsStaff}}checked{{end}}>
							</div>
						</div>
						<div class="inline field">
							<div class="ui checkbox">
								<label><strong>This user is Gitote Developer</strong></label>
								<input name="gitote_developer" type="checkbox" {{if .User.GitoteDeveloper}}checked{{end}}>
							</div>
						</div>
						<div class="inline field">
							<div class="ui checkbox">
								<label><strong>This account is Beta Member</strong> <i class="developer octicon octicon-circuit-board"></i></label>
								<input name="is_beta" type="checkbox" {{if .User.IsBeta}}checked{{end}}>
							</div>
						</div>
						<div class="inline field">
							<div class="ui checkbox">
								<label><strong style="color:red">This account is suspended</strong></label>
								<input name="suspended" type="checkbox" {{if .User.Suspended}}checked{{end}}>
							</div>
						</div>
						<div class="inline field">
							<div class="ui checkbox">
								<label><strong>This account has administrator permissions</strong></label>
								<input name="admin" type="checkbox" {{if .User.IsAdmin}}checked{{end}}>
							</div>
						</div>
						<div class="inline field">
							<div class="ui checkbox">
								<label><strong>This account has permissions to create Git hooks</strong></label>
								<input name="allow_git_hook" type="checkbox" {{if .User.CanEditGitHook}}checked{{end}}>
							</div>
						</div>
						{{if .EnableLocalPathMigration}}
							<div class="inline field">
								<div class="ui checkbox">
									<label><strong>This account has permissions to import local repositories</strong></label>
									<input name="allow_import_local" type="checkbox" {{if .User.CanImportLocal}}checked{{end}}>
								</div>
							</div>
						{{end}}

						<div class="ui divider"></div>

						<div class="field">
							<button class="ui green button">Update Account Profile</button>
							<div class="ui red button delete-button" data-url="{{$.Link}}/delete" data-id="{{.User.ID}}">Delete This Account</div>
						</div>
					</form>
				</div>
			</div>
		</div>
	</div>
</div>

<div class="ui small basic delete modal">
	<div class="ui icon header">
		<i class="trash icon"></i>
		Account Deletion
	</div>
	<div class="content">
		<p>This account is going to be deleted permanently, do you want to continue?</p>
	</div>
	{{template "base/delete_modal_actions" .}}
</div>
{{template "base/footer" .}}
