fix: Version tag should open new tab, related type improvements
closes #3737
This commit is contained in:
@@ -37,7 +37,7 @@ function Breadcrumb({
|
|||||||
return (
|
return (
|
||||||
<Flex justify="flex-start" align="center">
|
<Flex justify="flex-start" align="center">
|
||||||
{topLevelItems.map((item, index) => (
|
{topLevelItems.map((item, index) => (
|
||||||
<React.Fragment key={item.to || index}>
|
<React.Fragment key={String(item.to) || index}>
|
||||||
{item.icon}
|
{item.icon}
|
||||||
{item.to ? (
|
{item.to ? (
|
||||||
<Item
|
<Item
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { LocationDescriptor } from "history";
|
||||||
import { ExpandedIcon } from "outline-icons";
|
import { ExpandedIcon } from "outline-icons";
|
||||||
import { darken, lighten } from "polished";
|
import { darken, lighten } from "polished";
|
||||||
import * as React from "react";
|
import * as React from "react";
|
||||||
@@ -155,7 +156,7 @@ export type Props<T> = {
|
|||||||
primary?: boolean;
|
primary?: boolean;
|
||||||
fullwidth?: boolean;
|
fullwidth?: boolean;
|
||||||
as?: T;
|
as?: T;
|
||||||
to?: string;
|
to?: LocationDescriptor;
|
||||||
borderOnHover?: boolean;
|
borderOnHover?: boolean;
|
||||||
href?: string;
|
href?: string;
|
||||||
"data-on"?: string;
|
"data-on"?: string;
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { LocationDescriptor } from "history";
|
||||||
import { CheckmarkIcon } from "outline-icons";
|
import { CheckmarkIcon } from "outline-icons";
|
||||||
import * as React from "react";
|
import * as React from "react";
|
||||||
import { MenuItem as BaseMenuItem } from "reakit/Menu";
|
import { MenuItem as BaseMenuItem } from "reakit/Menu";
|
||||||
@@ -10,7 +11,7 @@ type Props = {
|
|||||||
selected?: boolean;
|
selected?: boolean;
|
||||||
disabled?: boolean;
|
disabled?: boolean;
|
||||||
dangerous?: boolean;
|
dangerous?: boolean;
|
||||||
to?: string;
|
to?: LocationDescriptor;
|
||||||
href?: string;
|
href?: string;
|
||||||
target?: "_blank";
|
target?: "_blank";
|
||||||
as?: string | React.ComponentType<any>;
|
as?: string | React.ComponentType<any>;
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { LocationDescriptor } from "history";
|
||||||
import { observer } from "mobx-react";
|
import { observer } from "mobx-react";
|
||||||
import * as React from "react";
|
import * as React from "react";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
@@ -35,7 +36,7 @@ type Props = {
|
|||||||
showLastViewed?: boolean;
|
showLastViewed?: boolean;
|
||||||
showParentDocuments?: boolean;
|
showParentDocuments?: boolean;
|
||||||
document: Document;
|
document: Document;
|
||||||
to?: string;
|
to?: LocationDescriptor;
|
||||||
};
|
};
|
||||||
|
|
||||||
const DocumentMeta: React.FC<Props> = ({
|
const DocumentMeta: React.FC<Props> = ({
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { LocationDescriptor } from "history";
|
||||||
import { observer, useObserver } from "mobx-react";
|
import { observer, useObserver } from "mobx-react";
|
||||||
import * as React from "react";
|
import * as React from "react";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
@@ -12,7 +13,7 @@ import useStores from "~/hooks/useStores";
|
|||||||
type Props = {
|
type Props = {
|
||||||
document: Document;
|
document: Document;
|
||||||
isDraft: boolean;
|
isDraft: boolean;
|
||||||
to?: string;
|
to?: LocationDescriptor;
|
||||||
rtl?: boolean;
|
rtl?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -69,7 +69,11 @@ const ListItem = (
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const Wrapper = styled.a<{ $small?: boolean; $border?: boolean; to?: string }>`
|
const Wrapper = styled.a<{
|
||||||
|
$small?: boolean;
|
||||||
|
$border?: boolean;
|
||||||
|
to?: string;
|
||||||
|
}>`
|
||||||
display: flex;
|
display: flex;
|
||||||
padding: ${(props) => (props.$border === false ? 0 : "8px 0")};
|
padding: ${(props) => (props.$border === false ? 0 : "8px 0")};
|
||||||
margin: ${(props) =>
|
margin: ${(props) =>
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
// This file is pulled almost 100% from react-router with the addition of one
|
// This file is pulled almost 100% from react-router with the addition of one
|
||||||
// thing, automatic scroll to the active link. It's worth the copy paste because
|
// thing, automatic scroll to the active link. It's worth the copy paste because
|
||||||
// it avoids recalculating the link match again.
|
// it avoids recalculating the link match again.
|
||||||
import { Location, createLocation } from "history";
|
import { Location, createLocation, LocationDescriptor } from "history";
|
||||||
import * as React from "react";
|
import * as React from "react";
|
||||||
import {
|
import {
|
||||||
__RouterContext as RouterContext,
|
__RouterContext as RouterContext,
|
||||||
@@ -13,12 +13,12 @@ import { Link } from "react-router-dom";
|
|||||||
import scrollIntoView from "smooth-scroll-into-view-if-needed";
|
import scrollIntoView from "smooth-scroll-into-view-if-needed";
|
||||||
|
|
||||||
const resolveToLocation = (
|
const resolveToLocation = (
|
||||||
to: string | Record<string, any>,
|
to: LocationDescriptor | ((location: Location) => LocationDescriptor),
|
||||||
currentLocation: Location
|
currentLocation: Location
|
||||||
) => (typeof to === "function" ? to(currentLocation) : to);
|
) => (typeof to === "function" ? to(currentLocation) : to);
|
||||||
|
|
||||||
const normalizeToLocation = (
|
const normalizeToLocation = (
|
||||||
to: string | Record<string, any>,
|
to: LocationDescriptor,
|
||||||
currentLocation: Location
|
currentLocation: Location
|
||||||
) => {
|
) => {
|
||||||
return typeof to === "string"
|
return typeof to === "string"
|
||||||
@@ -30,17 +30,15 @@ const joinClassnames = (...classnames: (string | undefined)[]) => {
|
|||||||
return classnames.filter((i) => i).join(" ");
|
return classnames.filter((i) => i).join(" ");
|
||||||
};
|
};
|
||||||
|
|
||||||
export type Props = React.HTMLAttributes<HTMLAnchorElement> & {
|
export type Props = React.AnchorHTMLAttributes<HTMLAnchorElement> & {
|
||||||
activeClassName?: string;
|
activeClassName?: string;
|
||||||
activeStyle?: React.CSSProperties;
|
activeStyle?: React.CSSProperties;
|
||||||
className?: string;
|
|
||||||
scrollIntoViewIfNeeded?: boolean;
|
scrollIntoViewIfNeeded?: boolean;
|
||||||
exact?: boolean;
|
exact?: boolean;
|
||||||
isActive?: (match: match | null, location: Location) => boolean;
|
isActive?: (match: match | null, location: Location) => boolean;
|
||||||
location?: Location;
|
location?: Location;
|
||||||
strict?: boolean;
|
strict?: boolean;
|
||||||
style?: React.CSSProperties;
|
to: LocationDescriptor;
|
||||||
to: string | Record<string, any>;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { LocationDescriptor } from "history";
|
||||||
import * as React from "react";
|
import * as React from "react";
|
||||||
import styled, { useTheme, css } from "styled-components";
|
import styled, { useTheme, css } from "styled-components";
|
||||||
import breakpoint from "styled-components-breakpoint";
|
import breakpoint from "styled-components-breakpoint";
|
||||||
@@ -14,8 +15,7 @@ export type DragObject = NavigationNode & {
|
|||||||
};
|
};
|
||||||
|
|
||||||
type Props = Omit<NavLinkProps, "to"> & {
|
type Props = Omit<NavLinkProps, "to"> & {
|
||||||
to?: string | Record<string, any>;
|
to?: LocationDescriptor;
|
||||||
href?: string | Record<string, any>;
|
|
||||||
innerRef?: (ref: HTMLElement | null | undefined) => void;
|
innerRef?: (ref: HTMLElement | null | undefined) => void;
|
||||||
onClick?: React.MouseEventHandler<HTMLAnchorElement>;
|
onClick?: React.MouseEventHandler<HTMLAnchorElement>;
|
||||||
onMouseEnter?: React.MouseEventHandler<HTMLAnchorElement>;
|
onMouseEnter?: React.MouseEventHandler<HTMLAnchorElement>;
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ export default function Version() {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<SidebarLink
|
<SidebarLink
|
||||||
|
target="_blank"
|
||||||
href="https://github.com/outline/outline/releases"
|
href="https://github.com/outline/outline/releases"
|
||||||
label={
|
label={
|
||||||
<>
|
<>
|
||||||
|
|||||||
@@ -1,17 +1,14 @@
|
|||||||
import { m } from "framer-motion";
|
import { m } from "framer-motion";
|
||||||
import * as React from "react";
|
import * as React from "react";
|
||||||
import styled, { useTheme } from "styled-components";
|
import styled, { useTheme } from "styled-components";
|
||||||
import NavLinkWithChildrenFunc from "~/components/NavLink";
|
import NavLink from "~/components/NavLink";
|
||||||
|
|
||||||
type Props = Omit<
|
type Props = Omit<React.ComponentProps<typeof NavLink>, "children"> & {
|
||||||
React.ComponentProps<typeof NavLinkWithChildrenFunc>,
|
|
||||||
"children"
|
|
||||||
> & {
|
|
||||||
to: string;
|
to: string;
|
||||||
exact?: boolean;
|
exact?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
const TabLink = styled(NavLinkWithChildrenFunc)`
|
const TabLink = styled(NavLink)`
|
||||||
position: relative;
|
position: relative;
|
||||||
display: inline-flex;
|
display: inline-flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { Location } from "history";
|
import { Location, LocationDescriptor } from "history";
|
||||||
import { TFunction } from "react-i18next";
|
import { TFunction } from "react-i18next";
|
||||||
import RootStore from "~/stores/RootStore";
|
import RootStore from "~/stores/RootStore";
|
||||||
import Document from "~/models/Document";
|
import Document from "~/models/Document";
|
||||||
@@ -40,7 +40,7 @@ export type MenuHeading = {
|
|||||||
export type MenuInternalLink = {
|
export type MenuInternalLink = {
|
||||||
type: "route";
|
type: "route";
|
||||||
title: React.ReactNode;
|
title: React.ReactNode;
|
||||||
to: string;
|
to: LocationDescriptor;
|
||||||
visible?: boolean;
|
visible?: boolean;
|
||||||
selected?: boolean;
|
selected?: boolean;
|
||||||
disabled?: boolean;
|
disabled?: boolean;
|
||||||
|
|||||||
Reference in New Issue
Block a user