diff --git a/src/FilterLists.Web.V2/src/modules/allListsTable/AllListsTable.tsx b/src/FilterLists.Web.V2/src/modules/allListsTable/AllListsTable.tsx index 482fb214d..c896e435d 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: any, 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 f55794893..852a29c6e 100644 --- a/src/FilterLists.Web.V2/src/shared/SubscribeButton.tsx +++ b/src/FilterLists.Web.V2/src/shared/SubscribeButton.tsx @@ -1,56 +1,54 @@ import * as React from "react"; import { Button } from 'antd'; -import { ButtonType } from "antd/lib/button"; +import { ButtonType, ButtonProps } from "antd/lib/button"; interface Props { name: string; - url: string; + viewUrl: string; text?: string; }; -export const SubscribeButton = (props: Props) => { - let buttonType: ButtonType; +export const SubscribeButton = (props: Props) => props.viewUrl + ? + : null; + +function buildButtonProps(props: Props): ButtonProps { + let type: ButtonType; let titlePrefix: string; - if (props.url.indexOf(".onion/") > 0) { - buttonType = "ghost"; + if (props.viewUrl.indexOf(".onion/") > 0) { + type = "ghost"; titlePrefix = "Tor address - "; - } else if (props.url.indexOf("http://") === 0) { - buttonType = "danger"; + } + else if (props.viewUrl.indexOf("http://") === 0) { + type = "danger"; titlePrefix = "Not Secure - "; - } else { - buttonType = "primary"; + } + else { + type = "primary"; titlePrefix = ""; } const hrefTitle = `${encodeURIComponent(props.name)}`; - let href; - if (props.url.indexOf(".tpl") > 0) { - href = `javascript:window.external.msAddTrackingProtectionList('${encodeURIComponent(props.url)}', '${hrefTitle}')`; - } else if (props.url.indexOf(".lsrules") > 0) { - href = `x-littlesnitch:subscribe-rules?url=${encodeURIComponent(props.url)}`; - } else if (props.url.indexOf("?hostformat=littlesnitch") > 0) { - href = `x-littlesnitch:subscribe-rules?url=${encodeURIComponent(props.url)}`; - } else { - href = `abp:subscribe?location=${encodeURIComponent(props.url)}&title=${hrefTitle}`; - }; + let href: string; + let title: string; - let title; - if (props.url.indexOf(".tpl") > 0) { + if (props.viewUrl.indexOf(".tpl") > 0) { + href = `javascript:window.external.msAddTrackingProtectionList('${encodeURIComponent(props.viewUrl)}', '${hrefTitle}')`; title = `${titlePrefix}Subscribe to ${props.name} with Internet Explorer's Tracking Protection List feature.`; - } else if (props.url.indexOf(".lsrules") > 0) { + } + else if (props.viewUrl.indexOf(".lsrules") > 0) { + href = `x-littlesnitch:subscribe-rules?url=${encodeURIComponent(props.viewUrl)}`; title = `${titlePrefix}Subscribe to ${props.name} with Little Snitch's rule group subscription feature.`; - } else if (props.url.indexOf("?hostformat=littlesnitch") > 0) { + } + else if (props.viewUrl.indexOf("?hostformat=littlesnitch") > 0) { + href = `x-littlesnitch:subscribe-rules?url=${encodeURIComponent(props.viewUrl)}`; title = `${titlePrefix}Subscribe to ${props.name} with Little Snitch's rule group subscription feature.`; - } else { + } + else { + href = `abp:subscribe?location=${encodeURIComponent(props.viewUrl)}&title=${hrefTitle}`; title = `${titlePrefix}Subscribe to ${props.name} with a browser extension supporting the "abp:" protocol (e.g. uBlock Origin, Adblock Plus).`; - }; - - return props.url - ? - : null; -}; \ No newline at end of file + } + + return { type, href, title } as ButtonProps +}