From 615137a883d9182b4864d06d6c2959a1e44f6928 Mon Sep 17 00:00:00 2001 From: Julianna Tetreault <32834804+juliannatetreault@users.noreply.github.com> Date: Thu, 20 Jan 2022 07:31:35 -0700 Subject: [PATCH] Remove the "Getting Started" Section from the Config (#16033) * Removes the Getting Started section and related code from the config * Removes the admin_manages_configuration_spec.rb * Removes "Required" tags from Config * Reverts removal of activateMissingKeysModal * Removes mandatory.rb --- app/helpers/application_helper.rb | 6 -- .../admin/controllers/config_controller.js | 3 +- app/models/settings/mandatory.rb | 29 ------ app/validators/bytesize_validator.rb | 1 - .../admin/settings/forms/_mandatory.html.erb | 45 --------- app/views/admin/settings/show.html.erb | 29 ------ .../config/getStartedSection.spec.js | 92 ------------------- .../admin/admin_manages_configuration_spec.rb | 17 ---- 8 files changed, 1 insertion(+), 221 deletions(-) delete mode 100644 app/models/settings/mandatory.rb delete mode 100644 app/views/admin/settings/forms/_mandatory.html.erb delete mode 100644 cypress/integration/seededFlows/adminFlows/config/getStartedSection.spec.js delete mode 100644 spec/system/admin/admin_manages_configuration_spec.rb diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 7dec2afce..6144ab32e 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -270,12 +270,6 @@ module ApplicationHelper def admin_config_label(method, content = nil, model: Settings::General) content ||= tag.span(method.to_s.humanize) - if method.to_sym.in?(Settings::Mandatory.keys) - required = tag.span(I18n.t("helpers.application_helper.required"), - class: "c-indicator c-indicator--danger") - content = safe_join([content, required]) - end - label_prefix = model.name.split("::").map(&:underscore).join("_") tag.label(content, class: "site-config__label crayons-field__label", for: "#{label_prefix}_#{method}") end diff --git a/app/javascript/admin/controllers/config_controller.js b/app/javascript/admin/controllers/config_controller.js index e206cf618..fc4f3ba4a 100644 --- a/app/javascript/admin/controllers/config_controller.js +++ b/app/javascript/admin/controllers/config_controller.js @@ -158,7 +158,6 @@ export default class ConfigController extends Controller { communityName.parentNode.replaceChild(newLogo, communityName); } else { for (const logo of document.querySelectorAll('.site-logo__img')) { - if (logo !== previewLogo) { logo.src = previewLogo.src; } @@ -417,7 +416,7 @@ export default class ConfigController extends Controller { activateMissingKeysModal(providers) { this.configModalAnchorTarget.innerHTML = adminModal({ - title: 'Getting started', + title: 'Setup not complete', controllerName: 'config', closeModalFunction: 'closeAdminModal', body: this.missingAuthKeysModalBody(providers), diff --git a/app/models/settings/mandatory.rb b/app/models/settings/mandatory.rb deleted file mode 100644 index 19c316b7a..000000000 --- a/app/models/settings/mandatory.rb +++ /dev/null @@ -1,29 +0,0 @@ -module Settings - # We use this model to back the "Get Started" form of the config admin page. - class Mandatory - include ActiveModel::Naming - - MAPPINGS = { - community_name: Settings::Community, - community_description: Settings::Community, - - suggested_tags: Settings::General, - suggested_users: Settings::General - }.freeze - MAPPING_KEYS = MAPPINGS.keys - - MAPPINGS.each do |setting, settings_model| - delegate setting, "#{setting}=", to: settings_model - end - - def self.keys - MAPPING_KEYS - end - - def self.missing - MAPPINGS.reject do |settings, settings_model| - settings_model.public_send(settings).present? - end.keys - end - end -end diff --git a/app/validators/bytesize_validator.rb b/app/validators/bytesize_validator.rb index 0be8cccac..081dd89c6 100644 --- a/app/validators/bytesize_validator.rb +++ b/app/validators/bytesize_validator.rb @@ -7,7 +7,6 @@ class BytesizeValidator < ActiveModel::EachValidator CHECKS = { maximum: :<= }.freeze RESERVED_OPTIONS = %i[maximum too_long].freeze - def check_validity! raise ArgumentError, ERROR_MESSAGE unless options.key?(:maximum) diff --git a/app/views/admin/settings/forms/_mandatory.html.erb b/app/views/admin/settings/forms/_mandatory.html.erb deleted file mode 100644 index fde7cb6d7..000000000 --- a/app/views/admin/settings/forms/_mandatory.html.erb +++ /dev/null @@ -1,45 +0,0 @@ -<%= form_with(url: admin_settings_mandatory_settings_path, data: { action: "submit->config#updateConfigurationSettings", testid: "getStartedSectionForm" }) do |f| %> -
- - <% Settings::Mandatory::MAPPINGS.each do |config_key, settings_model| %> - <%# we need to list the config as separate fields if the data structure is a Hash %> - <% placeholder_module = Constants.const_get(settings_model.name) %> - <% if settings_model.public_send(config_key).is_a?(Hash) %> - <%= admin_config_label config_key.to_s %> -
- <%= f.fields_for config_key do |a_field| %> - <% settings_model.public_send(config_key).each do |key, value| %> -
- <%= admin_config_label key.to_s %> - <%= admin_config_description "#{key} #{config_key.to_s.tr! '_', ' '}" %> - <%= a_field.text_field key, - class: "crayons-textfield", - value: settings_model.public_send(config_key)[key], - placeholder: placeholder_module::DETAILS[config_key][:placeholder] %> -
- <% end %> - <% end %> -
- <% elsif settings_model.public_send(config_key).is_a?(Array) %> -
- <%= admin_config_label config_key %> - <%= admin_config_description placeholder_module::DETAILS[config_key][:description] %> - <%= f.text_field config_key, - class: "crayons-textfield", - value: settings_model.public_send(config_key).join(","), - placeholder: placeholder_module::DETAILS[config_key][:placeholder] %> -
- <% else %> -
- <%= admin_config_label config_key %> - <%= admin_config_description placeholder_module::DETAILS[config_key][:description] %> - <%= f.text_field config_key, - class: "form-control", - value: settings_model.public_send(config_key), - placeholder: placeholder_module::DETAILS[config_key][:placeholder] %> -
- <% end %> - <% end %> -
- <%= render "update_setting_button", f: f %> -<% end %> diff --git a/app/views/admin/settings/show.html.erb b/app/views/admin/settings/show.html.erb index 16c6656a6..c396e0639 100644 --- a/app/views/admin/settings/show.html.erb +++ b/app/views/admin/settings/show.html.erb @@ -7,35 +7,6 @@ <% end %> -
-
-
- -

Get Started

- - -
- -
- <%= render partial: "forms/mandatory" %> -
-
-
-
{ - beforeEach(() => { - cy.testSetup(); - cy.fixture('users/adminUser.json').as('user'); - - cy.get('@user').then((user) => { - cy.loginUser(user); - }); - }); - - describe('Community name setting', () => { - it('updates the community name', () => { - cy.get('@user').then(() => { - cy.visit('/admin/customization/config'); - - cy.findByTestId('getStartedSectionForm').as('getStartedSectionForm'); - - cy.get('@getStartedSectionForm') - .get('#community_name') - .clear() - .type('Awesome community'); - - cy.get('@getStartedSectionForm').findByText('Update Settings').click(); - - cy.url().should('contains', '/admin/customization/config'); - - cy.findByTestId('snackbar').within(() => { - cy.findByRole('alert').should( - 'have.text', - 'Successfully updated settings.', - ); - }); - - // Page reloaded so need to get a new reference to the form. - cy.findByTestId('getStartedSectionForm').as('getStartedSectionForm'); - cy.get('#community_name').should('have.value', 'Awesome community'); - }); - }); - - it('updates the suggested tags', () => { - cy.get('@user').then(() => { - cy.visit('/admin/customization/config'); - - cy.findByTestId('getStartedSectionForm').as('getStartedSectionForm'); - - cy.get('@getStartedSectionForm') - .get('#suggested_tags') - .clear() - .type('much tag, so wow'); - - cy.get('@getStartedSectionForm').findByText('Update Settings').click(); - - cy.url().should('contains', '/admin/customization/config'); - - cy.findByTestId('snackbar').within(() => { - cy.findByRole('alert').should( - 'have.text', - 'Successfully updated settings.', - ); - }); - - // Page reloaded so need to get a new reference to the form. - cy.findByTestId('getStartedSectionForm').as('getStartedSectionForm'); - cy.get('#suggested_tags').should('have.value', 'much tag, so wow'); - }); - }); - - it('generates error message when update fails', () => { - cy.intercept('POST', '/admin/settings/mandatory_settings', { - error: 'some error msg', - }); - cy.get('@user').then(() => { - cy.visit('/admin/customization/config'); - - cy.findByTestId('getStartedSectionForm').as('getStartedSectionForm'); - - cy.get('@getStartedSectionForm') - .get('#suggested_tags') - .clear() - .type('much tag, so wow'); - - cy.get('@getStartedSectionForm').findByText('Update Settings').click(); - - cy.url().should('contains', '/admin/customization/config'); - - cy.findByTestId('snackbar').within(() => { - cy.findByRole('alert').should('have.text', 'some error msg'); - }); - }); - }); - }); -}); diff --git a/spec/system/admin/admin_manages_configuration_spec.rb b/spec/system/admin/admin_manages_configuration_spec.rb deleted file mode 100644 index ba8b0f52d..000000000 --- a/spec/system/admin/admin_manages_configuration_spec.rb +++ /dev/null @@ -1,17 +0,0 @@ -require "rails_helper" - -RSpec.describe "Admin manages configuration", type: :system do - let(:admin) { create(:user, :super_admin) } - - before do - sign_in admin - visit admin_config_path - end - - Settings::Mandatory::MAPPINGS.each do |option, _setting_model| - it "marks #{option} as required" do - selector = "label[for='settings_general_#{option}']" - expect(first(selector).text).to include("Required") - end - end -end