<commit_before><link rel="import" href="noflo-modal-styles.html">
<dom-module id="noflo-project-inspector">
  <template>
    <style include="noflo-modal-styles">
      button.delete {
        position: absolute;
        right: 36px;
        border: 0px solid hsla( 0, 98%, 46%, .8) !important;
        color: hsla( 0, 98%, 46%, .8) !important;
      }
    </style>
    <div class="modal-container" on-click="bgClick">
      <h1><span>{{project.name}}</span> settings</h1>
      <div class="modal-content">
      <template is="dom-if" if="{{errorText}}">
        <div class="error">{{errorText}}</div>
      </template>
      <form>
        <label>
          <span>GitHub repository</span>
          <input type="text" value="{{repo::input}}" placeholder="username/my-project" autocapitalize="off" autocorrect="off" required="">
        </label>
        <label>
          <span>Project label</span>
          <input type="text" value="{{name::input}}" placeholder="My Cool Project" required="">
        </label>
        <label>
          <span>Project namespace</span>
          <input type="text" value="{{namespace::input}}" placeholder="my-cool-project" required="">
        </label>
        <label>
          <span>Main graph</span>
          <select name="type" value="{{main::input}}">
            <template is="dom-repeat" items="{{project.graphs}}" as="graph">
              <option value="{{graph.properties.id}}" selected$="[[_mainSelected(graph.properties.id, main)]]">{{graph.name}}</option>
            </template>
          </select>
        </label>
        </form>
      </div>
      <div class="toolbar">
        <button on-click="send">Save</button>
        <a on-click="close">Cancel</a>
        <a href="https://github.com/new" target="_blank">New Repository</a>
        <button class="delete" on-click="delete">Delete</button>
      </div>
      </div>
  </template>
  <script>
    Polymer({
      is: 'noflo-project-inspector',
      properties: {
        errorText: {
          type: String,
          value: ''
        },
        main: {
          type: String,
          value: ''
        },
        name: {
          type: String,
          value: ''
        },
        namespace: {
          type: String,
          value: ''
        },
        originalRepo: {
          type: String,
          value: ''
        },
        project: { observer: 'projectChanged' },
        repo: {
          type: String,
          value: ''
        },
      },
      attached: function () {
        Polymer.dom(document.getElementById('container')).classList.add('blur');
        Polymer.dom(this).classList.add('modal-content');
      },
      detached: function () {
        Polymer.dom(document.getElementById('container')).classList.remove('blur');
      },
      projectChanged: function () {
        this.originalRepo = this.project.repo;
        this.repo = this.project.repo;
        this.name = this.project.name;
        this.namespace = this.project.namespace || this.project.id;
        this.main = this.project.main;
      },
      updateProject: function () {
        this.fire('updated', {
          id: this.project.id,
          name: this.name,
          namespace: this.namespace,
          main: this.main,
          type: this.project.type,
          repo: this.repo
        });
        this.close();
      },
      send: function (event) {
        if (event) {
          event.preventDefault();
        }
        if (typeof ga === 'function') {
          ga('send', 'event', 'button', 'click', 'saveProjectProperties');
        }
        this.updateProject();
      },
      delete: function (event) {
        event.preventDefault();
        if (typeof ga === 'function') {
          ga('send', 'event', 'button', 'click', 'deleteProject');
        }
        this.fire('delete', this.project);
        this.close();
      },
      bgClick: function (event) {
        // Don't close if clicking within container
        event.stopPropagation();
      },
      close: function () {
        if (!Polymer.dom(this).parentNode) {
          return;
        }
        Polymer.dom(Polymer.dom(this).parentNode).removeChild(this);
      },
      listeners: { click: 'close' },
      _mainSelected: function(graphId, main) {
        if (graphId === main) {
          return true;
        }
        return false;
      }
    });
  </script>
</dom-module><commit_msg>Only expose main graphs in the project selector<commit_after><link rel="import" href="noflo-modal-styles.html">
<dom-module id="noflo-project-inspector">
  <template>
    <style include="noflo-modal-styles">
      button.delete {
        position: absolute;
        right: 36px;
        border: 0px solid hsla( 0, 98%, 46%, .8) !important;
        color: hsla( 0, 98%, 46%, .8) !important;
      }
    </style>
    <div class="modal-container" on-click="bgClick">
      <h1><span>{{project.name}}</span> settings</h1>
      <div class="modal-content">
      <template is="dom-if" if="{{errorText}}">
        <div class="error">{{errorText}}</div>
      </template>
      <form>
        <label>
          <span>GitHub repository</span>
          <input type="text" value="{{repo::input}}" placeholder="username/my-project" autocapitalize="off" autocorrect="off" required="">
        </label>
        <label>
          <span>Project label</span>
          <input type="text" value="{{name::input}}" placeholder="My Cool Project" required="">
        </label>
        <label>
          <span>Project namespace</span>
          <input type="text" value="{{namespace::input}}" placeholder="my-cool-project" required="">
        </label>
        <label>
          <span>Main graph</span>
          <select name="type" value="{{main::input}}">
            <template is="dom-repeat" items="[[_getMainGraphs(project.graphs)]]" as="graph">
              <option value="{{graph.properties.id}}" selected$="[[_mainSelected(graph.properties.id, main)]]">{{graph.name}}</option>
            </template>
          </select>
        </label>
        </form>
      </div>
      <div class="toolbar">
        <button on-click="send">Save</button>
        <a on-click="close">Cancel</a>
        <a href="https://github.com/new" target="_blank">New Repository</a>
        <button class="delete" on-click="delete">Delete</button>
      </div>
      </div>
  </template>
  <script>
    Polymer({
      is: 'noflo-project-inspector',
      properties: {
        errorText: {
          type: String,
          value: ''
        },
        main: {
          type: String,
          value: ''
        },
        name: {
          type: String,
          value: ''
        },
        namespace: {
          type: String,
          value: ''
        },
        originalRepo: {
          type: String,
          value: ''
        },
        project: { observer: 'projectChanged' },
        repo: {
          type: String,
          value: ''
        },
      },
      attached: function () {
        Polymer.dom(document.getElementById('container')).classList.add('blur');
        Polymer.dom(this).classList.add('modal-content');
      },
      detached: function () {
        Polymer.dom(document.getElementById('container')).classList.remove('blur');
      },
      projectChanged: function () {
        this.originalRepo = this.project.repo;
        this.repo = this.project.repo;
        this.name = this.project.name;
        this.namespace = this.project.namespace || this.project.id;
        this.main = this.project.main;
      },
      updateProject: function () {
        this.fire('updated', {
          id: this.project.id,
          name: this.name,
          namespace: this.namespace,
          main: this.main,
          type: this.project.type,
          repo: this.repo
        });
        this.close();
      },
      send: function (event) {
        if (event) {
          event.preventDefault();
        }
        if (typeof ga === 'function') {
          ga('send', 'event', 'button', 'click', 'saveProjectProperties');
        }
        this.updateProject();
      },
      delete: function (event) {
        event.preventDefault();
        if (typeof ga === 'function') {
          ga('send', 'event', 'button', 'click', 'deleteProject');
        }
        this.fire('delete', this.project);
        this.close();
      },
      bgClick: function (event) {
        // Don't close if clicking within container
        event.stopPropagation();
      },
      close: function () {
        if (!Polymer.dom(this).parentNode) {
          return;
        }
        Polymer.dom(Polymer.dom(this).parentNode).removeChild(this);
      },
      listeners: { click: 'close' },
      _mainSelected: function(graphId, main) {
        if (graphId === main) {
          return true;
        }
        return false;
      },
      _getMainGraphs: function (graphs) {
        return graphs.filter(function (graph) {
          return graph.properties.main;
        });
      }
    });
  </script>
</dom-module>
{'fraction_non_alphanumeric': 0.16568245125348188, 'fraction_numerical': 0.003788300835654596, 'mean_word_length': 1.9439160380452607, 'pattern_counts': {'":': 0, '<': 119, '<?xml version=': 0, '>': 119, 'https://': 2, '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': '3502981', 'n_tokens_mistral': 2616, 'n_tokens_neox': 2581, 'n_words': 496}