Skip to content

feat(settings): Simplifies Config #409

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Dec 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions app/controllers/manage/configs_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ class Manage::ConfigsController < Manage::ApplicationController

def index
@config = HackathonConfig.get_all
@basics = ['name', 'event_start_date', 'digital_hackathon'].freeze
@questionnaire_settings = ['accepting_questionnaires', 'last_day_to_apply', 'auto_late_waitlist', 'disabled_fields'].freeze
@styling = ['default_page_title', 'homepage_url', 'logo_asset', 'email_banner_asset', 'favicon_asset', 'custom_css'].freeze
@communications = ['email_from', 'disclaimer_message', 'thanks_for_applying_message', 'thanks_for_rsvp_message', 'questionnaires_closed_message', 'bus_captain_notes']
@legal = ['agreement_pdf_asset'].freeze
respond_with(HackathonConfig.get_all)
end

Expand Down
239 changes: 184 additions & 55 deletions app/views/manage/configs/index.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,54 @@

.row
.col-lg-6.mb-3
- @config.each_key do |key|
- value = @config[key]
.card.mb-3
.card-body
.card.mb-3
.card-body
%h4.card-title.font-weight-bold
The Basics
%h6.card-subtitle.mb-2.text-muted
Core information about your hackathon.
- @basics.each_entry do |key|
- value = HackathonConfig[key]
%hr
%p.mb-1
= link_to edit_manage_config_path(key), class: 'icon-space-r' do
%span.fa.fa-pencil
%b
= t("simple_form.labels.hackathon_config.#{key}")
%p.text-muted= t("simple_form.hints.hackathon_config.#{key}").html_safe
- if value.nil? || value == ''
%p.mb-0
%span.badge.badge-secondary Not set
- else
%pre.mb-0= value
- if value.is_a?(String)
- images = ['.ico', '.jpg', '.jpeg', '.png', '.gif', '.svg'].freeze
- links = ['http://', 'https://'].freeze
- if value.end_with?(*images)
%br
= image_tag value, style: 'max-height: 100px;', class: 'img-thumbnail img-template'
- elsif value.start_with?(*links)
%br
= link_to value, target: 'blank' do
%span
%span.fa.fa-external-link.icon-space-r-half
Open link
.card.mb-3
.card-body
%h4.card-title.font-weight-bold
Applying to
= HackathonConfig['name']
%h6.card-subtitle.mb-2.text-muted
Configuring questionnaires for your hackathon.
- @questionnaire_settings.each_entry do |key|
- value = HackathonConfig[key]
%hr
%p.mb-1
= link_to edit_manage_config_path(key), class: 'icon-space-r' do
%span.fa.fa-pencil
%b
= t("simple_form.labels.hackathon_config.#{key}")
&nbsp;
%small
%code= key
%p.text-muted= t("simple_form.hints.hackathon_config.#{key}").html_safe
- if key == 'custom_css'
%p
= link_to enter_theming_editor_manage_configs_path do
%span.fa.fa-paint-brush.icon-space-r-half
Interactive editor
- if key == 'disabled_fields'
- cleaned_value = value
- cleaned_value = cleaned_value.join(' ') if cleaned_value.is_a?(Array)
Expand All @@ -45,49 +75,148 @@
%span
%span.fa.fa-external-link.icon-space-r-half
Open link

.col-lg-6.mb-3
.card.mb-3
.card-body
%h5.card-title Environment Variables
%h4.card-title.font-weight-bold
Styling for
= HackathonConfig['name']
%h6.card-subtitle.mb-2.text-muted
Environment variables are configured on the production server.
= render 'docs_link', title: 'Environment variable documentation', url: 'https://coderit.org/hackathon-manager/docs/deployment-environment-variables'
%hr
= render 'config_row', name: 'AWS S3 Bucket for Resumes', key: 'AWS_BUCKET'
= render 'config_row', name: 'AWS S3 Region', key: 'AWS_REGION'
= render 'config_row', name: 'AWS S3 Access Key ID', key: 'AWS_ACCESS_KEY_ID'
= render 'config_row', name: 'AWS S3 Secret Access Key', key: 'AWS_SECRET_ACCESS_KEY', secret: true
= render 'config_row', name: 'AWS S3 Endpoint', key: 'AWS_ENDPOINT', required: false
%hr
= render 'config_row', name: 'Domain Name', key: 'HM_DOMAIN_NAME'
= render 'config_row', name: 'Domain Protocol', key: 'HM_DOMAIN_PROTOCOL', default: 'https'
%hr
= render 'config_row', name: 'MyMLH Application ID', key: 'MLH_KEY'
= render 'config_row', name: 'MyMLH Secret', key: 'MLH_SECRET', secret: true
%hr
= render 'config_row', name: 'Rollbar Access Token', key: 'ROLLBAR_ACCESS_TOKEN', secret: true, required: false
%hr
= render 'config_row', name: 'Time Zone', key: 'TIME_ZONE', default: 'UTC', required: false
%hr
%p.mb-0
%b Email Provider
- if Rails.application.config.action_mailer.delivery_method == :smtp
%p
%span.badge.badge-secondary SendGrid
%span.badge.badge-success SMTP
%br
%small
%i To switch to SendGrid, unset the <code>SMTP_ADDRESS</code> environment variable
= render 'config_row', name: 'SMTP Address', key: 'SMTP_ADDRESS'
= render 'config_row', name: 'SMTP Port', key: 'SMTP_PORT', default: 587
= render 'config_row', name: 'SMTP Username', key: 'SMTP_USER_NAME', secret: true
= render 'config_row', name: 'SMTP Password', key: 'SMTP_PASSWORD', secret: true
- else
%p
%span.badge.badge-success SendGrid
%span.badge.badge-secondary SMTP
%br
%small
%i To switch to SMTP, set the <code>SMTP_ADDRESS</code> environment variable
= render 'config_row', name: 'SendGrid API Key', key: 'SENDGRID_API_KEY', secret: true
Matching your hackathon's style.
- @styling.each_entry do |key|
- value = HackathonConfig[key]
%hr
%p.mb-1
= link_to edit_manage_config_path(key), class: 'icon-space-r' do
%span.fa.fa-pencil
%b
= t("simple_form.labels.hackathon_config.#{key}")
%p.text-muted= t("simple_form.hints.hackathon_config.#{key}").html_safe
- if key == 'custom_css'
%p
= link_to enter_theming_editor_manage_configs_path do
%span.fa.fa-paint-brush.icon-space-r-half
Interactive editor
- if value.nil? || value == ''
%p.mb-0
%span.badge.badge-secondary Not set
- else
%pre.mb-0= value
- if value.is_a?(String)
- images = ['.ico', '.jpg', '.jpeg', '.png', '.gif', '.svg'].freeze
- links = ['http://', 'https://'].freeze
- if value.end_with?(*images)
%br
= image_tag value, style: 'max-height: 100px;', class: 'img-thumbnail img-template'
- elsif value.start_with?(*links)
%br
= link_to value, target: 'blank' do
%span
%span.fa.fa-external-link.icon-space-r-half
Open link
.card.mb-3
.card-body
%h4.card-title.font-weight-bold
Legal
%h6.card-subtitle.mb-2.text-muted
Agreements for your hackers.
- @legal.each_entry do |key|
- value = HackathonConfig[key]
%hr
%p.mb-1
= link_to edit_manage_config_path(key), class: 'icon-space-r' do
%span.fa.fa-pencil
%b
= t("simple_form.labels.hackathon_config.#{key}")
%p.text-muted= t("simple_form.hints.hackathon_config.#{key}").html_safe
%pre.mb-0= value
- if value.is_a?(String)
- images = ['.ico', '.jpg', '.jpeg', '.png', '.gif', '.svg'].freeze
- links = ['http://', 'https://'].freeze
- if value.end_with?(*images)
%br
= image_tag value, style: 'max-height: 100px;', class: 'img-thumbnail img-template'
- elsif value.start_with?(*links)
%br
= link_to value, target: 'blank' do
%span
%span.fa.fa-external-link.icon-space-r-half
Open link
.col-lg-6
.card.mb-3
.card-body
%h4.card-title.font-weight-bold
Communications
%h6.card-subtitle.mb-2.text-muted
Get the word out.
- @communications.each_entry do |key|
- value = HackathonConfig[key]
%hr
%p.mb-1
= link_to edit_manage_config_path(key), class: 'icon-space-r' do
%span.fa.fa-pencil
%b
= t("simple_form.labels.hackathon_config.#{key}")
%p.text-muted= t("simple_form.hints.hackathon_config.#{key}").html_safe
- if value.nil? || value == ''
%p.mb-0
%span.badge.badge-secondary Not set
- else
%pre.mb-0= value
- if value.is_a?(String)
- images = ['.ico', '.jpg', '.jpeg', '.png', '.gif', '.svg'].freeze
- links = ['http://', 'https://'].freeze
- if value.end_with?(*images)
%br
= image_tag value, style: 'max-height: 100px;', class: 'img-thumbnail img-template'
- elsif value.start_with?(*links)
%br
= link_to value, target: 'blank' do
%span
%span.fa.fa-external-link.icon-space-r-half
Open link
.mb-3
.card.mb-3
.card-body
%h4.card-title.font-weight-bold
Environment Variables
%h6.card-subtitle.mb-2.text-muted
Environment variables are configured on the production server.
= render 'docs_link', title: 'Environment variable documentation', url: 'https://coderit.org/hackathon-manager/docs/deployment-environment-variables'
%hr
= render 'config_row', name: 'AWS S3 Bucket for Resumes', key: 'AWS_BUCKET'
= render 'config_row', name: 'AWS S3 Region', key: 'AWS_REGION'
= render 'config_row', name: 'AWS S3 Access Key ID', key: 'AWS_ACCESS_KEY_ID'
= render 'config_row', name: 'AWS S3 Secret Access Key', key: 'AWS_SECRET_ACCESS_KEY', secret: true
= render 'config_row', name: 'AWS S3 Endpoint', key: 'AWS_ENDPOINT', required: false
%hr
= render 'config_row', name: 'Domain Name', key: 'HM_DOMAIN_NAME'
= render 'config_row', name: 'Domain Protocol', key: 'HM_DOMAIN_PROTOCOL', default: 'https'
%hr
= render 'config_row', name: 'My MLH Application ID', key: 'MLH_KEY'
= render 'config_row', name: 'My MLH Secret', key: 'MLH_SECRET', secret: true
%hr
= render 'config_row', name: 'Rollbar Access Token', key: 'ROLLBAR_ACCESS_TOKEN', secret: true, required: false
%hr
= render 'config_row', name: 'Time Zone', key: 'TIME_ZONE', default: 'UTC', required: false
%hr
%p.mb-0
%b Email Provider
- if Rails.application.config.action_mailer.delivery_method == :smtp
%p
%span.badge.badge-secondary SendGrid
%span.badge.badge-success SMTP
%br
%small
%i To switch to SendGrid, unset the <code>SMTP_ADDRESS</code> environment variable
= render 'config_row', name: 'SMTP Address', key: 'SMTP_ADDRESS'
= render 'config_row', name: 'SMTP Port', key: 'SMTP_PORT', default: 587
= render 'config_row', name: 'SMTP Username', key: 'SMTP_USER_NAME', secret: true
= render 'config_row', name: 'SMTP Password', key: 'SMTP_PASSWORD', secret: true
- else
%p
%span.badge.badge-success SendGrid
%span.badge.badge-secondary SMTP
%br
%small
%i To switch to SMTP, set the <code>SMTP_ADDRESS</code> environment variable
= render 'config_row', name: 'SendGrid API Key', key: 'SENDGRID_API_KEY', secret: true