{{template "base/head" .}}
<div class="repository settings options">
	{{template "repo/header" .}}
	<div class="ui container">
		<div class="ui grid">
			{{template "repo/settings/navbar" .}}
			<div class="twelve wide column content">
				{{template "base/alert" .}}
				<h4 class="ui top attached header">
				  {{.i18n.Tr "repo.settings.basic_settings"}}
				</h4>
				<div class="ui attached segment">
					<form class="ui form" action="{{.Link}}" method="post">
						{{.CsrfTokenHtml}}
      			<input type="hidden" name="action" value="update">
					  <div class="required field {{if .Err_RepoName}}error{{end}}">
					    <label for="repo_name">{{.i18n.Tr "repo.repo_name"}}<span class="text red hide" id="repo-name-change-prompt"> {{.i18n.Tr "repo.settings.change_reponame_prompt"}}</span></label>
					    <input id="repo_name" name="repo_name" value="{{.Repository.Name}}" data-repo-name="{{.Repository.Name}}" autofocus required>
					  </div>
					  <div class="field {{if .Err_Description}}error{{end}}">
					    <label for="description">{{$.i18n.Tr "repo.repo_desc"}}</label>
					    <textarea id="description" name="description" rows="2">{{.Repository.Description}}</textarea>
					  </div>
					  <div class="field {{if .Err_Website}}error{{end}}">
					    <label for="website">{{.i18n.Tr "repo.settings.site"}}</label>
					    <input id="website" name="website" type="url" value="{{.Repository.Website}}">
					  </div>

					  <div class="ui divider"></div>
					  {{if not .Repository.IsBare}}
					  <div class="required inline field">
					    <label>{{.i18n.Tr "repo.default_branch"}}</label>
					    <div class="ui selection dropdown">
					      <input type="hidden" id="branch" name="branch" value="{{.Repository.DefaultBranch}}">
					      <div class="text">{{.Repository.DefaultBranch}}</div>
					      <i class="dropdown icon"></i>
					      <div class="menu">
                  {{range .Branches}}
					        <div class="item" data-value="{{.}}">{{.}}</div>
                  {{end}}
					      </div>
					    </div>
					  </div>
					  {{end}}
					  {{if not .Repository.IsFork}}
	          <div class="inline field">
	            <label>{{.i18n.Tr "repo.visibility"}}</label>
	            <div class="ui checkbox">
	              <input name="private" type="checkbox" {{if .Repository.IsPrivate}}checked{{end}}>
	              <label>{{.i18n.Tr "repo.visiblity_helper" | Safe}} {{if .Repository.NumForks}}<span class="text red">{{.i18n.Tr "repo.visiblity_fork_helper"}}</span>{{end}}</label>
	            </div>
	          </div>
	          {{end}}
	          {{if .Repository.IsMirror}}
					  <div class="inline field {{if .Err_Interval}}error{{end}}">
					    <label for="interval">{{.i18n.Tr "repo.mirror_interval"}}</label>
					    <input id="interval" name="interval" type="number" value="{{.MirrorInterval}}">
					  </div>
					  {{end}}

					  <div class="field">
					     <button class="ui green button">{{$.i18n.Tr "repo.settings.update_settings"}}</button>
					  </div>
					</form>
        </div>

        <h4 class="ui top attached warning header">
          {{.i18n.Tr "repo.settings.danger_zone"}}
        </h4>
        <div class="ui attached warning table danger segment">
					<div class="item">
						<div class="ui right">
							<button class="ui basic red show-modal button" data-modal="#transfer-repo-modal">{{.i18n.Tr "repo.settings.transfer"}}</button>
						</div>
						<div>
							<h5>{{.i18n.Tr "repo.settings.transfer"}}</h5>
							<p>{{.i18n.Tr "repo.settings.transfer_desc"}}</p>
						</div>
					</div>
					
					<div class="ui divider"></div>

					<div class="item">
						<div class="ui right">
							<button class="ui basic red show-modal button" data-modal="#delete-repo-modal">{{.i18n.Tr "repo.settings.delete"}}</button>
						</div>
						<div>
							<h5>{{.i18n.Tr "repo.settings.delete"}}</h5>
							<p>{{.i18n.Tr "repo.settings.delete_desc"}}</p>
						</div>
					</div>
        </div>
      </div>
    </div>
  </div>
</div>

<div class="ui small modal" id="transfer-repo-modal">
  <div class="header">
    {{.i18n.Tr "repo.settings.transfer"}}
  </div>
  <div class="content">
		<div class="ui warning message text left">
			{{.i18n.Tr "repo.settings.transfer_notices_1" | Safe}} <br>
			{{.i18n.Tr "repo.settings.transfer_notices_2" | Safe}}
		</div>
  	<form class="ui form" action="{{.Link}}" method="post">
      {{.CsrfTokenHtml}}
			<input type="hidden" name="action" value="transfer">
			<div class="field">
				<label>
					{{.i18n.Tr "repo.settings.transfer_form_title"}}
					<span class="text red">{{.Repository.Name}}</span>
				</label>
			</div>
		  <div class="required field">
		    <label for="repo_name">{{.i18n.Tr "repo.repo_name"}}</label>
		    <input id="repo_name" name="repo_name" required>
		  </div>
		  <div class="required field">
		    <label for="new_owner_name">{{.i18n.Tr "repo.settings.transfer_owner"}}</label>
		    <input id="new_owner_name" name="new_owner_name" required>
		  </div>
			
			<div class="text right actions">
				<div class="ui cancel button">{{.i18n.Tr "settings.cancel"}}</div>
				<button class="ui red button">{{.i18n.Tr "repo.settings.make_transfer"}}</button>
			</div>
  	</form>
  </div>
</div>

<div class="ui small modal" id="delete-repo-modal">
  <div class="header">
    {{.i18n.Tr "repo.settings.delete"}}
  </div>
  <div class="content">
		<div class="ui warning message text left">
			{{.i18n.Tr "repo.settings.delete_notices_1" | Safe}} <br>
			{{.i18n.Tr "repo.settings.delete_notices_2" | Safe}}
			{{if .Repository.NumForks}}<br>
			{{.i18n.Tr "repo.settings.delete_notices_fork_1" | Safe}} <br>
			{{.i18n.Tr "repo.settings.delete_notices_fork_2" | Safe}} <br>
			{{.i18n.Tr "repo.settings.delete_notices_fork_3" | Safe}}
			{{end}}
		</div>
  	<form class="ui form" action="{{.Link}}" method="post">
      {{.CsrfTokenHtml}}
			<input type="hidden" name="action" value="delete">
			<div class="field">
				<label>
					{{.i18n.Tr "repo.settings.transfer_form_title"}}
					<span class="text red">{{.Repository.Name}}</span>
				</label>
			</div>
		  <div class="required field">
		    <label for="repo_name">{{.i18n.Tr "repo.repo_name"}}</label>
		    <input id="repo_name" name="repo_name" required>
		  </div>
			
			<div class="text right actions">
				<div class="ui cancel button">{{.i18n.Tr "settings.cancel"}}</div>
				<button class="ui red button">{{.i18n.Tr "repo.settings.confirm_delete"}}</button>
			</div>
  	</form>
  </div>
</div>
{{template "base/footer" .}}