Skip to content

Commit

Permalink
feat: updated rel attribute (#139)
Browse files Browse the repository at this point in the history
  • Loading branch information
Fran McDade authored and Fran McDade committed Jul 19, 2024
1 parent 2959124 commit 36b7814
Show file tree
Hide file tree
Showing 11 changed files with 61 additions and 22 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import React, { ElementType } from "react";
import { ButtonPrimary } from "../../../../../common/Button/components/ButtonPrimary/buttonPrimary";
import { FluidPaper } from "../../../../../common/Paper/paper.styles";
import { ANCHOR_TARGET } from "../../../../../Links/common/entities";
import {
ANCHOR_TARGET,
REL_ATTRIBUTE,
} from "../../../../../Links/common/entities";
import {
Section,
SectionActions,
Expand All @@ -18,7 +21,11 @@ export const ExportToTerraReady = ({
exportURL,
}: ExportToTerraReadyProps): JSX.Element => {
const onOpenTerra = (): void => {
window.open(exportURL, ANCHOR_TARGET.BLANK, "noopener noreferrer");
window.open(
exportURL,
ANCHOR_TARGET.BLANK,
REL_ATTRIBUTE.NO_OPENER_NO_REFERRER
);
};
return (
<FluidPaper>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ import { useAuthentication } from "../../../../../../../../../../hooks/useAuthen
import { TerraResponse } from "../../../../../../../../../../hooks/useAuthentication/useFetchTerraProfile";
import { useConfig } from "../../../../../../../../../../hooks/useConfig";
import { ButtonPrimary } from "../../../../../../../../../common/Button/components/ButtonPrimary/buttonPrimary";
import { ANCHOR_TARGET } from "../../../../../../../../../Links/common/entities";
import {
ANCHOR_TARGET,
REL_ATTRIBUTE,
} from "../../../../../../../../../Links/common/entities";
import { FormStep } from "../../formStep";

export interface AcceptTerraTOSProps {
Expand All @@ -25,7 +28,11 @@ export const AcceptTerraTOS = ({

const onOpenTerra = (): void => {
if (exportToTerraUrl) {
window.open(exportToTerraUrl, ANCHOR_TARGET.BLANK, "noopener noreferrer");
window.open(
exportToTerraUrl,
ANCHOR_TARGET.BLANK,
REL_ATTRIBUTE.NO_OPENER_NO_REFERRER
);
}
};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import React, { ReactNode } from "react";
import { ButtonPrimary } from "../../../../../../../../../common/Button/components/ButtonPrimary/buttonPrimary";
import { ANCHOR_TARGET } from "../../../../../../../../../Links/common/entities";
import {
ANCHOR_TARGET,
REL_ATTRIBUTE,
} from "../../../../../../../../../Links/common/entities";
import { FormStep } from "../../formStep";

export interface ConnectTerraToNIHAccountProps {
Expand All @@ -18,7 +21,7 @@ export const ConnectTerraToNIHAccount = ({
window.open(
"https://support.terra.bio/hc/en-us/articles/360038086332-Linking-authorization-accessing-controlled-data-on-external-servers",
ANCHOR_TARGET.BLANK,
"noopener noreferrer"
REL_ATTRIBUTE.NO_OPENER_NO_REFERRER
);
};
return (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import React, { ReactNode } from "react";
import { useConfig } from "../../../../../../../../../../hooks/useConfig";
import { ButtonPrimary } from "../../../../../../../../../common/Button/components/ButtonPrimary/buttonPrimary";
import { ANCHOR_TARGET } from "../../../../../../../../../Links/common/entities";
import {
ANCHOR_TARGET,
REL_ATTRIBUTE,
} from "../../../../../../../../../Links/common/entities";
import { FormStep } from "../../formStep";

export interface CreateTerraAccountProps {
Expand All @@ -20,7 +23,11 @@ export const CreateTerraAccount = ({

const onOpenTerra = (): void => {
if (exportToTerraUrl) {
window.open(exportToTerraUrl, ANCHOR_TARGET.BLANK, "noopener noreferrer");
window.open(
exportToTerraUrl,
ANCHOR_TARGET.BLANK,
REL_ATTRIBUTE.NO_OPENER_NO_REFERRER
);
}
};

Expand Down
1 change: 1 addition & 0 deletions src/components/Links/common/entities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export enum ANCHOR_TARGET {
}

export enum REL_ATTRIBUTE {
NO_OPENER = "noopener",
NO_OPENER_NO_REFERRER = "noopener noreferrer",
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
} from "../../../../../../providers/exploreState";
import {
ANCHOR_TARGET,
REL_ATTRIBUTE,
UrlObjectWithHrefAndQuery,
} from "../../../../common/entities";
import { LinkProps } from "../../link";
Expand Down Expand Up @@ -51,7 +52,7 @@ export const ExploreViewLink = ({
className={className}
href={url.href}
onClick={onNavigate}
rel="noopener"
rel={REL_ATTRIBUTE.NO_OPENER}
target={target}
>
{label}
Expand Down
6 changes: 3 additions & 3 deletions src/components/Links/components/Link/link.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import React, { ReactNode } from "react";
import { isValidUrl } from "../../../../common/utils";
import { CopyToClipboard } from "../../../common/CopyToClipboard/copyToClipboard";
import { TypographyProps } from "../../../common/Typography/common/entities";
import { ANCHOR_TARGET, Url } from "../../common/entities";
import { ANCHOR_TARGET, REL_ATTRIBUTE, Url } from "../../common/entities";
import {
isClientSideNavigation,
isURLObjectWithHrefAndQuery,
Expand Down Expand Up @@ -57,7 +57,7 @@ export const Link = ({
<NLink href={url} legacyBehavior passHref>
<MLink
className={className}
rel="noopener"
rel={REL_ATTRIBUTE.NO_OPENER}
noWrap={noWrap}
target={target || ANCHOR_TARGET.SELF}
onClick={onClick}
Expand All @@ -79,7 +79,7 @@ export const Link = ({
href={url}
noWrap={noWrap}
onClick={onClick}
rel="noopener noreferrer"
rel={REL_ATTRIBUTE.NO_OPENER_NO_REFERRER}
target={target || ANCHOR_TARGET.BLANK}
{...TypographyProps}
>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import NLink from "next/link";
import React, { ElementType } from "react";
import { ANCHOR_TARGET } from "../../../../Links/common/entities";
import {
ANCHOR_TARGET,
REL_ATTRIBUTE,
} from "../../../../Links/common/entities";
import { isClientSideNavigation } from "../../../../Links/common/utils";
import { ButtonPrimary } from "../ButtonPrimary/buttonPrimary";

Expand Down Expand Up @@ -31,7 +34,7 @@ export const CallToActionButton = ({
className={className}
disabled={disabled}
href="passHref"
rel="noopener"
rel={REL_ATTRIBUTE.NO_OPENER}
target={target || ANCHOR_TARGET.SELF}
>
{label}
Expand All @@ -42,7 +45,7 @@ export const CallToActionButton = ({
className={className}
disabled={disabled}
href={url}
rel="noopener noreferrer"
rel={REL_ATTRIBUTE.NO_OPENER_NO_REFERRER}
target={target || ANCHOR_TARGET.BLANK}
>
{label}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import { SvgIconProps } from "@mui/material";
import Link from "next/link";
import React from "react";
import { ANCHOR_TARGET } from "../../../../Links/common/entities";
import {
ANCHOR_TARGET,
REL_ATTRIBUTE,
} from "../../../../Links/common/entities";
import { isClientSideNavigation } from "../../../../Links/common/utils";
import { HelpIcon } from "../../../CustomIcon/components/HelpIcon/helpIcon";
import { HelpIconButton as Button } from "./helpIconButton.styles";
Expand All @@ -22,7 +25,7 @@ export const HelpIconButton = ({
<Link href={url} legacyBehavior passHref>
<Button
href="passHref"
rel="noopener"
rel={REL_ATTRIBUTE.NO_OPENER}
target={target || ANCHOR_TARGET.SELF}
>
<HelpIcon fontSize={size} />
Expand All @@ -31,7 +34,7 @@ export const HelpIconButton = ({
) : (
<Button
href={url}
rel="noopener noreferrer"
rel={REL_ATTRIBUTE.NO_OPENER_NO_REFERRER}
target={target || ANCHOR_TARGET.BLANK}
>
<HelpIcon fontSize={size} />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import { CardActionArea as MCardActionArea } from "@mui/material";
import { useRouter } from "next/router";
import React, { ReactNode } from "react";
import { ANCHOR_TARGET } from "../../../../Links/common/entities";
import {
ANCHOR_TARGET,
REL_ATTRIBUTE,
} from "../../../../Links/common/entities";
import { isClientSideNavigation } from "../../../../Links/common/utils";

export interface CardActionAreaProps {
Expand All @@ -22,7 +25,11 @@ export const CardActionArea = ({
if (isClientSideNavigation(url)) {
push(url);
} else {
window.open(url, ANCHOR_TARGET.BLANK, "noopener noreferrer");
window.open(
url,
ANCHOR_TARGET.BLANK,
REL_ATTRIBUTE.NO_OPENER_NO_REFERRER
);
}
}
};
Expand Down
4 changes: 2 additions & 2 deletions src/components/common/Socials/socials.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import React, {
forwardRef,
ReactNode,
} from "react";
import { ANCHOR_TARGET } from "../../Links/common/entities";
import { ANCHOR_TARGET, REL_ATTRIBUTE } from "../../Links/common/entities";
import {
IconButton as StyledIconButton,
Socials as StyledSocials,
Expand Down Expand Up @@ -42,7 +42,7 @@ export const Socials = forwardRef<HTMLDivElement, SocialsProps>(
<IconButton
key={i}
href={url}
rel="noopener noreferrer"
rel={REL_ATTRIBUTE.NO_OPENER_NO_REFERRER}
size={buttonSize}
target={ANCHOR_TARGET.BLANK}
>
Expand Down

0 comments on commit 36b7814

Please sign in to comment.