## -*- coding: utf-8 -*-
<%inherit file="/base/base.html"/>

<%def name="title()">
    ${_('Edit repository')} ${c.repo_info.repo_name} - ${c.rhodecode_name}
</%def>

<%def name="breadcrumbs_links()">
    ${h.link_to(_('Admin'),h.url('admin_home'))}
    &raquo;
    ${h.link_to(_('Repositories'),h.url('repos'))}
    &raquo;
    ${_('edit')} &raquo; ${h.link_to(c.repo_info.just_name,h.url('summary_home',repo_name=c.repo_name))}
</%def>

<%def name="page_nav()">
	${self.menu('admin')}
</%def>

<%def name="main()">
<div class="box box-left">
    <!-- box / title -->
    <div class="title">
        ${self.breadcrumbs()}
    </div>
    ${h.form(url('repo', repo_name=c.repo_info.repo_name),method='put')}
    <div class="form">
        <!-- fields -->
        <div class="fields">
            <div class="field">
                <div class="label">
                    <label for="repo_name">${_('Name')}:</label>
                </div>
                <div class="input">
                    ${h.text('repo_name',class_="medium")}
                </div>
           </div>
	       <div class="field">
	           <div class="label">
	               <label for="clone_uri">${_('Clone uri')}:</label>
	           </div>
	           <div class="input">
	               ${h.text('clone_uri',class_="medium")}
                 <span class="help-block">${_('Optional http[s] url from which repository should be cloned.')}</span>
	           </div>
	        </div>
	        <div class="field">
	            <div class="label">
	                <label for="repo_group">${_('Repository group')}:</label>
	            </div>
	            <div class="input">
	                ${h.select('repo_group','',c.repo_groups,class_="medium")}
                    <span class="help-block">${_('Optional select a group to put this repository into.')}</span>
	            </div>
	        </div>
            <div class="field">
                <div class="label">
                    <label for="repo_type">${_('Type')}:</label>
                </div>
                <div class="input">
                    ${h.select('repo_type','hg',c.backends,class_="medium")}
                </div>
            </div>
            <div class="field">
                <div class="label label-textarea">
                    <label for="description">${_('Description')}:</label>
                </div>
                <div class="textarea text-area editor">
                    ${h.textarea('description')}
                    <span class="help-block">${_('Keep it short and to the point. Use a README file for longer descriptions.')}</span>
                </div>
            </div>

            <div class="field">
                <div class="label label-checkbox">
                    <label for="private">${_('Private repository')}:</label>
                </div>
                <div class="checkboxes">
                    ${h.checkbox('private',value="True")}
                    <span class="help-block">${_('Private repositories are only visible to people explicitly added as collaborators.')}</span>
                </div>
            </div>
            <div class="field">
                <div class="label label-checkbox">
                    <label for="enable_statistics">${_('Enable statistics')}:</label>
                </div>
                <div class="checkboxes">
                    ${h.checkbox('enable_statistics',value="True")}
                    <span class="help-block">${_('Enable statistics window on summary page.')}</span>
                </div>
            </div>
            <div class="field">
                <div class="label label-checkbox">
                    <label for="enable_downloads">${_('Enable downloads')}:</label>
                </div>
                <div class="checkboxes">
                    ${h.checkbox('enable_downloads',value="True")}
                    <span class="help-block">${_('Enable download menu on summary page.')}</span>
                </div>
            </div>
            <div class="field">
                <div class="label">
                    <label for="user">${_('Owner')}:</label>
                </div>
                <div class="input input-medium ac">
                    <div class="perm_ac">
                       ${h.text('user',class_='yui-ac-input')}
                       <span class="help-block">${_('Change owner of this repository.')}</span>
                       <div id="owner_container"></div>
                    </div>
                </div>
             </div>

            <div class="field">
                <div class="label">
                    <label for="input">${_('Permissions')}:</label>
                </div>
                <div class="input">
                    <%include file="repo_edit_perms.html"/>
                </div>

                <div class="buttons">
                  ${h.submit('save','Save',class_="ui-button")}
                  ${h.reset('reset','Reset',class_="ui-button")}
                </div>
            </div>
    </div>
    </div>
    ${h.end_form()}
</div>

<div class="box box-right">
    <div class="title">
        <h5>${_('Administration')}</h5>
    </div>

        <h3>${_('Statistics')}</h3>
        ${h.form(url('repo_stats', repo_name=c.repo_info.repo_name),method='delete')}
        <div class="form">
           <div class="fields">
               ${h.submit('reset_stats_%s' % c.repo_info.repo_name,_('Reset current statistics'),class_="ui-btn",onclick="return confirm('"+_('Confirm to remove current statistics')+"');")}
               <div class="field" style="border:none;color:#888">
               <ul>
                    <li>${_('Fetched to rev')}: ${c.stats_revision}/${c.repo_last_rev}</li>
                    <li>${_('Stats gathered')}: ${c.stats_percentage}%</li>
               </ul>
               </div>
           </div>
        </div>
        ${h.end_form()}

        %if c.repo_info.clone_uri:
        <h3>${_('Remote')}</h3>
        ${h.form(url('repo_pull', repo_name=c.repo_info.repo_name),method='put')}
        <div class="form">
           <div class="fields">
               ${h.submit('remote_pull_%s' % c.repo_info.repo_name,_('Pull changes from remote location'),class_="ui-btn",onclick="return confirm('"+_('Confirm to pull changes from remote side')+"');")}
               <div class="field" style="border:none">
               <ul>
                    <li><a href="${c.repo_info.clone_uri}">${c.repo_info.clone_uri}</a></li>
               </ul>
               </div>
           </div>
        </div>
        ${h.end_form()}
        %endif

        <h3>${_('Cache')}</h3>
        ${h.form(url('repo_cache', repo_name=c.repo_info.repo_name),method='delete')}
        <div class="form">
           <div class="fields">
               ${h.submit('reset_cache_%s' % c.repo_info.repo_name,_('Invalidate repository cache'),class_="ui-btn",onclick="return confirm('"+_('Confirm to invalidate repository cache')+"');")}
           </div>
        </div>
        ${h.end_form()}

        <h3>${_('Public journal')}</h3>
        ${h.form(url('repo_public_journal', repo_name=c.repo_info.repo_name),method='put')}
        <div class="form">
                ${h.hidden('auth_token',str(h.get_token()))}
                <div class="field">
                %if c.in_public_journal:
                    ${h.submit('set_public_%s' % c.repo_info.repo_name,_('Remove from public journal'),class_="ui-btn")}
                %else:
		            ${h.submit('set_public_%s' % c.repo_info.repo_name,_('Add to public journal'),class_="ui-btn")}
		        %endif
                </div>
               <div class="field" style="border:none;color:#888">
               <ul>
                    <li>${_('''All actions made on this repository will be accessible to everyone in public journal''')}
                    </li>
               </ul>
               </div>
        </div>
        ${h.end_form()}

        <h3>${_('Delete')}</h3>
        ${h.form(url('repo', repo_name=c.repo_info.repo_name),method='delete')}
        <div class="form">
           <div class="fields">
               ${h.submit('remove_%s' % c.repo_info.repo_name,_('Remove this repository'),class_="ui-btn red",onclick="return confirm('"+_('Confirm to delete this repository')+"');")}
           </div>
           <div class="field" style="border:none;color:#888">
           <ul>
                <li>${_('''This repository will be renamed in a special way in order to be unaccesible for RhodeCode and VCS systems.
                         If you need fully delete it from filesystem please do it manually''')}
                </li>
           </ul>
           </div>
        </div>
        ${h.end_form()}

        <h3>${_('Set as fork')}</h3>
        ${h.form(url('repo_as_fork', repo_name=c.repo_info.repo_name),method='put')}
        <div class="form">
           <div class="fields">
               ${h.select('id_fork_of','',c.repos_list,class_="medium")}
               ${h.submit('set_as_fork_%s' % c.repo_info.repo_name,_('set'),class_="ui-btn",)}
           </div>
               <div class="field" style="border:none;color:#888">
               <ul>
                    <li>${_('''Manually set this repository as a fork of another''')}</li>
               </ul>
               </div>
        </div>
        ${h.end_form()}

</div>


</%def>
