mirror of
https://github.com/grafana/grafana.git
synced 2026-08-16 16:14:59 -05:00
Footer: Add release notes url to version label (#52909)
* Add release note url to footer's version label * Filter out pre-release versions in release notes link at the footer * correct links for beta/prerelease release notes * make all links target blank * Fix TeamPages test Co-authored-by: joshhunt <josh@trtr.co>
This commit is contained in:
@@ -8,7 +8,6 @@ export interface FooterLink {
|
|||||||
id?: string;
|
id?: string;
|
||||||
icon?: IconName;
|
icon?: IconName;
|
||||||
url?: string;
|
url?: string;
|
||||||
target?: string;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export let getFooterLinks = (): FooterLink[] => {
|
export let getFooterLinks = (): FooterLink[] => {
|
||||||
@@ -17,23 +16,30 @@ export let getFooterLinks = (): FooterLink[] => {
|
|||||||
text: 'Documentation',
|
text: 'Documentation',
|
||||||
icon: 'document-info',
|
icon: 'document-info',
|
||||||
url: 'https://grafana.com/docs/grafana/latest/?utm_source=grafana_footer',
|
url: 'https://grafana.com/docs/grafana/latest/?utm_source=grafana_footer',
|
||||||
target: '_blank',
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
text: 'Support',
|
text: 'Support',
|
||||||
icon: 'question-circle',
|
icon: 'question-circle',
|
||||||
url: 'https://grafana.com/products/enterprise/?utm_source=grafana_footer',
|
url: 'https://grafana.com/products/enterprise/?utm_source=grafana_footer',
|
||||||
target: '_blank',
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
text: 'Community',
|
text: 'Community',
|
||||||
icon: 'comments-alt',
|
icon: 'comments-alt',
|
||||||
url: 'https://community.grafana.com/?utm_source=grafana_footer',
|
url: 'https://community.grafana.com/?utm_source=grafana_footer',
|
||||||
target: '_blank',
|
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export function getVersionMeta(version: string) {
|
||||||
|
const containsHyphen = version.includes('-');
|
||||||
|
const isBeta = version.includes('-beta');
|
||||||
|
|
||||||
|
return {
|
||||||
|
hasReleaseNotes: !containsHyphen || isBeta,
|
||||||
|
isBeta,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
export let getVersionLinks = (): FooterLink[] => {
|
export let getVersionLinks = (): FooterLink[] => {
|
||||||
const { buildInfo, licenseInfo } = config;
|
const { buildInfo, licenseInfo } = config;
|
||||||
const links: FooterLink[] = [];
|
const links: FooterLink[] = [];
|
||||||
@@ -45,7 +51,16 @@ export let getVersionLinks = (): FooterLink[] => {
|
|||||||
return links;
|
return links;
|
||||||
}
|
}
|
||||||
|
|
||||||
links.push({ text: `v${buildInfo.version} (${buildInfo.commit})` });
|
const { hasReleaseNotes, isBeta } = getVersionMeta(buildInfo.version);
|
||||||
|
const versionSlug = buildInfo.version.replace(/\./g, '-'); // replace all periods with hyphens
|
||||||
|
const docsVersion = isBeta ? 'next' : 'latest';
|
||||||
|
|
||||||
|
links.push({
|
||||||
|
text: `v${buildInfo.version} (${buildInfo.commit})`,
|
||||||
|
url: hasReleaseNotes
|
||||||
|
? `https://grafana.com/docs/grafana/${docsVersion}/release-notes/release-notes-${versionSlug}/`
|
||||||
|
: undefined,
|
||||||
|
});
|
||||||
|
|
||||||
if (buildInfo.hasUpdate) {
|
if (buildInfo.hasUpdate) {
|
||||||
links.push({
|
links.push({
|
||||||
@@ -53,7 +68,6 @@ export let getVersionLinks = (): FooterLink[] => {
|
|||||||
text: `New version available!`,
|
text: `New version available!`,
|
||||||
icon: 'download-alt',
|
icon: 'download-alt',
|
||||||
url: 'https://grafana.com/grafana/download?utm_source=grafana_footer',
|
url: 'https://grafana.com/grafana/download?utm_source=grafana_footer',
|
||||||
target: '_blank',
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -77,9 +91,7 @@ export const Footer: FC = React.memo(() => {
|
|||||||
<ul>
|
<ul>
|
||||||
{links.map((link) => (
|
{links.map((link) => (
|
||||||
<li key={link.text}>
|
<li key={link.text}>
|
||||||
<a href={link.url} target={link.target} rel="noopener" id={link.id}>
|
<FooterItem item={link} />
|
||||||
{link.icon && <Icon name={link.icon} />} {link.text}
|
|
||||||
</a>
|
|
||||||
</li>
|
</li>
|
||||||
))}
|
))}
|
||||||
</ul>
|
</ul>
|
||||||
@@ -89,3 +101,19 @@ export const Footer: FC = React.memo(() => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
Footer.displayName = 'Footer';
|
Footer.displayName = 'Footer';
|
||||||
|
|
||||||
|
function FooterItem({ item }: { item: FooterLink }) {
|
||||||
|
const content = item.url ? (
|
||||||
|
<a href={item.url} target="_blank" rel="noopener noreferrer" id={item.id}>
|
||||||
|
{item.text}
|
||||||
|
</a>
|
||||||
|
) : (
|
||||||
|
item.text
|
||||||
|
);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
{item.icon && <Icon name={item.icon} />} {content}
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|||||||
@@ -40,6 +40,12 @@ jest.mock('@grafana/runtime', () => ({
|
|||||||
bootData: { navTree: [], user: {} },
|
bootData: { navTree: [], user: {} },
|
||||||
buildInfo: {
|
buildInfo: {
|
||||||
edition: 'Open Source',
|
edition: 'Open Source',
|
||||||
|
version: '7.5.0',
|
||||||
|
commit: 'abc123',
|
||||||
|
env: 'production',
|
||||||
|
latestVersion: '',
|
||||||
|
hasUpdate: false,
|
||||||
|
hideVersion: false,
|
||||||
},
|
},
|
||||||
appSubUrl: '',
|
appSubUrl: '',
|
||||||
},
|
},
|
||||||
@@ -93,7 +99,7 @@ const setup = (propOverrides?: object) => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
describe('Render', () => {
|
describe('TeamPages', () => {
|
||||||
it('should render member page if team not empty', async () => {
|
it('should render member page if team not empty', async () => {
|
||||||
setup({
|
setup({
|
||||||
team: getMockTeam(),
|
team: getMockTeam(),
|
||||||
@@ -123,26 +129,26 @@ describe('Render', () => {
|
|||||||
|
|
||||||
expect(await screen.findByText('Team group sync')).toBeInTheDocument();
|
expect(await screen.findByText('Team group sync')).toBeInTheDocument();
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
||||||
describe('when feature toggle editorsCanAdmin is turned on', () => {
|
describe('when feature toggle editorsCanAdmin is turned on', () => {
|
||||||
it('should render settings page if user is team admin', async () => {
|
it('should render settings page if user is team admin', async () => {
|
||||||
setup({
|
setup({
|
||||||
team: getMockTeam(),
|
team: getMockTeam(),
|
||||||
pageName: 'settings',
|
pageName: 'settings',
|
||||||
preferences: {
|
preferences: {
|
||||||
homeDashboardUID: 'home-dashboard',
|
homeDashboardUID: 'home-dashboard',
|
||||||
theme: 'Default',
|
theme: 'Default',
|
||||||
timezone: 'Default',
|
timezone: 'Default',
|
||||||
},
|
},
|
||||||
editorsCanAdmin: true,
|
editorsCanAdmin: true,
|
||||||
signedInUser: {
|
signedInUser: {
|
||||||
id: 1,
|
id: 1,
|
||||||
isGrafanaAdmin: false,
|
isGrafanaAdmin: false,
|
||||||
orgRole: OrgRole.Admin,
|
orgRole: OrgRole.Admin,
|
||||||
} as User,
|
} as User,
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(await screen.findByText('Team settings')).toBeInTheDocument();
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(await screen.findByText('Team settings')).toBeInTheDocument();
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
color: $footer-link-hover;
|
color: $footer-link-hover;
|
||||||
|
text-decoration: underline;
|
||||||
}
|
}
|
||||||
|
|
||||||
i {
|
i {
|
||||||
|
|||||||
Reference in New Issue
Block a user