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
This commit is contained in:
parent
71b2724faa
commit
615137a883
8 changed files with 1 additions and 221 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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),
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
@ -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)
|
||||
|
||||
|
|
|
|||
|
|
@ -1,45 +0,0 @@
|
|||
<%= form_with(url: admin_settings_mandatory_settings_path, data: { action: "submit->config#updateConfigurationSettings", testid: "getStartedSectionForm" }) do |f| %>
|
||||
<fieldset class="grid gap-4">
|
||||
|
||||
<% 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 %>
|
||||
<div class="form-group">
|
||||
<%= f.fields_for config_key do |a_field| %>
|
||||
<% settings_model.public_send(config_key).each do |key, value| %>
|
||||
<div class="crayons-field">
|
||||
<%= 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] %>
|
||||
</div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</div>
|
||||
<% elsif settings_model.public_send(config_key).is_a?(Array) %>
|
||||
<div class="crayons-field">
|
||||
<%= 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] %>
|
||||
</div>
|
||||
<% else %>
|
||||
<div class="crayons-field">
|
||||
<%= 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] %>
|
||||
</div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</fieldset>
|
||||
<%= render "update_setting_button", f: f %>
|
||||
<% end %>
|
||||
|
|
@ -7,35 +7,6 @@
|
|||
</div>
|
||||
<% end %>
|
||||
|
||||
<div id="getStarted">
|
||||
<div class="card w-100">
|
||||
<div
|
||||
id="getStartedHeader"
|
||||
class="card-header"
|
||||
data-toggle="collapse"
|
||||
data-target="#getStartedBodyContainer"
|
||||
aria-expanded="true"
|
||||
aria-controls="getStartedBodyContainer">
|
||||
|
||||
<h2 class="d-inline">Get Started</h2>
|
||||
|
||||
<button
|
||||
class="crayons-btn crayons-btn--secondary float-right"
|
||||
type="button"
|
||||
data-action="click->config#toggleAccordionButtonLabel">
|
||||
Hide Getting Started
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div
|
||||
id="getStartedBodyContainer"
|
||||
class="show expand p-3"
|
||||
aria-labelledby="getStartedHeader">
|
||||
<%= render partial: "forms/mandatory" %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="settings">
|
||||
<div class="card w-100">
|
||||
<div
|
||||
|
|
|
|||
|
|
@ -1,92 +0,0 @@
|
|||
describe('Get Started Section', () => {
|
||||
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');
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
@ -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
|
||||
Loading…
Add table
Reference in a new issue