diff --git a/app/components/create_log_actions_component.rb b/app/components/create_log_actions_component.rb index c61a85b80..11c63c3a9 100644 --- a/app/components/create_log_actions_component.rb +++ b/app/components/create_log_actions_component.rb @@ -14,6 +14,7 @@ class CreateLogActionsComponent < ViewComponent::Base def display_actions? return false if bulk_upload.present? return true if user.support? + return false if !user.organisation.holds_own_stock? && user.organisation.stock_owners.empty? && user.organisation.absorbed_organisations.empty? user.organisation.data_protection_confirmed? end diff --git a/app/components/data_protection_confirmation_banner_component.rb b/app/components/data_protection_confirmation_banner_component.rb index 5757ad87f..745c79e20 100644 --- a/app/components/data_protection_confirmation_banner_component.rb +++ b/app/components/data_protection_confirmation_banner_component.rb @@ -3,8 +3,6 @@ class DataProtectionConfirmationBannerComponent < ViewComponent::Base attr_reader :user, :organisation - HELPDESK_URL = "https://dluhcdigital.atlassian.net/servicedesk/customer/portal/6/group/11".freeze - def initialize(user:, organisation: nil) @user = user @organisation = organisation @@ -58,7 +56,7 @@ private end def link_href - dpo_required? ? HELPDESK_URL : data_sharing_agreement_organisation_path(org_or_user_org) + dpo_required? ? GlobalConstants::HELPDESK_URL : data_sharing_agreement_organisation_path(org_or_user_org) end def dpo_required? diff --git a/app/components/missing_stock_owners_banner_component.html.erb b/app/components/missing_stock_owners_banner_component.html.erb new file mode 100644 index 000000000..157a4a625 --- /dev/null +++ b/app/components/missing_stock_owners_banner_component.html.erb @@ -0,0 +1,10 @@ +<% if display_banner? %> + <%= govuk_notification_banner(title_text: "Important") do %> +
+
+ <%= banner_text %> +
+ <% end %> +<% end %> diff --git a/app/components/missing_stock_owners_banner_component.rb b/app/components/missing_stock_owners_banner_component.rb new file mode 100644 index 000000000..f2cee801c --- /dev/null +++ b/app/components/missing_stock_owners_banner_component.rb @@ -0,0 +1,61 @@ +class MissingStockOwnersBannerComponent < ViewComponent::Base + include Rails.application.routes.url_helpers + + attr_reader :user, :organisation + + def initialize(user:, organisation: nil) + @user = user + @organisation = organisation || user.organisation + + super + end + + def display_banner? + return false if DataProtectionConfirmationBannerComponent.new(user:, organisation:).display_banner? + + !organisation.holds_own_stock? && organisation.stock_owners.empty? && organisation.absorbed_organisations.empty? + end + + def header_text + if user.data_coordinator? || user.support? + "Your organisation does not own stock. You must #{add_stock_owner_link} before you can create logs.".html_safe + else + "Your organisation does not own stock. You must add a stock owner before you can create logs.".html_safe + end + end + + def banner_text + if user.data_coordinator? || user.support? + "If your organisation does own stock, #{contact_helpdesk_link} to update your details.".html_safe + else + "Ask a data coordinator to add a stock owner. Find your data coordinators on the #{users_link}. + If your organisation does own stock, #{contact_helpdesk_link} to update your details.".html_safe + end + end + +private + + def add_stock_owner_link + govuk_link_to( + "add a stock owner", + stock_owners_add_organisation_path(id: organisation.id), + class: "govuk-notification-banner__link govuk-!-font-weight-bold", + ) + end + + def contact_helpdesk_link + govuk_link_to( + "contact the helpdesk", + GlobalConstants::HELPDESK_URL, + class: "govuk-notification-banner__link govuk-!-font-weight-bold", + ) + end + + def users_link + govuk_link_to( + "users page", + users_path, + class: "govuk-notification-banner__link govuk-!-font-weight-bold", + ) + end +end diff --git a/app/constants/global_constants.rb b/app/constants/global_constants.rb new file mode 100644 index 000000000..c25bf7c92 --- /dev/null +++ b/app/constants/global_constants.rb @@ -0,0 +1,3 @@ +module GlobalConstants + HELPDESK_URL = "https://dluhcdigital.atlassian.net/servicedesk/customer/portal/6/group/11".freeze +end diff --git a/app/mailers/csv_download_mailer.rb b/app/mailers/csv_download_mailer.rb index b590ebcfc..681f864e9 100644 --- a/app/mailers/csv_download_mailer.rb +++ b/app/mailers/csv_download_mailer.rb @@ -29,8 +29,6 @@ class CsvDownloadMailer < NotifyMailer private - HELPDESK_URL = "https://dluhcdigital.atlassian.net/servicedesk/customer/portal/6/group/11".freeze - def issue_explanation(issue_types, log_type) [ "We have found #{multiple_issue_types?(issue_types) ? 'these issues' : 'this issue'} in your logs imported to the new version of CORE:\n", @@ -43,7 +41,7 @@ private def how_to_fix(issue_types, link, log_type) [ "You need to:\n\n", - "- download [this spreadsheet for #{log_type} logs](#{link}). This link will expire in one week. To request another link, [contact the CORE helpdesk](#{HELPDESK_URL}).\n", + "- download [this spreadsheet for #{log_type} logs](#{link}). This link will expire in one week. To request another link, [contact the CORE helpdesk](#{GlobalConstants::HELPDESK_URL}).\n", issue_types.include?("missing_address") || issue_types.include?("missing_town") ? "- fill in the missing address data\n" : "", uprn_issues_only(issue_types) ? "- check that the address data is correct\n" : "- check that the existing address data is correct\n", has_uprn_issues(issue_types) ? "- correct any address errors\n" : "", diff --git a/app/views/errors/not_found.html.erb b/app/views/errors/not_found.html.erb index 23401c82b..f79b1422d 100644 --- a/app/views/errors/not_found.html.erb +++ b/app/views/errors/not_found.html.erb @@ -5,6 +5,6 @@If you typed the web address, check it is correct.
If you pasted the web address, check you copied the entire address.
-<%= govuk_link_to "Get help", "https://dluhcdigital.atlassian.net/servicedesk/customer/portal/6/group/11" %> if the web address is correct and not working.
+<%= govuk_link_to "Get help", GlobalConstants::HELPDESK_URL %> if the web address is correct and not working.
diff --git a/app/views/layouts/_footer.html.erb b/app/views/layouts/_footer.html.erb index f105cb9d5..cadc13db6 100644 --- a/app/views/layouts/_footer.html.erb +++ b/app/views/layouts/_footer.html.erb @@ -6,7 +6,7 @@- <%= govuk_link_to("CORE helpdesk (opens in a new tab)", "https://dluhcdigital.atlassian.net/servicedesk/customer/portal/6/group/11", class: "govuk-footer__link", rel: "noreferrer noopener", target: "_blank") %> + <%= govuk_link_to("CORE helpdesk (opens in a new tab)", GlobalConstants::HELPDESK_URL, class: "govuk-footer__link", rel: "noreferrer noopener", target: "_blank") %>
You will be able to use the service from 9am on Thursday 16 November 2023.
Changes from the page you were on have not been saved. Changes on pages where you have selected 'save and continue' have been saved.
-<%= govuk_link_to "Contact the helpdesk", "https://dluhcdigital.atlassian.net/servicedesk/customer/portal/6/group/11" %> if you need help.
+<%= govuk_link_to "Contact the helpdesk", GlobalConstants::HELPDESK_URL %> if you need help.
To report a merge or update your organisation details, <%= govuk_link_to "contact the helpdesk", "https://dluhcdigital.atlassian.net/servicedesk/customer/portal/6/group/11" %>.
+To report a merge or update your organisation details, <%= govuk_link_to "contact the helpdesk", GlobalConstants::HELPDESK_URL %>.
<% end %> <%= render partial: "organisations/merged_organisation_details" %> diff --git a/app/views/schemes/changes.html.erb b/app/views/schemes/changes.html.erb index 850cc63ce..74c23f0f6 100644 --- a/app/views/schemes/changes.html.erb +++ b/app/views/schemes/changes.html.erb @@ -28,6 +28,6 @@If you upload logs in bulk, you can use either the new or old scheme codes in your template.
You should be able to recognise a scheme migrated from old CORE by viewing its details or locations. Try searching for it by postcode.
-If you still can’t find a scheme that was migrated from old CORE, either create a new one if you know the details, or <%= govuk_link_to("contact the helpdesk", "https://dluhcdigital.atlassian.net/servicedesk/customer/portal/6/group/11", rel: "noreferrer noopener", target: "_blank") %> to report the problem. Only data coordinators can create and edit schemes.
+If you still can’t find a scheme that was migrated from old CORE, either create a new one if you know the details, or <%= govuk_link_to("contact the helpdesk", GlobalConstants::HELPDESK_URL, rel: "noreferrer noopener", target: "_blank") %> to report the problem. Only data coordinators can create and edit schemes.
diff --git a/app/views/start/index.html.erb b/app/views/start/index.html.erb index 8ce802478..3c10232d2 100644 --- a/app/views/start/index.html.erb +++ b/app/views/start/index.html.erb @@ -18,7 +18,7 @@Use your account details to sign in.
-If you need to set up a new account, speak to your organisation’s CORE data coordinator. If you don’t know who that is, <%= govuk_link_to("contact the helpdesk", "https://dluhcdigital.atlassian.net/servicedesk/customer/portal/6/group/11") %>.
+If you need to set up a new account, speak to your organisation’s CORE data coordinator. If you don’t know who that is, <%= govuk_link_to("contact the helpdesk", GlobalConstants::HELPDESK_URL) %>.
You can <%= govuk_mail_to("dluhc.digital-services@levellingup.gov.uk", "request an account", subject: "CORE: Request a new account") %> if your organisation doesn’t have one.
diff --git a/spec/requests/lettings_logs_controller_spec.rb b/spec/requests/lettings_logs_controller_spec.rb index 97db942b1..d2ea715ff 100644 --- a/spec/requests/lettings_logs_controller_spec.rb +++ b/spec/requests/lettings_logs_controller_spec.rb @@ -291,6 +291,60 @@ RSpec.describe LettingsLogsController, type: :request do expect(page).to have_content("Managed by") end end + + context "and organisation does not own stock or have valid stock owners" do + before do + organisation.update!(holds_own_stock: false) + end + + it "hides button to create a new log" do + get "/lettings-logs" + expect(page).not_to have_content("Create a new lettings log") + end + + context "with coordinator user" do + let(:user) { FactoryBot.create(:user, :data_coordinator) } + + it "displays a banner exlaining why create new logs button is missing" do + get "/lettings-logs", headers:, params: {} + expect(page).to have_css(".govuk-notification-banner") + expect(page).to have_content("Your organisation does not own stock.") + expect(page).to have_link("add a stock owner", href: /stock-owners\/add/) + expect(page).not_to have_link("users page", href: /users/) + end + end + + context "with provider user" do + let(:user) { FactoryBot.create(:user, :data_provider) } + + it "displays a banner exlaining why create new logs button is missing" do + get "/lettings-logs", headers:, params: {} + expect(page).to have_css(".govuk-notification-banner") + expect(page).to have_content("Your organisation does not own stock.") + expect(page).not_to have_link("add a stock owner", href: /stock-owners\/add/) + expect(page).to have_link("users page", href: /users/) + end + end + end + + context "and organisation owns stock" do + before do + organisation.update!(holds_own_stock: true) + end + + it "displays button to create a new log" do + get "/lettings-logs" + expect(page).to have_content("Create a new lettings log") + end + + it "does not display the missing stock owners banner" do + get "/lettings-logs", headers:, params: {} + expect(page).not_to have_css(".govuk-notification-banner") + expect(page).not_to have_content("Your organisation does not own stock.") + expect(page).not_to have_link("add a stock owner", href: /stock-owners\/add/) + expect(page).not_to have_link("users page", href: /users/) + end + end end context "when the user is a customer support user" do diff --git a/spec/requests/sales_logs_controller_spec.rb b/spec/requests/sales_logs_controller_spec.rb index 4b16d81ef..e837a21dc 100644 --- a/spec/requests/sales_logs_controller_spec.rb +++ b/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" 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 context "when there are multiple sets of duplicates" do