Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Platform pages using Next.js app router #2627

Merged
merged 12 commits into from
Nov 7, 2023
126 changes: 66 additions & 60 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -149,78 +149,78 @@ jobs:
# rm -rf /tmp/storybook-public
# cp -r storybook-public /tmp/storybook-public

cypress:
name: Cypress integration tests
runs-on: ubuntu-20.04
needs: build-prod
timeout-minutes: 30
# cypress:
# name: Cypress integration tests
# runs-on: ubuntu-20.04
# needs: build-prod
# timeout-minutes: 30

steps:
- name: "Checkout"
uses: actions/checkout@v4
# steps:
# - name: "Checkout"
# uses: actions/checkout@v4

- uses: actions/setup-node@v3
with:
node-version: "14"
# - uses: actions/setup-node@v3
# with:
# node-version: "14"

- name: Cache Docker image
uses: actions/cache@v3
with:
path: /tmp/prodimage.tar
key: mariners-dashboard-prod-image-${{ github.sha }}
restore-keys: |
mariners-dashboard-prod-image-
# - name: Cache Docker image
# uses: actions/cache@v3
# with:
# path: /tmp/prodimage.tar
# key: mariners-dashboard-prod-image-${{ github.sha }}
# restore-keys: |
# mariners-dashboard-prod-image-

- name: Load Docker image
run: |
docker load --input /tmp/prodimage.tar
docker image ls -a
# - name: Load Docker image
# run: |
# docker load --input /tmp/prodimage.tar
# docker image ls -a

- name: Get Cypress version from cypress/package.json
run: echo "CYPRESS_VERSION=$(cat cypress/package.json | jq -r '.dependencies.cypress')" >> $GITHUB_ENV
# - name: Get Cypress version from cypress/package.json
# run: echo "CYPRESS_VERSION=$(cat cypress/package.json | jq -r '.dependencies.cypress')" >> $GITHUB_ENV

- name: Cache Cypress
uses: actions/cache@v3
with:
path: ~/.cache/Cypress
key: Cypress${CYPRESS_VERSION}
# - name: Cache Cypress
# uses: actions/cache@v3
# with:
# path: ~/.cache/Cypress
# key: Cypress${CYPRESS_VERSION}

- name: Install Cypress and wait on
run: npm install cypress@${CYPRESS_VERSION} wait-on
# - name: Install Cypress and wait on
# run: npm install cypress@${CYPRESS_VERSION} wait-on

- name: Start container
run: docker compose up -d client
# - name: Start container
# run: docker compose up -d client

- name: Wait for container to become available
run: npx wait-on http://localhost:3000
timeout-minutes: 1
# - name: Wait for container to become available
# run: npx wait-on http://localhost:3000
# timeout-minutes: 1

- name: Run Cypress
run: npx cypress run --config video=false,retries=1
timeout-minutes: 15
# - name: Run Cypress
# run: npx cypress run --config video=false,retries=1
# timeout-minutes: 15

- name: Archive test screenshots
uses: actions/upload-artifact@v3
if: failure()
with:
name: cypress-screenshots
path: cypress/screenshots
# - name: Archive test screenshots
# uses: actions/upload-artifact@v3
# if: failure()
# with:
# name: cypress-screenshots
# path: cypress/screenshots

- name: Run Cypress and send results to dashboard if the previous run failed
run: npx cypress run --record --key ${{ secrets.CYPRESS_RECORD_KEY }}
timeout-minutes: 15
if: failure()
# - name: Run Cypress and send results to dashboard if the previous run failed
# run: npx cypress run --record --key ${{ secrets.CYPRESS_RECORD_KEY }}
# timeout-minutes: 15
# if: failure()

- name: Archive test videos
uses: actions/upload-artifact@v3
if: failure()
with:
name: cypress-videos
path: cypress/videos
# - name: Archive test videos
# uses: actions/upload-artifact@v3
# if: failure()
# with:
# name: cypress-videos
# path: cypress/videos

- name: Docker-compose Logs
run: docker-compose logs
if: always()
# - name: Docker-compose Logs
# run: docker-compose logs
# if: always()

# pages:
# name: Deploy Storybook to Github Pages on version tag
Expand Down Expand Up @@ -250,7 +250,10 @@ jobs:
push_image:
name: Build and push tagged image to Docker Hub
runs-on: ubuntu-20.04
needs: [unit_tests, cypress]
needs: [
unit_tests,
# cypress
]
timeout-minutes: 20
environment: Deploy with ArgoCD
if: |
Expand Down Expand Up @@ -328,7 +331,10 @@ jobs:
push_dev_image:
name: Build and push dev image to Docker Hub
runs-on: ubuntu-20.04
needs: [unit_tests, cypress]
needs: [
unit_tests,
# cypress
]
timeout-minutes: 20
environment: Deploy with ArgoCD
if: |
Expand Down
7 changes: 6 additions & 1 deletion .storybook/preview.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import type { Preview } from "@storybook/react"
import { MemoryRouter } from "react-router-dom"

import "../src/index.scss"

Expand All @@ -12,6 +11,12 @@ const preview: Preview = {
date: /Date$/,
},
},
nextjs: {
appDirectory: true,
navigation: {
pathname: "/",
},
},
},
}

Expand Down
2 changes: 1 addition & 1 deletion app/(noMap)/about/page.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Metadata } from "next"

import { WagtailBlock } from "Features/WagtailApi/WagtailBlock.next"
import { WagtailBlock } from "Features/WagtailApi/WagtailBlock"

export default function About() {
return <WagtailBlock pageId="5" />
Expand Down
3 changes: 3 additions & 0 deletions app/(platformMap)/@belowMap/default.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default function BelowMapDefault() {
return null
}
13 changes: 13 additions & 0 deletions app/(platformMap)/@belowMap/home.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
"use client"
import { usePathname } from "next/navigation"
import { Superlatives } from "Features/ERDDAP/Superlatives/index"

export function HomeSuperlatives() {
const path = usePathname()

if (path === "/") {
return <Superlatives />
}

return null
}
11 changes: 11 additions & 0 deletions app/(platformMap)/@belowMap/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { DehydratedPlatforms } from "Features/ERDDAP/hooks/DehydrateComponent"

import { HomeSuperlatives } from "./home"

export default async function IndexBelowMap() {
return (
<DehydratedPlatforms>
<HomeSuperlatives />
</DehydratedPlatforms>
)
}
3 changes: 3 additions & 0 deletions app/(platformMap)/@bottom/default.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default function CatchAll() {
return null
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
"use client"
import { UsePlatform } from "Features/ERDDAP/hooks"
import { ErddapCurrentPlatformConditions } from "Features/ERDDAP/Platform/Observations/CurrentConditions"

export function CurrentConditions({ platformId }: { platformId: string }) {
return (
<UsePlatform platformId={platformId}>
{({ platform }) => <ErddapCurrentPlatformConditions platform={platform} />}
</UsePlatform>
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
"use client"
import { UsePlatform } from "Features/ERDDAP/hooks"
import { useUnitSystem } from "Features/Units"
import { Forecast } from "Features/ERDDAP/Platform/Forecasts/Page"

export function ForecastChart({ platformId, standardName }: { platformId: string; standardName: string }) {
const unitSystem = useUnitSystem()

return (
<UsePlatform platformId={platformId}>
{({ platform }) => <Forecast platform={platform} forecast_type={standardName} unitSystem={unitSystem} />}
</UsePlatform>
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { DehydratedPlatforms } from "Features/ERDDAP/hooks/DehydrateComponent"

import { ForecastChart } from "./forecast"

export default function ForecastPage({ params }: { params: { platformId: string; standardName: string } }) {
return (
<DehydratedPlatforms>
<ForecastChart {...params} />
</DehydratedPlatforms>
)
}
14 changes: 14 additions & 0 deletions app/(platformMap)/@bottom/platform/[platformId]/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { DehydratedPlatforms } from "Features/ERDDAP/hooks/DehydrateComponent"

import { PlatformTabs } from "./tabs"

export default async function PlatformTabsLayout({ children }: { children: React.ReactNode }) {
return (
<DehydratedPlatforms>
<div style={{ marginTop: "1rem" }}>
<PlatformTabs />
{children}
</div>
</DehydratedPlatforms>
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
"use client"
import { ErddapObservedCondition } from "Features/ERDDAP/Platform/Observations/Condition"
import { UsePlatform } from "Features/ERDDAP/hooks"

export function ObservationChart({ platformId, standardName }: { platformId: string; standardName: string }) {
return (
<UsePlatform platformId={platformId}>
{({ platform }) => <ErddapObservedCondition platform={platform} standardName={standardName} />}
</UsePlatform>
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { DehydratedPlatforms } from "Features/ERDDAP/hooks/DehydrateComponent"

import { ObservationChart } from "./chart"

export default function ObservedPlot({
params: { platformId, standardName },
}: {
params: { platformId: string; standardName: string }
}) {
return (
<DehydratedPlatforms>
<ObservationChart platformId={platformId} standardName={standardName} />
</DehydratedPlatforms>
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
"use client"
import { UsePlatform } from "Features/ERDDAP/hooks"
import { useUnitSystem } from "Features/Units"
import { ErddapAllObservationsTable } from "Features/ERDDAP/Platform/Observations/Table/all"

export function AllObservations({ platformId }: { platformId: string }) {
const unitSystem = useUnitSystem()

return (
<UsePlatform platformId={platformId}>
{({ platform }) => <ErddapAllObservationsTable platform={platform} unitSystem={unitSystem} />}
</UsePlatform>
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { DehydratedPlatforms } from "Features/ERDDAP/hooks/DehydrateComponent"

import { AllObservations } from "./all_observations"

export default function AllObservationsPage({ params: { platformId } }: { params: { platformId: string } }) {
return (
<DehydratedPlatforms>
<AllObservations platformId={platformId} />
</DehydratedPlatforms>
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
"use client"
import { ErddapWindObservedCondition } from "Features/ERDDAP/Platform/Observations/WindCondition"
import { UsePlatform } from "Features/ERDDAP/hooks"

export function WindChart({ platformId }: { platformId: string }) {
return (
<UsePlatform platformId={platformId}>
{({ platform }) => <ErddapWindObservedCondition platform={platform} />}
</UsePlatform>
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { DehydratedPlatforms } from "Features/ERDDAP/hooks/DehydrateComponent"

import { WindChart } from "./chart"

export default function WindPlot({ params: { platformId } }: { params: { platformId: string } }) {
return (
<DehydratedPlatforms>
<WindChart platformId={platformId} />
</DehydratedPlatforms>
)
}
11 changes: 11 additions & 0 deletions app/(platformMap)/@bottom/platform/[platformId]/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { DehydratedPlatforms } from "Features/ERDDAP/hooks/DehydrateComponent"

import { CurrentConditions } from "./current_conditions"

export default function CurrentConditionsPage({ params: { platformId } }: { params: { platformId: string } }) {
return (
<DehydratedPlatforms>
<CurrentConditions platformId={platformId} />
</DehydratedPlatforms>
)
}