disable TPL subscribe buttons since site doesn't support IE

This commit is contained in:
Collin M. Barrett 2019-08-24 13:00:18 -05:00
parent 5bcf367af6
commit ef9769741f

View file

@ -17,16 +17,22 @@ export const SubscribeButton = (props: Props): JSX.Element =>
(props.viewUrlMirrors && props.viewUrlMirrors.length)
? <ButtonDropdown {...props} />
: <div>
<Button className={styles.single} size="small" {...buildButtonProps(props.name, props.viewUrl)}>Subscribe</Button>
<Button disabled={buildButtonProps(props.name, props.viewUrl)[1]}
className={styles.single} size="small"
{...buildButtonProps(props.name, props.viewUrl)[0]}>
Subscribe
</Button>
</div>;
const ButtonDropdown = (props: Props): JSX.Element => {
var buttonProps = buildButtonProps(props.name, props.viewUrl);
return <Dropdown.Button size="small"
return <Dropdown.Button
disabled={buttonProps[1]}
size="small"
placement="bottomRight"
type={buttonProps.type as DropdownButtonType}
href={buttonProps.href}
title={buttonProps.title}
type={buttonProps[0].type as DropdownButtonType}
href={buttonProps[0].href}
title={buttonProps[0].title}
overlay={<DropdownOverlay viewUrlMirrors={props.viewUrlMirrors} name={props.name} />}>
Subscribe
</Dropdown.Button>;
@ -41,13 +47,18 @@ const DropdownOverlay = (props: DropdownOverlayProps) =>
<Menu>
{props.viewUrlMirrors.map((viewUrlMirror: string, i: number) =>
<Menu.Item className={styles.sub_li} key={i}>
<Button className={styles.sub_a} size="small" {...buildButtonProps(props.name, viewUrlMirror)}>{`Mirror ${i + 1}`}</Button>
<Button disabled={buildButtonProps(props.name, viewUrlMirror)[1]}
className={styles.sub_a} size="small"
{...buildButtonProps(props.name, viewUrlMirror)[0]}>
{`Mirror ${i + 1}`}
</Button>
</Menu.Item>
)}
</Menu>;
const buildButtonProps = (name: string, viewUrl: string): ButtonProps => {
const buildButtonProps = (name: string, viewUrl: string): [ButtonProps, boolean] => {
let type: ButtonType = "primary";
let disabled: boolean = false;
const hrefLocation = `${encodeURIComponent(viewUrl)}`;
const hrefTitle = `${encodeURIComponent(name)}`;
@ -68,8 +79,9 @@ const buildButtonProps = (name: string, viewUrl: string): ButtonProps => {
// Software protocols
if (viewUrl.includes(".tpl")) {
href = `javascript:window.external.msAddTrackingProtectionList('${hrefLocation}', '${hrefTitle}')`;
message = `Subscribe to ${name} with Internet Explorer's Tracking Protection List feature.`;
disabled = true; // IE not supported by FilterLists
// href = `javascript:window.external.msAddTrackingProtectionList('${hrefLocation}', '${hrefTitle}')`;
// message = `Subscribe to ${name} with Internet Explorer's Tracking Protection List feature.`;
}
if (viewUrl.includes(".lsrules") || viewUrl.includes("?hostformat=littlesnitch")) {
href = `x-littlesnitch:subscribe-rules?url=${hrefLocation}`;
@ -78,5 +90,5 @@ const buildButtonProps = (name: string, viewUrl: string): ButtonProps => {
const title = `${prefixes.length ? prefixes.join(" | ") + " | " : ""}${message}`;
return { type, href, title }
return [{ type, href, title }, disabled]
}