power favicon via env var (#5810)

This commit is contained in:
Gabe Lyons 2022-09-01 17:06:30 -07:00 committed by GitHub
parent 4956f5a165
commit d75b2e8c9f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 20 additions and 0 deletions

View File

@ -115,6 +115,7 @@ public class AppConfigResolver implements DataFetcher<CompletableFuture<AppConfi
final VisualConfig visualConfig = new VisualConfig();
if (_visualConfiguration != null && _visualConfiguration.getAssets() != null) {
visualConfig.setLogoUrl(_visualConfiguration.getAssets().getLogoUrl());
visualConfig.setFaviconUrl(_visualConfiguration.getAssets().getFaviconUrl());
}
appConfig.setVisualConfig(visualConfig);

View File

@ -167,6 +167,11 @@ type VisualConfig {
Custom logo url for the homepage & top banner
"""
logoUrl: String
"""
Custom favicon url for the homepage & top banner
"""
faviconUrl: String
}
"""

View File

@ -5,6 +5,16 @@ import { checkAuthStatus } from './app/auth/checkAuthStatus';
import { AppConfigContext, DEFAULT_APP_CONFIG } from './appConfigContext';
import { useAppConfigQuery } from './graphql/app.generated';
function changeFavicon(src) {
let link = document.querySelector("link[rel~='icon']") as any;
if (!link) {
link = document.createElement('link');
link.rel = 'icon';
document.getElementsByTagName('head')[0].appendChild(link);
}
link.href = src;
}
const AppConfigProvider = ({ children }: { children: React.ReactNode }) => {
const { data: appConfigData, refetch } = useAppConfigQuery();
@ -20,6 +30,7 @@ const AppConfigProvider = ({ children }: { children: React.ReactNode }) => {
} else {
localStorage.setItem(THIRD_PARTY_LOGGING_KEY, 'false');
}
changeFavicon(appConfigData.appConfig.visualConfig.faviconUrl);
}
}, [appConfigData]);

View File

@ -36,6 +36,7 @@ query appConfig {
}
visualConfig {
logoUrl
faviconUrl
}
telemetryConfig {
enableThirdPartyLogging

View File

@ -9,4 +9,5 @@ public class AssetsConfiguration {
* The url of the logo to render in the DataHub Application.
*/
public String logoUrl;
public String faviconUrl;
}

View File

@ -92,6 +92,7 @@ platformAnalytics:
visualConfig:
assets:
logoUrl: ${REACT_APP_LOGO_URL:/assets/platforms/datahublogo.png}
faviconUrl: ${REACT_APP_FAVICON_URL:/assets/favicon.ico}
# Storage Layer