From 7ea5febcc0f4c43c8bab7bc013c8b6ab8ac1a7d9 Mon Sep 17 00:00:00 2001 From: Stuart Olivera Date: Mon, 20 May 2019 17:47:24 -0400 Subject: [PATCH 1/2] [improvement] Better listing display of environment var config --- .../manage/configs/_config_row.html.haml | 16 ++++++ app/views/manage/configs/index.html.haml | 49 +++++-------------- 2 files changed, 29 insertions(+), 36 deletions(-) create mode 100644 app/views/manage/configs/_config_row.html.haml diff --git a/app/views/manage/configs/_config_row.html.haml b/app/views/manage/configs/_config_row.html.haml new file mode 100644 index 000000000..c8a17b47f --- /dev/null +++ b/app/views/manage/configs/_config_row.html.haml @@ -0,0 +1,16 @@ +- secret ||= false # default value if prop not set +- value = ENV[key] + +%p + %b= name +   + %small + %code= key + %br + - if value.present? + - if secret + %span.badge.badge-success Set + - else + %pre= value + - else + %span.badge.badge-danger Not set diff --git a/app/views/manage/configs/index.html.haml b/app/views/manage/configs/index.html.haml index e73ea2955..f06ad71b9 100644 --- a/app/views/manage/configs/index.html.haml +++ b/app/views/manage/configs/index.html.haml @@ -16,9 +16,7 @@ %p.text-muted= t("simple_form.hints.hackathon_config.#{key}").html_safe - if @config[key] == '' %p.mb-0 - %em - %small - — Not set — + %span.badge.badge-secondary Not set - else %pre.mb-0= @config[key] @@ -29,40 +27,19 @@ %h6.card-subtitle.mb-2.text-muted Environment variables are configured on the production server. %hr - %p - %b AWS S3 Bucket for Resumes: - %pre= ENV['AWS_BUCKET'] || '[No value]' - %p - %b AWS S3 Region: - %pre= ENV['AWS_REGION'] || '[No value]' - %p - %b AWS S3 Access Key ID: - %pre= ENV['AWS_ACCESS_KEY_ID'] || '[No value]' - %p - %b AWS S3 Secret Access Key: - %em= ENV['AWS_SECRET_ACCESS_KEY'].present? ? 'Set' : 'Not set' + = 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 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 %hr - %p - %b Domain Name: - %pre= ENV['HM_DOMAIN_NAME'] || '[No value]' - %p - %b Domain Protocol: - %pre= ENV['HM_DOMAIN_PROTOCOL'] || 'https' + = render 'config_row', name: 'Domain Name', key: 'HM_DOMAIN_NAME' + = render 'config_row', name: 'Domain Protocol', key: 'HM_DOMAIN_PROTOCOL' %hr - %p - %b Sparkpost API Key: - %em= ENV['SPARKPOST_API_KEY'].present? ? 'Set' : 'Not set' - %p - %b Sparkpost Campaign ID: - %pre= ENV['SPARKPOST_CAMPAIGN_ID'] || '[No value]' + = render 'config_row', name: 'Sparkpost API Key', key: 'SPARKPOST_API_KEY', secret: true + = render 'config_row', name: 'Sparkpost Campaign ID', key: 'SPARKPOST_CAMPAIGN_ID' %hr - %p - %b My MLH Application ID - %pre= ENV['MLH_KEY'] || '[No value]' - %p - %b My MLH Secret - %em= ENV['MLH_KEY'].present? ? 'Set' : 'Not set' + = render 'config_row', name: 'My MLH Application ID', key: 'MLH_KEY' + = render 'config_row', name: 'My MLH Secret', key: 'MLH_SECRET', secret: true %hr - %p - %b Rollbar Access Token: - %em= ENV['ROLLBAR_ACCESS_TOKEN'].present? ? 'Set' : 'Not set' + = render 'config_row', name: 'Rollbar Access Token', key: 'ROLLBAR_ACCESS_TOKEN', secret: true From f8f98a10697ea41626f216f834c1eb84142b3dd0 Mon Sep 17 00:00:00 2001 From: Stuart Olivera Date: Mon, 20 May 2019 17:49:05 -0400 Subject: [PATCH 2/2] Support default fallback --- app/views/manage/configs/_config_row.html.haml | 3 ++- app/views/manage/configs/index.html.haml | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/views/manage/configs/_config_row.html.haml b/app/views/manage/configs/_config_row.html.haml index c8a17b47f..31edfc6e3 100644 --- a/app/views/manage/configs/_config_row.html.haml +++ b/app/views/manage/configs/_config_row.html.haml @@ -1,5 +1,6 @@ - secret ||= false # default value if prop not set -- value = ENV[key] +- default ||= nil # default value if prop not set +- value = ENV[key] || default %p %b= name diff --git a/app/views/manage/configs/index.html.haml b/app/views/manage/configs/index.html.haml index f06ad71b9..471443a1a 100644 --- a/app/views/manage/configs/index.html.haml +++ b/app/views/manage/configs/index.html.haml @@ -34,7 +34,7 @@ = render 'config_row', name: 'AWS S3 Secret Access Key', key: 'AWS_SECRET_ACCESS_KEY', secret: true %hr = render 'config_row', name: 'Domain Name', key: 'HM_DOMAIN_NAME' - = render 'config_row', name: 'Domain Protocol', key: 'HM_DOMAIN_PROTOCOL' + = render 'config_row', name: 'Domain Protocol', key: 'HM_DOMAIN_PROTOCOL', default: 'https' %hr = render 'config_row', name: 'Sparkpost API Key', key: 'SPARKPOST_API_KEY', secret: true = render 'config_row', name: 'Sparkpost Campaign ID', key: 'SPARKPOST_CAMPAIGN_ID'