<commit_before>kd                   = require 'kd'
JView                = require 'app/jview'
whoami               = require 'app/util/whoami'
remote               = require('app/remote').getInstance()
globals              = require 'globals'
showError            = require 'app/util/showError'
applyMarkdown        = require 'app/util/applyMarkdown'
CustomLinkView       = require 'app/customlinkview'
integrationHelpers   = require 'app/helpers/integration'


module.exports = class AdminIntegrationDetailsView extends JView

  constructor: (options = {}, data) ->

    options.cssClass = 'integration-details'

    super options, data

    @eventCheckboxes = {}

    @createInstructionsView()

    @settingsForm = new kd.FormViewWithFields @getFormOptions()

    @createEventCheckboxes()

    @createAuthView()

    @disableAdminRepos()


  disableAdminRepos: ->
    data = @getData()
    disabledRepos = data.repositories.filter (r) -> return r.disabled
    selectOptions = @settingsForm.inputs.repository?.getElement().options
    disabledRepos.forEach (repo) ->
      for option in selectOptions when option.value is repo.value
        option.setAttribute 'disabled', 'disabled'


  createInstructionsView: ->

    { integration } = @getData()

    { instructions } = integration

    if instructions
      @instructionsView = new kd.CustomHTMLView
        tagName  : 'section'
        cssClass : 'has-markdown instructions container'
        partial  : """
          <h4 class='title'>Setup Instructions</h4>
          <p class='subtitle'>Here are the steps necessary to add the #{integration.title} integration.</p>
          <hr />
        """
      @instructionsView.addSubView new kd.CustomHTMLView
        partial  : applyMarkdown instructions
    else<commit_msg>Client: default empty array is added for selectedRepo<commit_after>kd                   = require 'kd'
JView                = require 'app/jview'
whoami               = require 'app/util/whoami'
remote               = require('app/remote').getInstance()
globals              = require 'globals'
showError            = require 'app/util/showError'
applyMarkdown        = require 'app/util/applyMarkdown'
CustomLinkView       = require 'app/customlinkview'
integrationHelpers   = require 'app/helpers/integration'


module.exports = class AdminIntegrationDetailsView extends JView

  constructor: (options = {}, data) ->

    options.cssClass = 'integration-details'

    super options, data

    @eventCheckboxes = {}

    @createInstructionsView()

    @settingsForm = new kd.FormViewWithFields @getFormOptions()

    @createEventCheckboxes()

    @createAuthView()

    @disableAdminRepos()


  disableAdminRepos: ->
    data = @getData()
    disabledRepos = data.repositories.filter (r) -> return r.disabled
    selectOptions = @settingsForm.inputs.repository?.getElement().options or []
    disabledRepos.forEach (repo) ->
      for option in selectOptions when option.value is repo.value
        option.setAttribute 'disabled', 'disabled'


  createInstructionsView: ->

    { integration } = @getData()

    { instructions } = integration

    if instructions
      @instructionsView = new kd.CustomHTMLView
        tagName  : 'section'
        cssClass : 'has-markdown instructions container'
        partial  : """
          <h4 class='title'>Setup Instructions</h4>
          <p class='subtitle'>Here are the steps necessary to add the #{integration.title} integration.</p>
          <hr />
        """
      @instructionsView.addSubView new kd.CustomHTMLView
        partial  : applyMarkdown instructions
    else
{'fraction_non_alphanumeric': 0.10033351862145637, 'fraction_numerical': 0.0011117287381878821, 'mean_word_length': 2.7489583333333334, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 23, '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': '3751890', 'n_tokens_mistral': 982, 'n_tokens_neox': 942, 'n_words': 227}