Maintenance banner moved to admin site (#1775)

* initial

* finish

* travis fixes

* travis again

* not required
This commit is contained in:
MrKeksi 2020-06-26 20:30:56 +02:00 committed by GitHub
parent 495c375685
commit 9a96df6a37
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 64 additions and 6 deletions

View File

@ -134,6 +134,17 @@ function changePrivacyPolicyURL(path) {
$.post(path, {value: url})
}
// Display the maintenance Banner
function displayMaintenanceBanner(path) {
var message = $("#maintenance-banner").val()
$.post(path, {value: message})
}
// Clear the maintenance Banner
function clearMaintenanceBanner(path) {
$.post(path, {value: ""})
}
function mergeUsers() {
let userToMerge = $("#from-uid").text()
$.post($("#merge-save-access").data("path"), {merge: userToMerge})

View File

@ -145,6 +145,10 @@ input:focus {
border-color: $primary !important;
}
.input-group button:focus {
box-shadow: none !important;
}
.list-group-item-action.active {
color: $primary;
}

View File

@ -84,9 +84,9 @@ class ApplicationController < ActionController::Base
help: I18n.t("errors.maintenance.help"),
}
end
if Rails.configuration.maintenance_window.present?
unless cookies[:maintenance_window] == Rails.configuration.maintenance_window
flash.now[:maintenance] = Rails.configuration.maintenance_window
if @settings.get_value("Maintenance Banner").present?
unless cookies[:maintenance_window] == @settings.get_value("Maintenance Banner")
flash.now[:maintenance] = @settings.get_value("Maintenance Banner")
end
end
end

View File

@ -36,4 +36,8 @@ module ThemingHelper
def user_color
@settings.get_value("Primary Color") || Rails.configuration.primary_color_default
end
def maintenance_banner
@settings.get_value("Maintenance Banner")
end
end

View File

@ -203,6 +203,21 @@
</div>
</div>
</div>
<div class="mb-6 row">
<div class="col-12">
<div class="form-group">
<label class="form-label"><%= t("administrator.site_settings.maintenance_banner.title") %></label>
<label class="form-label text-muted"><%= t("administrator.site_settings.maintenance_banner.info") %></label>
<div class="input-group">
<input id="maintenance-banner" type="text" class="form-control" value="<%= maintenance_banner %>" placeholder="<%= t("administrator.site_settings.maintenance_banner.time") %>">
<span class="input-group-append">
<button onclick="displayMaintenanceBanner('<%= admin_update_settings_path(setting: 'Maintenance Banner') %>')" class="settings-button btn btn-primary" type="button"><%= t("administrator.site_settings.maintenance_banner.display") %></button>
<button onclick="clearMaintenanceBanner('<%= admin_update_settings_path(setting: 'Maintenance Banner') %>')" class="settings-button btn btn-danger" type="button"><%= t("administrator.site_settings.maintenance_banner.clear") %></button>
</span>
</div>
</div>
</div>
</div>
<% if current_user.has_role? :super_admin%>
<hr>
<div class="row">

View File

@ -82,6 +82,12 @@ en:
info: Set the default recording visbility for new recordings
title: Recording Default Visibility
warning: This setting will only be applied to rooms that aren't running
maintenance_banner:
info: Displays a Banner to inform the user of a scheduled maintenance
title: Maintenance Banner
display: Set
clear: Clear
time: "Maintenance: On Friday, there may be disruptions in service starting at 6 p.m."
registration:
info: Change the way that users register to the website
title: Registration Method
@ -106,7 +112,7 @@ en:
demoted: User has been successfully demoted
invite: Invite successfully sent to %{email}
invite_email_verification: Emails must be enabled in order to use this method. Please contact your system administrator.
merge_fail: There was an issue merging the user accounts. Please check the users selected and try again
merge_fail: There was an issue merging the user accounts. Please check the users selected and try again
merge_success: User accounts merged successfully
perm_deleted: User has been permanently deleted
promoted: User has been successfully promoted
@ -136,7 +142,7 @@ en:
edit_site_settings: Allow users with this role to edit site settings
edit_roles: Allow users with this role to edit other roles
manage_users: Allow users with this role to manage users
invalid_assignment: There was a problem assigning the roles to the user. Please check the values and try again
invalid_assignment: There was a problem assigning the roles to the user. Please check the values and try again
colour:
title: Role Colour
info: Set the colour that will be associated with the role
@ -474,7 +480,7 @@ en:
fail: Your account has not been approved yet. If multiples days have passed since you signed up, please contact your administrator.
signup: Your account was successfully created. It has been sent to an administrator for approval.
banned:
fail: You do not have access to this application. If you believe this is a mistake, please contact your administrator.
fail: You do not have access to this application. If you believe this is a mistake, please contact your administrator.
deprecated:
new_signin: Select a new login method for you account. All your rooms from your old account will be migrated to the new account
twitter_signin: Signing in via Twitter has been deprecated and will be removed in the next release. Click <a href="%{link}"> here </a> to move your account to a new authentication method

View File

@ -461,6 +461,24 @@ describe AdminsController, type: :controller do
end
end
context "POST #maintenance_banner" do
it "displays a banner with the maintenance string" do
allow(Rails.configuration).to receive(:loadbalanced_configuration).and_return(true)
allow_any_instance_of(User).to receive(:greenlight_account?).and_return(true)
@request.session[:user_id] = @admin.id
fake_banner_string = "Maintenance work at 2 pm"
post :update_settings, params: { setting: "Maintenance Banner", value: fake_banner_string }
feature = Setting.find_by(provider: "provider1").features.find_by(name: "Maintenance Banner")
expect(flash[:success]).to be_present
expect(feature[:value]).to eq(fake_banner_string)
expect(response).to redirect_to(admin_site_settings_path)
end
end
context "POST #shared_access" do
it "changes the shared access setting" do
allow(Rails.configuration).to receive(:loadbalanced_configuration).and_return(true)