Skip to content

Commit

Permalink
Updating next-release/main branch (#7862)
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>

---------

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: jacoblogan <jacob.maiola.logan@gmail.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>
  • Loading branch information
1 parent 5c0932e commit b6368aa
Show file tree
Hide file tree
Showing 82 changed files with 2,763 additions and 390 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/check_for_broken_links.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
role-to-assume: arn:aws:iam::464149486631:role/github_action_read_slack_webhook_url
aws-region: us-west-2
- name: Read secrets from AWS Secrets Manager into environment variables
uses: aws-actions/aws-secretsmanager-get-secrets@ff26a0aa6bd4dd5e51326b5afb3f5f6874c958c7 # v2.0.3
uses: aws-actions/aws-secretsmanager-get-secrets@98c2d6bf1dd67c2575fa2bb14294aa64103d426c # v2.0.5
with:
secret-ids: |
SLACK_WEBHOOK_URL
Expand Down
58 changes: 58 additions & 0 deletions .github/workflows/scripts/validate-redirects.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
module.exports = {
invalidRedirects: () => {
const Ajv = require('ajv');
const redirects = require('../../../redirects.json');
const ajv = new Ajv();

const schema = {
type: 'array',
items: {
type: 'object',
required: ['source', 'target', 'status'],
properties: {
source: {
description: 'The address the user requested.',
type: 'string',
pattern: '^/'
},
target: {
description:
'The address that actually serves the content that the user sees',
type: 'string',
pattern: '^[(https)(/)]'
},
status: {
description:
'Types include a permanent redirect (301), a temporary redirect (302), a rewrite (200), or not found (404).',
type: 'string',
pattern: '^[0-5-]+$'
}
}
}
};

const errors = [];
const validate = ajv.compile(schema);

const validateEntries = (redirects) => {
const valid = validate(redirects);

if (!valid) {
const error = validate.errors[0];
const invalidEntry =
JSON.stringify(redirects[error.instancePath.slice(1, -7)]);
const loc = error.schemaPath.slice(error.schemaPath.indexOf('properties') + 11, -8);
const errorMessage = '\n\n' + 'INVALID ENTRY: Please correct the error in the "' + loc +'" property of the following entry: \n' + invalidEntry + '\n' + 'ERROR MESSAGE: ' + error.message;
errors.push(errorMessage);

validateEntries(redirects.splice(parseInt(error.instancePath.slice(1, -7)) + 1));

}
}
validateEntries(redirects);

return errors;
}
}


32 changes: 32 additions & 0 deletions .github/workflows/validate_redirects.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Validate Redirects
on:
pull_request:
branches: [main]
types: [opened, synchronize]
env:
BUILD_DIR: 'client/www/next-build'
permissions:
contents: read
jobs:
ValidateRedirects:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
- name: Setup Node.js 20.x
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
with:
node-version: 20.x
- name: Install Dependencies
run: yarn
- name: Validate redirects
id: redirects
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
with:
result-encoding: string
script: |
const { invalidRedirects } = require('./.github/workflows/scripts/validate-redirects.js');
return await invalidRedirects();
- name: Fail if any invalid redirects have been found
if: ${{ steps.redirects.outputs.result }}
run: exit 1 && echo ${{ steps.redirects.outputs.result }}
2 changes: 2 additions & 0 deletions cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -532,10 +532,12 @@
"Didfinishlaunchingwithoptions",
"displayMode",
"displayOrder",
"dists",
"DocSet",
"DocSets",
"Donef",
"Dont",
"dotenvx",
"downcasting",
"dropdown",
"dynamoDB",
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@
"license": "Apache-2.0",
"private": true,
"dependencies": {
"@aws-amplify/amplify-cli-core": "^4.3.8",
"@aws-amplify/amplify-cli-core": "^4.3.9",
"@aws-amplify/ui-react": "^6.1.12",
"@docsearch/react": "3",
"ajv": "^8.16.0",
"aws-amplify": "^6.0.9",
"next": "^14.2.3",
"next-image-export-optimizer": "^1.8.3",
Expand Down
2 changes: 1 addition & 1 deletion redirects.json
Original file line number Diff line number Diff line change
Expand Up @@ -3011,7 +3011,7 @@
},
{
"source": "/lib/client-configuration/configuring-amplify-categories/q/platform/react-native/",
"target": "react-native/tools/libraries/configure-categories/",
"target": "/react-native/tools/libraries/configure-categories/",
"status": "301"
},
{
Expand Down
2 changes: 2 additions & 0 deletions src/components/Accordion/Accordion.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,12 @@ export const Accordion: React.FC<AccordionProps> = ({

const closeAccordion = () => {
const details = detailsRef.current;
const summary = summaryRef.current;
if (details) {
const scrollToLoc = details.offsetTop - 48 - 70 - 10; // account for nav heights and 10px buffer
setDetailsOpen(false);
details.animate(collapse, animationTiming);
summary?.focus();
window.scrollTo({
left: 0,
top: scrollToLoc,
Expand Down
5 changes: 4 additions & 1 deletion src/components/Accordion/__tests__/Accordion.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,13 @@ describe('Accordion', () => {
});
});

it('should collapse Accordion when close button is clicked', async () => {
it('should collapse Accordion and refocus on Accordion element when close button is clicked', async () => {
render(component);
const accordionHeading = screen.getByText('Accordion component example');
userEvent.click(accordionHeading);
const detailsEl = await screen.getByRole('group');
const summaryEl = detailsEl.firstChild;

expect(detailsEl).toHaveAttribute('open');

const text = await screen.getByText(content);
Expand All @@ -79,6 +81,7 @@ describe('Accordion', () => {
await waitFor(() => {
expect(text).not.toBeVisible();
expect(detailsEl).not.toHaveAttribute('open');
expect(summaryEl).toHaveFocus();
});
});

Expand Down
13 changes: 11 additions & 2 deletions src/components/Callout/Callout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,21 @@ import { Message, View } from '@aws-amplify/ui-react';
interface CalloutProps {
info?: boolean;
warning?: boolean;
backgroundColor?: string;
children?: React.ReactNode;
}

export const Callout = ({ warning, children }: CalloutProps) => {
export const Callout = ({
warning,
backgroundColor,
children
}: CalloutProps) => {
return (
<Message variation="filled" colorTheme={warning ? 'warning' : 'info'}>
<Message
variation="filled"
colorTheme={warning ? 'warning' : 'info'}
backgroundColor={backgroundColor}
>
<View>{children}</View>
</Message>
);
Expand Down
13 changes: 13 additions & 0 deletions src/components/Callout/__tests__/Callout.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,17 @@ describe('Callout', () => {

consoleErrorFn.mockRestore();
});

it('should pass the backgroundColor through to the Message component', async () => {
const child = <div>Callout Child</div>;
const ele = render(
<Callout info={true} backgroundColor={'red'}>
{child}
</Callout>
);

const styles = getComputedStyle(ele.container.children[0]);
console.log(styles);
expect(styles.backgroundColor).toBe('red');
});
});
20 changes: 20 additions & 0 deletions src/components/FeatureFlags/feature-flags.json
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,26 @@
"defaultExistingProject": false
}
]
},
"subscriptionsInheritPrimaryAuth": {
"description": "Toggles whether subscriptions will inherit related authorization when relational fields are set as required",
"type": "Feature",
"valueType": "Boolean",
"versionAdded": "12.12.4",
"values": [
{
"value": "true",
"description": "Subscriptions will inherit the primary model authorization rules for the relational fields",
"defaultNewProject": false,
"defaultExistingProject": false
},
{
"value": "false",
"description": "Relational fields will be redacted in mutation response when there is a difference between auth rules between primary and related models.",
"defaultNewProject": true,
"defaultExistingProject": true
}
]
}
}
},
Expand Down
7 changes: 6 additions & 1 deletion src/components/Feedback/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,12 @@ const Feedback = function Feedback(router) {

return (
<Flex className="feedback" key={router?.router?.asPath}>
<div id="start-state" aria-labelledby="feedbackGroupTitle" role="group">
<div
id="start-state"
aria-labelledby="feedbackGroupTitle"
role="group"
aria-live="polite"
>
<Text className="feedback-text" id="feedbackGroupTitle">
{c.feedbackQuestion}
</Text>
Expand Down
20 changes: 20 additions & 0 deletions src/components/Gen1Banner/Gen1Banner.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { Callout } from '@/components/Callout';
import Link from 'next/link';
import classNames from 'classnames';

export const Gen1Banner = ({ currentPlatform }) => {
return (
<Callout backgroundColor="background.error">
For new Amplify apps, we recommend using Amplify Gen 2. You can learn more
in our{' '}
<Link
href={`/${currentPlatform}/start/quickstart`}
passHref
className={classNames('amplify-link')}
>
Gen 2 Docs
</Link>
.
</Callout>
);
};
1 change: 1 addition & 0 deletions src/components/Gen1Banner/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { Gen1Banner } from './Gen1Banner';
11 changes: 11 additions & 0 deletions src/components/Layout/Layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import {
NEXT_PREVIOUS_SECTIONS
} from '@/components/NextPrevious';
import { Modal } from '@/components/Modal';
import { Gen1Banner } from '@/components/Gen1Banner';

export const Layout = ({
children,
Expand Down Expand Up @@ -127,6 +128,13 @@ export const Layout = ({
}
}, 20);

const isGen1GettingStarted = /\/gen1\/\w+\/start\/getting-started\//.test(
asPathWithNoHash
);
const isGen1HowAmplifyWorks = /\/gen1\/\w+\/how-amplify-works\//.test(
asPathWithNoHash
);

useEffect(() => {
const headings: HeadingInterface[] = [];

Expand Down Expand Up @@ -254,6 +262,9 @@ export const Layout = ({
{useCustomTitle ? null : (
<Heading level={1}>{pageTitle}</Heading>
)}
{(isGen1GettingStarted || isGen1HowAmplifyWorks) && (
<Gen1Banner currentPlatform={currentPlatform} />
)}
{children}
{showNextPrev && <NextPrevious />}
</Flex>
Expand Down
3 changes: 1 addition & 2 deletions src/components/MDXComponents/MDXCopyCodeButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,9 @@ export const MDXCopyCodeButton = ({
<Button
size="small"
variation="link"
disabled={copied}
className="code-copy"
testId={testId}
aria-describedby={title ? undefined : codeId}
aria-describedby={codeId}
>
<IconClipboard /> {copied ? 'Copied!' : 'Copy'}
<VisuallyHidden>
Expand Down
2 changes: 1 addition & 1 deletion src/components/MDXComponents/MDXHeading.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export const MDXHeading = (props) => {
const { level, children, id } = props;

return (
<Heading level={level} id={id}>
<Heading level={level} id={id} tabIndex={-1}>
{/* Only output heading links for h2 and h3 \ */}
{level == 2 || level == 3 ? (
<Link href={`#${id}`}>{children}</Link>
Expand Down
1 change: 0 additions & 1 deletion src/components/MDXComponents/MDXTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ export const MDXTable: React.FC<MDXTableProps> = ({ children, ...props }) => {
return (
<ScrollView
tabIndex={0}
role="region"
aria-label="Scrollable table"
className="scrollview"
>
Expand Down
26 changes: 26 additions & 0 deletions src/components/MDXComponents/__tests__/MDXHeading.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { render, screen } from '@testing-library/react';
import { MDXHeading } from '../MDXHeading';
import { TableOfContents } from '../../TableOfContents/index';
import userEvent from '@testing-library/user-event';

describe('MDXHeading', () => {
it('should render H2 with string and anchor link', () => {
Expand Down Expand Up @@ -53,4 +55,28 @@ describe('MDXHeading', () => {
expect(heading).toHaveTextContent(props.children);
expect(link).not.toBeInTheDocument();
});

it('should shift focus to in-content heading on TOC click', async () => {
const props = {
level: 2,
children: 'Test heading',
id: 'test-heading'
};
render(<MDXHeading {...props} />);

const heading = screen.queryByRole('heading', { level: 2 });
const tocHeadings = [
{ linkText: 'Test heading', hash: 'test-heading', level: 'h2' }
];

const tableOfContents = <TableOfContents headers={tocHeadings} />;
render(tableOfContents);

const tocEntry = await screen.findByRole('heading', {
name: 'Test heading'
});

userEvent.click(tocEntry);
expect(heading).toHaveFocus();
});
});
6 changes: 3 additions & 3 deletions src/components/Overview/Overview.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { PageNode } from '@/directory/directory';
import { Card, Flex, View, Text } from '@aws-amplify/ui-react';
import { Card, Flex, View, Heading } from '@aws-amplify/ui-react';
import Link from 'next/link';
import { useRouter } from 'next/router';
import { Platform } from '@/data/platforms';
Expand Down Expand Up @@ -40,9 +40,9 @@ export function Overview({ childPageNodes }: OverviewProps) {
>
<Card className="overview__link__card" variation="outlined">
<Flex direction="column" gap="xs">
<Text className="overview__link__card__title">
<Heading level={2} className="overview__link__card__title">
{node.title}
</Text>
</Heading>
<View className="overview__link__card__description">
{node.description}
</View>
Expand Down
Loading

0 comments on commit b6368aa

Please sign in to comment.