Skip to content

Commit

Permalink
Merge branch 'main' into feature/triage-scan-results
Browse files Browse the repository at this point in the history
  • Loading branch information
davidmreed committed May 19, 2023
2 parents e3ce722 + b4213a3 commit 1cba753
Show file tree
Hide file tree
Showing 16 changed files with 101 additions and 61 deletions.
1 change: 1 addition & 0 deletions locales_dev/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@
"Notify Assigned Tester by Email": "Notify Assigned Tester by Email",
"Notify {{username}} by email": "Notify {{username}} by email",
"Only displaying the first {{limit}} objects. Enter a term above to search the full list.": "Only displaying the first {{limit}} objects. Enter a term above to search the full list.",
"Opens in new tab": "Opens in new tab",
"Optional Configuration Directories": "Optional Configuration Directories",
"Optional description of this Project": "Optional description of this Project",
"Optional notes about this Scratch Org": "Optional notes about this Scratch Org",
Expand Down
4 changes: 3 additions & 1 deletion src/js/components/commits/list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ const CommitTableCell = ({ item, className, ...props }: TableCellProps) => {
title={item.id}
className={classNames(className, 'commits-sha')}
>
<ExternalLink url={item.url}>{shortSha}</ExternalLink>
<ExternalLink url={item.url} showButtonIcon>
{shortSha}
</ExternalLink>
</DataTableCell>
);
};
Expand Down
10 changes: 1 addition & 9 deletions src/js/components/epics/table/detailCell.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import DataTableCell from '@salesforce/design-system-react/components/data-table/cell';
import Icon from '@salesforce/design-system-react/components/icon';
import classNames from 'classnames';
import React from 'react';
import { useTranslation } from 'react-i18next';
Expand Down Expand Up @@ -59,15 +58,8 @@ const DetailTableCell = ({
slds-truncate"
>
{t('Branch:')}{' '}
<ExternalLink url={branch_url}>
<ExternalLink url={branch_url} showButtonIcon>
{branch_name}
<Icon
category="utility"
name="new_window"
size="xx-small"
className="slds-m-bottom_xx-small"
containerClassName="slds-m-left_xx-small"
/>
</ExternalLink>
</p>
)}
Expand Down
12 changes: 1 addition & 11 deletions src/js/components/githubIssues/selectIssueModal.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import Button from '@salesforce/design-system-react/components/button';
import Icon from '@salesforce/design-system-react/components/icon';
import Modal from '@salesforce/design-system-react/components/modal';
import Radio from '@salesforce/design-system-react/components/radio';
import RadioGroup from '@salesforce/design-system-react/components/radio-group';
Expand Down Expand Up @@ -50,17 +49,8 @@ export const GitHubIssueLink = ({ url }: { url: string }) => {
const { t } = useTranslation();

return (
<ExternalLink url={url}>
<ExternalLink url={url} showButtonIcon>
{t('View on GitHub')}
<Icon
category="utility"
name="new_window"
size="xx-small"
className="slds-button__icon
slds-button__icon_right
slds-m-bottom_xx-small"
containerClassName="slds-icon_container slds-current-color"
/>
</ExternalLink>
);
};
Expand Down
6 changes: 5 additions & 1 deletion src/js/components/orgs/cards/footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,11 @@ const Footer = ({
);
}
const label = readyForReview ? t('Test Changes in Org') : t('View Org');
return <ExternalLink url={orgUrl}>{label}</ExternalLink>;
return (
<ExternalLink url={orgUrl} showButtonIcon>
{label}
</ExternalLink>
);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/js/components/orgs/cards/orgIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const OrgIcon = ({
onClick={openRefreshOrgModal}
/>
) : (
<ExternalLink url={orgUrl} title={t('View Org')}>
<ExternalLink url={orgUrl} title={t('View Org')} showButtonIcon>
{iconLink}
</ExternalLink>
);
Expand Down
4 changes: 2 additions & 2 deletions src/js/components/orgs/cards/orgInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ const OrgInfo = ({
<>
{' '}
(
<ExternalLink url={compareChangesUrl}>
<ExternalLink url={compareChangesUrl} showButtonIcon>
{t('view changes')}
</ExternalLink>
)
Expand All @@ -123,7 +123,7 @@ const OrgInfo = ({
<li>
<strong>{t('Deployed Commit:')}</strong>{' '}
{org.latest_commit_url ? (
<ExternalLink url={org.latest_commit_url}>
<ExternalLink url={org.latest_commit_url} showButtonIcon>
{org.latest_commit.substring(0, 7)}
</ExternalLink>
) : (
Expand Down
1 change: 1 addition & 0 deletions src/js/components/orgs/cards/refresh.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ const RefreshOrgModal = ({
be testing the latest changes.
</Trans>
<ExternalLink
showButtonIcon
url={orgUrl}
className="slds-button
slds-size_full
Expand Down
9 changes: 1 addition & 8 deletions src/js/components/steps/stepsItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,8 @@ const StepsItem = ({
if (isActive) {
if (step.link) {
label = (
<ExternalLink url={step.link}>
<ExternalLink url={step.link} showButtonIcon>
{step.label}
<Icon
category="utility"
name="new_window"
size="xx-small"
className="slds-m-bottom_xx-small"
containerClassName="slds-m-left_xx-small"
/>
</ExternalLink>
);
}
Expand Down
10 changes: 8 additions & 2 deletions src/js/components/user/connect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,17 @@ const ConnectModal = ({
<Trans i18nKey="devHubInfo">
Connection to a Salesforce Org with Dev Hub enabled is required to
create a Dev, Test, or Scratch Org. Learn how to{' '}
<ExternalLink url="https://developer.salesforce.com/signup">
<ExternalLink
url="https://developer.salesforce.com/signup"
showButtonIcon
>
create a Developer Edition Org
</ExternalLink>{' '}
and{' '}
<ExternalLink url="https://help.salesforce.com/articleView?id=sfdx_setup_enable_devhub.htm&type=0">
<ExternalLink
url="https://help.salesforce.com/articleView?id=sfdx_setup_enable_devhub.htm&type=0"
showButtonIcon
>
enable Dev Hub
</ExternalLink>
.
Expand Down
5 changes: 4 additions & 1 deletion src/js/components/user/info.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,10 @@ const ConnectionInfoWarning = () => (
<Trans i18nKey="devHubNotEnabled">
This Salesforce Org does not have Dev Hub enabled or your user does not have
permission to create Dev, Test, or Scratch Orgs. Learn how to{' '}
<ExternalLink url="https://help.salesforce.com/articleView?id=sfdx_setup_enable_devhub.htm&type=0">
<ExternalLink
url="https://help.salesforce.com/articleView?id=sfdx_setup_enable_devhub.htm&type=0"
showButtonIcon
>
enable Dev Hub
</ExternalLink>
.
Expand Down
2 changes: 1 addition & 1 deletion src/js/components/utils/detailPageLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ const DetailPageLayout = ({
}
info={
headerUrl && headerUrlText ? (
<ExternalLink url={headerUrl} showGitHubIcon>
<ExternalLink url={headerUrl} showGitHubIcon showButtonIcon>
/{headerUrlText}
</ExternalLink>
) : null
Expand Down
47 changes: 26 additions & 21 deletions src/js/components/utils/externalLink.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Icon from '@salesforce/design-system-react/components/icon';
import React, { ReactNode } from 'react';
import { useTranslation } from 'react-i18next';

import githubIcon from '@/img/github.svg';

Expand All @@ -15,26 +16,30 @@ const ExternalLink = ({
showGitHubIcon?: boolean;
children?: ReactNode;
[key: string]: any;
}) => (
<a href={url} target="_blank" rel="noreferrer noopener" {...props}>
{showGitHubIcon && (
<Icon
path={`${githubIcon}#github`}
size="xx-small"
className="icon-link slds-m-bottom_xx-small"
/>
)}
{showButtonIcon && (
<Icon
category="utility"
name="new_window"
size="xx-small"
className="slds-button__icon slds-button__icon_left"
containerClassName="slds-icon_container slds-current-color"
/>
)}
{children}
</a>
);
}) => {
const { t } = useTranslation();
return (
<a href={url} target="_blank" rel="noreferrer noopener" {...props}>
{showGitHubIcon && (
<Icon
path={`${githubIcon}#github`}
size="xx-small"
className="icon-link slds-m-bottom_xx-small"
/>
)}
{children}
{showButtonIcon && (
<Icon
category="utility"
name="new_window"
size="xx-small"
className="slds-button__icon slds-button__icon_right"
containerClassName="slds-icon_container slds-current-color"
assistiveText={{ label: t('Opens in new tab') }}
/>
)}
</a>
);
};

export default ExternalLink;
5 changes: 4 additions & 1 deletion src/js/components/utils/submitModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,10 @@ const SubmitModal = ({
<p>
<Trans i18nKey="markdownGuide">
For more options, view this{' '}
<ExternalLink url="https://guides.github.com/features/mastering-markdown/">
<ExternalLink
url="https://guides.github.com/features/mastering-markdown/"
showButtonIcon
>
Markdown Guide
</ExternalLink>
.
Expand Down
9 changes: 7 additions & 2 deletions test/js/components/epics/__snapshots__/steps.test.jsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -373,14 +373,19 @@ exports[`<EpicStatusSteps /> renders steps: epic with pr 1`] = `
>
Merge pull request on GitHub
<span
class="slds-m-left_xx-small"
class="slds-icon_container slds-current-color"
>
<svg
aria-hidden="true"
class="slds-m-bottom_xx-small slds-icon slds-icon_xx-small slds-icon-text-default"
class="slds-button__icon slds-button__icon_right slds-icon slds-icon_xx-small slds-icon-text-default"
>
<use />
</svg>
<span
class="slds-assistive-text"
>
Opens in new tab
</span>
</span>
</a>
</div>
Expand Down
35 changes: 35 additions & 0 deletions test/js/components/utils/externalLink.test.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import React from 'react';

import { ExternalLink } from '@/js/components/utils';

import { render } from '../../utils';

describe('<ExternalLink />', () => {
test('renders with defaults', () => {
const { getByText } = render(
<ExternalLink url="testurl">test link</ExternalLink>,
);
expect(getByText('test link')).toBeVisible();
});

test('renders with new-tab icon', () => {
const { getByText } = render(
<ExternalLink url="testurl" showButtonIcon>
test link
</ExternalLink>,
);

expect(getByText('test link')).toBeVisible();
expect(getByText('Opens in new tab')).toBeVisible();
});

test('renders with Github icon', () => {
const { container } = render(
<ExternalLink url="testurl" showGitHubIcon>
test link
</ExternalLink>,
);

expect(container.querySelector('[href$=github]')).toBeVisible();
});
});

0 comments on commit 1cba753

Please sign in to comment.