Whitelabeling: Add a config option to hide the Grafana edition from the footer (#73412)

This commit is contained in:
Joao Silva 2023-08-18 15:09:36 +01:00 committed by GitHub
parent 1976ac0695
commit 3bb23d6be7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 17 additions and 10 deletions

View File

@ -111,6 +111,7 @@ type FrontendSettingsWhitelabelingDTO struct {
LoginSubtitle *string `json:"loginSubtitle,omitempty"` LoginSubtitle *string `json:"loginSubtitle,omitempty"`
LoginBoxBackground *string `json:"loginBoxBackground,omitempty"` LoginBoxBackground *string `json:"loginBoxBackground,omitempty"`
LoadingLogo *string `json:"loadingLogo,omitempty"` LoadingLogo *string `json:"loadingLogo,omitempty"`
HideEdition *bool `json:"hideEdition,omitempty"`
PublicDashboardFooter *FrontendSettingsPublicDashboardFooterConfigDTO `json:"publicDashboardFooter,omitempty"` // PR TODO: type this properly PublicDashboardFooter *FrontendSettingsPublicDashboardFooterConfigDTO `json:"publicDashboardFooter,omitempty"` // PR TODO: type this properly
} }

View File

@ -61,6 +61,7 @@ export class Branding {
static LoginBoxBackground = LoginBoxBackground; static LoginBoxBackground = LoginBoxBackground;
static AppTitle = 'Grafana'; static AppTitle = 'Grafana';
static LoginTitle = 'Welcome to Grafana'; static LoginTitle = 'Welcome to Grafana';
static HideEdition = false;
static GetLoginSubTitle = (): null | string => { static GetLoginSubTitle = (): null | string => {
return null; return null;
}; };

View File

@ -12,5 +12,6 @@ export interface BrandingSettings {
menuLogo?: string; menuLogo?: string;
favIcon?: string; favIcon?: string;
loadingLogo?: string; loadingLogo?: string;
hideEdition?: boolean;
appleTouchIcon?: string; appleTouchIcon?: string;
} }

View File

@ -48,17 +48,19 @@ export function getVersionMeta(version: string) {
}; };
} }
export function getVersionLinks(): FooterLink[] { export function getVersionLinks(hideEdition?: boolean): FooterLink[] {
const { buildInfo, licenseInfo } = config; const { buildInfo, licenseInfo } = config;
const links: FooterLink[] = []; const links: FooterLink[] = [];
const stateInfo = licenseInfo.stateInfo ? ` (${licenseInfo.stateInfo})` : ''; const stateInfo = licenseInfo.stateInfo ? ` (${licenseInfo.stateInfo})` : '';
links.push({ if (!hideEdition) {
target: '_blank', links.push({
id: 'license', target: '_blank',
text: `${buildInfo.edition}${stateInfo}`, id: 'license',
url: licenseInfo.licenseUrl, text: `${buildInfo.edition}${stateInfo}`,
}); url: licenseInfo.licenseUrl,
});
}
if (buildInfo.hideVersion) { if (buildInfo.hideVersion) {
return links; return links;
@ -93,10 +95,11 @@ export function setFooterLinksFn(fn: typeof getFooterLinks) {
export interface Props { export interface Props {
/** Link overrides to show specific links in the UI */ /** Link overrides to show specific links in the UI */
customLinks?: FooterLink[] | null; customLinks?: FooterLink[] | null;
hideEdition?: boolean;
} }
export const Footer = React.memo(({ customLinks }: Props) => { export const Footer = React.memo(({ customLinks, hideEdition }: Props) => {
const links = (customLinks || getFooterLinks()).concat(getVersionLinks()); const links = (customLinks || getFooterLinks()).concat(getVersionLinks(hideEdition));
return ( return (
<footer className="footer"> <footer className="footer">

View File

@ -29,6 +29,7 @@ export const LoginLayout = ({ children, branding, isChangingPassword }: React.Pr
const loginTitle = branding?.loginTitle ?? Branding.LoginTitle; const loginTitle = branding?.loginTitle ?? Branding.LoginTitle;
const loginBoxBackground = branding?.loginBoxBackground || Branding.LoginBoxBackground(); const loginBoxBackground = branding?.loginBoxBackground || Branding.LoginBoxBackground();
const loginLogo = branding?.loginLogo; const loginLogo = branding?.loginLogo;
const hideEdition = branding?.hideEdition ?? Branding.HideEdition;
useEffect(() => setStartAnim(true), []); useEffect(() => setStartAnim(true), []);
@ -54,7 +55,7 @@ export const LoginLayout = ({ children, branding, isChangingPassword }: React.Pr
<div className={loginStyles.loginOuterBox}>{children}</div> <div className={loginStyles.loginOuterBox}>{children}</div>
</div> </div>
</div> </div>
{branding?.hideFooter ? <></> : <Footer customLinks={branding?.footerLinks} />} {branding?.hideFooter ? <></> : <Footer hideEdition={hideEdition} customLinks={branding?.footerLinks} />}
</Branding.LoginBackground> </Branding.LoginBackground>
); );
}; };