Skip to content

Commit 926f279

Browse files
authored
Merge pull request #683 from lsst-epo/revert_port_change
Revert port change
2 parents 0817e29 + 3ded956 commit 926f279

File tree

81 files changed

+60681
-650
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+60681
-650
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
# testing
77
/coverage
8+
/cypress/screenshots
89

910
# next.js
1011
/.next/
@@ -37,4 +38,4 @@ env files
3738
.vscode
3839

3940
# storybook
40-
/storybook-static/*
41+
/storybook-static/*

app/[locale]/[...uriSegments]/page.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,10 @@ const pickFeaturedImage = async (
4343
};
4444

4545
export async function generateMetadata(
46-
{ params: { locale, uriSegments }, searchParams = {} }: UriSegmentProps,
46+
{
47+
params: { locale, uriSegments },
48+
searchParams = {},
49+
}: WithSearchParams<UriSegmentProps>,
4750
parent: ResolvingMetadata
4851
): Promise<Metadata> {
4952
const uri = uriSegments.join("/");
@@ -109,10 +112,9 @@ const sectionMap = {
109112
staffProfiles: StaffPageTemplate,
110113
};
111114

112-
const UriSegmentsPage: FunctionComponent<UriSegmentProps> = async ({
113-
params: { locale, uriSegments },
114-
searchParams,
115-
}) => {
115+
const UriSegmentsPage: FunctionComponent<
116+
WithSearchParams<UriSegmentProps>
117+
> = async ({ params: { locale, uriSegments }, searchParams }) => {
116118
const uri = uriSegments.join("/");
117119
let previewToken: string | undefined;
118120

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import { FunctionComponent, PropsWithChildren } from "react";
2+
import { getAssetBreadcrumb, getRecentAssets } from "@/lib/api/galleries/asset";
3+
import Container from "@rubin-epo/epo-react-lib/Container";
4+
import Stack from "@rubin-epo/epo-react-lib/Stack";
5+
import Breadcrumbs from "@/components/page/Breadcrumbs";
6+
import BackButton from "@/components/molecules/BackButton";
7+
import { addLocaleUriSegment, useTranslation } from "@/lib/i18n";
8+
9+
export async function generateStaticParams({
10+
params: { locale, gallery },
11+
}: GalleryProps) {
12+
return getRecentAssets(locale, gallery);
13+
}
14+
15+
const AssetLayout: FunctionComponent<
16+
PropsWithChildren<GalleryAssetProps>
17+
> = async ({ children, params: { locale, gallery, asset } }) => {
18+
const { t } = await useTranslation(locale);
19+
const breadcrumbs = await getAssetBreadcrumb({ locale, gallery, asset });
20+
21+
const parentPath = addLocaleUriSegment(locale, `/gallery/${gallery}`);
22+
23+
return (
24+
<>
25+
<Breadcrumbs breadcrumbs={breadcrumbs} />
26+
<Container width="wide">
27+
<Stack>
28+
{children}
29+
<BackButton
30+
fallback={parentPath}
31+
matches={parentPath}
32+
data-cy="back-to-gallery"
33+
>
34+
{t("gallery.back-to-gallery")}
35+
</BackButton>
36+
</Stack>
37+
</Container>
38+
</>
39+
);
40+
};
41+
42+
export default AssetLayout;
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
import { ComponentType, FunctionComponent } from "react";
2+
import { Metadata } from "next";
3+
import { notFound } from "next/navigation";
4+
import { getAssetFromGallery } from "@/lib/api/galleries/asset";
5+
import { assetTitle, assetToPageMetadata } from "@/lib/api/canto/metadata";
6+
import { SupportedCantoAssetScheme } from "@/lib/api/galleries/schema";
7+
import CantoFigure from "@/components/organisms/gallery/CantoFigure";
8+
import SingleMediaAsset from "@/components/templates/SingleMediaAsset";
9+
import ImageSizes from "@/components/organisms/gallery/metadata/Sizes";
10+
import AssetTags from "@/components/organisms/gallery/metadata/Tags";
11+
import CantoImage from "@/components/organisms/gallery/CantoImage";
12+
import CantoVideo from "@/components/organisms/gallery/CantoVideo";
13+
import AssetMetadata from "@/components/organisms/gallery/metadata/Asset";
14+
15+
export async function generateMetadata({
16+
params: { locale, gallery, asset: id },
17+
}: GalleryAssetProps): Promise<Metadata> {
18+
const asset = await getAssetFromGallery(gallery, id, locale);
19+
20+
if (!asset) {
21+
notFound();
22+
}
23+
24+
return assetToPageMetadata(asset, locale);
25+
}
26+
27+
const assetComponent: Record<SupportedCantoAssetScheme, ComponentType> = {
28+
image: CantoImage,
29+
video: CantoVideo,
30+
};
31+
32+
const GalleryAsset: FunctionComponent<GalleryAssetProps> = async ({
33+
params: { locale, gallery, asset: id },
34+
}) => {
35+
const asset = await getAssetFromGallery(gallery, id, locale);
36+
37+
if (!asset) {
38+
notFound();
39+
}
40+
41+
const {
42+
name,
43+
width,
44+
height,
45+
url,
46+
scheme,
47+
tag,
48+
additional,
49+
size,
50+
default: { DateCreated },
51+
} = asset;
52+
53+
const { directUrlPreview, directUrlOriginal } = url;
54+
55+
const validTagsOnly =
56+
tag?.filter((maybeTag): maybeTag is string => {
57+
if (typeof maybeTag === "string") {
58+
return maybeTag.toLowerCase() !== "untagged";
59+
}
60+
return false;
61+
}) || [];
62+
63+
const links: Record<SupportedCantoAssetScheme, JSX.Element> = {
64+
image: (
65+
<>
66+
<ImageSizes
67+
width={parseInt(width)}
68+
height={parseInt(height)}
69+
{...{ directUrlPreview, directUrlOriginal }}
70+
/>
71+
<AssetTags tags={validTagsOnly} parentUri={`/gallery/${gallery}`} />
72+
</>
73+
),
74+
video: <AssetTags tags={validTagsOnly} parentUri={`/gallery/${gallery}`} />,
75+
};
76+
77+
const Asset = assetComponent[scheme];
78+
79+
return (
80+
<SingleMediaAsset
81+
title={assetTitle(additional, locale) || name}
82+
asset={
83+
<CantoFigure
84+
downloadUrl={directUrlOriginal}
85+
asset={<Asset {...{ asset, locale }} />}
86+
{...{ locale, additional, width, height, gallery, id, name }}
87+
/>
88+
}
89+
metadataBlocks={
90+
<AssetMetadata
91+
size={parseInt(size)}
92+
dateCreated={new Date(DateCreated)}
93+
{...{ scheme, width, height }}
94+
/>
95+
}
96+
metadataLinks={links[scheme]}
97+
/>
98+
);
99+
};
100+
101+
export default GalleryAsset;
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import { FunctionComponent, PropsWithChildren } from "react";
2+
import { Metadata } from "next";
3+
import { notFound } from "next/navigation";
4+
import { getAllGalleries, getGalleryMetadata } from "@/lib/api/galleries";
5+
import { assetToOpenGraphImage } from "@/lib/api/canto/metadata";
6+
7+
export const dynamicParams = false;
8+
9+
export async function generateStaticParams({
10+
params: { locale },
11+
}: LocaleProps) {
12+
return getAllGalleries(locale);
13+
}
14+
15+
export async function generateMetadata({
16+
params: { locale, gallery },
17+
}: GalleryProps): Promise<Metadata> {
18+
const metadata = await getGalleryMetadata(gallery, locale);
19+
20+
if (!metadata) {
21+
notFound();
22+
}
23+
24+
const { title, description, representativeImage } = metadata;
25+
26+
return {
27+
title,
28+
description,
29+
openGraph: {
30+
images: representativeImage
31+
? assetToOpenGraphImage(representativeImage, locale)
32+
: undefined,
33+
},
34+
};
35+
}
36+
37+
export const GalleryLayout: FunctionComponent<PropsWithChildren> = ({
38+
children,
39+
}) => {
40+
return <>{children}</>;
41+
};
42+
43+
export default GalleryLayout;
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import { FunctionComponent } from "react";
2+
import Container from "@rubin-epo/epo-react-lib/Container";
3+
import Stack from "@rubin-epo/epo-react-lib/Stack";
4+
import { useTranslation } from "@/lib/i18n";
5+
import { getGalleryMetadata } from "@/lib/api/galleries";
6+
import {
7+
GalleryFilterSchema,
8+
SupportedCantoScheme,
9+
} from "@/lib/api/galleries/schema";
10+
import FilterDropdownList from "@/components/molecules/FilterDropdownList";
11+
import PreviewGrid from "@/components/organisms/gallery/PreviewGrid";
12+
import Filters from "@/components/organisms/Filters";
13+
import UniqueIconComposer from "@/components/svg/UniqueIconComposer";
14+
15+
const Gallery: FunctionComponent<WithSearchParams<GalleryProps>> = async ({
16+
params: { locale, gallery },
17+
searchParams = {},
18+
}) => {
19+
const metadata = await getGalleryMetadata(gallery, locale);
20+
const { t } = await useTranslation(locale);
21+
22+
const filters = GalleryFilterSchema.parse(searchParams);
23+
24+
const filterOptions = [
25+
...SupportedCantoScheme.options.map((value) => {
26+
return { name: t(`gallery.filters.${value}`), query: "type", value };
27+
}),
28+
];
29+
30+
return (
31+
<>
32+
<Filters width="wide">
33+
<FilterDropdownList
34+
name="Filter"
35+
filters={filterOptions}
36+
icon={<UniqueIconComposer icon="Filter" />}
37+
/>
38+
</Filters>
39+
<Container width="wide">
40+
<Stack space="var(--size-spacing-s)">
41+
<h1>{metadata?.title}</h1>
42+
<PreviewGrid {...{ locale, gallery, filters }} />
43+
</Stack>
44+
</Container>
45+
</>
46+
);
47+
};
48+
49+
export default Gallery;

app/[locale]/layout.tsx

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { FunctionComponent, PropsWithChildren, Suspense } from "react";
22
import { Metadata } from "next";
3+
import { notFound } from "next/navigation";
34
import { GoogleOAuthProvider } from "@react-oauth/google";
45
import { GlobalStyles } from "@rubin-epo/epo-react-lib/styles";
56
import { getGlobalData } from "@/lib/api/globals";
@@ -10,7 +11,7 @@ import I18NextClientProvider from "@/contexts/i18next";
1011
import { AuthenticationContextProvider } from "@/contexts/Authentication";
1112
import PageWrapper from "@/components/organisms/PageWrapper";
1213
import RootScripts from "./scripts";
13-
import { notFound } from "next/navigation";
14+
import { HistoryProvider } from "@/contexts/History";
1415

1516
const GOOGLE_APP_ID = process.env.NEXT_PUBLIC_GOOGLE_APP_ID || "";
1617

@@ -80,14 +81,16 @@ const LocaleLayout: FunctionComponent<PropsWithChildren<LocaleProps>> = async ({
8081
<body className={SourceSansPro.variable}>
8182
<I18NextClientProvider {...{ locale }}>
8283
<Suspense>
83-
<AuthenticationContextProvider>
84-
<StyledComponentsRegistry>
85-
<GoogleOAuthProvider clientId={GOOGLE_APP_ID}>
86-
<GlobalStyles />
87-
<PageWrapper {...{ locale }}>{children}</PageWrapper>
88-
</GoogleOAuthProvider>
89-
</StyledComponentsRegistry>
90-
</AuthenticationContextProvider>
84+
<HistoryProvider>
85+
<AuthenticationContextProvider>
86+
<StyledComponentsRegistry>
87+
<GoogleOAuthProvider clientId={GOOGLE_APP_ID}>
88+
<GlobalStyles />
89+
<PageWrapper {...{ locale }}>{children}</PageWrapper>
90+
</GoogleOAuthProvider>
91+
</StyledComponentsRegistry>
92+
</AuthenticationContextProvider>
93+
</HistoryProvider>
9194
</Suspense>
9295
</I18NextClientProvider>
9396
<RootScripts {...{ locale }} />

app/[locale]/page.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import HomePageTemplate from "@/templates/HomePage";
88
export async function generateMetadata({
99
params: { locale },
1010
searchParams = {},
11-
}: LocaleProps): Promise<Metadata> {
11+
}: WithSearchParams<LocaleProps>): Promise<Metadata> {
1212
let previewToken: string | undefined;
1313

1414
if (draftMode().isEnabled) {
@@ -24,7 +24,7 @@ export async function generateMetadata({
2424
return { title, description };
2525
}
2626

27-
const RootPage: FunctionComponent<LocaleProps> = async ({
27+
const RootPage: FunctionComponent<WithSearchParams<LocaleProps>> = async ({
2828
params: { locale },
2929
searchParams = {},
3030
}) => {

0 commit comments

Comments
 (0)