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

StackTemplateListView = require './stacktemplatelistview'

module.exports = class InitialView extends kd.View

  JView.mixin @prototype

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

    options.cssClass = 'stacktemplates'

    super options, data

    @createStackButton = new kd.ButtonView
      title    : 'Create new Stack'
      cssClass : 'solid compact green action'
      callback : => @emit 'CreateNewStack', skipOnboarding: yes

    @stackTemplateList = new StackTemplateListView

    @stackTemplateList.listView.on 'ItemSelected', (stackTemplate) =>
      @emit 'EditStack', stackTemplate

    @stackTemplateList.listController.on 'ItemsLoaded', (stackTemplates) =>
      @emit 'NoTemplatesFound'  if stackTemplates.length is 0


  reload: ->
    @stackTemplateList.listController.loadItems()


  pistachio: ->
    """
      <div class='text header'>Compute Stack Templates</div>
      <div class=top>
        <div class='text intro'>
          Stack Templates are awesome because when a user
          joins your group you can preconfigure their work
          environment by defining stacks.
          Learn more about stacks
        </div>
        {{> @createStackButton}}
      </div>
      {{> @stackTemplateList}}
    """
<commit_msg>StacksInitialView: don't allow more than 1 stack template [completes #104714314]<commit_after>kd    = require 'kd'
JView = require 'app/jview'

StackTemplateListView = require './stacktemplatelistview'

module.exports = class InitialView extends kd.View

  JView.mixin @prototype

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

    options.cssClass = 'stacktemplates'

    super options, data

    @_stackTemplatesLength = 0

    @createStackButton = new kd.ButtonView
      title    : 'Create new Stack'
      cssClass : 'solid compact green action hidden'
      callback : (event) =>
        console.log @_stackTemplatesLength
        if @_stackTemplatesLength >= 1 and not event?.shiftKey
          @showWarning "Multiple Stack Template support will be
                        provided soon. You still can modify your
                        existing stack templates."
        else
          @emit 'CreateNewStack', skipOnboarding: yes

    @stackTemplateList = new StackTemplateListView

    @stackTemplateList.listView.on 'ItemSelected', (stackTemplate) =>
      @emit 'EditStack', stackTemplate

    @stackTemplateList.listView.on 'ItemDeleted', =>
      @_stackTemplatesLength = @stackTemplateList.listView.items.length - 1

    @stackTemplateList.listController.on 'ItemsLoaded', (stackTemplates) =>
      @emit 'NoTemplatesFound'  if stackTemplates.length is 0
      @_stackTemplatesLength = stackTemplates.length
      @createStackButton.show()


  reload: ->
    @stackTemplateList.listController.loadItems()


  showWarning: (content) ->
    modal = new kd.ModalView
      title          : ''
      content        : content
      overlay        : yes
      overlayOptions :
        cssClass     : 'second-overlay'
        overlayClick : yes
      buttons        :
        close        :
          title      : 'Close'
          cssClass   : 'solid medium gray'
          callback   : -> modal.destroy()


  pistachio: ->
    """
      <div class='text header'>Compute Stack Templates</div>
      <div class=top>
        <div class='text intro'>
          Stack Templates are awesome because when a user
          joins your group you can preconfigure their work
          environment by defining stacks.
          Learn more about stacks
        </div>
        {{> @createStackButton}}
      </div>
      {{> @stackTemplateList}}
    """

{'fraction_non_alphanumeric': 0.09334793320558445, 'fraction_numerical': 0.004106214070626882, 'mean_word_length': 2.557935735150925, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 35, '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': '247006', 'n_tokens_mistral': 1023, 'n_tokens_neox': 969, 'n_words': 272}