Fixed issue#428 - Switching storage provider for attachments in UI has no effect.

This commit is contained in:
Martin Edenhofer 2016-11-17 15:06:31 +01:00
parent be3ee48a3c
commit 15975eaaf7
5 changed files with 60 additions and 5 deletions

View file

@ -0,0 +1,2 @@
class App.SettingsAreaStorageProvider extends App.SettingsAreaItem
template: 'settings/storage_provider'

View file

@ -0,0 +1,22 @@
<form class="settings-entry" id="<%= @setting.name %>">
<h2><%- @T(@setting.title) %></h2>
<p class="help-text"><%- @T('You can switch between the backend for new attachments even on a system that is already in production without any loss of data.') %></p>
<p class="help-text"><%- @T('If you want to move already stored attachments from one backend to another, you need to execute the following via console.') %></p>
</p>
<p class="help-text"><%- @T('Move all from "%s" to "%s"', 'filesystem', 'database') %>:</p>
</p>
<code>
rails&gt; Store::File.move('File', 'DB')
</code>
<p class="help-text"><%- @T('Move all from "%s" to "%s"', 'database', 'filesystem') %>:</p>
</p>
<code>
rails&gt; Store::File.move('DB', 'File')
</code>
<br>
<br>
<div class="horizontal end">
<div class="form-item flex"></div>
<button type="submit" class="btn btn--primary"><%- @T('Submit') %></button>
</div>
</form>

View file

@ -1,7 +1,6 @@
<form class="settings-entry" id="<%= @setting.name %>">
<h2><%- @T(@setting.title) %></h2>
<p class="help-text">
<%- @T('The format of the subject.') %>
<p class="help-text"><%- @T('The format of the subject.') %></p>
<ul>
<li><%- @T('|Right| means |Some Subject [Ticket#12345]|') %>
<li><%- @T('|Left| means |[Ticket#12345] Some Subject|') %>

View file

@ -0,0 +1,30 @@
class StoreConfigNameUpdateIssue428 < ActiveRecord::Migration
def up
# return if it's a new setup
return if !Setting.find_by(name: 'system_init_done')
setting = Setting.find_by(name: 'storage')
return if !Setting
setting.name = 'storage_provider'
setting.options = {
form: [
{
display: '',
null: true,
name: 'storage_provider',
tag: 'select',
tranlate: true,
options: {
'DB' => 'Database',
'File' => 'Filesystem',
},
},
],
}
setting.preferences = {
controller: 'SettingsAreaStorageProvider',
online_service_disable: true,
permission: ['admin.system'],
}
setting.save!
end
end

View file

@ -259,7 +259,7 @@ Setting.create_if_not_exists(
Setting.create_if_not_exists(
title: 'Storage Mechanism',
name: 'storage',
name: 'storage_provider',
area: 'System::Storage',
description: '"Database" stores all attachments in the database (not recommended for storing large amounts of data). "Filesystem" stores the data on the filesystem. You can switch between the modules even on a system that is already in production without any loss of data.',
options: {
@ -267,17 +267,19 @@ Setting.create_if_not_exists(
{
display: '',
null: true,
name: 'storage',
name: 'storage_provider',
tag: 'select',
tranlate: true,
options: {
'DB' => 'Database',
'FS' => 'Filesystem',
'File' => 'Filesystem',
},
},
],
},
state: 'DB',
preferences: {
controller: 'SettingsAreaStorageProvider',
online_service_disable: true,
permission: ['admin.system'],
},