From 2928b5256c18ca1adaf109217e188fe02e6c45e5 Mon Sep 17 00:00:00 2001 From: guerler Date: Fri, 23 Oct 2020 10:45:22 -0400 Subject: [PATCH 1/2] Allow admins to add custom logo to the masthead --- client/src/components/Masthead/Masthead.vue | 15 +++++++++++++-- client/src/layout/masthead.js | 1 + client/src/style/scss/base.scss | 1 + doc/source/admin/galaxy_options.rst | 20 ++++++++++++++++++++ lib/galaxy/config/sample/galaxy.yml.sample | 6 ++++++ lib/galaxy/managers/configuration.py | 4 ++-- lib/galaxy/webapps/galaxy/config_schema.yml | 13 +++++++++++++ 7 files changed, 56 insertions(+), 4 deletions(-) diff --git a/client/src/components/Masthead/Masthead.vue b/client/src/components/Masthead/Masthead.vue index 29aa39db4f2..eb92c3852e2 100644 --- a/client/src/components/Masthead/Masthead.vue +++ b/client/src/components/Masthead/Masthead.vue @@ -9,6 +9,7 @@ > logo + logo {{ brandTitle }} @@ -44,27 +45,39 @@ export default { }, brand: { type: String, + default: null, }, brandLink: { type: String, + default: null, }, brandImage: { type: String, + default: null, + }, + brandImageSecondary: { + type: String, + default: null, }, activeTab: { type: String, + default: null, }, mastheadState: { type: Object, + default: null, }, appRoot: { type: String, + default: null, }, galaxy: { type: Object, + default: null, }, menuOptions: { type: Object, + default: null, }, }, components: { @@ -141,5 +154,3 @@ export default { }, }; - - diff --git a/client/src/layout/masthead.js b/client/src/layout/masthead.js index 03d3168d77f..3128ef0c418 100644 --- a/client/src/layout/masthead.js +++ b/client/src/layout/masthead.js @@ -51,6 +51,7 @@ export function mountMasthead(el, options, mastheadState) { brand: options.brand, brandLink: options.logo_url, brandImage: options.logo_src, + brandImageSecondary: options.logo_src_secondary, appRoot: getAppRoot(), galaxy: getGalaxyInstance(), menuOptions: options, diff --git a/client/src/style/scss/base.scss b/client/src/style/scss/base.scss index 3f3e1a909a6..fcc8607b2a8 100644 --- a/client/src/style/scss/base.scss +++ b/client/src/style/scss/base.scss @@ -390,6 +390,7 @@ body { display: inline; margin-right: 0.3rem; border: none; + max-height: 2rem; } .navbar-brand-title { color: $brand-masthead-text; diff --git a/doc/source/admin/galaxy_options.rst b/doc/source/admin/galaxy_options.rst index 0288c19b124..17e761b54e8 100644 --- a/doc/source/admin/galaxy_options.rst +++ b/doc/source/admin/galaxy_options.rst @@ -1660,6 +1660,26 @@ :Type: str +~~~~~~~~~~~~ +``logo_src`` +~~~~~~~~~~~~ + +:Description: + The brand image source. +:Default: ``/static/favicon.png`` +:Type: str + + +~~~~~~~~~~~~~~~~~~~~~~ +``logo_src_secondary`` +~~~~~~~~~~~~~~~~~~~~~~ + +:Description: + The custom brand image source. +:Default: ``None`` +:Type: str + + ~~~~~~~~~~~~~~~~ ``helpsite_url`` ~~~~~~~~~~~~~~~~ diff --git a/lib/galaxy/config/sample/galaxy.yml.sample b/lib/galaxy/config/sample/galaxy.yml.sample index 23c441f1ec7..1636cca716f 100644 --- a/lib/galaxy/config/sample/galaxy.yml.sample +++ b/lib/galaxy/config/sample/galaxy.yml.sample @@ -874,6 +874,12 @@ galaxy: # The URL linked by the "Galaxy/brand" text. #logo_url: / + # The brand image source. + #logo_src: /static/favicon.png + + # The custom brand image source. + #logo_src_secondary: null + # The URL linked by the "Galaxy Help" link in the "Help" menu. #helpsite_url: null diff --git a/lib/galaxy/managers/configuration.py b/lib/galaxy/managers/configuration.py index b530b53c2f4..166f7bd9a2d 100644 --- a/lib/galaxy/managers/configuration.py +++ b/lib/galaxy/managers/configuration.py @@ -43,9 +43,9 @@ class ConfigSerializer(base.ModelSerializer): 'is_admin_user' : lambda *a, **c: False, 'brand' : _use_config, 'display_galaxy_brand' : _use_config, - # TODO: this doesn't seem right 'logo_url' : lambda config, key, **context: self.url_for(config.get(key, '/')), - 'logo_src' : lambda config, key, **context: self.url_for('/static/favicon.png'), + 'logo_src' : lambda config, key, **context: self.url_for(config.get(key, '/static/favicon.png')), + 'logo_src_secondary' : lambda config, key, **context: self.url_for(config.get(key)) if config.get(key) else None, 'terms_url' : _use_config, 'myexperiment_target_url' : _use_config, 'wiki_url' : _use_config, diff --git a/lib/galaxy/webapps/galaxy/config_schema.yml b/lib/galaxy/webapps/galaxy/config_schema.yml index 64d8b384ad5..1b1e211de69 100644 --- a/lib/galaxy/webapps/galaxy/config_schema.yml +++ b/lib/galaxy/webapps/galaxy/config_schema.yml @@ -1246,6 +1246,19 @@ mapping: desc: | The URL linked by the "Galaxy/brand" text. + logo_src: + type: str + default: /static/favicon.png + required: false + desc: | + The brand image source. + + logo_src_secondary: + type: str + required: false + desc: | + The custom brand image source. + helpsite_url: type: str required: false From 850a978b9b78963933c3a0aad9056b51196fd604 Mon Sep 17 00:00:00 2001 From: guerler Date: Sun, 25 Oct 2020 10:02:04 -0400 Subject: [PATCH 2/2] Parse secondary logo in legacy masthead mako --- templates/webapps/galaxy/galaxy.masthead.mako | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/templates/webapps/galaxy/galaxy.masthead.mako b/templates/webapps/galaxy/galaxy.masthead.mako index 33dd0d9ee7a..e0325eef3af 100644 --- a/templates/webapps/galaxy/galaxy.masthead.mako +++ b/templates/webapps/galaxy/galaxy.masthead.mako @@ -24,7 +24,8 @@ 'terms_url' : app.config.terms_url or '', 'allow_user_creation' : app.config.allow_user_creation, 'logo_url' : h.url_for(app.config.logo_url), - 'logo_src' : h.url_for( app.config.get( 'logo_src', '/static/favicon.png' ) ), + 'logo_src' : h.url_for(app.config.get('logo_src', '/static/favicon.png')), + 'logo_src_secondary' : h.url_for(app.config.get('logo_src_secondary')) if app.config.get('logo_src_secondary') else None, 'is_admin_user' : trans.user_is_admin, 'active_view' : active_view, 'ftp_upload_site' : app.config.ftp_upload_site,