<commit_before>kd    = require 'kd'
JView = require 'app/jview'


module.exports = class CredentialListItem extends kd.ListItemView

  JView.mixin @prototype

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

    options.cssClass = kd.utils.curry 'credential-item clearfix', options.cssClass
    super options, data

    delegate = @getDelegate()
    { identifier, owner, title, verified } = @getData()

    @deleteButton = new kd.ButtonView
      cssClass : 'solid compact outline red secondary'
      title    : 'DELETE'
      callback : delegate.lazyBound 'deleteItem', this

    @showCredentialButton = new kd.ButtonView
      cssClass : 'solid compact outline secondary'
      title    : 'SHOW'
      callback : delegate.lazyBound 'showItemContent', this

    @verifyButton = new kd.ButtonView
      cssClass : 'solid compact outline'
      title    : 'USE THIS & CONTINUE'
      loader   :
        color  : '#666'
      callback : @bound 'verifyCredential'

    @inuseView = new kd.CustomHTMLView
      cssClass : 'inuse-tag hidden'
      partial  : 'IN USE'
      tooltip  :
        title  : 'This stack template currently using this credential'

    { stackTemplate }       = @getOptions()
    { selectedCredentials } = delegate.getOptions()

    credentials = stackTemplate?.credentials ? {}
    credentials = (credentials[val].first.identifier for val of credentials)
    credentials = credentials.concat (selectedCredentials or [])

    if identifier in credentials
      @inuseView.show()

    @warningView = new kd.CustomHTMLView
      cssClass : 'warning-message hidden'


  setVerified: (state, reason) ->
<commit_msg>Fix for IN USE label<commit_after>kd    = require 'kd'
JView = require 'app/jview'


module.exports = class CredentialListItem extends kd.ListItemView

  JView.mixin @prototype

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

    options.cssClass = kd.utils.curry 'credential-item clearfix', options.cssClass
    super options, data

    delegate = @getDelegate()
    { identifier, owner, title, verified } = @getData()

    @deleteButton = new kd.ButtonView
      cssClass : 'solid compact outline red secondary'
      title    : 'DELETE'
      callback : delegate.lazyBound 'deleteItem', this

    @showCredentialButton = new kd.ButtonView
      cssClass : 'solid compact outline secondary'
      title    : 'SHOW'
      callback : delegate.lazyBound 'showItemContent', this

    @verifyButton = new kd.ButtonView
      cssClass : 'solid compact outline'
      title    : 'USE THIS & CONTINUE'
      loader   :
        color  : '#666'
      callback : @bound 'verifyCredential'

    @inuseView = new kd.CustomHTMLView
      cssClass : 'inuse-tag hidden'
      partial  : 'IN USE'
      tooltip  :
        title  : 'This stack template currently using this credential'

    { stackTemplate }       = @getOptions()
    { selectedCredentials } = delegate.getOptions()

    credentials = stackTemplate?.credentials ? {}
    credentials = (credentials[val].first for val of credentials)
    credentials = credentials.concat (selectedCredentials or [])

    if identifier in credentials
      @inuseView.show()

    @warningView = new kd.CustomHTMLView
      cssClass : 'warning-message hidden'


  setVerified: (state, reason) ->

{'fraction_non_alphanumeric': 0.0959284392350401, 'fraction_numerical': 0.001850709438618137, 'mean_word_length': 2.9452554744525545, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '3099295', 'n_tokens_mistral': 939, 'n_tokens_neox': 910, 'n_words': 254}