From fda0cfafc6800dcdc09c21b7d2ce138e35dbb01f Mon Sep 17 00:00:00 2001 From: Adam Cooke Date: Fri, 2 Jun 2017 12:11:19 +0100 Subject: [PATCH] rename admin to advanced settings & add help text closes #163 --- app/controllers/servers_controller.rb | 2 +- app/models/server.rb | 1 - app/views/servers/_settings_header.html.haml | 2 +- app/views/servers/admin.html.haml | 50 ------------- app/views/servers/advanced.html.haml | 77 ++++++++++++++++++++ config/routes.rb | 2 +- 6 files changed, 80 insertions(+), 54 deletions(-) delete mode 100644 app/views/servers/admin.html.haml create mode 100644 app/views/servers/advanced.html.haml diff --git a/app/controllers/servers_controller.rb b/app/controllers/servers_controller.rb index db6ccab..dd759f9 100644 --- a/app/controllers/servers_controller.rb +++ b/app/controllers/servers_controller.rb @@ -3,7 +3,7 @@ class ServersController < ApplicationController include WithinOrganization before_action :require_organization_admin, :only => [:new, :create, :delete, :destroy] - before_action :admin_required, :only => [:admin, :suspend, :unsuspend] + before_action :admin_required, :only => [:advanced, :suspend, :unsuspend] before_action { params[:id] && @server = organization.servers.present.find_by_permalink!(params[:id]) } def index diff --git a/app/models/server.rb b/app/models/server.rb index ca526b4..2bddb47 100644 --- a/app/models/server.rb +++ b/app/models/server.rb @@ -79,7 +79,6 @@ class Server < ApplicationRecord before_validation(:on => :create) do self.token = self.token.downcase if self.token - self.outbound_spam_threshold = 3.0 if self.outbound_spam_threshold.blank? end after_create do diff --git a/app/views/servers/_settings_header.html.haml b/app/views/servers/_settings_header.html.haml index 5105b94..b235654 100644 --- a/app/views/servers/_settings_header.html.haml +++ b/app/views/servers/_settings_header.html.haml @@ -7,6 +7,6 @@ - if Postal.ip_pools? %li.navBar__item= link_to "IP Rules", [organization, @server, :ip_pool_rules], :class => ['navBar__link', active_nav == :ip_pool_rules ? 'is-active' : ''] - if current_user.admin? - %li.navBar__item= link_to "Admin", [:admin, organization, @server], :class => ['navBar__link', active_nav == :admin ? 'is-active' : ''] + %li.navBar__item= link_to "Advanced Settings", [:advanced, organization, @server], :class => ['navBar__link', active_nav == :admin ? 'is-active' : ''] - if organization.admin?(current_user) %li.navBar__item= link_to "Delete", [:delete, organization, @server], :class => ['navBar__link', active_nav == :delete ? 'is-active' : ''] diff --git a/app/views/servers/admin.html.haml b/app/views/servers/admin.html.haml deleted file mode 100644 index 77495e4..0000000 --- a/app/views/servers/admin.html.haml +++ /dev/null @@ -1,50 +0,0 @@ -- page_title << @server.name -- page_title << "Settings" -- page_title << "Admin" -= render 'sidebar', :active_server => @server -= render 'header', :active_nav => :settings -= render 'settings_header', :active_nav => :admin -.pageContent.pageContent--compact - .u-margin - = form_for [organization, @server], :remote => true do |f| - = f.error_messages - %fieldset.fieldSet.fieldSet--wide - .fieldSet__field - = f.label :send_limit, :class => 'fieldSet__label' - .fieldSet__input= f.text_field :send_limit, :class => 'input input--text', :placeholder => "No limit" - .fieldSet__field - = f.label :allow_sender, "Allow sender header", :class => 'fieldSet__label' - .fieldSet__input= f.select :allow_sender, [["No", false], ["Yes - can use Sender header", true]], {}, :class => 'input input--select' - .fieldSet__field - = f.label :log_smtp_data, "Log SMTP data?", :class => 'fieldSet__label' - .fieldSet__input= f.select :log_smtp_data, [["No", false], ["Yes - log all SMTP DATA (debug only)", true]], {}, :class => 'input input--select' - .fieldSet__field - = f.label :outbound_spam_threshold, :class => 'fieldSet__label' - .fieldSet__input= f.text_field :outbound_spam_threshold, :class => 'input input--text', :placeholder => "No outbound spam checking" - .fieldSet__field - = f.label :message_retention_days, :class => 'fieldSet__label' - .fieldSet__input= f.text_field :message_retention_days, :class => 'input input--text' - .fieldSet__field - = f.label :raw_message_retention_days, :class => 'fieldSet__label' - .fieldSet__input= f.text_field :raw_message_retention_days, :class => 'input input--text' - .fieldSet__field - = f.label :raw_message_retention_size, :class => 'fieldSet__label' - .fieldSet__input= f.text_field :raw_message_retention_size, :class => 'input input--text' - - .fieldSetSubmit.fieldSetSubmit--wide.buttonSet - = f.submit "Save server", :class => 'button button--positive js-form-submit' - - - if @server.suspended_at - = form_tag [:unsuspend, organization, @server], :remote => true do - .fieldSetSubmit.fieldSetSubmit--wide.buttonSet - = submit_tag "Unsuspend server", :class => 'button button--danger js-form-submit' - - - else - = form_tag [:suspend, organization, @server], :remote => true do - %fieldset.fieldSet.fieldSet--wide - .fieldSet__field - = label_tag :reason, 'Suspension Reason', :class => 'fieldSet__label' - .fieldSet__input= text_field_tag :reason, '', :class => 'input input--text', :required => true - - .fieldSetSubmit.fieldSetSubmit--wide.buttonSet - = submit_tag "Suspend server", :class => 'button button--positive js-form-submit' diff --git a/app/views/servers/advanced.html.haml b/app/views/servers/advanced.html.haml new file mode 100644 index 0000000..b5d83e9 --- /dev/null +++ b/app/views/servers/advanced.html.haml @@ -0,0 +1,77 @@ +- page_title << @server.name +- page_title << "Settings" +- page_title << "Advanced" += render 'sidebar', :active_server => @server += render 'header', :active_nav => :settings += render 'settings_header', :active_nav => :admin +.pageContent.pageContent--compact + .u-margin + = form_for [organization, @server], :remote => true do |f| + = f.error_messages + %fieldset.fieldSet.fieldSet--wide + .fieldSet__field + = f.label :send_limit, :class => 'fieldSet__label' + .fieldSet__input + = f.text_field :send_limit, :class => 'input input--text', :placeholder => "No limit" + %p.fieldSet__text This is the maximum number of e-mails that can be sent through this mail server in a 60 minute period. + .fieldSet__field + = f.label :allow_sender, "Allow sender header", :class => 'fieldSet__label' + .fieldSet__input + = f.select :allow_sender, [["No", false], ["Yes - can use Sender header", true]], {}, :class => 'input input--select' + %p.fieldSet__text If enabled, outgoing messages can use any address in the From header as long as a Sender header is included with an authorized address. + + .fieldSet__field + = f.label :log_smtp_data, "Log SMTP data?", :class => 'fieldSet__label' + .fieldSet__input + = f.select :log_smtp_data, [["No", false], ["Yes - log all SMTP DATA (debug only)", true]], {}, :class => 'input input--select' + %p.fieldSet__text + By default, no information after the DATA command in an SMTP command is logged. If enabled, all this data will be logged too. This should only + be used for debugging. + .fieldSet__field + = f.label :outbound_spam_threshold, :class => 'fieldSet__label' + .fieldSet__input + = f.text_field :outbound_spam_threshold, :class => 'input input--text', :placeholder => "No outbound spam checking" + %p.fieldSet__text + By default, outgoing messages aren't scanned for spam. You can specify a threshold here and outgoing messages that exceed this will + not be permitted to be sent through the mail server. + .fieldSet__field + = f.label :message_retention_days, :class => 'fieldSet__label' + .fieldSet__input + = f.text_field :message_retention_days, :class => 'input input--text' + %p.fieldSet__text + The number of days that message meta data is stored in the database after it has been added. + .fieldSet__field + = f.label :raw_message_retention_days, :class => 'fieldSet__label' + .fieldSet__input + = f.text_field :raw_message_retention_days, :class => 'input input--text' + %p.fieldSet__text + The number of days that raw message data (bodies & attachments) are stored in the database after it has been added. + .fieldSet__field + = f.label :raw_message_retention_size, :class => 'fieldSet__label' + .fieldSet__input + = f.text_field :raw_message_retention_size, :class => 'input input--text' + %p.fieldSet__text + The total amount of disk space (in bytes) to allow raw message data to use on the disk. Older messages will be deleted to keep + the total usage below this amount. + + .fieldSetSubmit.fieldSetSubmit--wide.buttonSet + = f.submit "Save server", :class => 'button button--positive js-form-submit' + + - if @server.suspended_at + = form_tag [:unsuspend, organization, @server], :remote => true do + .fieldSetSubmit.fieldSetSubmit--wide.buttonSet + = submit_tag "Unsuspend server", :class => 'button button--danger js-form-submit' + + - else + = form_tag [:suspend, organization, @server], :remote => true do + %fieldset.fieldSet.fieldSet--wide + .fieldSet__field + = label_tag :reason, 'Suspension Reason', :class => 'fieldSet__label' + .fieldSet__input + = text_field_tag :reason, '', :class => 'input input--text', :required => true + %p.fieldSet__text + If you wish to disable this server and stop it sending messages, enter a reason above. Any users assigned to the + server will be notified of the suspension by e-mail. + + .fieldSetSubmit.fieldSetSubmit--wide.buttonSet + = submit_tag "Suspend server", :class => 'button button--positive js-form-submit' diff --git a/config/routes.rb b/config/routes.rb index 566dd3a..7e7523d 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -52,7 +52,7 @@ Rails.application.routes.draw do get :delete, :on => :member get 'help/outgoing' => 'help#outgoing' get 'help/incoming' => 'help#incoming' - get :admin, :on => :member + get :advanced, :on => :member post :suspend, :on => :member post :unsuspend, :on => :member end