fix(web): 🐛 show mirror subscribe links

ref #1958
This commit is contained in:
Collin M. Barrett 2020-09-20 14:47:29 -05:00
parent df9b9029f4
commit ab05d1d6e6
2 changed files with 11 additions and 14 deletions

View file

@ -5,25 +5,24 @@ import React from "react";
interface Props {
name: string;
viewUrl: string;
viewUrlMirrors: string[];
viewUrls: string[];
}
export const SubscribeButtons = (props: Props) =>
props.viewUrl ? (
props.viewUrls.length ? (
<>
<SubscribeButton
name={props.name}
viewUrl={props.viewUrl}
viewUrl={props.viewUrls[0]}
text="Subscribe"
/>
<MirrorButtons name={props.name} viewUrlMirrors={props.viewUrlMirrors} />
<MirrorButtons name={props.name} viewUrlMirrors={props.viewUrls.slice(1)} />
</>
) : null;
interface MirrorButtonsProps {
name: string;
viewUrlMirrors: string[];
viewUrlMirrors: string[] | undefined;
}
const MirrorButtons = (props: MirrorButtonsProps) => (

View file

@ -72,9 +72,8 @@ export const ListInfoDrawer = (props: RouteComponentProps & Props) => {
document.title = originalTitle;
};
}, [list, originalTitle, listName]);
const viewUrl = list?.viewUrls.find(
(u) => u.primariness === 1 && u.segmentNumber === 1
)?.url;
const viewUrlModels = list?.viewUrls.filter((u) => u.segmentNumber === 1);
const viewUrls = viewUrlModels == null ? [] : viewUrlModels.map(u => u.url);
return list ? (
<Drawer
visible={true}
@ -100,16 +99,15 @@ export const ListInfoDrawer = (props: RouteComponentProps & Props) => {
<Maintainers maintainers={listMaintainers} />
<Divider />
<ButtonGroup style={{ display: "inherit" }}>
{viewUrl && (
{viewUrls.length && (
<SubscribeButtons
name={list.name}
viewUrl={viewUrl}
viewUrlMirrors={[]}
viewUrls={viewUrls}
/>
)}
{viewUrl && (
{viewUrlModels && (
<LinkButton
url={viewUrl}
url={viewUrls[0]}
text="View"
title={`View ${list.name} in its raw format`}
icon={<SearchOutlined />}