Newer
Older
GitBucket / src / main / twirl / gitbucket / core / settings / options.scala.html
@Naoki Takezoe Naoki Takezoe on 15 Feb 2018 9 KB Set autocomplete=off to almost forms
@(repository: gitbucket.core.service.RepositoryService.RepositoryInfo, info: Option[Any])(implicit context: gitbucket.core.controller.Context)
@import gitbucket.core.view.helpers
@gitbucket.core.html.main("Settings", Some(repository)){
  @gitbucket.core.html.menu("settings", repository){
    @gitbucket.core.settings.html.menu("options", repository){
      @gitbucket.core.helper.html.information(info)
      <form id="form" method="post" action="@helpers.url(repository)/settings/options" validate="true" autocomplete="off">
        <div class="panel panel-default">
          <div class="panel-heading strong">Settings</div>
          <div class="panel-body">
            <fieldset class="form-group">
              <label for="repositoryName" class="strong">Repository Name:</label>
              <input type="text" name="repositoryName" id="repositoryName" class="form-control" value="@repository.name"/>
              <span id="error-repositoryName" class="error"></span>
            </fieldset>
            <fieldset class="border-top form-group">
              <label for="description" class="strong">Description:</label>
              <input type="text" name="description" id="description" class="form-control" value="@repository.repository.description"/>
            </fieldset>
            <fieldset class="border-top">
              <label class="radio">
                <input type="radio" name="isPrivate" value="false"
                  @if(!repository.repository.isPrivate              ){ checked  }
                  @if(repository.repository.parentUserName.isDefined){ disabled }
                >
                <span class="strong"><i class="octicon octicon-repo"></i> Public</span><br>
                <div class="normal muted">
                  Anyone can see this repository. You choose who can commit.
                </div>
              </label>
              <label class="radio">
                <input type="radio" name="isPrivate" value="true"
                  @if(repository.repository.isPrivate               ){ checked  }
                  @if(repository.repository.parentUserName.isDefined){ disabled }
                >
                <span class="strong"><i class="octicon octicon-lock"></i> Private</span><br>
                <div class="normal muted">
                  You choose who can see and commit to this repository.
                </div>
              </label>
            </fieldset>
            <fieldset class="form-group">
              <label class="checkbox" for="allowFork">
                <input type="checkbox" id="allowFork" name="allowFork"@if(repository.repository.options.allowFork){ checked}/>
                Forks<br>
                <div class="normal muted">
                  Allow users who can access this repository to fork it.
                </div>
              </label>
            </fieldset>
          </div>
        </div>
        <div class="panel panel-default">
          <div class="panel-heading strong">Issues and Pull Requests</div>
          <div class="panel-body">
            <fieldset class="form-group">
              <div class="radio">
                <label>
                  <input type="radio" name="issuesOption" value="DISABLE" @if(repository.repository.options.issuesOption == "DISABLE"){ checked}> Disable issue tracking and pull request system
                </label>
              </div>
              <div class="radio">
                <label>
                  <input type="radio" name="issuesOption" value="PRIVATE" @if(repository.repository.options.issuesOption == "PRIVATE"){ checked}> Developers can view, create and comment on issues and pull requests
                </label>
              </div>
              <div class="radio">
                <label>
                  <input type="radio" name="issuesOption" value="PUBLIC" @if(repository.repository.options.issuesOption == "PUBLIC"){ checked}> Developers and guests can view, create and comment on issues and pull requests
                </label>
              </div>
              <div class="radio for-public-repo">
                <label>
                  <input type="radio" name="issuesOption" value="ALL" @if(repository.repository.options.issuesOption == "ALL"){ checked}> All users can view, create and comment on issues and pull requests
                </label>
              </div>
              <label for="externalIssuesUrl" class="strong">External URL:
                <span class="normal muted">(Fill if you use an external issue tracking system for this project)</span>
              </label>
              <input type="text" class="form-control" id="externalIssuesUrl" name="externalIssuesUrl" value="@repository.repository.options.externalIssuesUrl"/>
            </fieldset>
          </div>
        </div>
        <div class="panel panel-default">
          <div class="panel-heading strong">Wiki</div>
          <div class="panel-body">
            <fieldset class="form-group">
              <div class="radio">
                <label>
                  <input type="radio" name="wikiOption" value="DISABLE" @if(repository.repository.options.wikiOption == "DISABLE"){ checked}> Disable wiki
                </label>
              </div>
              <div class="radio">
                <label>
                  <input type="radio" name="wikiOption" value="PRIVATE" @if(repository.repository.options.wikiOption == "PRIVATE"){ checked}> Developers can view, create and edit wiki pages
                </label>
              </div>
              <div class="radio">
                <label>
                  <input type="radio" name="wikiOption" value="PUBLIC" @if(repository.repository.options.wikiOption == "PUBLIC"){ checked}> Developers and guests can view, create and edit wiki pages
                </label>
              </div>
              <div class="radio for-public-repo">
                <label>
                  <input type="radio" name="wikiOption" value="ALL" @if(repository.repository.options.wikiOption == "ALL"){ checked}> All users can view, create and edit wiki pages
                </label>
              </div>
              <label for="externalWikiUrl" class="strong">External URL:
                <span class="normal muted">(Fill if you use an external wiki for this project)</span>
              </label>
              <input type="text" class="form-control" id="externalWikiUrl" name="externalWikiUrl" value="@repository.repository.options.externalWikiUrl"/>
            </fieldset>
          </div>
        </div>
        <div class="panel panel-default">
          <div class="panel-heading strong">Merge strategy</div>
          <div class="panel-body">
            Select pull request merge strategies which are available in this repository. At least one option must be enabled.
            <fieldset class="form-group">
              @defining(repository.repository.options.mergeOptions.split(",")){ mergeOptions =>
                <div class="checkbox">
                  <label for="mergeOptions_MergeCommit">
                    <input type="checkbox" name="mergeOptions" id="mergeOptions_MergeCommit" value="merge-commit" @if(mergeOptions.contains("merge-commit")){checked}>
                  <span class="strong">Merge commit</span>
                  <div class="normal muted">Commits will be added to the base branch via a merge commit.</div>
                  </label>
                </div>
                <div class="checkbox">
                  <label for="mergeOptions_Squash">
                    <input type="checkbox" name="mergeOptions" id="mergeOptions_Squash" value="squash" @if(mergeOptions.contains("squash")){checked}>
                    <span class="strong">Squash</span>
                    <div class="normal muted">Commits will be combined into one commit in the base branch.</div>
                  </label>
                </div>
                <div class="checkbox">
                  <label for="mergeOptions_Rebase">
                    <input type="checkbox" name="mergeOptions" id="mergeOptions_Rebase" value="rebase" @if(mergeOptions.contains("rebase")){checked}>
                    <span class="strong">Rebase</span>
                    <div class="normal muted">Commits will be rebased and added to the base branch.</div>
                  </label>
                </div>
                <span id="error-mergeOptions" class="error"></span>
              }
              <fieldset class="form-group">
                <label for="defaultMergeOption">Default merge strategy</label>
                <select name="defaultMergeOption" id="defaultMergeOption">
                  <option value="merge-commit">Merge commit</option>
                  <option value="squash">Squash</option>
                  <option value="rebase">Rebase</option>
                </select>
                <span id="error-defaultMergeOption" class="error"></span>
              </fieldset>
            </fieldset>
          </div>
        </div>
        <div class="align-right" style="margin-top: 20px;">
          <input type="submit" class="btn btn-success" value="Apply changes"/>
        </div>
      </form>
    }
  }
}
<script>
$(function(){
  updateFeatures();
  $('input[name=isPrivate], input[name=issuesOption], input[name=wikiOption]').click(function(){
    updateFeatures();
  });
});

function updateFeatures() {
  if($('input[name=isPrivate]:checked').val() == 'false'){
    $('.for-public-repo').show();
  } else {
    if($('input[name=issuesOption]:checked').val() == 'ALL'){
      $('input[name=issuesOption][value=PUBLIC]').prop('checked', true);
    }
    if($('input[name=wikiOption]:checked').val() == 'ALL'){
      $('input[name=wikiOption][value=PUBLIC]').prop('checked', true);
    }
    $('.for-public-repo').hide();
  }

  $('#externalIssuesUrl').prop('disabled', $('input[name=issuesOption]:checked').val() != 'DISABLE');
  $('#externalWikiUrl').prop('disabled', $('input[name=wikiOption]:checked').val() != 'DISABLE');
}
</script>