Skip to content

Commit

Permalink
Merge main into next-release/main (#7901)
Browse files Browse the repository at this point in the history
* Update versions.ts Android Amplify V2.19.1 (#7767)

* chore(flutter): update android section of Amplify Flutter getting started guide (#7760)

* chore: update android section of Flutter getting started guide

* chore: update gen 2 flutter platform setup

* chore: add info to enable network permissions on android

* chore: update H3 headers to H2

* chore: update min Xcode version to 15

* chore: update xcode verison to 15.0 for macOS

* chore: update ios and macos setup to be consistent with Android, add callout for missing podfile

* update mobile quickstarts with link to fullstack branch deployment guide #7741 (#7746)

* chore: add serverComponentsExternalPackages callout for Next.js (#7757)

* chore: add serverComponentsExternalPackages callout for Next.js

* Apply suggestions from code review

Co-authored-by: Jim Blanchard <jim.l.blanchard@gmail.com>

* Apply suggestions from code review

* Update src/pages/gen1/[platform]/build-a-backend/server-side-rendering/nextjs/index.mdx

Co-authored-by: Jim Blanchard <jim.l.blanchard@gmail.com>

* Update src/pages/gen1/[platform]/build-a-backend/server-side-rendering/nextjs/index.mdx

Co-authored-by: josef <josef.aidt@gmail.com>

* Update src/pages/[platform]/build-a-backend/server-side-rendering/index.mdx

Co-authored-by: josef <josef.aidt@gmail.com>

---------

Co-authored-by: Jim Blanchard <jim.l.blanchard@gmail.com>
Co-authored-by: josef <josef.aidt@gmail.com>

* add warning callout to gen1 backend-config (#7773)

* Revert "chore: add region to scrollable table (#7744)" (#7784)

This reverts commit 67496c5.

* chore: change outputs to amplifyConfig in flutter gen 2 docs (#7764)

* chore: change outputs to amplifyConfig in flutter gen 2 docs

* chore: change amplifyconfiguration.dart import to amplify_outputs.dart

* chore: remove --outputs-version 0 and downgrade config file callout

* chore: remove --outputs-version 0 from snippets

* chore: remove gen 2 config conversion callout

* chore: remove amplifyconfiguration.dart references from gen 2

* fix: heading order on gen1/prev subscribe-data page (#7790)

* add warning regarding subscription and mutation redaction of relational fields (#7768)

* add warning regarding subscription and mutation redaction of relational fields

* replace authn with authz in warning

* chore(api): Callout for field redaction on Swift Android relational models

* Update src/pages/gen1/[platform]/build-a-backend/graphqlapi/relational-models/index.mdx

* add feature flag to warning for gen 1

* Fix heading order in fragments affecting this page

* add protected redaction message components

* Add tests for redaction message Gen 1 and Gen 2 components

* add snapshots for redaction Gen 1 and Gen 2 component tests

* Adds ProtectedRedactionMessage components for Gen 1 and Gen2

* Render ProtectedRedactionGen1Message component on Gen 1 realtime page

* Render ProtectedRedactionGen1Message component on Gen 2 data modeling page

* Render ProtectedRedactionGen2Message component on Gen 2 realtime page

* Render ProtectedRedactionGen1Message component on Gen 1 data modeling page

* Render ProtectedRedactionGen1Message component on Gen 1 V5 realtime page

* add subscriptionsInheritPrimaryAuth as a feature flag

* correct version for subscriptionsInheritPrimaryAuth

* remove commented code

* fix heading order

---------

Co-authored-by: Michael Law <1365977+lawmicha@users.noreply.github.com>
Co-authored-by: Heather <hbuchel@gmail.com>
Co-authored-by: katiegoines <katiegoines@gmail.com>

* fix subscriptionsInheritPrimaryAuth default value (#7795)

* change overview card titles from p to h2 (#7780)

Co-authored-by: katiegoines <katiegoines@gmail.com>

* remove conditional in aria-describedby={codeId} for MDXCopyCodeButton (#7779)

Co-authored-by: katiegoines <katiegoines@gmail.com>

* Update index.mdx to fix typo (#7798)

Removed mention of create-vite-app

* add workflow to validate redirects (#7726)

* add workflow to validate redirects

* change filename

* removing testing errors

* finding all invalid redirects

* running validation to catch all issues

* remove unneeded code

---------

Co-authored-by: katiegoines <katiegoines@gmail.com>

* update set up function guide with data example (#7759)

* update set up function guide with data example

* add mobile snippets

* remove checkboxes and circle (#7783)

* fix: heading order (#7803)

* restore autoSignIn section for SignIn page, and Switching Authentication Flows page for js categories (#7769)

Co-authored-by: JoonWon Choi <joonwonc@amazon.com>

* replace `amplify` to `ampx` (#7804)

* feat(js): list api subpathStrategy parameter (#7794)

* feat(js): list api subpathStrategy parameter

* fix: adds style guide suggestions

* fix: adds result structure

* fix: tried to delineate between recursive exploration of entire path and subpathStrategy option

* Update src/pages/[platform]/build-a-backend/storage/list-files/index.mdx

Co-authored-by: Harshita Daddala <harshita.d11@gmail.com>

* Update src/pages/[platform]/build-a-backend/storage/list-files/index.mdx

Co-authored-by: Harshita Daddala <harshita.d11@gmail.com>

* Update src/pages/[platform]/build-a-backend/storage/list-files/index.mdx

Co-authored-by: Harshita Daddala <harshita.d11@gmail.com>

* Update src/pages/[platform]/build-a-backend/storage/list-files/index.mdx

Co-authored-by: Harshita Daddala <harshita.d11@gmail.com>

* Update src/pages/[platform]/build-a-backend/storage/list-files/index.mdx

Co-authored-by: ashika112 <155593080+ashika112@users.noreply.github.com>

* Update src/pages/[platform]/build-a-backend/storage/list-files/index.mdx

Co-authored-by: josef <josef.aidt@gmail.com>

* comments and prettier

* undid prettier table change

* Update src/pages/[platform]/build-a-backend/storage/list-files/index.mdx

Co-authored-by: josef <josef.aidt@gmail.com>

---------

Co-authored-by: haverchuck <dnnoyes@amazon.com>
Co-authored-by: Harshita Daddala <harshita.d11@gmail.com>
Co-authored-by: ashika112 <155593080+ashika112@users.noreply.github.com>
Co-authored-by: josef <josef.aidt@gmail.com>

* chore: update domains for proxy (#7808)

* fix: typo on client code generation page (#7809)

* Fix anchor link, add some scroll margin to h4 headings (#7810)

* chore(deps): bump @aws-amplify/amplify-cli-core from 4.3.8 to 4.3.9 (#7788)

Bumps [@aws-amplify/amplify-cli-core](https://github.com/aws-amplify/amplify-cli/tree/HEAD/packages/amplify-cli-core) from 4.3.8 to 4.3.9.
- [Release notes](https://github.com/aws-amplify/amplify-cli/releases)
- [Changelog](https://github.com/aws-amplify/amplify-cli/blob/dev/packages/amplify-cli-core/CHANGELOG.md)
- [Commits](https://github.com/aws-amplify/amplify-cli/commits/@aws-amplify/amplify-cli-core@4.3.9/packages/amplify-cli-core)

---
updated-dependencies:
- dependency-name: "@aws-amplify/amplify-cli-core"
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chore(deps): bump aws-actions/aws-secretsmanager-get-secrets (#7792)

Bumps [aws-actions/aws-secretsmanager-get-secrets](https://github.com/aws-actions/aws-secretsmanager-get-secrets) from 2.0.3 to 2.0.5.
- [Release notes](https://github.com/aws-actions/aws-secretsmanager-get-secrets/releases)
- [Commits](aws-actions/aws-secretsmanager-get-secrets@ff26a0a...98c2d6b)

---
updated-dependencies:
- dependency-name: aws-actions/aws-secretsmanager-get-secrets
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* storage(android): update getURL options (#7736)

* storage(android): update getURL options

* add more code examples

* Add Gen 2 SDL docs (#7793)

* add gen 2 SDL docs

* Update src/pages/[platform]/build-a-backend/data/data-modeling/index.mdx

Co-authored-by: josef <josef.aidt@gmail.com>

* Update src/pages/[platform]/build-a-backend/data/data-modeling/index.mdx

Co-authored-by: josef <josef.aidt@gmail.com>

* move support callout to migration page

* update doc to state ddb-backed sources only

* made updates to the sdl explanation

---------

Co-authored-by: josef <josef.aidt@gmail.com>
Co-authored-by: Nikhil Swaminathan <nikhil@live.ca>

* Cbonif/add-non-model-auth-section (#7817)

* add callout for sql custom query/mutation return types with example

* Merge branch 'main' of github.com:aws-amplify/docs

* revert sql page change

* revert change on gen 1 sql page

* add auth permissions (#7796)

* add auth permissions

* fix accessibility error

* fix heading

* callout for mysql/postgres custom query return types (#7813)

* add callout for sql custom query/mutation return types with example

* add gen 1 example

* shorten gen 2 example a bit

* remove line breaks from gen 1 example

* remove line break

* Update index.mdx

Co-authored-by: josef <josef.aidt@gmail.com>

* Update src/pages/gen1/[platform]/build-a-backend/graphqlapi/connect-api-to-existing-database/index.mdx

Co-authored-by: josef <josef.aidt@gmail.com>

* remove ts import from bottom of page

---------

Co-authored-by: josef <josef.aidt@gmail.com>

* Clarify Manual Loading of Environment Variables in Sandbox Environments (#7822)

* Clarify Manual Loading of Environment Variables in Sandbox Environments

* Update src/pages/[platform]/deploy-and-host/fullstack-branching/secrets-and-vars/index.mdx

Co-authored-by: josef <josef.aidt@gmail.com>

---------

Co-authored-by: josef <josef.aidt@gmail.com>

* fix data env name in function example, ref #7825 (#7826)

* Update app id reference for CI/CD deployments (#7832)

* fix(swift): updated concurrency in quickstart (#7828)

* chore(android): Update versions.ts - Android SDK 2.76.0(#7833)

* feat(Swift): Adding SubpathStrategy documentation for Storage.List (#7831)

* Add Gen1 banner to getting started pages (#7839)

* add Gen1 Banner to all gen 1 getting started pages

* update link location and add banner to how amplify works

---------

Co-authored-by: Jacob Logan <lognjc@amazon.com>

* remove temporary disabling of copy-code button (#7835)

Co-authored-by: katiegoines <katiegoines@gmail.com>

* add streaming function logs docs (#7841)

* add streaming function logs docs

* Update src/pages/[platform]/build-a-backend/functions/streaming-logs/index.mdx

Co-authored-by: Amplifiyer <51211245+Amplifiyer@users.noreply.github.com>

* rm multiline log callout, added note for chaining --out-file

* clarify log output in terminal where sandbox is running

---------

Co-authored-by: Amplifiyer <51211245+Amplifiyer@users.noreply.github.com>

* a11y-when closing accordion from bottom, focus back on summary element (#7837)

* when closing accordion from bottom, focus back on summary element

* add test

* remove extra spaces

---------

Co-authored-by: katiegoines <katiegoines@gmail.com>

* a11y-remove alt text for decorative image (#7836)

* remove alt text for decorative image

* mark images as decorative

---------

Co-authored-by: katiegoines <katiegoines@gmail.com>

* Update index.mdx (#7840)

* put feedback responses in aria-live (#7844)

Co-authored-by: katiegoines <katiegoines@gmail.com>

* when clicking on toc entry, focus on respective heading in content (#7845)

Co-authored-by: katiegoines <katiegoines@gmail.com>

* add scheduling functions docs (#7842)

* add scheduling functions docs

* fix path

* Update src/pages/[platform]/build-a-backend/functions/scheduling-functions/index.mdx

* add docs for auth custom attribute support (#7846)

* add docs for auth custom attribute support

* Update src/pages/[platform]/build-a-backend/auth/concepts/user-attributes/index.mdx

* correct heading order

* fix broken links

* add mobile platform to concepts page for user attributes

* remove studio reference in Amplify Gen 2 docs (#7860)

* storage(android): update storage list with delimiter support (#7830)

* feat(Swift): Adding SubpathStrategy documentation for Storage.List

* storage(android): update storage list with delimiter support

* feat(Swift): Adding SubpathStrategy documentation for Storage.List

* chore: resolve review comments

* chore: update per review comments

* chore: resolve review comments

* fix exclude subpath sample

---------

Co-authored-by: Sebastian Villena <97059974+ruisebas@users.noreply.github.com>

* Add resolution for fast-xml-parser (#7859)

* a11y videos have aria-hidden but can still receive focus (#7866)

* adding ariaDescriptions onto some videos to test for required prop build failure

* testing error for missing prop

* testing error for missing prop

* fixing testing failure

* re-order props

* re-order props

* fix invalid heading order

* replace prop name

---------

Co-authored-by: katiegoines <katiegoines@gmail.com>

* chore(flutter): added push notifications snippet for updated settings.gradle file (#7848)

* chore: added push notifications snippet for updated settings.gradle file

* chore: remove commented code

* fix: change gen2 monorepo setting image path (#7786)

* fix: change gen2 monorepo setting image path

* empty commit

* fix: empty commit

* fix: delete new line

* adds storage, user and data management pages (#7814)

* adds storage, user and data mangement pages

* add non-dev mode info to figma to react docs (#7878)

* rework "use existing cognito resources" prose, highlight configuring client libs directly (#7806)

* rework "use existing cognito resources" prose, highlight configuring client libs directly

* pivot use existing aws resources page to generalized 'connect _to_'

* rm backend snippets in favor of referenceAuth rfc

* a11y- add more descriptive text to learn more in gen2 modal (#7869)

* add more descriptive text to learn more in gen2 modal

* remove excess space

* Update src/components/Modal/Modal.tsx

Co-authored-by: Heather Buchel <hbuchel@gmail.com>

---------

Co-authored-by: katiegoines <katiegoines@gmail.com>
Co-authored-by: Heather Buchel <hbuchel@gmail.com>

* a11y - add aria-label to external link instances (#7874)

* remove import

* adding externallink aria-labels

---------

Co-authored-by: katiegoines <katiegoines@gmail.com>

* add id to popovertrigger (#7881)

Co-authored-by: katiegoines <katiegoines@gmail.com>

* fix: removed hyphen from the logGroupName (#7856)

* updated the logGroupName

* added vendedlogs to cspell.json

* updated the fieldname is index mapping

* updating axios dependency to use new safe version (#7886)

* update cdk bootstrap cmd (#7889)

* update cdk bootstrap cmd

* Update index.mdx

* Update index.mdx

* Add Docs for Email Invitation Customization (#7891)

* add email invite template docs

* Update src/pages/[platform]/build-a-backend/auth/customize-auth-lifecycle/email-customization/index.mdx

Co-authored-by: josef <josef.aidt@gmail.com>

---------

Co-authored-by: josef <josef.aidt@gmail.com>

* [Multi-bucket] Storage - add multi bucket setup and usage examples (#7858)

* adding multi bucket sections / examples

* adding callout for copy

* fix link

* adding list example and rewording

* rename to remove support

* add setup section and update links

* fix accessibility violations

* remove from non JS sections

* update download files option language

Co-authored-by: ashika112 <155593080+ashika112@users.noreply.github.com>

* update copy example to include alternatives

* update language for alternative on download

Co-authored-by: ashika112 <155593080+ashika112@users.noreply.github.com>

* punctuation

* unify language across pages

* adding title to copy section

* adding subpath strategy to options

* resolve broken link

* manual override amplify outputs

* remove type def

* remove amplify outputs in setup guide

* modify existing storage examples

* remove section from download

* remove section from list page

* remove section from remove

* update copy files page

* unify language

* unify language

* modify existing resources section

* use resource config in override

* addressing feedback

* remove redundant link

* address feedback

* add / update links

* add full code examples

* update heading

* clean up code samples

* full examples on setup page

* remove redundant text

* consistent setup examples

* restructure storage setup

* simplify upload code examples

* update tables with default values

* update code snippets

* Revamp list file code

* update upload examples

* fix leak

* address feedback

* moved / revamped storage without backend section

---------

Co-authored-by: ashika112 <155593080+ashika112@users.noreply.github.com>
Co-authored-by: ashika112 <akasivis@amazon.com>

* remove untrue claim about device tracking (#7898)

* Feat (Auth): added docs for fetchCurrentDevice API (#7737)

Feat (Auth): added docs for fetchCurrentDevice API (#7737)

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: Michael Law <1365977+lawmicha@users.noreply.github.com>
Co-authored-by: Jordan Nelson <nejrd@amazon.com>
Co-authored-by: josef <josef.aidt@gmail.com>
Co-authored-by: Hui Zhao <10602282+HuiSF@users.noreply.github.com>
Co-authored-by: Jim Blanchard <jim.l.blanchard@gmail.com>
Co-authored-by: Heather Buchel <hbuchel@gmail.com>
Co-authored-by: Kha Truong <64438356+khatruong2009@users.noreply.github.com>
Co-authored-by: Chris Bonifacio <christopher.bonifacio@gmail.com>
Co-authored-by: katiegoines <katiegoines@gmail.com>
Co-authored-by: Dane Pilcher <dppilche@amazon.com>
Co-authored-by: Katie Goines <30757403+katiegoines@users.noreply.github.com>
Co-authored-by: Nikhil Swaminathan <2429410+swaminator@users.noreply.github.com>
Co-authored-by: Kethan sai <ykethan@amazon.com>
Co-authored-by: Joon Choi <requiemdeciel@gmail.com>
Co-authored-by: JoonWon Choi <joonwonc@amazon.com>
Co-authored-by: MURAKAMI Masahiko <fossamagna2@gmail.com>
Co-authored-by: Dustin Noyes <dustin.noyes.dev@gmail.com>
Co-authored-by: haverchuck <dnnoyes@amazon.com>
Co-authored-by: Harshita Daddala <harshita.d11@gmail.com>
Co-authored-by: ashika112 <155593080+ashika112@users.noreply.github.com>
Co-authored-by: MJ Zhang <0618@users.noreply.github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Tuan Pham <103537251+phantumcode@users.noreply.github.com>
Co-authored-by: Nikhil Swaminathan <nikhil@live.ca>
Co-authored-by: Kazuki Hamasaki <ne.vivam.si.abis@gmail.com>
Co-authored-by: Jay Raval <jay.ambrish.raval@gmail.com>
Co-authored-by: Sébastien Stormacq <sebastien.stormacq@gmail.com>
Co-authored-by: Sebastian Villena <97059974+ruisebas@users.noreply.github.com>
Co-authored-by: Jacob Logan <lognjc@amazon.com>
Co-authored-by: Amplifiyer <51211245+Amplifiyer@users.noreply.github.com>
Co-authored-by: taka <106423245+takaya-okamoto@users.noreply.github.com>
Co-authored-by: Emma Sauerborn <70536670+esauerbo@users.noreply.github.com>
Co-authored-by: magisystem0408 <61937077+magisystem0408@users.noreply.github.com>
Co-authored-by: Anil Maktala <maktala.anil@gmail.com>
Co-authored-by: Jordan Van Ness <jordvn@amazon.com>
Co-authored-by: James Graham <grahamjamesr7@users.noreply.github.com>
Co-authored-by: James Jarvis <jjarvisp@amazon.com>
Co-authored-by: ashika112 <akasivis@amazon.com>
Co-authored-by: Kamil Sobol <sobol.k.r@gmail.com>
Co-authored-by: Andrew Hahn <58017052+hahnandrew@users.noreply.github.com>
  • Loading branch information
Show file tree
Hide file tree
Showing 71 changed files with 1,205 additions and 433 deletions.
2 changes: 1 addition & 1 deletion Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ let mut a = String::from("a");
Videos can be added using the `<Video />` component and referencing a path to the video file. The video should be an `.mp4` file and should exist in the `/public` directory

```jsx
<Video src="/path/to/video.mp4" />
<Video src="/path/to/video.mp4" description="Video - [video description]" />
```

## Accessibility testing
Expand Down
1 change: 1 addition & 0 deletions cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -1396,6 +1396,7 @@
"validationData",
"vanillajs",
"varchar",
"vendedlogs",
"verify.js",
"VerifyAuthChallengeResponse",
"VeriSign",
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"@types/react": "^18.0.0",
"@types/url-parse": "^1.4.3",
"@typescript-eslint/eslint-plugin": "^6.13.1",
"axios": "^1.3.4",
"axios": "^1.7.4",
"cheerio": "^1.0.0-rc.12",
"classnames": "^2.3.2",
"cross-env": "^7.0.3",
Expand Down Expand Up @@ -89,7 +89,7 @@
"loader-utils": "2.0.4",
"minimatch": "3.1.2",
"decode-uri-component": "0.2.1",
"fast-xml-parser": "4.2.5",
"**/fast-xml-parser": "4.4.1",
"semver": "7.5.2",
"tough-cookie": "4.1.3",
"aws-cdk-lib": "2.80.0",
Expand Down
Binary file modified public/images/gen2/fullstack-branching/monorepo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/gen2/manage/data-manager.mp4
Binary file not shown.
Binary file added public/images/gen2/manage/storage-manager.mp4
Binary file not shown.
Binary file added public/images/gen2/manage/user-manager.mp4
Binary file not shown.
13 changes: 10 additions & 3 deletions src/components/ExternalLink/__tests__/ExternalLink.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,27 @@ describe('ExternalLink', () => {
it('should render the ExternalLink component', async () => {
render(component);
const externalLink = await screen.getByRole('link', {
name: 'Click Here!'
name: '(opens in new tab)'
});
const externalLinkText = await screen.findByText('Click Here!');

expect(externalLink).toBeInTheDocument();
await waitFor(() => {
expect(externalLink).toBeInTheDocument();
expect(externalLinkText).toBeInTheDocument();
});
});

it('should open external links in a new window', async () => {
render(component);
const externalLink = await screen.getByRole('link', {
name: 'Click Here!'
name: '(opens in new tab)'
});
const externalLinkText = await screen.findByText('Click Here!');

expect(externalLink).toHaveAttribute('rel', 'noopener noreferrer');
expect(externalLink).toHaveAttribute('target', '_blank');
expect(externalLinkText).toHaveAttribute('rel', 'noopener noreferrer');
expect(externalLinkText).toHaveAttribute('target', '_blank');
});

it('should trackExternalLink on click', async () => {
Expand Down
14 changes: 13 additions & 1 deletion src/components/ExternalLink/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, { useEffect, useRef } from 'react';
import { trackExternalLink } from '../../utils/track';

type ExternalLinkProps = {
Expand All @@ -15,15 +15,27 @@ const ExternalLink: React.FC<ExternalLinkProps> = ({
href,
className
}) => {
const [label, setLabel] = React.useState('');
const linkRef = useRef<HTMLAnchorElement>(null);

useEffect(() => {
if (linkRef.current) {
const text = linkRef.current.innerText;
setLabel(text ? text : '');
}
}, []);

return (
<a
href={href}
className={className}
aria-label={label + ' (opens in new tab)'}
rel="noopener noreferrer"
target="_blank"
onClick={() => {
trackLink(href);
}}
ref={linkRef}
>
{children}
</a>
Expand Down
14 changes: 14 additions & 0 deletions src/components/ExternalLinkButton/ExternalLinkButton.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { Button, ButtonProps } from '@aws-amplify/ui-react';
import { IconExternalLink } from '../Icons';
import { trackExternalLink } from '../../utils/track';
import { useEffect, useRef } from 'react';
import React from 'react';

interface ExternalLinkButtonProps {
variation?: ButtonProps['variation'];
Expand All @@ -21,6 +23,16 @@ export const ExternalLinkButton = ({
children,
className
}: ExternalLinkButtonProps) => {
const [label, setLabel] = React.useState('');
const buttonRef = useRef<HTMLAnchorElement>(null);

useEffect(() => {
if (buttonRef.current) {
const text = buttonRef.current.innerText;
setLabel(text ? text : '');
}
}, []);

return (
<Button
href={href}
Expand All @@ -32,9 +44,11 @@ export const ExternalLinkButton = ({
as="a"
align-items="center"
className={className}
aria-label={label + ' (opens in new tab)'}
onClick={() => {
trackLink(href);
}}
ref={buttonRef}
>
{children} <IconExternalLink />
</Button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,15 @@ describe('ExternalLinkButton', () => {
it('should render the ExternalLinkButton component', async () => {
render(component);

const externalLinkButtonNode = await screen.findByRole('link', {
name: 'Click Here!'
const externalLinkButtonNode = await screen.getByRole('link', {
name: '(opens in new tab)'
});
const externalLinkButtonNodeText = await screen.findByText('Click Here!');

await waitFor(() => {
expect(externalLinkButtonNode).toBeInTheDocument();
expect(externalLinkButtonNodeText).toBeInTheDocument();
});
expect(externalLinkButtonNode).toBeInTheDocument();
});

it('should render the ExternalLink icon', async () => {
Expand Down

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion src/components/GlobalNav/__tests__/GlobalNav.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ describe('GlobalNav', () => {

it('should render the GlobalNav component', async () => {
render(component);
const link = await screen.findByRole('link', { name: 'About AWS Amplify' });
const link = await screen.findByRole('link', {
name: 'About AWS Amplify (opens in new tab)'
});
expect(link).toBeInTheDocument();
});
});
1 change: 1 addition & 0 deletions src/components/GlobalNav/components/NavMenuLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export function NavMenuLink({
return (
<Link
isExternal={true}
aria-label={label + ' (opens in new tab)'}
className="navbar-menu-item"
href={navMenuItem.url}
>
Expand Down
7 changes: 6 additions & 1 deletion src/components/LinkCard/LinkCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,12 @@ const LinkCard: React.FC<LinkCardProps> = ({
}) => {
return (
href && (
<Link href={href} isExternal={isExternal} className="link-card">
<Link
href={href}
isExternal={isExternal}
className="link-card"
aria-label={children + ' (opens in new tab)'}
>
<Flex direction="column" justifyContent="space-between" height="100%">
<View>{icon()}</View>
<View className="link-card-children">{children}</View>
Expand Down
8 changes: 4 additions & 4 deletions src/components/LinkCards/__tests__/LinkCards.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,21 @@ describe('LinkCards', () => {
it('should render the LinkCards component', async () => {
render(component);
const linkCardNode = await screen.findByRole('link', {
name: 'React Libraries on GitHub'
name: 'React Libraries on GitHub (opens in new tab)'
});
expect(linkCardNode).toBeInTheDocument();
});

it('should link each card to external href', async () => {
render(component);
const githubCard = await screen.findByRole('link', {
name: 'React Libraries on GitHub'
name: 'React Libraries on GitHub (opens in new tab)'
});
const discordCard = await screen.findByRole('link', {
name: 'Amplify Discord'
name: 'Amplify Discord (opens in new tab)'
});
const learnCard = await screen.findByRole('link', {
name: 'Amplify Learn'
name: 'Amplify Learn (opens in new tab)'
});

expect(githubCard.href).toBe('https://github.com/aws-amplify/amplify-ui');
Expand Down
10 changes: 8 additions & 2 deletions src/components/MDXComponents/__tests__/MDXLink.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const routerMock = {
jest.mock('next/router', () => routerMock);

describe('MDXLink', () => {
it('should render external link', () => {
it('should render external link', async () => {
const externalUrl = 'https://amazon.com';
const linkText = 'External Site';

Expand All @@ -26,10 +26,16 @@ describe('MDXLink', () => {
</MDXLink>
);

const linkElement = screen.getByRole('link', { name: linkText });
const linkElement = await screen.getByRole('link', {
name: '(opens in new tab)'
});
const linkElementText = await screen.findByText('External Site');
expect(linkElement).toBeInTheDocument();
expect(linkElement).toHaveAttribute('href', externalUrl);
expect(linkElement).toHaveAttribute('rel', 'noopener noreferrer');
expect(linkElementText).toBeInTheDocument();
expect(linkElementText).toHaveAttribute('href', externalUrl);
expect(linkElementText).toHaveAttribute('rel', 'noopener noreferrer');
});

it('should render internal link', () => {
Expand Down
1 change: 1 addition & 0 deletions src/components/Menu/MenuItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ export function MenuItem({
className={`menu__list-item__link menu__list-item__link--external ${listItemLinkStyle}`}
href={pageNode.route}
isExternal={true}
aria-label={pageNode.title + ' (opens in new tab)'}
onClick={onLinkClick}
>
<Flex
Expand Down
5 changes: 1 addition & 4 deletions src/components/Menu/RepoActions/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,7 @@ export default function RepoActions({ router }) {
{shouldShowEditLink && (
<Flex className="repo-actions">
<ExternalLink href={editLink}>
<Flex
className="repo-actions-link"
aria-label="Edit this page on GitHub"
>
<Flex className="repo-actions-link">
<IconPencil />
Edit on GitHub
</Flex>
Expand Down
3 changes: 2 additions & 1 deletion src/components/Modal/Modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@ export const Modal = ({ isGen1 }: ModalProps) => {
variation="primary"
className="modal-action modal-action--primary"
>
Learn more <IconChevron className="icon-rotate-270" />
Learn more about Gen 2
<IconChevron className="icon-rotate-270" />
</InternalLinkButton>
</Flex>
</Flex>
Expand Down
3 changes: 2 additions & 1 deletion src/components/PlatformNavigator/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,10 @@ export function PlatformNavigator({
<Flex alignItems="center">
<Popover flex="1 0 auto">
<Popover.Trigger
id="selectedLabel"
className={`platform-navigator__button`}
isFullWidth={true}
aria-describedby="platformNavigatorLabel"
aria-labelledby="platformNavigatorLabel selectedLabel"
>
{platformItem.icon}
{platformTitle}
Expand Down
11 changes: 8 additions & 3 deletions src/components/Video/Video.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { useState, useEffect, useRef } from 'react';
import { View } from '@aws-amplify/ui-react';

interface VideoProps {
description: string;
autoPlay?: boolean;
muted?: boolean;
loop?: true;
Expand All @@ -14,17 +15,21 @@ export const reducedMotionMediaQuery =

/**
* @description The Video component defaults to a muted, auto play video.
* Currently, we also assume the surrounding content will adequately describe
* the video so we default to aria-hidden="true".
*/
export const Video = ({
description,
autoPlay = true,
muted = true,
loop = true,
src,
testId,
...rest
}: VideoProps) => {
if (!description) {
throw new Error(
`<Video src="${src}"> is missing required description prop`
);
}
/**
* Assume user prefers reduced motion until we can check
* in the useEffect for the media query match, otherwise Next SSG
Expand Down Expand Up @@ -70,7 +75,7 @@ export const Video = ({
width="100%"
playsInline={true}
controls={true}
aria-hidden="true"
aria-label={description}
testId={testId}
{...rest}
>
Expand Down
8 changes: 7 additions & 1 deletion src/components/Video/__tests__/Video.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,13 @@ const playSpy = jest

describe('Video', () => {
const testId = 'videoTest';
const component = <Video src="test-video.mp4" testId={testId}></Video>;
const component = (
<Video
src="test-video.mp4"
description="Video - Test"
testId={testId}
></Video>
);

beforeEach(() => {
mockMatchMedia('');
Expand Down
21 changes: 6 additions & 15 deletions src/components/contribute/HowItWorks.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
import {
Divider,
Flex,
Heading,
Text,
Badge,
Link
} from '@aws-amplify/ui-react';
import { Divider, Flex, Heading, Text, Badge } from '@aws-amplify/ui-react';
import {
MdOutlineBadge,
MdLabelOutline,
Expand All @@ -14,6 +7,7 @@ import {
} from 'react-icons/md';
import { FiGitPullRequest } from 'react-icons/fi';
import { IconCheck, IconExternalLink } from '@/components/Icons';
import ExternalLink from '../ExternalLink';

export default function HowItWorks() {
return (
Expand Down Expand Up @@ -123,9 +117,9 @@ export default function HowItWorks() {
<Text>
If this is your first approved pull request, the Amplify team
designates you as a Contributor in the{' '}
<Link href="https://discord.com/invite/amplify" isExternal>
<ExternalLink href="https://discord.com/invite/amplify">
Amplify Community Discord server <IconExternalLink />
</Link>
</ExternalLink>
.
</Text>
</Flex>
Expand All @@ -147,12 +141,9 @@ export default function HowItWorks() {
</Flex>
<Text>
You collect an{' '}
<Link
href="https://aws.amazon.com/blogs/mobile/new-introducing-the-amplify-badge-program/"
isExternal
>
<ExternalLink href="https://aws.amazon.com/blogs/mobile/new-introducing-the-amplify-badge-program/">
Amplify badge <IconExternalLink />
</Link>{' '}
</ExternalLink>{' '}
for your first contribution or make progress toward the Intermediate
and Advanced badges!
</Text>
Expand Down
Loading

0 comments on commit b5db1bf

Please sign in to comment.