Commit 887d4fe6 authored by lauren j's avatar lauren j

app/config: Bring in config key deprecation warnings from EARMMS

Adds warnings on the configuration key-value list and key edit pages
for deprecated keys, as defined in the `APP_CONFIG_DEPRECATED_ENTRIES`
constant in `config/default_config.rb`.

This adds the 'allow-outside-file-upload' key to the deprecation list,
that key was deprecated in v1.1.1 (see commit d3b40219 for details).
parent 15bccf9c
......@@ -13,11 +13,13 @@ class ReConnect::Controllers::SystemConfigurationKeysController < ReConnect::Con
@title = t(:'system/configuration/key_value/title')
@entries = config_keyvalue_entries
@has_deprecated = @entries.keys.map{|k| ReConnect::APP_CONFIG_DEPRECATED_ENTRIES.key?(k)}.any?
haml(:'system/layout', :locals => {:title => @title}) do
haml(:'system/configuration/keyvalue/list', :layout => false, :locals => {
:title => @title,
:entries => @entries,
:has_deprecated => @has_deprecated,
})
end
end
......@@ -52,6 +54,7 @@ class ReConnect::Controllers::SystemConfigurationKeysController < ReConnect::Con
:is_new => entry.nil?,
:type => type,
:value => value,
:deprecated => ReConnect::APP_CONFIG_DEPRECATED_ENTRIES[key],
:delete_url => "/system/configuration/keys/#{key}/delete",
})
end
......
......@@ -13,6 +13,7 @@ module ReConnect::Helpers::SystemConfigurationHelpers
:type => e.type,
:value => value,
:value_truncated => truncated,
:deprecated => ReConnect::APP_CONFIG_DEPRECATED_ENTRIES[e.key],
:edit_link => "/system/configuration/keys/#{e.key}",
}
]
......
......@@ -9,6 +9,13 @@
%input{:type => 'hidden', :name => '_csrf', :value => session[:csrf]}
%h1= t(:'system/configuration/key_value/edit_key/edit')
- if deprecated
.message.message-warning
= succeed ': ' do
= t(:'system/configuration/key_value/edit_key/deprecated_message', :dep_in => deprecated[:in])
%span
&= deprecated[:reason]
%label{:for => 'type'}= t(:'system/configuration/key_value/edit_key/type')
%select#type{:name => 'type', :required => true}
%option{:value => 'bool', :selected => (type == "bool")}
......
......@@ -8,20 +8,39 @@
.form-wrapped
%h1= t(:'system/configuration/key_value/keys/section_title')
- if has_deprecated
.message.message-warning
= succeed ' ' do
= t(:'system/configuration/key_value/deprecated/one_or_more')
%span.badge
%i.fa.fa-exclamation-circle= ""
= t(:'system/configuration/key_value/deprecated/badge', :dep_in => ReConnect::VERSION)
%ul.block-list
- entries.each do |k, v|
%li
- if has_role?("system:configuration:edit")
.block-form
%a.block-button.pure-button.button{:href => v[:edit_link], :title => t(:edit)}
%i.fa.fa-pencil
.cfgkvlist-name.y-margin
%strong
&= k
%span
%strong= k
= "(#{v[:type]}): "
= surround '(', ')' do
&= v[:type]
%code.code-line
&= v[:value_truncated]
- if v[:deprecated]
%span.badge
%i.fa.fa-exclamation-circle= ""
= t(:'system/configuration/key_value/deprecated/badge', :dep_in => v[:deprecated][:in])
.cfgkvlist-value.y-margin
%code.code-line
&= v[:value_truncated]
- if has_role?("system:configuration:edit")
.block-form.cfgkvlist-form
%a.block-button.pure-button.button{:href => v[:edit_link], :title => t(:edit)}
%i.fa.fa-pencil= ""
= t(:'system/configuration/key_value/keys/edit')
%form.pure-form.pure-form-stacked.form-wrapped{:method => "GET", :action => url("/system/configuration/keys/new-key")}
%h1= t(:'system/configuration/key_value/new_key/section_title')
......
......@@ -120,6 +120,16 @@ module ReConnect
},
}
APP_CONFIG_DEPRECATED_ENTRIES = {
"allow-outside-file-upload" => {
:in => "1.1.1",
:reason => (
"Moved to 'disable-outside-file-upload', keeping the name in line " \
"with other 'disable-*' configuration entries."
),
},
}
class Application
configure do
set :session_secret, ENV.fetch('SESSION_SECRET') {SecureRandom.hex(32)}
......
......@@ -654,12 +654,16 @@
:'system/configuration/title': "Configuration"
:'system/configuration/key_value/title': "Edit config by key/value"
:'system/configuration/key_value/back_to_list': "Back to key/value list"
:'system/configuration/key_value/deprecated/one_or_more': "One or more configuration keys currently in the database have been marked as deprecated. These entries will appear with a badge beside them that looks like the following:"
:'system/configuration/key_value/deprecated/badge': "Deprecated<% unless dep_in.nil? %>: v<%= e(dep_in) %><% end %>"
:'system/configuration/key_value/entry_truncated': "… (entry truncated, length <%= length %>)"
:'system/configuration/key_value/keys/section_title': "Existing keys"
:'system/configuration/key_value/keys/edit': "Edit"
:'system/configuration/key_value/new_key/section_title': "New key"
:'system/configuration/key_value/new_key/key_name': "Key to add"
:'system/configuration/key_value/new_key/submit': "Create key"
:'system/configuration/key_value/edit_key/title': "Editing key <%= key %>"
:'system/configuration/key_value/edit_key/deprecated_message': "This configuration key was deprecated in <strong>v<%= e(dep_in) %></strong>"
:'system/configuration/key_value/edit_key/edit': "Edit value"
:'system/configuration/key_value/edit_key/delete': "Delete key"
:'system/configuration/key_value/edit_key/delete/invalid': "Oops! Can't delete a key that doesn't exist."
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment