Page: Remove footer from new page layout (#63455)

* Page: Option to hide footer, enabled by default for PluginPage

* Remove footer from new page layout
This commit is contained in:
Torkel Ödegaard 2023-02-22 13:30:57 +01:00 committed by GitHub
parent 89b3663a23
commit f64b7fe8a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 30 additions and 16 deletions

View File

@ -35,15 +35,8 @@ export function TopNavBarMenu({ node: nodePlain }: TopNavBarMenuProps) {
}
>
{node.children?.map((item) => {
const showExternalLinkIcon = /^https?:\/\//.test(item.url || '');
return item.url ? (
<MenuItem
url={item.url}
label={item.text}
icon={showExternalLinkIcon ? 'external-link-alt' : undefined}
target={item.target}
key={item.id}
/>
<MenuItem url={item.url} label={item.text} icon={item.icon} target={item.target} key={item.id} />
) : (
<MenuItem icon={item.icon} onClick={item.onClick} label={item.text} key={item.id} />
);

View File

@ -48,7 +48,7 @@ export function getVersionMeta(version: string) {
};
}
export let getVersionLinks = (): FooterLink[] => {
export function getVersionLinks(): FooterLink[] {
const { buildInfo, licenseInfo } = config;
const links: FooterLink[] = [];
const stateInfo = licenseInfo.stateInfo ? ` (${licenseInfo.stateInfo})` : '';
@ -84,16 +84,12 @@ export let getVersionLinks = (): FooterLink[] => {
}
return links;
};
}
export function setFooterLinksFn(fn: typeof getFooterLinks) {
getFooterLinks = fn;
}
export function setVersionLinkFn(fn: typeof getFooterLinks) {
getVersionLinks = fn;
}
export interface Props {
/** Link overrides to show specific links in the UI */
customLinks?: FooterLink[] | null;

View File

@ -54,6 +54,7 @@ export const enrichConfigItems = (items: NavModelItem[], location: Location<unkn
link.children = [
...menuItems,
...getFooterLinks(),
...getEditionAndUpdateLinks(),
{
id: 'keyboard-shortcuts',
text: t('nav.help/keyboard-shortcuts', 'Keyboard shortcuts'),
@ -170,3 +171,29 @@ export const isSearchActive = (location: Location<unknown>) => {
export function getNavModelItemKey(item: NavModelItem) {
return item.id ?? item.text;
}
export function getEditionAndUpdateLinks(): NavModelItem[] {
const { buildInfo, licenseInfo } = config;
const stateInfo = licenseInfo.stateInfo ? ` (${licenseInfo.stateInfo})` : '';
const links: NavModelItem[] = [];
links.push({
target: '_blank',
id: 'version',
text: `${buildInfo.edition}${stateInfo}`,
url: licenseInfo.licenseUrl,
icon: 'external-link-alt',
});
if (buildInfo.hasUpdate) {
links.push({
target: '_blank',
id: 'updateVersion',
text: `New version available!`,
icon: 'download-alt',
url: 'https://grafana.com/grafana/download?utm_source=grafana_footer',
});
}
return links;
}

View File

@ -6,7 +6,6 @@ import { GrafanaTheme2, PageLayoutType } from '@grafana/data';
import { CustomScrollbar, useStyles2 } from '@grafana/ui';
import { useGrafana } from 'app/core/context/GrafanaContext';
import { Footer } from '../Footer/Footer';
import { PageType } from '../Page/types';
import { usePageNav } from '../Page/usePageNav';
import { usePageTitle } from '../Page/usePageTitle';
@ -69,7 +68,6 @@ export const Page: PageType = ({
{pageNav && pageNav.children && <PageTabs navItem={pageNav} />}
<div className={styles.pageContent}>{children}</div>
</div>
<Footer />
</CustomScrollbar>
</div>
</div>