Do not show chat in navbar until chat is enabled.
This commit is contained in:
parent
9d2bd0051c
commit
a5a1f41423
3 changed files with 24 additions and 9 deletions
|
@ -80,6 +80,11 @@ class App.CustomerChat extends App.Controller
|
|||
active: @meta.active
|
||||
)
|
||||
|
||||
featureActive: =>
|
||||
if @Config.get('chat')
|
||||
return true
|
||||
false
|
||||
|
||||
render: ->
|
||||
if !@isRole('Chat')
|
||||
@renderScreenUnauthorized(objectName: 'Chat')
|
||||
|
@ -713,4 +718,4 @@ class Setting extends App.ControllerModal
|
|||
|
||||
App.Config.set( 'customer_chat', CustomerChatRouter, 'Routes' )
|
||||
App.Config.set( 'CustomerChat', { controller: 'CustomerChat', authentication: true }, 'permanentTask' )
|
||||
App.Config.set( 'CustomerChat', { prio: 1200, parent: '', name: 'Customer Chat', target: '#customer_chat', key: 'CustomerChat', role: ['Chat'], class: 'chat' }, 'NavBar' )
|
||||
App.Config.set( 'CustomerChat', { prio: 1200, parent: '', name: 'Customer Chat', target: '#customer_chat', key: 'CustomerChat', shown: false, role: ['Chat'], class: 'chat' }, 'NavBar' )
|
||||
|
|
|
@ -50,7 +50,11 @@ class App.Navigation extends App.ControllerWidgetPermanent
|
|||
items = @getItems( navbar: @Config.get( 'NavBar' ) )
|
||||
|
||||
# apply counter and switch info from persistant controllers (if exists)
|
||||
itemsNew = []
|
||||
for item in items
|
||||
shown = true
|
||||
if item.shown isnt undefined
|
||||
shown = item.shown
|
||||
if item.key
|
||||
worker = App.TaskManager.worker(item.key)
|
||||
if worker
|
||||
|
@ -58,6 +62,14 @@ class App.Navigation extends App.ControllerWidgetPermanent
|
|||
item.counter = worker.counter()
|
||||
if worker.switch
|
||||
item.switch = worker.switch()
|
||||
if worker.featureActive
|
||||
if worker.featureActive()
|
||||
shown = true
|
||||
else
|
||||
shown = false
|
||||
if shown
|
||||
itemsNew.push item
|
||||
items = itemsNew
|
||||
|
||||
# get open tabs to repopen on rerender
|
||||
open_tab = {}
|
||||
|
|
|
@ -29,16 +29,14 @@ class ChatTest < TestCase
|
|||
css: '#content .js-chatSetting',
|
||||
type: 'off',
|
||||
)
|
||||
sleep 25 # wait for rerendering
|
||||
click(
|
||||
|
||||
# nav bar shuld be gone
|
||||
sleep 2
|
||||
exists_not(
|
||||
browser: agent,
|
||||
css: 'a[href="#customer_chat"]',
|
||||
)
|
||||
match(
|
||||
browser: agent,
|
||||
css: '.active.content',
|
||||
value: 'disabled',
|
||||
)
|
||||
sleep 15
|
||||
|
||||
customer = browser_instance
|
||||
location(
|
||||
|
|
Loading…
Reference in a new issue