Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
use ExternalLink components for external links (#10758)
Browse files Browse the repository at this point in the history
* use ExternalLink components for external links

* test

* strict
  • Loading branch information
Kerry authored May 3, 2023
1 parent 42e6c98 commit 37b7dfe
Show file tree
Hide file tree
Showing 13 changed files with 281 additions and 47 deletions.
5 changes: 3 additions & 2 deletions src/components/structures/RoomStatusBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import AccessibleButton from "../views/elements/AccessibleButton";
import InlineSpinner from "../views/elements/InlineSpinner";
import MatrixClientContext from "../../contexts/MatrixClientContext";
import { RoomStatusBarUnsentMessages } from "./RoomStatusBarUnsentMessages";
import ExternalLink from "../views/elements/ExternalLink";

const STATUS_BAR_HIDDEN = 0;
const STATUS_BAR_EXPANDED = 1;
Expand Down Expand Up @@ -213,9 +214,9 @@ export default class RoomStatusBar extends React.PureComponent<IProps, IState> {
{},
{
consentLink: (sub) => (
<a href={consentError!.data?.consent_uri} target="_blank" rel="noreferrer noopener">
<ExternalLink href={consentError!.data?.consent_uri} target="_blank" rel="noreferrer noopener">
{sub}
</a>
</ExternalLink>
),
},
);
Expand Down
5 changes: 3 additions & 2 deletions src/components/structures/SpaceRoomView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ import MainSplit from "./MainSplit";
import RightPanel from "./RightPanel";
import SpaceHierarchy, { showRoom } from "./SpaceHierarchy";
import { RoomPermalinkCreator } from "../../utils/permalinks/Permalinks";
import ExternalLink from "../views/elements/ExternalLink";

interface IProps {
space: Room;
Expand Down Expand Up @@ -593,9 +594,9 @@ const SpaceSetupPrivateInvite: React.FC<{
{
b: (sub) => <b>{sub}</b>,
link: () => (
<a href="https://app.element.io/" rel="noreferrer noopener" target="_blank">
<ExternalLink href="https://app.element.io/" rel="noreferrer noopener" target="_blank">
app.element.io
</a>
</ExternalLink>
),
},
)}
Expand Down
5 changes: 3 additions & 2 deletions src/components/views/dialogs/AnalyticsLearnMoreDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import DialogButtons from "../elements/DialogButtons";
import Modal, { ComponentProps } from "../../../Modal";
import SdkConfig from "../../../SdkConfig";
import { getPolicyUrl } from "../../../toasts/AnalyticsToast";
import ExternalLink from "../elements/ExternalLink";

export enum ButtonClicked {
Primary,
Expand Down Expand Up @@ -55,10 +56,10 @@ export const AnalyticsLearnMoreDialog: React.FC<IProps> = ({
{
PrivacyPolicyUrl: (sub) => {
return (
<a href={privacyPolicyUrl} rel="norefferer noopener" target="_blank">
<ExternalLink href={privacyPolicyUrl} rel="norefferer noopener" target="_blank">
{sub}
<span className="mx_AnalyticsPolicyLink" />
</a>
</ExternalLink>
);
},
},
Expand Down
13 changes: 9 additions & 4 deletions src/components/views/dialogs/FeedbackDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import InfoDialog from "./InfoDialog";
import { submitFeedback } from "../../../rageshake/submit-rageshake";
import { useStateToggle } from "../../../hooks/useStateToggle";
import StyledCheckbox from "../elements/StyledCheckbox";
import ExternalLink from "../elements/ExternalLink";

interface IProps {
feature?: string;
Expand Down Expand Up @@ -130,16 +131,20 @@ const FeedbackDialog: React.FC<IProps> = (props: IProps) => {
{
existingIssuesLink: (sub) => {
return (
<a target="_blank" rel="noreferrer noopener" href={existingIssuesUrl}>
<ExternalLink
target="_blank"
rel="noreferrer noopener"
href={existingIssuesUrl}
>
{sub}
</a>
</ExternalLink>
);
},
newIssueLink: (sub) => {
return (
<a target="_blank" rel="noreferrer noopener" href={newIssueUrl}>
<ExternalLink target="_blank" rel="noreferrer noopener" href={newIssueUrl}>
{sub}
</a>
</ExternalLink>
);
},
},
Expand Down
9 changes: 7 additions & 2 deletions src/components/views/dialogs/ServerPickerDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import StyledRadioButton from "../elements/StyledRadioButton";
import TextWithTooltip from "../elements/TextWithTooltip";
import withValidation, { IFieldState, IValidationResult } from "../elements/Validation";
import { ValidatedServerConfig } from "../../../utils/ValidatedServerConfig";
import ExternalLink from "../elements/ExternalLink";

interface IProps {
title?: string;
Expand Down Expand Up @@ -236,9 +237,13 @@ export default class ServerPickerDialog extends React.PureComponent<IProps, ISta
</AccessibleButton>

<h2>{_t("Learn more")}</h2>
<a href="https://matrix.org/faq/#what-is-a-homeserver%3F" target="_blank" rel="noreferrer noopener">
<ExternalLink
href="https://matrix.org/faq/#what-is-a-homeserver%3F"
target="_blank"
rel="noreferrer noopener"
>
{_t("About homeservers")}
</a>
</ExternalLink>
</form>
</BaseDialog>
);
Expand Down
5 changes: 3 additions & 2 deletions src/components/views/dialogs/TermsDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { _t, pickBestLanguage } from "../../../languageHandler";
import DialogButtons from "../elements/DialogButtons";
import BaseDialog from "./BaseDialog";
import { ServicePolicyPair } from "../../../Terms";
import ExternalLink from "../elements/ExternalLink";

interface ITermsCheckboxProps {
onChange: (url: string, checked: boolean) => void;
Expand Down Expand Up @@ -148,9 +149,9 @@ export default class TermsDialog extends React.PureComponent<ITermsDialogProps,
<td className="mx_TermsDialog_summary">{summary}</td>
<td>
{termDoc[termsLang].name}
<a rel="noreferrer noopener" target="_blank" href={termDoc[termsLang].url}>
<ExternalLink rel="noreferrer noopener" target="_blank" href={termDoc[termsLang].url}>
<span className="mx_TermsDialog_link" />
</a>
</ExternalLink>
</td>
<td>
<TermsCheckbox
Expand Down
13 changes: 9 additions & 4 deletions src/components/views/settings/EventIndexPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import EventIndexPeg from "../../../indexing/EventIndexPeg";
import { SettingLevel } from "../../../settings/SettingLevel";
import SeshatResetDialog from "../dialogs/SeshatResetDialog";
import InlineSpinner from "../elements/InlineSpinner";
import ExternalLink from "../elements/ExternalLink";

interface IState {
enabling: boolean;
Expand Down Expand Up @@ -197,9 +198,9 @@ export default class EventIndexPanel extends React.Component<{}, IState> {
},
{
nativeLink: (sub) => (
<a href={nativeLink} target="_blank" rel="noreferrer noopener">
<ExternalLink href={nativeLink} target="_blank" rel="noreferrer noopener">
{sub}
</a>
</ExternalLink>
),
},
)}
Expand All @@ -217,9 +218,13 @@ export default class EventIndexPanel extends React.Component<{}, IState> {
},
{
desktopLink: (sub) => (
<a href="https://element.io/get-started" target="_blank" rel="noreferrer noopener">
<ExternalLink
href="https://element.io/get-started"
target="_blank"
rel="noreferrer noopener"
>
{sub}
</a>
</ExternalLink>
),
},
)}
Expand Down
65 changes: 39 additions & 26 deletions src/components/views/settings/tabs/user/HelpUserSettingsTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import { Action } from "../../../../../dispatcher/actions";
import { UserTab } from "../../../dialogs/UserTab";
import dis from "../../../../../dispatcher/dispatcher";
import CopyableText from "../../../elements/CopyableText";
import ExternalLink from "../../../elements/ExternalLink";

interface IProps {
closeSettingsFn: () => void;
Expand Down Expand Up @@ -114,9 +115,9 @@ export default class HelpUserSettingsTab extends React.Component<IProps, IState>
for (const tocEntry of tocLinks) {
legalLinks.push(
<div key={tocEntry.url}>
<a href={tocEntry.url} rel="noreferrer noopener" target="_blank">
<ExternalLink href={tocEntry.url} rel="noreferrer noopener" target="_blank">
{tocEntry.text}
</a>
</ExternalLink>
</div>,
);
}
Expand All @@ -143,27 +144,31 @@ export default class HelpUserSettingsTab extends React.Component<IProps, IState>
{},
{
photo: (sub) => (
<a
<ExternalLink
href="themes/element/img/backgrounds/lake.jpg"
rel="noreferrer noopener"
target="_blank"
>
{sub}
</a>
</ExternalLink>
),
author: (sub) => (
<a href="https://www.flickr.com/golan" rel="noreferrer noopener" target="_blank">
<ExternalLink
href="https://www.flickr.com/golan"
rel="noreferrer noopener"
target="_blank"
>
{sub}
</a>
</ExternalLink>
),
terms: (sub) => (
<a
<ExternalLink
href="https://creativecommons.org/licenses/by-sa/4.0/"
rel="noreferrer noopener"
target="_blank"
>
{sub}
</a>
</ExternalLink>
),
},
)}
Expand All @@ -175,27 +180,27 @@ export default class HelpUserSettingsTab extends React.Component<IProps, IState>
{},
{
colr: (sub) => (
<a
<ExternalLink
href="https://github.com/matrix-org/twemoji-colr"
rel="noreferrer noopener"
target="_blank"
>
{sub}
</a>
</ExternalLink>
),
author: (sub) => (
<a href="https://mozilla.org" rel="noreferrer noopener" target="_blank">
<ExternalLink href="https://mozilla.org" rel="noreferrer noopener" target="_blank">
{sub}
</a>
</ExternalLink>
),
terms: (sub) => (
<a
<ExternalLink
href="https://www.apache.org/licenses/LICENSE-2.0"
rel="noreferrer noopener"
target="_blank"
>
{sub}
</a>
</ExternalLink>
),
},
)}
Expand All @@ -208,23 +213,31 @@ export default class HelpUserSettingsTab extends React.Component<IProps, IState>
{},
{
twemoji: (sub) => (
<a href="https://twemoji.twitter.com/" rel="noreferrer noopener" target="_blank">
<ExternalLink
href="https://twemoji.twitter.com/"
rel="noreferrer noopener"
target="_blank"
>
{sub}
</a>
</ExternalLink>
),
author: (sub) => (
<a href="https://twemoji.twitter.com/" rel="noreferrer noopener" target="_blank">
<ExternalLink
href="https://twemoji.twitter.com/"
rel="noreferrer noopener"
target="_blank"
>
{sub}
</a>
</ExternalLink>
),
terms: (sub) => (
<a
<ExternalLink
href="https://creativecommons.org/licenses/by/4.0/"
rel="noreferrer noopener"
target="_blank"
>
{sub}
</a>
</ExternalLink>
),
},
)}
Expand Down Expand Up @@ -256,9 +269,9 @@ export default class HelpUserSettingsTab extends React.Component<IProps, IState>
},
{
a: (sub) => (
<a href="https://element.io/help" rel="noreferrer noopener" target="_blank">
<ExternalLink href="https://element.io/help" rel="noreferrer noopener" target="_blank">
{sub}
</a>
</ExternalLink>
),
},
);
Expand All @@ -273,9 +286,9 @@ export default class HelpUserSettingsTab extends React.Component<IProps, IState>
},
{
a: (sub) => (
<a href="https://element.io/help" rel="noreferrer noopener" target="_blank">
<ExternalLink href="https://element.io/help" rel="noreferrer noopener" target="_blank">
{sub}
</a>
</ExternalLink>
),
},
)}
Expand Down Expand Up @@ -321,13 +334,13 @@ export default class HelpUserSettingsTab extends React.Component<IProps, IState>
{},
{
a: (sub) => (
<a
<ExternalLink
href="https://matrix.org/security-disclosure-policy/"
rel="noreferrer noopener"
target="_blank"
>
{sub}
</a>
</ExternalLink>
),
},
)}
Expand Down
5 changes: 3 additions & 2 deletions src/utils/ErrorUtils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { MatrixError, ConnectionError } from "matrix-js-sdk/src/http-api";
import { _t, _td, Tags, TranslatedString } from "../languageHandler";
import SdkConfig from "../SdkConfig";
import { ValidatedServerConfig } from "./ValidatedServerConfig";
import ExternalLink from "../components/views/elements/ExternalLink";

export const resourceLimitStrings = {
"monthly_active_user": _td("This homeserver has hit its Monthly Active User limit."),
Expand Down Expand Up @@ -183,9 +184,9 @@ export function messageForConnectionError(
{},
{
a: (sub) => (
<a target="_blank" rel="noreferrer noopener" href={serverConfig.hsUrl}>
<ExternalLink target="_blank" rel="noreferrer noopener" href={serverConfig.hsUrl}>
{sub}
</a>
</ExternalLink>
),
},
)}
Expand Down
Loading

0 comments on commit 37b7dfe

Please sign in to comment.