Skip to content

Commit

Permalink
Merge branch 'main' into console-error-script
Browse files Browse the repository at this point in the history
  • Loading branch information
jacoblogan authored Oct 19, 2023
2 parents ae31210 + dabe5db commit 85ae718
Show file tree
Hide file tree
Showing 766 changed files with 14,295 additions and 2,724 deletions.
4 changes: 3 additions & 1 deletion cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -1522,7 +1522,9 @@
"cloudwatchlogs",
"userids",
"xmark",
"refreshable"
"refreshable",
"querytransfers",
"generatemodelsforlazyloadandcustomselectionset"
],
"flagWords": ["hte", "full-stack", "Full-stack", "Full-Stack", "sudo"],
"patterns": [
Expand Down
24 changes: 0 additions & 24 deletions generatePathMap.cjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,19 +126,6 @@ function generatePathMap(
} else if (route.startsWith('/start')) {
filterKind = 'integration';
}

if (filterKind !== '') {
const aOrAn = 'aeiou'.includes(filterKind[0]) ? 'an' : 'a';
pathMap[route] = {
page: '/ChooseFilterPage',
query: {
address: route,
directoryPath: '/ChooseFilterPage',
filterKind: filterKind,
message: `Choose ${aOrAn} ${filterKind}:`
}
};
}
}

if (items) {
Expand Down Expand Up @@ -208,17 +195,6 @@ function generatePathMap(
page: `${route}/q/${routeType}/[${routeType}]`
};
});
const aOrAn = 'aeiou'.includes(routeType[0]) ? 'an' : 'a';
pathMap[route] = {
page: '/ChooseFilterPage',
query: {
address: route,
directoryPath: '/ChooseFilterPage',
filterKind: routeType,
filters: filters,
message: `Choose ${aOrAn} ${routeType}:`
}
};
}
return pathMap;
}
Expand Down
1 change: 0 additions & 1 deletion next.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ export default async (phase, { defaultConfig }) => {
// !! WARN !!
ignoreBuildErrors: true
},
exportPathMap,
trailingSlash: true,
transpilePackages: [
'@algolia/autocomplete-shared',
Expand Down
10 changes: 8 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"@algolia/autocomplete-shared": "^1.5.6",
"@algolia/autocomplete-theme-classic": "^1.6.1",
"@algolia/client-search": "^4.13.0",
"@aws-amplify/amplify-cli-core": "^4.2.7",
"@aws-amplify/amplify-cli-core": "^4.2.10",
"@aws-amplify/ui-react": "^5.3.1",
"@emotion/react": "^11.1.5",
"@emotion/styled": "^11.3.0",
Expand Down Expand Up @@ -96,6 +96,8 @@
},
"resolutions": {
"**/trim": "0.0.3",
"@babel/core": "^7.23.2",
"@babel/traverse": "^7.23.2",
"loader-utils": "2.0.4",
"minimatch": "3.1.2",
"json5": "2.2.2",
Expand Down Expand Up @@ -127,7 +129,11 @@
],
"setupFilesAfterEnv": [
"<rootDir>/jest.setup.js"
]
],
"moduleNameMapper": {
"\\.(css|less|scss)$": "<rootDir>/src/__mocks__/styleMock.js"
},
"transformIgnorePatterns": []
},
"scripts": {
"clean": "rm -rf node_modules yarn.lock",
Expand Down
1 change: 1 addition & 0 deletions src/__mocks__/styleMock.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = {};
7 changes: 6 additions & 1 deletion src/components/Accordion/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ const Accordion: React.FC<AccordionProps> = ({
const [expandedHeight, setExpandedHeight] = useState(0);
const docsExpander = useRef<HTMLElement>(null);

let pathName = '';
if (typeof window !== 'undefined') {
pathName = window.location.pathname;
}

useEffect(() => {
const expander = docsExpander.current;

Expand Down Expand Up @@ -62,7 +67,7 @@ const Accordion: React.FC<AccordionProps> = ({

const anchor = createElement(
'a',
{ href: window.location.pathname + '#' + headingId },
{ href: pathName + '#' + headingId },
expanderTitle
);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import Layout from '../components/Layout';
import Layout from '../Layout';
import styled from '@emotion/styled';
import { Grid } from '@theme-ui/components';
import { useEffect, useRef, useState } from 'react';
import MetaContent from '../components/Page/metaContent';
import { Container } from '../components/Container';
import { Card, CardDetail, CardGraphic } from '../components/Card';
import MetaContent from '../Page/metaContent';
import { Container } from '../Container';
import { Card, CardDetail, CardGraphic } from '../Card';
import {
filterOptionsByName,
filterMetadataByOption
} from '../utils/filter-data';
} from '../../utils/filter-data';
import {
getChapterDirectory,
getProductDirectory,
isProductRoot
} from '../utils/getLocalDirectory';
} from '../../utils/getLocalDirectory';

const H3 = styled.h3`
margin-top: 0.375rem;
Expand All @@ -34,7 +34,6 @@ function ChooseFilterPage({
// "url" cannot be a CFP prop for legacy reasons
let url = address;
const [_, setHref] = useState('https://docs.amplify.aws');
const [menuIsOpen, setMenuIsOpen] = useState(false);
const footerRef = useRef(null);

useEffect(() => {
Expand Down Expand Up @@ -125,7 +124,4 @@ function ChooseFilterPage({
);
}

ChooseFilterPage.getInitialProps = (initialProps) => {
return initialProps.query;
};
export default ChooseFilterPage;
2 changes: 1 addition & 1 deletion src/components/FeatureFlags/feature-flags.json
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,7 @@
]
},
"enableDartNullSafety": {
"description": "Generate Dart models with null safety for Flutter applications using DataStore. Refer to https://docs.amplify.aws/lib/project-setup/null-safety/q/platform/flutter for more information",
"description": "Generate Dart models with null safety for Flutter applications using DataStore.",
"type": "Feature",
"valueType": "Boolean",
"versionAdded": "5.1.0",
Expand Down
11 changes: 11 additions & 0 deletions src/components/FeaturesGrid/__tests__/FeaturesGrid.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,17 @@ import * as React from 'react';
import { render, screen } from '@testing-library/react';
import FeaturesGrid from '../index';

jest.mock('next/router', () => ({
useRouter() {
return {
route: '/',
pathname: '',
query: '',
asPath: ''
};
}
}));

describe('FeaturesGrid', () => {
const featureSections = [
'Authentication',
Expand Down
35 changes: 22 additions & 13 deletions src/components/FeaturesGrid/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,26 +25,35 @@ export default function FeaturesGrid() {
</p>
</CardDetail>
</Card>
<Card href="/lib/storage/getting-started" className="border-radius">
<CardGraphic alt="" src="/assets/features/storage.svg" />
<Card href="/cli/graphql/overview/" className="border-radius">
<CardGraphic alt="" src="/assets/features/api.svg" />
<CardDetail>
<h4>Storage</h4>
<h4>
GraphQL API{' '}
<sup
style={{
background: 'var(--color-orange-hv)',
padding: '4px 6px',
color: 'white',
borderRadius: 16
}}
>
Supports AWS CDK
</sup>
</h4>
<p>
A simple mechanism for managing user content in public,
protected or private storage
Easy and secure solution to access your backend data with
support for real-time updates using GraphQL
</p>
</CardDetail>
</Card>
<Card
href="/lib/graphqlapi/getting-started"
className="border-radius"
>
<CardGraphic alt="" src="/assets/features/api.svg" />
<Card href="/lib/storage/getting-started" className="border-radius">
<CardGraphic alt="" src="/assets/features/storage.svg" />
<CardDetail>
<h4>GraphQL API</h4>
<h4>Storage</h4>
<p>
Easy and secure solution to access your backend data with
support for real-time updates using GraphQL
A simple mechanism for managing user content in public,
protected or private storage
</p>
</CardDetail>
</Card>
Expand Down
3 changes: 1 addition & 2 deletions src/components/FilterChildren/index.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { useRouter } from 'next/router';

export default function FilterChildren({ children }) {
export default function FilterChildren({ children, filterKey = '' }) {
const router = useRouter();

let filterKey = '';
if ('platform' in router.query) {
filterKey = router.query.platform as string;
} else if ('integration' in router.query) {
Expand Down
4 changes: 3 additions & 1 deletion src/components/Fragments/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ export default function Fragments({ fragments }) {
let frontmatter: MdxFrontmatterType;

const { state, dispatch } = useLastUpdatedDatesContext();
let filterKey = '';

for (const key in fragments) {
if (!filterKey) filterKey = key;
const fragment = fragments[key]([]);
frontmatter = fragment.props.frontmatter;

Expand All @@ -29,5 +31,5 @@ export default function Fragments({ fragments }) {
children.push(<div key={key}>{fragment}</div>);
}

return <FilterChildren>{children}</FilterChildren>;
return <FilterChildren filterKey={filterKey}>{children}</FilterChildren>;
}
2 changes: 1 addition & 1 deletion src/components/Hero/styles.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import styled from "@emotion/styled";
import styled from '@emotion/styled';

export const Hero = styled.div`
display: flex;
Expand Down
49 changes: 38 additions & 11 deletions src/components/InternalLink/__tests__/InternalLink.test.tsx
Original file line number Diff line number Diff line change
@@ -1,28 +1,43 @@
import * as React from 'react';
import { render, screen } from '@testing-library/react';
import InternalLink from '../index';
import { PageContext } from '../../Page';

const localStorageMock = jest.spyOn(
require('../../../utils/parseLocalStorage'),
'parseLocalStorage'
);
localStorageMock.mockReturnValue({
const pageContext = {
platform: 'js',
integration: 'js',
framework: 'js'
});
};

jest.mock('next/router', () => ({
useRouter() {
return {
route: '/',
pathname: '',
query: '',
asPath: ''
};
}
}));
describe('InternalLink', () => {
it('should render the InternalLink component', async () => {
render(<InternalLink href="/lib/auth">Internal Link</InternalLink>);
render(
<PageContext.Provider value={pageContext}>
<InternalLink href="/lib/auth">Internal Link</InternalLink>
</PageContext.Provider>
);

const linkNode = await screen.findByText('Internal Link');
expect(linkNode).toBeInTheDocument();
});

it('should add the platform to the link', async () => {
const href = '/lib/libFile';
render(<InternalLink href={href}>Internal Link</InternalLink>);
render(
<PageContext.Provider value={pageContext}>
<InternalLink href={href}>Internal Link</InternalLink>
</PageContext.Provider>
);

const linkNode = await screen.findByText('Internal Link');
const linkHref = linkNode.href;
Expand All @@ -31,7 +46,11 @@ describe('InternalLink', () => {

it('should add the integration to the link', async () => {
const href = '/start/startFile';
render(<InternalLink href={href}>Internal Link</InternalLink>);
render(
<PageContext.Provider value={pageContext}>
<InternalLink href={href}>Internal Link</InternalLink>
</PageContext.Provider>
);

const linkNode = await screen.findByText('Internal Link');
const linkHref = linkNode.href;
Expand All @@ -40,7 +59,11 @@ describe('InternalLink', () => {

it('should add the framework to the link', async () => {
const href = '/ui/uiFile';
render(<InternalLink href={href}>Internal Link</InternalLink>);
render(
<PageContext.Provider value={pageContext}>
<InternalLink href={href}>Internal Link</InternalLink>
</PageContext.Provider>
);

const linkNode = await screen.findByText('Internal Link');
const linkHref = linkNode.href;
Expand All @@ -49,7 +72,11 @@ describe('InternalLink', () => {

it('should not change the href if the platform already exists', async () => {
const href = '/lib/libFile/q/platform/js';
render(<InternalLink href={href}>Internal Link</InternalLink>);
render(
<PageContext.Provider value={pageContext}>
<InternalLink href={href}>Internal Link</InternalLink>
</PageContext.Provider>
);

const expectedHref = `http://localhost${href}`;
const linkNode = await screen.findByText('Internal Link');
Expand Down
8 changes: 5 additions & 3 deletions src/components/InternalLink/index.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import Link from 'next/link';
import { useRouter } from 'next/router';
import { parseLocalStorage } from '../../utils/parseLocalStorage';
import { useContext } from 'react';
import { PageContext } from '../Page';

export default function InternalLink({ href, children }) {
const router = useRouter();
const filterKeys = useContext(PageContext);

let filterKind = '';
if (href.startsWith('/cli') || href.startsWith('/console')) {
filterKind = '';
Expand All @@ -20,7 +24,6 @@ export default function InternalLink({ href, children }) {

if (filterKind != '') {
if (!href.includes(`/q/${filterKind}/`)) {
const filterKeys = parseLocalStorage('filterKeys', {});
if (filterKind in filterKeys) {
const filterKey = filterKeys[filterKind];
if (href.includes('#')) {
Expand All @@ -34,7 +37,6 @@ export default function InternalLink({ href, children }) {
}

if (href[0] === '#') {
const router = useRouter();
const prevPath = router.asPath.split('#')[0];
href = prevPath + href;
}
Expand Down
Loading

0 comments on commit 85ae718

Please sign in to comment.