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"`
LoginBoxBackground *string `json:"loginBoxBackground,omitempty"`
LoadingLogo *string `json:"loadingLogo,omitempty"`
HideEdition *bool `json:"hideEdition,omitempty"`
PublicDashboardFooter *FrontendSettingsPublicDashboardFooterConfigDTO `json:"publicDashboardFooter,omitempty"` // PR TODO: type this properly
}

View File

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

View File

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

View File

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