From a5a1f41423d64bee35dd7feebe5eb5a9955a7873 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Thu, 28 Jan 2016 13:33:56 +0100 Subject: [PATCH] Do not show chat in navbar until chat is enabled. --- app/assets/javascripts/app/controllers/chat.coffee | 9 +++++++-- .../javascripts/app/controllers/navigation.coffee | 12 ++++++++++++ test/browser/chat_test.rb | 12 +++++------- 3 files changed, 24 insertions(+), 9 deletions(-) diff --git a/app/assets/javascripts/app/controllers/chat.coffee b/app/assets/javascripts/app/controllers/chat.coffee index fe2786b68..299a3b641 100644 --- a/app/assets/javascripts/app/controllers/chat.coffee +++ b/app/assets/javascripts/app/controllers/chat.coffee @@ -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') @@ -634,7 +639,7 @@ class ChatWindow extends App.Controller addStatusMessage: (message, args) -> @maybeAddTimestamp() - + @body.append App.view('customer_chat/chat_status_message') message: message args: args @@ -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' ) diff --git a/app/assets/javascripts/app/controllers/navigation.coffee b/app/assets/javascripts/app/controllers/navigation.coffee index 594abe1f2..20dd58956 100644 --- a/app/assets/javascripts/app/controllers/navigation.coffee +++ b/app/assets/javascripts/app/controllers/navigation.coffee @@ -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 = {} diff --git a/test/browser/chat_test.rb b/test/browser/chat_test.rb index cba4cbb93..fb879641c 100644 --- a/test/browser/chat_test.rb +++ b/test/browser/chat_test.rb @@ -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(