diff --git a/src/FilterLists.Web.V2/src/modules/allListsTable/AllListsTable.tsx b/src/FilterLists.Web.V2/src/modules/allListsTable/AllListsTable.tsx index db141a530..10c704a47 100644 --- a/src/FilterLists.Web.V2/src/modules/allListsTable/AllListsTable.tsx +++ b/src/FilterLists.Web.V2/src/modules/allListsTable/AllListsTable.tsx @@ -42,7 +42,7 @@ export class AllListsTable extends React.Component<{}, State> { dataIndex={nameof("viewUrl")} width={100} fixed="right" - render={(text: string, record: List, index: number) => } + render={(text: string, record: List, index: number) => } /> ); diff --git a/src/FilterLists.Web.V2/src/shared/SubscribeButton.tsx b/src/FilterLists.Web.V2/src/shared/SubscribeButton.tsx index e55a65ba5..f95f19546 100644 --- a/src/FilterLists.Web.V2/src/shared/SubscribeButton.tsx +++ b/src/FilterLists.Web.V2/src/shared/SubscribeButton.tsx @@ -1,50 +1,69 @@ -import { Button } from 'antd'; +import { Button, Dropdown, Icon, Menu } from 'antd'; import { ButtonProps, ButtonType } from "antd/lib/button"; import * as React from "react"; interface Props { name: string; viewUrl: string; + viewUrlMirrors: string[]; }; -export const SubscribeButton = (props: Props): JSX.Element | null => props.viewUrl - ? - : null; +export const SubscribeButton = (props: Props): JSX.Element | null => + (props.viewUrlMirrors && props.viewUrlMirrors.length > 0) + ? + : props.viewUrl + ? + : null; -const buildButtonProps = (props: Props): ButtonProps => { +const SubscribeButtonDropdown = (props: Props): JSX.Element => + + {props.viewUrlMirrors.map( + (viewUrlMirror: string, i: number) => + + + )} + + }> + + ; + +const buildButtonProps = (name: string, viewUrl: string): ButtonProps => { let type: ButtonType = "primary"; - const hrefLocation = `${encodeURIComponent(props.viewUrl)}`; - const hrefTitle = `${encodeURIComponent(props.name)}`; + const hrefLocation = `${encodeURIComponent(viewUrl)}`; + const hrefTitle = `${encodeURIComponent(name)}`; let href = `abp:subscribe?location=${hrefLocation}&title=${hrefTitle}`; - const defaultTitle = (prefix?: string) => `${prefix || ""}Subscribe to ${props.name} with a browser extension supporting the "abp:" protocol (e.g. uBlock Origin, Adblock Plus).`; + const defaultTitle = (prefix?: string) => `${prefix || ""}Subscribe to ${name} with a browser extension supporting the "abp:" protocol (e.g. uBlock Origin, Adblock Plus).`; let title: string; switch (true) { // HTTP protocols - case props.viewUrl.includes(".onion/"): + case viewUrl.includes(".onion/"): type = "dashed"; title = defaultTitle("Tor address - "); break; - case props.viewUrl.includes("http://"): + case viewUrl.includes("http://"): type = "danger"; title = defaultTitle("Not Secure - "); break; // Software protocols - case props.viewUrl.includes(".tpl"): + case viewUrl.includes(".tpl"): href = `javascript:window.external.msAddTrackingProtectionList('${hrefLocation}', '${hrefTitle}')`; - title = `Subscribe to ${props.name} with Internet Explorer's Tracking Protection List feature.`; + title = `Subscribe to ${name} with Internet Explorer's Tracking Protection List feature.`; break; - case props.viewUrl.includes(".lsrules"): + case viewUrl.includes(".lsrules"): href = `x-littlesnitch:subscribe-rules?url=${hrefLocation}`; - title = `Subscribe to ${props.name} with Little Snitch's rule group subscription feature.`; + title = `Subscribe to ${name} with Little Snitch's rule group subscription feature.`; break; - case props.viewUrl.includes("?hostformat=littlesnitch"): + case viewUrl.includes("?hostformat=littlesnitch"): href = `x-littlesnitch:subscribe-rules?url=${hrefLocation}`; - title = `Subscribe to ${props.name} with Little Snitch's rule group subscription feature.`; + title = `Subscribe to ${name} with Little Snitch's rule group subscription feature.`; break; default: title = defaultTitle();