Browse Source

Hide duplicate logs banner if other banners are present

pull/2086/head
Kat 2 years ago
parent
commit
a3526b44c4
  1. 4
      app/components/missing_stock_owners_banner_component.html.erb
  2. 2
      app/components/missing_stock_owners_banner_component.rb
  3. 8
      app/views/logs/index.html.erb
  4. 8
      app/views/organisations/logs.html.erb
  5. 24
      spec/requests/sales_logs_controller_spec.rb

4
app/components/missing_stock_owners_banner_component.html.erb

@ -3,6 +3,8 @@
<p class="govuk-notification-banner__heading govuk-!-width-full" style="max-width: fit-content"> <p class="govuk-notification-banner__heading govuk-!-width-full" style="max-width: fit-content">
<%= header_text %> <%= header_text %>
<p> <p>
<%= banner_text %> <p style="max-width: fit-content">
<%= banner_text %>
</p>
<% end %> <% end %>
<% end %> <% end %>

2
app/components/missing_stock_owners_banner_component.rb

@ -28,7 +28,7 @@ class MissingStockOwnersBannerComponent < ViewComponent::Base
if user.data_coordinator? || user.support? if user.data_coordinator? || user.support?
"If your organisation does own stock, #{contact_helpdesk_link} to update your details.".html_safe "If your organisation does own stock, #{contact_helpdesk_link} to update your details.".html_safe
else else
"Ask a data coordinator to add a stock owner. Find your data coordinators on the #{users_link}.</br> "Ask a data coordinator to add a stock owner. Find your data coordinators on the #{users_link}.</br></br>
If your organisation does own stock, #{contact_helpdesk_link} to update your details.".html_safe If your organisation does own stock, #{contact_helpdesk_link} to update your details.".html_safe
end end
end end

8
app/views/logs/index.html.erb

@ -3,16 +3,18 @@
<% content_for :title, title %> <% content_for :title, title %>
<%= render DataProtectionConfirmationBannerComponent.new( <% dpo_confirmation_banner = DataProtectionConfirmationBannerComponent.new(
user: current_user, user: current_user,
organisation: @organisation, organisation: @organisation,
) %> ) %>
<%= render dpo_confirmation_banner %>
<%= render MissingStockOwnersBannerComponent.new( <% missing_stock_owner_banner = MissingStockOwnersBannerComponent.new(
user: current_user, user: current_user,
) %> ) %>
<%= render missing_stock_owner_banner %>
<% if @duplicate_sets_count&.positive? %> <% if @duplicate_sets_count&.positive? && !dpo_confirmation_banner.display_banner? && !missing_stock_owner_banner.display_banner? %>
<%= govuk_notification_banner(title_text: "Important", text: govuk_link_to("Review logs", duplicate_logs_path(referrer: "duplicate_logs_banner"))) do |banner| %> <%= govuk_notification_banner(title_text: "Important", text: govuk_link_to("Review logs", duplicate_logs_path(referrer: "duplicate_logs_banner"))) do |banner| %>
<% banner.with_heading(text: I18n.t("notification.duplicate_sets", count: @duplicate_sets_count)) %> <% banner.with_heading(text: I18n.t("notification.duplicate_sets", count: @duplicate_sets_count)) %>
<% end %> <% end %>

8
app/views/organisations/logs.html.erb

@ -12,17 +12,19 @@
<h2 class="govuk-visually-hidden">Logs</h2> <h2 class="govuk-visually-hidden">Logs</h2>
<% end %> <% end %>
<%= render DataProtectionConfirmationBannerComponent.new( <% dpo_confirmation_banner = DataProtectionConfirmationBannerComponent.new(
user: current_user, user: current_user,
organisation: @organisation, organisation: @organisation,
) %> ) %>
<%= render dpo_confirmation_banner %>
<%= render MissingStockOwnersBannerComponent.new( <% missing_stock_owner_banner = MissingStockOwnersBannerComponent.new(
user: current_user, user: current_user,
organisation: @organisation, organisation: @organisation,
) %> ) %>
<%= render missing_stock_owner_banner %>
<% if @duplicate_sets_count&.positive? %> <% if @duplicate_sets_count&.positive? && !dpo_confirmation_banner.display_banner? && !missing_stock_owner_banner.display_banner? %>
<%= govuk_notification_banner(title_text: "Important", text: govuk_link_to("Review logs", organisation_duplicates_path(@organisation, referrer: "duplicate_logs_banner"))) do |banner| %> <%= govuk_notification_banner(title_text: "Important", text: govuk_link_to("Review logs", organisation_duplicates_path(@organisation, referrer: "duplicate_logs_banner"))) do |banner| %>
<% banner.with_heading(text: I18n.t("notification.duplicate_sets", count: @duplicate_sets_count)) %> <% banner.with_heading(text: I18n.t("notification.duplicate_sets", count: @duplicate_sets_count)) %>
<% end %> <% end %>

24
spec/requests/sales_logs_controller_spec.rb

@ -804,6 +804,30 @@ RSpec.describe SalesLogsController, type: :request do
expect(page).not_to have_content "duplicate logs" expect(page).not_to have_content "duplicate logs"
end end
end end
context "and the data sharing agreement banner is shown" do
before do
user.organisation.data_protection_confirmation.destroy!
user.organisation.reload
end
it "displays the correct copy in the banner" do
get sales_logs_path
expect(page).not_to have_content "duplicate logs"
end
end
context "and the missing stock owner banner is shown" do
before do
user.organisation.update!(holds_own_stock: false)
user.organisation.reload
end
it "displays the correct copy in the banner" do
get sales_logs_path
expect(page).not_to have_content "duplicate logs"
end
end
end end
context "when there are multiple sets of duplicates" do context "when there are multiple sets of duplicates" do

Loading…
Cancel
Save