     @details.toggleClass  'hidden'
     @roleLabel.toggleClass 'active'
 
+
+  showPlanModal: (team, _plans) ->
+
+    getDetails = (plan) ->
+
+      data = if not plan or plan is 'noplan' \
+        then { restriction: 'No restriction' }
+        else _plans[plan]
+
+      details = objectToString data, separator: "  "
+
+      applyMarkdown "```json \n#{details}\n```"
+
+    plans = [ { title: 'No plan', value: 'noplan' } ]
+    for plan of _plans
+      plans.push { title: plan, value: plan }
+
+    delegate = @getDelegate()
+
+    modal = new kd.ModalViewWithForms
+      title                       : "Set team plan for #{team.slug}"
+      overlay                     : yes
+      height                      : 'auto'
+      tabs                        :
+        forms                     :
+          setplan                 :
+            buttons               :
+              Cancel              :
+                itemClass         : kd.ButtonView
+                style             : 'solid medium'
+                loader            :
+                  color           : '#444444'
+                callback          : -> modal.destroy()
+              Save                :
+                itemClass         : kd.ButtonView
+                style             : 'solid green medium'
+                loader            :
+                  color           : '#444444'
+                callback          : ->
+
+                  { setplan } = modal.modalTabs.forms
+                  button      = setplan.buttons.Save
+                  plan        = setplan.inputs.plan.getValue()
+
+                  team.setPlan { plan }, (err) ->
+
+                    button.hideLoader()
+
+                    unless showError err
+                      new kd.NotificationView title: 'Team plan has been changed!'
+                      delegate.emit 'ReloadRequested'
+                      modal.destroy()
+
+            fields                :
+
+              plan                :
+                name              : 'plan'
+                label             : 'Plan'
+                type              : 'hidden'
+                nextElement       :
+                  plan            :
+                    itemClass     : kd.SelectBox
+                    defaultValue  : team.config?.plan ? 'noplan'
+                    selectOptions : plans
+                    callback      : (plan) ->
+                      { setplan } = modal.modalTabs.forms
+                      setplan.inputs.planDetails.updatePartial getDetails plan
+                      modal._windowDidResize()
+
+              planDetails         :
+                name              : 'plandetails'
+                label             : 'Plan Details'
+                type              : 'hidden'
+                nextElement       :
+                  planDetails     :
+                    cssClass      : 'has-markdown'
+                    itemClass     : kd.View
+                    partial       : getDetails team.config?.plan
+
   pistachio: ->
 
     """

    else 'Currently no plan is set, which means there is no limit for this team.'

    @details.addSubView new kd.View partial: message
    @details.addSubView new kd.ButtonView
      title    : 'Change Team Plan'
      cssClass : 'solid compact'
      callback : -> console.log 'WIP', team

    { appManager } = kd.singletons



timeago                   = require 'timeago'
showError                 = require 'app/util/showError'
applyMarkdown             = require 'app/util/applyMarkdown'
objectToString            = require 'app/util/objectToString'

AdminAppView              = require 'admin/views/customviews/adminappview'
ActivityItemMenuItem      = require 'activity/views/activityitemmenuitem'
