Browse Source

Fixes #2780 - Shared Organisation issue create your first ticket

Romit Choudhary 3 years ago
parent
commit
4f3e7f4003

+ 1 - 1
app/assets/javascripts/app/controllers/ticket_overview.coffee

@@ -1314,7 +1314,7 @@ class Table extends App.Controller
     return if ticketListShow[0] || @permissionCheck('ticket.agent')
 
     tickets_count = user.lifetimeCustomerTicketsCount()
-    @html App.view('customer_not_ticket_exists')(has_any_tickets: tickets_count > 0)
+    @html App.view('customer_not_ticket_exists')(has_any_tickets: tickets_count > 0, is_allowed_to_create_ticket: @Config.get('customer_ticket_create'))
 
     if tickets_count == 0
       @listenTo user, 'refresh', =>

+ 8 - 4
app/assets/javascripts/app/views/customer_not_ticket_exists.jst.eco

@@ -6,11 +6,15 @@
         <% if @has_any_tickets: %>
           <p><%- @T('You have no tickets to display in this overview.') %></p>
         <% else: %>
-          <p><%- @T('You have not created a ticket yet.') %></p>
-          <p><%- @T('The way to communicate with us is this thing called "ticket".') %></p>
-          <p><%- @T('Please click the button below to create your first one.') %></p>
+          <% if @is_allowed_to_create_ticket: %>
+            <p><%- @T('You have not created a ticket yet.') %></p>
+            <p><%- @T('The way to communicate with us is this thing called "ticket".') %></p>
+            <p><%- @T('Please click the button below to create your first one.') %></p>
 
-          <p><a class="btn btn--primary" href="#customer_ticket_new"><%- @T('Create your first ticket') %></a></p>
+            <p><a class="btn btn--primary" href="#customer_ticket_new"><%- @T('Create your first ticket') %></a></p>
+          <% else: %>
+            <p><%- @T('You currently don\'t have any tickets.') %></p>
+          <% end %>
         <% end %>
       </div>
     </div>

+ 13 - 0
spec/system/overview_spec.rb

@@ -23,6 +23,19 @@ RSpec.describe 'Overview', type: :system do
       end
     end
 
+    def authenticate
+      Setting.set('customer_ticket_create', false)
+      customer
+    end
+
+    it 'does not show create button when ticket creation via web is disabled', authenticated_as: :authenticate do
+      visit "ticket/view/#{main_overview.link}"
+
+      within :active_content do
+        expect(page).to have_text 'You currently don\'t have any tickets.'
+      end
+    end
+
     it 'shows overview-specific message if customer has tickets in other overview', performs_jobs: true do
       perform_enqueued_jobs only: TicketUserTicketCounterJob do
         create(:ticket, customer: customer)