A platform for community discussion. Free, open, simple.
FEATURE: PWA compatibility checks in the Dashboard (#6850)
Rafael dos Santos Silvaf73fe36772b3
diff --git a/app/models/admin_dashboard_data.rb b/app/models/admin_dashboard_data.rbindex 565a61f6207..5b4ed57766d 100644--- a/app/models/admin_dashboard_data.rb+++ b/app/models/admin_dashboard_data.rb@@ -98,8 +98,8 @@ class AdminDashboardDataadd_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 AdminDashboardDataendend+ 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?` callif !GlobalSetting.use_s3?diff --git a/config/locales/server.en.yml b/config/locales/server.en.ymlindex 743a573e480..7c7eb7674d8 100644--- a/config/locales/server.en.yml+++ b/config/locales/server.en.yml@@ -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>.'diff --git a/config/site_settings.yml b/config/site_settings.ymlindex afaa044a15b..546ba41581d 100644--- a/config/site_settings.yml+++ b/config/site_settings.yml@@ -285,6 +285,7 @@ basic:default: ''short_title:default: ''+ max: 12vapid_public_key_bytes:default: ''client: truediff --git a/spec/fixtures/images/large_icon_correct.png b/spec/fixtures/images/large_icon_correct.pngnew file mode 100644index 00000000000..e453d6fde50Binary files /dev/null and b/spec/fixtures/images/large_icon_correct.png differdiff --git a/spec/fixtures/images/large_icon_incorrect.png b/spec/fixtures/images/large_icon_incorrect.pngnew file mode 100644index 00000000000..e750b901960Binary files /dev/null and b/spec/fixtures/images/large_icon_incorrect.png differdiff --git a/spec/models/admin_dashboard_data_spec.rb b/spec/models/admin_dashboard_data_spec.rbindex 9ba85feb005..8df2a32f5ff 100644--- a/spec/models/admin_dashboard_data_spec.rb+++ b/spec/models/admin_dashboard_data_spec.rb@@ -192,6 +192,52 @@ describe AdminDashboardData doendend+ 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' doshared_examples 'problem detection for s3-dependent setting' dosubject { described_class.new.s3_config_check }