handle external pinned links

This commit is contained in:
Sean Yesmunt 2020-09-23 11:00:10 -04:00
parent 98e1dd880d
commit 14113f3c35
2 changed files with 30 additions and 22 deletions

View file

@ -94,7 +94,11 @@ const Button = forwardRef<any, {}>((props: Props, ref: any) => {
<span className="button__content">
{icon && <Icon icon={icon} iconColor={iconColor} size={iconSize} />}
{!largestLabel && label && <span dir="auto" className="button__label">{label}</span>}
{!largestLabel && label && (
<span dir="auto" className="button__label">
{label}
</span>
)}
{/* largestLabel is used when a single button has two different labels based on hover state */}
{largestLabel && (
@ -129,10 +133,16 @@ const Button = forwardRef<any, {}>((props: Props, ref: any) => {
</span>
);
// TODO: replace the below with an outbound link tracker for matomo
if (href) {
if (href || (navigate && navigate.startsWith('http'))) {
// TODO: replace the below with an outbound link tracker for matomo
return (
<a target="_blank" rel="noopener noreferrer" href={href} className={combinedClassName} onClick={onClick}>
<a
target="_blank"
rel="noopener noreferrer"
href={href || navigate}
className={combinedClassName}
onClick={onClick}
>
{content}
</a>
);

View file

@ -84,26 +84,24 @@ function SideNavigation(props: Props) {
icon: ICONS.PURCHASED,
hideForUnauth: true,
},
{
...(PINNED_URI_1 && PINNED_LABEL_1
? {
label: PINNED_LABEL_1,
navigate: PINNED_URI_1,
icon: ICONS.PINNED,
}
: {}),
},
{
...(PINNED_URI_2 && PINNED_LABEL_2
? {
label: PINNED_LABEL_2,
navigate: PINNED_URI_2,
icon: ICONS.PINNED,
}
: {}),
},
];
if (PINNED_URI_1 && PINNED_LABEL_1) {
TOP_LEVEL_LINKS.push({
label: PINNED_LABEL_1,
navigate: PINNED_URI_1,
icon: ICONS.PINNED,
});
}
if (PINNED_URI_2 && PINNED_LABEL_2) {
TOP_LEVEL_LINKS.push({
label: PINNED_LABEL_2,
navigate: PINNED_URI_2,
icon: ICONS.PINNED,
});
}
const ABSOLUTE_LINKS: Array<{
label: string,
navigate?: string,