<commit_before>import Ember from "ember";
import hbs from 'htmlbars-inline-precompile';
import Fetcher from "../lib/fetcher2";
import rpc from "../lib/rpc";

export default Ember.Component.extend({

  commits: Ember.computed(function(){
    return Fetcher.find('commit', 'index')
  }),

  actions: {
    approveCommit(commit){
      rpc["commit:approve"](commit.id, function(){
        Ember.set(commit, 'approved', true)
        Fetcher.find('commit', 'index', true)
      })
    },
    rejectCommit(commit){
      rpc["commit:reject"](commit.id, function(){
        Ember.set(commit, 'approved', false)
        Fetcher.find('commit', 'index', true)
      })
    },
  },

  layout: hbs`
    <h1 class="commit-list-header">Commits</h1>
    <div class="commit-list">
    {{#each commits.list as |commit|}}
      <div class="commit-list__item">
        <table class="table">
          <tbody>
            <tr>
              <td>ID</td><td>{{commit.id}}</td>
            </tr><tr>
              <td>Created On</td><td>{{commit.createdOn}}</td>
            </tr><tr>
              <td>Jurisdiction</td><td>{{commit.jurisdictionTitle}}</td>
            </tr><tr>
              <td>Standards Set</td><td>{{commit.standardSetTitle}}</td>
            </tr><tr>
              <td>Submitted By:</td><td>{{commit.committerName}}</td>
            </tr><tr>
              <td>Submitted By Email:</td><td>{{commit.committerEmail}}</td>
            </tr><tr>
              <td>Summary</td><td>{{commit.commitSummary}}</td>
            </tr><tr>
              <td>Diff</td><td>{{json-pretty obj=commit.diff}}</td>
            </tr><tr>
              <td>Actions</td>
              <td>
                <div class="btn btn-default" {{action "approveCommit" commit}}>Approve</div>
                <div class="btn btn-link" {{action "rejectCommit" commit}}>Reject</div>
              </td>
            </tr>
          </tbody>
        </table>
      </div>
    {{/each}}
    </div>

  `

})
<commit_msg>Show approval dialog before approving/rejecting<commit_after>import Ember from "ember";
import hbs from 'htmlbars-inline-precompile';
import Fetcher from "../lib/fetcher2";
import rpc from "../lib/rpc";

export default Ember.Component.extend({

  commits: Ember.computed(function(){
    return Fetcher.find('commit', 'index')
  }),

  actions: {
    approveCommit(commit){
      if (window.confirm("Are you sure you want to accept this?")){
        rpc["commit:approve"](commit.id, function(){
          Ember.set(commit, 'approved', true)
          Fetcher.find('commit', 'index', true)
        })
      }
    },
    rejectCommit(commit){
      if (window.confirm("Are you sure you want to reject this?")){
        rpc["commit:reject"](commit.id, function(){
          Ember.set(commit, 'approved', false)
          Fetcher.find('commit', 'index', true)
        })
      }
    },
  },

  layout: hbs`
    <h1 class="commit-list-header">Commits</h1>
    <div class="commit-list">
    {{#each commits.list as |commit|}}
      <div class="commit-list__item">
        <table class="table">
          <tbody>
            <tr>
              <td>ID</td><td>{{commit.id}}</td>
            </tr><tr>
              <td>Created On</td><td>{{commit.createdOn}}</td>
            </tr><tr>
              <td>Jurisdiction</td><td>{{commit.jurisdictionTitle}}</td>
            </tr><tr>
              <td>Standards Set</td><td>{{commit.standardSetTitle}}</td>
            </tr><tr>
              <td>Submitted By:</td><td>{{commit.committerName}}</td>
            </tr><tr>
              <td>Submitted By Email:</td><td>{{commit.committerEmail}}</td>
            </tr><tr>
              <td>Summary</td><td>{{commit.commitSummary}}</td>
            </tr><tr>
              <td>Diff</td><td>{{json-pretty obj=commit.diff}}</td>
            </tr><tr>
              <td>Actions</td>
              <td>
                <div class="btn btn-default" {{action "approveCommit" commit}}>Approve</div>
                <div class="btn btn-link" {{action "rejectCommit" commit}}>Reject</div>
              </td>
            </tr>
          </tbody>
        </table>
      </div>
    {{/each}}
    </div>

  `

})

{'fraction_non_alphanumeric': 0.19016786570743405, 'fraction_numerical': 0.0014388489208633094, 'mean_word_length': 2.0489766081871346, 'pattern_counts': {'":': 0, '<': 139, '<?xml version=': 0, '>': 139, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3926041', 'n_tokens_mistral': 1355, 'n_tokens_neox': 1293, 'n_words': 226}