FEATURE: PWA compatibility checks in the Dashboard (#6850)

This commit is contained in:
Rafael dos Santos Silva 2019-01-08 22:46:11 -02:00 committed by Guo Xiang Tan
parent 09cbd08c64
commit f73fe36772
6 changed files with 60 additions and 2 deletions

View File

@ -98,8 +98,8 @@ class AdminDashboardData
add_problem_check :rails_env_check, :host_names_check, :force_https_check,
:ram_check, :google_oauth2_config_check,
:facebook_config_check, :twitter_config_check,
:github_config_check, :s3_config_check, :image_magick_check,
:failing_emails_check,
:github_config_check, :pwa_config_check, :s3_config_check,
:image_magick_check, :failing_emails_check,
:subfolder_ends_in_slash_check,
:pop3_polling_configuration, :email_polling_errored_recently,
:out_of_date_themes, :unreachable_themes
@ -211,6 +211,15 @@ class AdminDashboardData
end
end
def pwa_config_check
unless SiteSetting.large_icon.present? && SiteSetting.large_icon.width == 512 && SiteSetting.large_icon.height == 512
return I18n.t('dashboard.pwa_config_icon_warning', base_path: Discourse.base_path)
end
unless SiteSetting.short_title.present? && SiteSetting.short_title.size <= 12
return I18n.t('dashboard.pwa_config_title_warning', base_path: Discourse.base_path)
end
end
def s3_config_check
# if set via global setting it is validated during the `use_s3?` call
if !GlobalSetting.use_s3?

View File

@ -1193,6 +1193,8 @@ en:
facebook_config_warning: 'The server is configured to allow signup and log in with Facebook (enable_facebook_logins), but the app id and app secret values are not set. Go to <a href="%{base_path}/admin/site_settings">the Site Settings</a> and update the settings. <a href="https://meta.discourse.org/t/configuring-facebook-login-for-discourse/13394" target="_blank">See this guide to learn more</a>.'
twitter_config_warning: 'The server is configured to allow signup and log in with Twitter (enable_twitter_logins), but the key and secret values are not set. Go to <a href="%{base_path}/admin/site_settings">the Site Settings</a> and update the settings. <a href="https://meta.discourse.org/t/configuring-twitter-login-for-discourse/13395" target="_blank">See this guide to learn more</a>.'
github_config_warning: 'The server is configured to allow signup and log in with GitHub (enable_github_logins), but the client id and secret values are not set. Go to <a href="%{base_path}/admin/site_settings">the Site Settings</a> and update the settings. <a href="https://meta.discourse.org/t/configuring-github-login-for-discourse/13745" target="_blank">See this guide to learn more</a>.'
pwa_config_icon_warning: 'The server is missing a proper large icon which allows users to add a homescreen shortcut to this site on Android devices. Go to <a href="%{base_path}/admin/site_settings/category/all_results?filter=large_icon">the Site Settings</a> and upload an icon of the recommended size.'
pwa_config_title_warning: 'The server is missing a short title which allows users to add a homescreen shortcut to this site on Android devices. Go to <a href="%{base_path}/admin/site_settings/category/all_results?filter=short_title">the Site Settings</a> and configure a title of the recommended length.'
s3_config_warning: 'The server is configured to upload files to S3, but at least one the following setting is not set: s3_access_key_id, s3_secret_access_key, s3_use_iam_profile, or s3_upload_bucket. Go to <a href="%{base_path}/admin/site_settings">the Site Settings</a> and update the settings. <a href="https://meta.discourse.org/t/how-to-set-up-image-uploads-to-s3/7229" target="_blank">See "How to set up image uploads to S3?" to learn more</a>.'
s3_backup_config_warning: 'The server is configured to upload backups to S3, but at least one the following setting is not set: s3_access_key_id, s3_secret_access_key, s3_use_iam_profile, or s3_backup_bucket. Go to <a href="%{base_path}/admin/site_settings">the Site Settings</a> and update the settings. <a href="https://meta.discourse.org/t/how-to-set-up-image-uploads-to-s3/7229" target="_blank">See "How to set up image uploads to S3?" to learn more</a>.'
image_magick_warning: 'The server is configured to create thumbnails of large images, but ImageMagick is not installed. Install ImageMagick using your favorite package manager or <a href="https://www.imagemagick.org/script/download.php" target="_blank">download the latest release</a>.'

View File

@ -285,6 +285,7 @@ basic:
default: ''
short_title:
default: ''
max: 12
vapid_public_key_bytes:
default: ''
client: true

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

View File

@ -192,6 +192,52 @@ describe AdminDashboardData do
end
end
describe 'pwa_config_check' do
subject { described_class.new.pwa_config_check }
it 'alerts for large_icon missing' do
SiteSetting.large_icon = nil
expect(subject).to eq(I18n.t('dashboard.pwa_config_icon_warning', base_path: Discourse.base_path))
end
it 'alerts for incompatible large_icon' do
upload = UploadCreator.new(
file_from_fixtures('large_icon_incorrect.png'),
'large_icon',
for_site_setting: true
).create_for(Discourse.system_user.id)
SiteSetting.large_icon = upload
expect(subject).to eq(I18n.t('dashboard.pwa_config_icon_warning', base_path: Discourse.base_path))
end
context 'when large_icon is correct' do
before do
upload = UploadCreator.new(
file_from_fixtures('large_icon_correct.png'),
'large_icon',
for_site_setting: true
).create_for(Discourse.system_user.id)
SiteSetting.large_icon = upload
end
it 'alerts for short_title missing' do
SiteSetting.short_title = nil
expect(subject).to eq(I18n.t('dashboard.pwa_config_title_warning', base_path: Discourse.base_path))
end
it 'returns nil when everything is ok' do
upload = UploadCreator.new(
file_from_fixtures('large_icon_correct.png'),
'large_icon',
for_site_setting: true
).create_for(Discourse.system_user.id)
SiteSetting.large_icon = upload
SiteSetting.short_title = 'title'
expect(subject).to be_nil
end
end
end
describe 's3_config_check' do
shared_examples 'problem detection for s3-dependent setting' do
subject { described_class.new.s3_config_check }