Skip to content

Commit

Permalink
power favicon via env var
Browse files Browse the repository at this point in the history
  • Loading branch information
gabe-lyons committed Sep 1, 2022
1 parent 9afda47 commit 788de40
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ public CompletableFuture<AppConfig> get(final DataFetchingEnvironment environmen
final VisualConfig visualConfig = new VisualConfig();
if (_visualConfiguration != null && _visualConfiguration.getAssets() != null) {
visualConfig.setLogoUrl(_visualConfiguration.getAssets().getLogoUrl());
visualConfig.setFaviconUrl(_visualConfiguration.getAssets().getFaviconUrl());
}
appConfig.setVisualConfig(visualConfig);

Expand Down
5 changes: 5 additions & 0 deletions datahub-graphql-core/src/main/resources/app.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

"""
Expand Down
11 changes: 11 additions & 0 deletions datahub-web-react/src/AppConfigProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand All @@ -20,6 +30,7 @@ const AppConfigProvider = ({ children }: { children: React.ReactNode }) => {
} else {
localStorage.setItem(THIRD_PARTY_LOGGING_KEY, 'false');
}
changeFavicon(appConfigData.appConfig.visualConfig.faviconUrl);
}
}, [appConfigData]);

Expand Down
1 change: 1 addition & 0 deletions datahub-web-react/src/graphql/app.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ query appConfig {
}
visualConfig {
logoUrl
faviconUrl
}
telemetryConfig {
enableThirdPartyLogging
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ public class AssetsConfiguration {
* The url of the logo to render in the DataHub Application.
*/
public String logoUrl;
public String faviconUrl;
}
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 788de40

Please sign in to comment.