Blob Blame Raw
{% extends "repo_master.html" %}
{% from "_formhelper.html" import render_field_in_row %}

{% block title %}{{ select.capitalize() }} - {{
    repo.namespace + '/' if repo.namespace }}{{ repo.name }}{% endblock %}
{% set tag = "home" %}

{% block repo %}

<section class="settings">
  <h3>Settings for {{ repo.fullname }}</h3>
  <div class="row">
    <div class="col-md-8 col-md-offset-2">
      <div class="card">
        <div class="card-header">
          Project Details
        </div>
        <div class="card-block">
          <form action="{{ url_for('.update_project',
                          repo=repo.name,
                          username=username,
                          namespace=repo.namespace) }}" method="post">
            <fieldset class="form-group">
              <label for="description">Description</label>
              <input class="form-control" name="description" value="{{
                repo.description if repo.description }}" required/>
              <small class="text-muted">Short description of the project</small>
            </fieldset>
            <fieldset class="form-group">
                <label for="url">Project's url</label>
                <input class="form-control" name="url" value="{{ repo.url if repo.url else '' }}" />
                <small class="text-muted">Website URL of the project</small>
            </fieldset>
            <fieldset class="form-group">
              <label for="avatar">Avatar email</label>
              <input class="form-control" name="avatar_email" value="{{ repo.avatar_email if repo.avatar_email else '' }}" />
              <small class="text-muted">Email address linked to avatar to display for the project</small>
            </fieldset>
            <fieldset class="form-group">
              <label for="tags">Project tags</label>
              <input class="form-control" name="tags" value="{{ repo.tags_text |join(', ') if repo.tags else '' }}" />
              <small class="text-muted">tags for project (separated by commas)</small>
            </fieldset>
            {% if config.get('PRIVATE_PROJECTS', False) and repo.private %}
                <fieldset class="form-group">
                    <label class="c-input c-checkbox">Private</lable>
                    <input type="checkbox" value="private" name="private" checked="" />
                    <span class="c-indicator"></span>
                </fieldset>
            {% endif %}
            <button class="btn btn-primary" type="submit" title="Update description">
              Update
            </button>
            {{ form.csrf_token }}
          </form>
        </div>
      </div>
    </div>
    <div class="col-md-8 col-md-offset-2">
      <div class="card">
        <div class="card-header">
          Default Branch
        </div>
        <div class="card-block">
          <form action="{{ url_for('change_ref_head',
                repo=repo.name,
                username=username,
                namespace=repo.namespace) }}" method="post">
            {{ branches_form.csrf_token }}
            {{ branches_form.branches(class_="c-select") }}
            <input class="btn btn-primary" type="submit" value="Make Default"/>
          </form>
        </div>
      </div>
    </div>
    {% if config.get('WEBHOOK', False) %}
    <div class="col-md-8 col-md-offset-2">
      <div class="card">
        <div class="card-header">
          <strong>Private web-hook key</strong>
        </div>
        <div class="card-block">
          <p>
            Each message sent to the web-hook are signed via hmac and SHA1 using
            this private key.
          </p>
          <p>
            This key is private to your project, make sure to store in a safe place
            and do not share it.
          </p>
          <div class="form-group">
            <div class="input-group">
              <div class="input-group-addon"><span class="oi" data-glyph="key"></span></div>
              <input class="form-control" type="text" value="{{ repo.hook_token }}" readonly>
            </div>
          </div>

          <form action="{{ url_for('.new_repo_hook_token',
                repo=repo.name,
                username=username,
                namespace=repo.namespace) }}"
              method="post" class="icon">
          <button class="btn btn-primary" type="submit"
            onclick="return confirm('Are you sure to generate a new token for '
              + 'this project/fork? \nThis will break all web hook in place and '
              + 'cannot be un-done.');"
            title="Generate a new hook token">
            <span class="oi" data-glyph="reload"></span> &nbsp;Re-generate
          </button>
          {{ form.csrf_token }}
        </form>
        </div>
      </div>
    </div>
    {% endif %}

    <div class="col-md-8 col-md-offset-2">
      <div class="card">
        <div class="card-header">
          <strong>API Keys</strong>
        </div>
        <div class="card-block">
          <p>
            API keys are tokens used to authenticate you on pagure. They can also
            be used to grant access to 3rd party application to behave on this
            project on your name.
          </p>
          <p>
            These are your personal tokens; they are not visible to the other
            admins of this repository.
          </p>
          <p>
            These keys are valid for <span class="strong">60</span> days.
          </p>
          <p>
            These keys are private to your project, make sure to store in a safe
            place and do not share it.
          </p>
        </div>
        {% if repo.tokens %}
        <ul class="list-group list-group-flush">
        {% for token in repo.tokens %}
          {% if token.user.username == g.fas_user.username %}
            <li class="list-group-item">
              <div class="form-group">
                <div class="input-group">
                  <strong>{{ token.description or '' }}</strong>
                </div>
                <div class="input-group">
                  <div class="input-group-addon">
                    <span class="oi" data-glyph="key"></span>
                  </div>
                  <input class="form-control" type="text" value="{{ token.id }}" readonly>
                </div>
              </div>
            {% if token.expired %}
              <span class="text-danger btn-align"><strong>Expired</strong> since {{ token.expiration.date() }}</span>
            {% else %}
              <span class="text-success btn-align"><strong>Valid</strong> until: {{ token.expiration.date() }}</span>
              <form class="pull-xs-right" action="{{ url_for(
                  '.revoke_api_token',
                  repo=repo.name,
                  username=username,
                  namespace=repo.namespace,
                  token_id=token.id) }}"
                method="post" class="icon">
                <button class="btn btn-danger" type="submit"
                    onclick="return confirm('Are you sure to revoke this token ?'
                        + '\nThis will break all application using it and '
                        + 'cannot be un-done.');"
                    title="Revoke token">
                  <span class="oi" data-glyph="trash"></span> &nbsp;Revoke
                </button>
                {{ form.csrf_token }}
              </form>
            {% endif %}
              <button type="button" class="btn btn-link"
                data-toggle="modal" data-target="#acls{{ token.id }}">
                ACLs
              </button>
              <div class="modal fade" id="acls{{ token.id }}" tabindex="-1"
                    role="dialog" aria-labelledby="ACLs" aria-hidden="true">
                <div class="modal-dialog" role="document">
                  <div class="modal-content">
                    <div class="modal-header">
                      <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                        <span aria-hidden="true">&times;</span>
                        <span class="sr-only">Close</span>
                      </button>
                      <h4 class="modal-title" id="myModalLabel">ACLs</h4>
                    </div>
                    <div class="modal-body">
                      <ul>
                        {% for acl in token.acls_list_pretty %}
                          <li>{{ acl }}</li>
                        {% endfor %}
                      </ul>
                    </div>
                  </div>
                </div>
              </div>
            </li>
          {% endif %}
        {% endfor %}
        </ul>
        {% endif %}
        <div class="card-block">
          <a href="{{ url_for(
                '.add_token',
                repo=repo.name,
                username=username,
                namespace=repo.namespace) }}"
              method="post" class="icon">
          <button class="btn btn-primary" type="submit"
            title="Generate a new API token">
            Create new key
          </button>
          </a>
        </div>
      </div>
    </div>

    <div class="col-md-8 col-md-offset-2">
      <div class="card">
        <div class="card-header">
          Project options
        </div>
        <div class="card-block">
          <form action="{{ url_for('.view_settings',
                repo=repo.name,
                username=username,
                namespace=repo.namespace) }}" method="post">
            {% for key in repo.settings | sort %}
            {% if not config.get('ENABLE_TICKETS', True) and key in ['issue_tracker', 'issues_default_to_private'] %}
            {% elif not config.get('DOC_APP_URL') and key in ['project_documentation'] %}
            {% elif not config.get('WEBHOOK') and key in ['Web-hooks'] %}
            {% else %}
              {% if repo.settings[key] in [True, False, 'y'] %}
                <div>
                  <label class="c-input c-checkbox">
                    <input id="{{ key }}" type="checkbox" value="y" name="{{ key }}" {%
                            if repo.settings[key] -%}checked=""{%- endif -%}/>
                    <span class="c-indicator"></span>
                    Activate {{ key | replace('_', ' ') }}
                  </label>
                </div>
              {% else %}
                <div class="form-inline">
                  <label for="{{ key }}">Activate {{ key | replace('_', ' ') }} :</label>
                  <input width="4em" class="form-control" id="{{ key }}" type="text" {% if repo.settings[key]
                        %}value="{{ repo.settings[key] }}"{% endif %} name="{{ key }}" />
                </div>
              {% endif %}
            {% endif %}
            {% endfor %}
          </table>
          <p class="p-t-2">
              <input type="submit" class="btn btn-primary" value="Update">
              {{ form.csrf_token }}
            </p>
          </form>

          {% if config.get('WEBHOOK') and repo.settings['Web-hooks'] %}
          <form action="{{ url_for('.test_web_hook',
                repo=repo.name,
                username=username,
                namespace=repo.namespace) }}" method="post">
              {{ form.csrf_token }}
            <input type="submit" class="btn btn-primary" value="Test web-hook"
             title="Sends a test notification to the web-hook server for testing">
          </form>
          {% endif %}
        </div>
      </div>
    </div>

    <div class="col-md-8 col-md-offset-2">
      <div class="card">
        <div class="card-header">
          Public notifications
        </div>
        <div class="card-block">
          <p>
            The email addresses entered below will receive all the notifications
            related to {% if config.get('ENABLE_TICKETS', True) %}
            (public) issues and {% endif %}pull-requests, this includes
            notifications about {% if config.get('ENABLE_TICKETS', True) %}
            new issue or {% endif %} new pull-request, new comment
            and status change.
          </p>
          <p>
            To enter multiple addresses, separate them with a comma.
          </p>
        </div>
        <form action="{{ url_for(
              '.update_public_notifications',
              repo=repo.name,
              username=username,
              namespace=repo.namespace) }}"
            method="post" class="icon">
          {{ tag_form.csrf_token }}
          <div class="card-block">

            {% if config.get('ENABLE_TICKETS', True) %}
            <div class="row">
              <div class="col-sm-12">
                <strong>Issues notifications</strong>
              </div>
            </div>

            <div id="issue-notifications">
              <div class="row p-t-1">
                <div class="col-sm-9 p-r-0">
                  <input type="text" name="issue_notifs"
                    value="{{ repo.notifications['issues'] | join(', ') }}" class="form-control"/>
                </div>
              </div>
            </div>

            {% endif %}
            <div class="row">
              <div class="col-sm-12 p-t-1">
                <strong>Pull-requests notifications</strong>
              </div>
            </div>

            <div id="pr-notifications">
              <div class="row p-t-1">
                <div class="col-sm-9 p-r-0">
                  <input type="text" name="pr_notifs"
                    value="{{ repo.notifications['requests'] | join(', ') }}" class="form-control"/>
                </div>
              </div>
            </div>

            <div class="row p-t-1">
              <div class="col-sm-12">
                <button class="btn btn-primary" type="submit"
                    title="Update notifications">
                  Update
                </button>
              </div>
            </div>

          </div>
        </form>
      </div>
    </div>

    <div class="col-md-8 col-md-offset-2">
      <div class="card">
        <div class="card-header">
          Re-generate git repos
        </div>
        <div class="card-block">
          {% if config.get('ENABLE_TICKETS', True) %}
            <form action="{{ url_for(
                '.regenerate_git',
                repo=repo.name,
                username=username,
                namespace=repo.namespace) }}" method="post"
                  class="icon">
              <input name="regenerate" value="tickets" type="hidden"/>
              <button class="btn btn-primary" type="submit"
                title="Regenerate tickets git repo">
                <span class="oi" data-glyph="reload"></span> &nbsp;Regenerate the git repo for issues
              </button>
              {{ form.csrf_token }}
            </form>
          {% endif %}
          <form class="m-t-2" action="{{ url_for(
              '.regenerate_git',
              repo=repo.name,
              username=username,
              namespace=repo.namespace) }}" method="post"
                class="icon">
            <input name="regenerate" value="requests" type="hidden"/>
            <button class="btn btn-primary" type="submit"
              title="Regenerate requests git repo">
              <span class="oi" data-glyph="reload"></span> &nbsp;Regenerate the git repo for requests
            </button>
            {{ form.csrf_token }}
          </form>
        </div>
      </div>
    </div>

    {% if config.get('ENABLE_USER_MNGT', True) %}
    <div class="col-md-8 col-md-offset-2">
      <div class="card">
        <div class="card-header">
          Users and Groups
        </div>
        <div class="card-block">

          <p>Below is the list of user having commit rights to this repo.</p>

          <p>
            <a href="{{ url_for(
                  '.add_user',
                  repo=repo.name,
                  username=username,
                  namespace=repo.namespace) }}"
                class="btn btn-primary">
                add user
            </a>

            <a href="{{ url_for(
                  '.add_group_project',
                  repo=repo.name,
                  username=username,
                  namespace=repo.namespace) }}"
                class="btn btn-primary">
                add group
            </a>
          </p>
        </div>
          <ul class="list-group list-group-flush">
            <li class="list-group-item">
              <a href="{{ url_for('.view_user', username=repo.user.user) }}">
                <span class="oi" data-glyph="person"></span>
                &nbsp; {{ repo.user.user }}
              </a>
              (main admin)
            </li>
          {% for access in access_users %}
            {% for user in access_users[access] %}
              <li class="list-group-item">
                <a href="{{ url_for('.view_user', username=user.user) }}">
                  <span class="oi" data-glyph="person"></span>
                  &nbsp; {{ user.user }}
                </a>
                ({{access}})
                <form class="pull-xs-right" method="POST"
                  action="{{ url_for(
                      '.remove_user',
                      repo=repo.name,
                      username=username,
                      namespace=repo.namespace,
                      userid=user.id) }}">
                  <button
                    onclick="return confirm('You sure you want to remove this user from this project?');"
                    title="Remove user" class="btn btn-danger btn-sm">
                    <span class="oi" data-glyph="trash"></span>
                  </button>
                  {{ form.csrf_token }}
                </form>
                  <a href="{{ url_for(
                      '.add_user',
                      repo=repo.name,
                      username=username,
                      namespace=repo.namespace)
                      }}?user={{ user.user }}">
                    <button title="Update User Access" class="btn btn-default btn-sm pull-xs-right">
                    <span class="oi" data-glyph="pencil"></span>
                    </button>
                  </a>
              </li>
            {% endfor %}
          {% endfor %}
          {% for access in access_groups %}
            {% for group in access_groups[access] %}
              <li class="list-group-item">
                <a href="{{ url_for('.view_group', group=group.group_name) }}">
                  <span class="oi" data-glyph="people"></span>
                  &nbsp; {{ group.group_name }}
                </a>
                ({{access}})
                <form class="pull-xs-right" method="POST"
                  action="{{ url_for(
                      '.remove_group_project',
                      repo=repo.name,
                      username=username,
                      namespace=repo.namespace,
                      groupid=group.id) }}">
                  <button
                    onclick="return confirm('You sure you want to remove this group from this project?');"
                    title="Remove group" class="btn btn-danger btn-sm pull-xs-right">
                    <span class="oi" data-glyph="trash"></span>
                  </button>
                  {{ form.csrf_token }}
                </form>
                  <a href="{{ url_for(
                      '.add_group_project',
                      repo=repo.name,
                      username=username,
                      namespace=repo.namespace)
                      }}?group={{ group.group_name }}">
                    <button class="btn btn-default btn-sm pull-xs-right" title="Update Group Access" >
                    <span class="oi" data-glyph="pencil"></span>
                    </button>
                  </a>

              </li>
            {% endfor %}
          {% endfor %}
          </ul>
      </div>
    </div>
    {% endif %}

    {% if config.get('DEPLOY_KEY', True) %}
    <div class="col-md-8 col-md-offset-2">
      <div class="card">
        <div class="card-header">
          Deploy Keys
        </div>
        <div class="card-block">

          <p>Below are this projects' deploy keys.</p>

          <p>
            <a href="{{ url_for(
                  '.add_deploykey',
                  repo=repo.name,
                  username=username,
                  namespace=repo.namespace) }}"
                class="btn btn-primary">
                add deploy key
            </a>
          </p>
        </div>
          <ul class="list-group list-group-flush">
          {% for deploykey in repo.deploykeys %}
            <li class="list-group-item">
              {{ deploykey.ssh_short_key }}
              {% if deploykey.pushaccess %}
              (PUSH ACCESS)
              {% endif %}
              <form class="pull-xs-right" method="POST"
                action="{{ url_for(
                    '.remove_deploykey',
                    repo=repo.name,
                    username=username,
                    namespace=repo.namespace,
                    keyid=deploykey.id) }}">
                <button
                  onclick="return confirm('You sure you want to remove this deploy key from this project?');"
                  title="Remove deploy key" class="btn btn-danger btn-sm">
                  <span class="oi" data-glyph="trash"></span>
                </button>
                {{ form.csrf_token }}
              </form>
            </li>
          {% endfor %}
          </ul>
      </div>
    </div>
    {% endif %}


    {% if plugins %}
    <div class="col-md-8 col-md-offset-2">
      <div class="card">
        <div class="card-header">
          Hooks
        </div>
        <div class="card-block">
          <div id="accordions" role="tablist" aria-multiselectable="true">
            {% set idcount = 1 %}
            {% for plugin in plugins %}
            {% if not config.get('ENABLE_TICKETS', True) and plugin in ['Pagure tickets'] %}
            {% else %}
            <div class="panel panel-default" >
              <div class="panel-heading" role="tab" id="pluginheading{{idcount}}">
                <h4 class="panel-title">
                  <a data-toggle="collapse" data-parent="#accordions"
                      href="#plugincollapse{{idcount}}" aria-expanded="true"
                      aria-controls="plugincollapse{{idcount}}">
                    <span id="dropdowncaret" class="oi" data-glyph="caret-right"></span>&nbsp;{{ plugin }}
                  </a>
                </h4>
              </div>
              <div id="plugincollapse{{ idcount }}" data-plugin="{{ plugin }}"
                  class="panel-collapse collapse" role="tabpanel"
                  aria-labelledby="pluginheading{{ idcount }}">
                <span class="oi oi-spin pull-left" data-glyph="loop-circular"></span>
              </div>
            </div>
            {% set idcount = idcount+1 %}
            {% endif %}
            {% endfor %}
          </div>
        </div>
      </div>
    </div>
    {% endif %}

    {% if config.get('ENABLE_TICKETS', True)
        and repo.settings.get('issue_tracker', True) %}
    <div class="col-md-8 col-md-offset-2">
      <div class="card">
        <div class="card-header">
          <strong>Priorities</strong>
        </div>
        <div class="card-block">
          <p>
            Below are the priorities you may assign to a ticket, allowing you
            to sort them with it. The Weight determines the ordering. Higher
            priority should correspond to lower weight.
            <span class="italic">
              To remove an entry, simply clean the Weight and Title
            </span>
          </p>
        </div>
        <form action="{{ url_for(
              '.update_priorities',
              repo=repo.name,
              username=username,
              namespace=repo.namespace) }}"
            method="post" class="icon">
          {{ tag_form.csrf_token }}
          <div class="card-block">
            <div class="row">
              <div class="col-sm-2">
                <strong>Weight</strong>
              </div>
              <div class="col-sm-10">
                <strong>Title</strong>
              </div>
            </div>
            <div id="priorities">
          {% for priority in ((repo.priorities or [""]) | sort) %}
              <div class="row p-t-1">
                <div class="col-sm-2 p-r-0">
                  <input type="text" name="priority_weigth"
                    value="{{ priority }}" size="3" class="form-control"/>
                </div>
                <div class="col-sm-9 p-r-0">
                  <input type="text" name="priority_title"
                    value="{{ repo.priorities[priority] }}" class="form-control"/>
                </div>
              </div>
          {% endfor %}
          </div>
          <div class="row p-t-1">
            <div class="col-sm-6">
              <a class="btn btn-secondary btn-sm btn-block extend-form" data-target="#priorities">
                  Add new priority
              </a>
            </div>
            {% if not repo.priorities %}
            <div class="col-sm-6">
              <a class="btn btn-secondary btn-sm btn-block" id="default_priorities">
                  Default priority set
              </a>
            </div>
            {% endif %}
          </div>
          <div class="row p-t-1">
            <div class="col-sm-12">
              <button class="btn btn-primary" type="submit"
                  title="Update the priorities">
                Update
              </button>
            </div>
          </div>
        </div>
        </form>
      </div>
    </div>

    <div class="col-md-8 col-md-offset-2">
      <div class="card">
        <div class="card-header">
          <strong>Roadmap</strong>
        </div>
        <div class="card-block">
          <p>
            Each issue can be assigned to a <em>milestone</em>. This way it is
            possible to create a roadmap for your project. Below you can create
            the milestones and optionally set dates for them.
          </p>
        </div>
        <form action="{{ url_for(
              '.update_milestones',
              repo=repo.name,
              username=username,
              namespace=repo.namespace) }}"
            method="post" class="icon">
          {{ tag_form.csrf_token }}
          <div class="card-block">
            <div class="row">
              <div class="col-sm-6">
                <strong>Milestone</strong>
              </div>
              <div class="col-sm-6">
                <strong>Date (optional)</strong>
              </div>
            </div>
            <div id="milestones">
          {% for milestone in repo.milestones or [""] | sort %}
              <div class="row p-t-1">
                <div class="col-sm-6 p-r-0">
                  <input type="text" name="milestones"
                    value="{{ milestone }}" size="3" class="form-control"/>
                </div>
                <div class="col-sm-6 p-r-0">
                  <input type="text" name="milestone_dates"
                    value="{{ repo.milestones[milestone]
                        if repo.milestones[milestone] is not none
                    }}" class="form-control"/>
                </div>
              </div>
          {% endfor %}
          </div>
          <div class="row p-t-1">
            <div class="col-sm-6">
              <a class="btn btn-secondary btn-sm btn-block extend-form" data-target="#milestones">
                  Add new milestone
              </a>
            </div>
          </div>
          <div class="row p-t-1">
            <div class="col-sm-12">
              <button class="btn btn-primary" type="submit"
                  title="Update the milestones">
                Update
              </button>
            </div>
          </div>
        </div>
        </form>
      </div>
    </div>

    <div class="col-md-8 col-md-offset-2">
      <div class="card">
        <div class="card-header">
          <strong>Close status</strong>
        </div>
        <div class="card-block">
          <p>
            Here is the list of all the status that can be used when closing
            an issue.
          </p>
        </div>
        <form action="{{ url_for(
              '.update_close_status',
              repo=repo.name,
              username=username,
              namespace=repo.namespace) }}"
            method="post" class="icon">
          {{ tag_form.csrf_token }}
          <div class="card-block">
            <div class="row">
              <div class="col-sm-6">
                <strong>Status</strong>
              </div>
            </div>
            <div id="close_sstatus">
            {% for status in repo.close_status or [""] | sort %}
              <div class="row p-t-1">
                <div class="col-sm-12 p-r-0">
                  <input type="text" name="close_status"
                    value="{{ status }}" class="form-control"/>
                </div>
              </div>
            {% endfor %}
          </div>
          <div class="row p-t-1">
            <div class="col-sm-6">
              <a class="btn btn-secondary btn-sm btn-block extend-form" data-target="#close_sstatus">
                  Add new close status
              </a>
            </div>
            {% if not repo.close_status %}
            <div class="col-sm-6">
              <a class="btn btn-secondary btn-sm btn-block" id="default_close_status">
                  Default close status set
              </a>
            </div>
            {% endif %}
          </div>
          <div class="row p-t-1">
            <div class="col-sm-12">
              <button class="btn btn-primary" type="submit"
                  title="Update the status">
                Update
              </button>
            </div>
          </div>
        </div>
        </form>
      </div>
    </div>

    <div class="col-md-8 col-md-offset-2">
      <div class="card">
        <div class="card-header">
          <strong>Custom issue fields</strong>
        </div>
        <div class="card-block">
          <p>
            Set some custom fields for your issues.  <i>Field Values</i> are currently
            only used for Lists, and it accepts a comma separated list of items
            for the drop down list.
          </p>
        </div>
        <form action="{{ url_for(
              '.update_custom_keys',
              repo=repo.name,
              username=username,
              namespace=repo.namespace) }}"
            method="post" class="icon">
          {{ tag_form.csrf_token }}
          <div class="card-block">
            <div class="row">
              <div class="col-sm-3">
                <strong>Fields</strong>
              </div>
              <div class="col-sm-2">
                <strong>Field Type</strong>
              </div>
              <div class="col-sm-6">
                <strong>Field Values</strong> <i>(Lists only)</i>
              </div>
              <div class="col-sm-1">
                <strong>Notify</strong>
              </div>
            </div>
            <div id="custom_fields">
            {% for field in repo.issue_keys or [dict(key_type="", name="")] | sort %}
              <div class="row p-t-1">
                <div class="col-sm-3 p-r-0">
                  <input type="text" name="custom_keys"
                    value="{{ field.name }}" class="form-control"/>
                </div>
                <div class="col-sm-2 p-r-0">
                  <select name="custom_keys_type" class="form-control">
                    <option value="text" {%
                      if field.key_type == 'text' %} selected {%
                      endif %}>Text</option>
                    <option value="boolean" {%
                      if field.key_type == 'boolean' %} selected {%
                      endif %}>Boolean</option>
                    <option value="link" {%
                      if field.key_type == 'link' %} selected {%
                      endif %}>Link</option>
                    <option value="list" {%
                      if field.key_type == 'list' %} selected {%
                      endif %}>List</option>
                  </select>
                </div>
                <div class="col-sm-6 p-r-0">
                    <input title="Comma separated list items" type="text" name="custom_keys_data"
                      value={% if field.data is none %}""{% else %}"{{ field.data | join(', ') }}"{% endif %} class="form-control"/>
                </div>
                <div class="col-sm-1 p-r-0">
                  <input type="checkbox" name="custom_keys_notify-{{ loop.index }}" title="Trigger email notification when updated"
                    {% if field.key_notify == True %}
                      checked="y"
                    {% endif %}
                  class="form-control"/>
                </div>
              </div>
            {% endfor %}
          </div>
          <div class="row p-t-1">
            <div class="col-sm-6">
              <a class="btn btn-secondary btn-sm btn-block extend-form" data-target="#custom_fields">
                  Add new custom field
              </a>
            </div>
          </div>
          <div class="row p-t-1">
            <div class="col-sm-12">
              <button class="btn btn-primary" type="submit"
                  title="Update the custom fields">
                Update
              </button>
            </div>
          </div>
        </div>
        </form>
      </div>
    </div>

    <div class="col-md-8 col-md-offset-2">
      <div class="card">
        <div class="card-header">
          <strong>Issue Tags</strong>
        </div>
        <div class="card-block">
          <p>
            Here is the list of tags associated with this project.
          </p>
        </div>
        <ul class="list-group list-group-flush">
        {% for tag in tags %}
          <li class="list-group-item clearfix">
            <a href="{{ url_for(
                'view_issues',
                repo=repo.name,
                username=username,
                namespace=repo.namespace,
                tags=tag.tag) }}">
              <span class="oi" data-glyph="tag"></span>&nbsp; {{ tag.tag }}
            </a>
            &nbsp<span class="label label-info" style="background-color:{{tag.tag_color}}">{{tag.tag}}</span>
            &nbsp;<span class="text-muted">{{ tag.tag_description or '' }}</span>
            <div class="pull-xs-right">
            <form class="icon del_icon pull-xs-right" method="POST"
              action="{{ url_for(
                'remove_tag',
                repo=repo.name,
                username=username,
                namespace=repo.namespace) }}">
              <input type="hidden" value="{{ tag.tag }}" name="tag" />
              {{ tag_form.csrf_token }}
              <button
                onclick="return confirm('Do you really want to remove the tag: {{ tag.tag }}?');"
                title="Remove tag" class="btn btn-danger btn-sm">
                <span class="oi" data-glyph="trash"></span>
              </button>
            </form>
            <a href="{{ url_for(
                  '.edit_tag',
                  repo=repo.name,
                  username=username,
                  namespace=repo.namespace,
                  tag=tag.tag) }}">
              <button class="btn btn-default btn-sm" title="Edit tag">
                <span class="oi" data-glyph="pencil"></span>
              </button>
            </a>
            </div>
          </li>
        {% endfor %}
        </ul>
        <form action="{{ url_for(
              '.update_tags',
              repo=repo.name,
              username=username,
              namespace=repo.namespace) }}"
            method="post" class="icon">
          {{ tag_form.csrf_token }}
          <div class="card-block">
          <!-- The "Add New Tag" rows/elements will fill in here  -->
          <div id="tagcolor">
          </div>
          <div class="row p-t-1">
            <div class="col-sm-6">
              <a class="btn btn-secondary btn-sm btn-block" id="new_tag">
                  Add New Tag
              </a>
            </div>
          </div>
          <div class="row p-t-1">
            <div class="col-sm-12">
              <button class="btn btn-primary" type="submit"
                  title="Update the tags">
                Update
              </button>
            </div>
          </div>
        </div>
        </form>
      </div>
    </div>

    <div class="col-md-8 col-md-offset-2">
      <div class="card">
        <div class="card-header">
          <strong>Reports</strong>
        </div>
        <div class="card-block">
          <p>
            Here is the list of reports saved for this project.
          </p>
        </div>
        <ul class="list-group list-group-flush">
        {% for report in repo.reports %}
          <li class="list-group-item clearfix">
            <a href="{{ url_for(
                'view_report',
                repo=repo.name,
                username=username,
                namespace=repo.namespace,
                report=report) }}">
              <span class="oi" data-glyph="box"></span>&nbsp; {{ report }}
            </a>
            <div class="pull-xs-right">
            <form class="icon del_icon pull-xs-right" method="POST"
              action="{{ url_for(
                'delete_report',
                repo=repo.name,
                username=username,
                namespace=repo.namespace) }}">
              <input type="hidden" value="{{ report }}" name="report" />
              {{ tag_form.csrf_token }}
              <button
                onclick="return confirm('Do you really want to remove the report: {{ report }}?');"
                title="Delete report" class="btn btn-danger btn-sm">
                <span class="oi" data-glyph="trash"></span>
              </button>
            </form>
            </div>
          </li>
        {% endfor %}
        </ul>
      </div>
    </div>
    {% endif %}

    {% if (config.get('ENABLE_TICKETS', True)
        and repo.settings.get('issue_tracker', True))
        or repo.settings.get('pull_requests', True) %}
    <div class="col-md-8 col-md-offset-2">
      <div class="card">
        <div class="card-header">
          <strong>Quick replies</strong>
        </div>
        <div class="card-block">
          <p>Quick replies will be offered in a new comment form on Issue or
          Pull Request page. This allows you to reply to common problems with a
          click of a button.</p>
          <p>The reply can use the same Markdown formatting as regular
          comments. The list you will choose the reply from will only show the
          first 50 characters. Please make sure the important message is at the
          beginning.</p>
          <p>The replies will be presented in the same order they are written
          here.</p>
        </div>
        <form action="{{ url_for(
              '.update_quick_replies',
              repo=repo.name,
              username=username,
              namespace=repo.namespace) }}"
            method="post">
          {{ tag_form.csrf_token }}
          <div class="card-block">
            <div id="quick_reply_list">
            {% for quick_reply in repo.quick_replies or [""] %}
              <div class="row p-t-1">
                <div class="col-sm-12 p-r-0">
                    <textarea class="form-control" name="quick_reply">{{quick_reply}}</textarea>
                </div>
              </div>
            {% endfor %}
          </div>
          <div class="row p-t-1">
            <div class="col-sm-6">
              <a class="btn btn-secondary btn-sm btn-block extend-form" data-target="#quick_reply_list">
                  Add new quick reply
              </a>
            </div>
          </div>
          <div class="row p-t-1">
            <div class="col-sm-12">
              <button class="btn btn-primary" type="submit"
                  title="Update quick replies">
                Update
              </button>
            </div>
          </div>
        </div>
        </form>
      </div>
    </div>
    {% endif %}

    {% if config.get('ENABLE_GIVE_PROJECTS', True)
          and repo.user.user == g.fas_user.username
          and not repo.is_fork %}
    <div class="col-md-8 col-md-offset-2">
      <div class="card">
        <div class="card-header">
          Give Project
        </div>
        <div class="card-block">
        <form action="{{ url_for(
            '.give_project',
            repo=repo.name,
            username=username,
            namespace=repo.namespace) }}"
              method="post" class="icon">
          {{ tag_form.csrf_token }}
          <input class="form-control" name="user" id="user"
            placeholder="Start typing to search users"
            value="" style="margin-bottom:1%"/>
          <button class="btn btn-danger" type="submit"
            onclick="return confirm('Are you sure to give {{ repo.fullname }}? \nThis is final and cannot be un-done.');"
            title="Give the project to someone">
              <span class="oi" data-glyph="share-boxed"></span>&nbsp; Give the {{repo.name}} project
          </button>
        </form>
        </div>
      </div>
    </div>
    {% endif %}

    {% if (not repo.is_fork and config.get('ENABLE_DEL_PROJECTS', True))
          or
          (repo.is_fork and not config.get('ENABLE_DEL_FORKS',
                config.get('ENABLE_DEL_PROJECTS', True))) %}
    <div class="col-md-8 col-md-offset-2">
      <div class="card">
        <div class="card-header">
          Delete Project
        </div>
        <div class="card-block">
        <form action="{{ url_for(
            '.delete_repo',
            repo=repo.name,
            username=username,
            namespace=repo.namespace) }}"
              method="post" class="icon">
          <button class="btn btn-danger" type="submit"
            onclick="return confirm('Are you sure to delete {{ repo.fullname }}? \nThis is final and cannot be un-done.');"
            title="Delete the project/fork">
              <span class="oi" data-glyph="trash"></span>&nbsp; Delete the {{repo.name}} project
          </button>
        </form>
        </div>
      </div>
    </div>
    {% endif %}

  </div>
</section>

{% endblock %}

{% block jscripts %}
{{ super() }}
<script>
function show_acls(acls) {
  var _txt = '<div title="ACLs details" id="show_meeting">'
    + '<ul>';

  for (i = 0; i < acls.length; i++) {
      _txt += '<li>' + acls[i] + '</li>';
  }

  _txt += '</ul>' + '</div>';
  var _elt = $(_txt);
  var _height = $(window).height() * 0.8;
  _elt.dialog({
      height: 250,
      width: 250,
      modal: true,
      cache: false,
  });
}

$('#accordions').on('shown.bs.collapse', function (e) {
  var _plugin = $(e.target).attr('data-plugin');
  $(e.target).siblings().find("#dropdowncaret").attr('data-glyph', "caret-bottom");
  if (!_plugin) {
    return false;
  }
  var _url = "{{ url_for(
    '.view_plugin',
    repo=repo.name,
    username=username,
    namespace=repo.namespace,
    plugin='') }}";
  _url += _plugin + '/0';
  console.log(_url);
  $.ajax({
      url: _url ,
      type: 'GET',
      dataType: 'html',
      success: function(res) {
          $("#"+e.target.id).html(res);
      },
  });
  return false;
})

$('#accordions').on('hide.bs.collapse', function (e) {
  $(e.target).siblings().find("#dropdowncaret").attr('data-glyph', "caret-right");
})

{% if not repo.priorities %}
$('#default_priorities').click(function(e) {
  let form = $('#priorities>div:last-child');
  form.find('input[type=text], textarea').val('');
  $('#priorities').html('');
  var def_priorities = ['', 'High', 'Normal', 'Low'];
  for (var cnt = 1; cnt < def_priorities.length; cnt++) {
    let f = form.clone();
    f.find("[name=priority_weigth]").val(cnt);
    f.find("[name=priority_title]").val(def_priorities[cnt]);
    $('#priorities').append(f);
  }
  console.log($('#priorities'));
});
{% endif %}

{% if not repo.close_status %}
$('#default_close_status').click(function(e) {
  let form = $('#close_sstatus>div:last-child');
  form.find('input[type=text], textarea').val('');
  $('#close_sstatus').html('');
  var def_closestatus = ['Fixed', 'Invalid', 'Duplicate', 'Insufficient Data'];
  for (var cnt = 0; cnt < def_closestatus.length; cnt++) {
    let f = form.clone();
    f.find("[name=close_status]").val(def_closestatus[cnt]);
    $('#close_sstatus').append(f);
  }
  console.log($('#close_sstatus'));
});
{% endif %}


var first_new_tag = 1;
$('#new_tag').click(function(e) {
  console.log('new tag');
  console.log($('#tagcolor'));
  if (first_new_tag == 1){
    // Only display the Tag row the first time Add New Tag is clicked
    $('#tagcolor').append(
     '<div class="row">\
        <div class="col-sm-4">\
          <strong>New Tag</strong>\
        </div>\
        <div class="col-sm-6">\
          <strong>Description</strong>\
        </div>\
        <div class="col-sm-2">\
          <strong>Tag Color</strong>\
        </div>\
      </div>');
    first_new_tag = 0;
  }
  $('#tagcolor').append(
   '<div class="row p-t-1"> \
        <div class="col-sm-4 p-r-0">\
          <input type="text" name="tag"\
            value="" size="3" class="form-control"/>\
        </div>\
        <div class="col-sm-6 p-r-0">\
          <input type="text" name="tag_description" placeholder="(optional)"\
            value="" size="15" class="form-control"/>\
        </div>\
        <div class="col-sm-2 p-r-0">\
          <input type="color" name="tag_color" class="form-control c-select" \
              onchange="clickColor(0, -1, -1, 5)" /> \
        </div>\
    </div>'
  );
});

$('.extend-form').click(function(e) {
  const tgt = $(this).attr('data-target');
  let form = $(tgt + ' > div:last-child').clone();
  form.find('input[type=text], textarea').val('');
  $(tgt).append(form);
});

{% if config.get('ENABLE_GIVE_PROJECTS', True)
          and repo.user.user == g.fas_user.username
          and not repo.is_fork %}
$('#user').selectize({
  valueField: 'user',
  labelField: 'user',
  searchField: 'user',
  maxItems: 1,
  create: false,
  load: function(query, callback) {
    if (!query.length) return callback();
    $.getJSON(
      "{{ url_for('api_ns.api_users') }}", {
        pattern: query.term
      },
      function( data ) {
        callback( data.users.map(function(x) { return { user: x }; }) );
      }
    );
  }
});
{% endif %}

</script>
{% endblock %}