Skip to content

Commit

Permalink
Remove _gcn pathless layout route
Browse files Browse the repository at this point in the history
It's no longer necessary since we are no longer housing the ACROSS
portal. This makes filenames easier to read.
  • Loading branch information
lpsinger committed Mar 20, 2024
1 parent 1760c22 commit 18ebf5d
Show file tree
Hide file tree
Showing 197 changed files with 242 additions and 266 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# General Coordinates Network Web Site

![GCN diagram](app/routes/_gcn._index/hero/center-cropped.jpg)
![GCN diagram](app/routes/_index/hero/center-cropped.jpg)

[![Node.js CI status](https://github.com/nasa-gcn/gcn.nasa.gov/workflows/Node.js%20CI/badge.svg)](https://github.com/nasa-gcn/gcn.nasa.gov/actions)
[![codecov](https://codecov.io/gh/nasa-gcn/gcn.nasa.gov/branch/main/graph/badge.svg?token=qBUHelfQxL)](https://codecov.io/gh/nasa-gcn/gcn.nasa.gov)
Expand Down
2 changes: 1 addition & 1 deletion __tests__/circulars.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
formatCircularText,
parseEventFromSubject,
subjectIsValid,
} from '../app/routes/_gcn.circulars/circulars.lib'
} from '../app/routes/circulars/circulars.lib'

describe('formatAuthor', () => {
const email = '[email protected]'
Expand Down
2 changes: 1 addition & 1 deletion __tests__/components/AnnounceBanner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { fireEvent, render, screen } from '@testing-library/react'

import AnnounceBanner, {
AnnouncementEvent,
} from '../../app/routes/_gcn/AnnounceBanner'
} from '../../app/root/AnnounceBanner'

const linkString = 'Register'

Expand Down
5 changes: 1 addition & 4 deletions __tests__/synonyms.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@ import type { AWSError, DynamoDB } from 'aws-sdk'
import * as awsSDKMock from 'aws-sdk-mock'
import crypto from 'crypto'

import {
createSynonyms,
putSynonyms,
} from '~/routes/_gcn.synonyms/synonyms.server'
import { createSynonyms, putSynonyms } from '~/routes/synonyms/synonyms.server'

jest.mock('@architect/functions')

Expand Down
2 changes: 1 addition & 1 deletion app/components/CircularsKeywords.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { Link } from '@remix-run/react'
import {
emailAutoReplyChecklist,
validSubjectKeywords,
} from '~/routes/_gcn.circulars/circulars.lib'
} from '~/routes/circulars/circulars.lib'

export function CircularsKeywords() {
return (
Expand Down
2 changes: 1 addition & 1 deletion app/components/CredentialCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
import { useRef } from 'react'

import TimeAgo from './TimeAgo'
import type { RedactedClientCredential } from '~/routes/_gcn.user.credentials/client_credentials.server'
import type { RedactedClientCredential } from '~/routes/user.credentials/client_credentials.server'

export default function CredentialCard({
name,
Expand Down
2 changes: 1 addition & 1 deletion app/components/NewCredentialForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { useState } from 'react'
import { ReCAPTCHA, verifyRecaptcha } from './ReCAPTCHA'
import { getFormDataString } from '~/lib/utils'
import { useRecaptchaSiteKey } from '~/root'
import { ClientCredentialVendingMachine } from '~/routes/_gcn.user.credentials/client_credentials.server'
import { ClientCredentialVendingMachine } from '~/routes/user.credentials/client_credentials.server'

export async function loader(args: LoaderFunctionArgs) {
return await handleCredentialLoader(args)
Expand Down
4 changes: 2 additions & 2 deletions app/email-incoming/circulars/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
formatAuthor,
parseEventFromSubject,
subjectIsValid,
} from '../../routes/_gcn.circulars/circulars.lib'
} from '../../routes/circulars/circulars.lib'
import { createEmailIncomingMessageHandler } from '../handler'
import {
getFromAddress,
Expand All @@ -26,7 +26,7 @@ import {
} from '~/lib/cognito.server'
import { sendEmail } from '~/lib/email.server'
import { hostname, origin } from '~/lib/env.server'
import { group, putRaw } from '~/routes/_gcn.circulars/circulars.server'
import { group, putRaw } from '~/routes/circulars/circulars.server'

interface UserData {
email: string
Expand Down
2 changes: 1 addition & 1 deletion app/email-incoming/circulars/parse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import type { AddressObject, Source } from 'mailparser'
import { simpleParser } from 'mailparser'
import addressparser from 'nodemailer/lib/addressparser'

import type { SubmittedHow } from '~/routes/_gcn.circulars/circulars.lib'
import type { SubmittedHow } from '~/routes/circulars/circulars.lib'

const legacyAddress = '[email protected]'
const legacyFromNameSplitter = ' via '
Expand Down
2 changes: 1 addition & 1 deletion app/lib/email.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import chunk from 'lodash/chunk'

import { hostname } from './env.server'
import { getEnvBannerHeaderAndDescription } from './utils'
import { encodeToURL } from '~/routes/_gcn.unsubscribe.$jwt/jwt.server'
import { encodeToURL } from '~/routes/unsubscribe.$jwt/jwt.server'

const client = new SESv2Client({})
// https://docs.aws.amazon.com/ses/latest/dg/quotas.html
Expand Down
2 changes: 1 addition & 1 deletion app/lib/schema-data.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { exampleSuffix, schemaSuffix } from './schema-data'
import type {
ReferencedSchema,
Schema,
} from '~/routes/_gcn.docs_._schema-browser.schema.($version).$/components'
} from '~/routes/docs_._schema-browser.schema.($version).$/components'

const GITHUB_API_TOKEN = getEnvOrDieInProduction('GITHUB_API_TOKEN')
const octokit = new Octokit({ auth: GITHUB_API_TOKEN })
Expand Down
137 changes: 131 additions & 6 deletions app/root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,27 +21,38 @@
import { cssBundleHref } from '@remix-run/css-bundle'
import type { LinksFunction, LoaderFunctionArgs } from '@remix-run/node'
import {
Link,
Links,
LiveReload,
Meta,
Outlet,
Scripts,
ScrollRestoration,
isRouteErrorResponse,
useLocation,
useNavigation,
useRouteError,
useRouteLoaderData,
} from '@remix-run/react'
import { GovBanner } from '@trussworks/react-uswds'
import {
ButtonGroup,
FormGroup,
GovBanner,
GridContainer,
} from '@trussworks/react-uswds'
import type { ReactNode } from 'react'
import TopBarProgress from 'react-topbar-progress-indicator'
import { useSpinDelay } from 'spin-delay'
import invariant from 'tiny-invariant'

import { features, getEnvOrDieInProduction, origin } from './lib/env.server'
import { DevBanner } from './root/DevBanner'
import { Title } from './root/Title'
import { getUser } from './routes/_gcn._auth/user.server'
import { moderatorGroup } from './routes/_gcn.circulars/circulars.server'
import { Footer } from './root/Footer'
import NewsBanner from './root/NewsBanner'
import { type BreadcrumbHandle, Title } from './root/Title'
import { Header } from './root/header/Header'
import { getUser } from './routes/_auth/user.server'
import { moderatorGroup } from './routes/circulars/circulars.server'

import highlightStyle from 'highlight.js/styles/github.css'
// FIXME: no top-level await, no import function
Expand Down Expand Up @@ -80,6 +91,10 @@ TopBarProgress.config({
},
})

export const handle: BreadcrumbHandle = {
breadcrumb: 'GCN',
}

export const links: LinksFunction = () => [
{
rel: 'stylesheet',
Expand Down Expand Up @@ -186,7 +201,7 @@ function Progress() {
return <>{showProgress && <TopBarProgress />}</>
}

export default function () {
function Document({ children }: { children?: ReactNode }) {
const noIndex = useHostname() !== 'gcn.nasa.gov'

return (
Expand All @@ -206,7 +221,18 @@ export default function () {
<Progress />
<GovBanner />
<DevBanner />
<Outlet />
<Header />
<NewsBanner>
New Announcement Feature, Code of Conduct, Circular Revisions. See{' '}
<Link
className="usa-link"
to="/news#new-announcement-feature-code-of-conduct-circular-revisions"
>
news and announcements
</Link>
</NewsBanner>
<main id="main-content">{children}</main>
<Footer />
<ScrollRestoration />
<Scripts />
<LiveReload />
Expand All @@ -216,3 +242,102 @@ export default function () {
</html>
)
}

function ErrorUnexpected({ children }: { children?: ReactNode }) {
return (
<Document>
<GridContainer className="usa-section">
<h1>Unexpected error {children}</h1>
<p className="usa-intro">An unexpected error occurred.</p>
<FormGroup>
<ButtonGroup>
<Link to="/" className="usa-button">
Go home
</Link>
</ButtonGroup>
</FormGroup>
</GridContainer>
</Document>
)
}

function ErrorUnauthorized() {
const url = useUrl()
return (
<Document>
<GridContainer className="usa-section">
<h1>Unauthorized</h1>
<p className="usa-intro">
We're sorry, you must log in to access the page you're looking for.
</p>
<p className="usa-paragraph">Log in to access that page, or go home.</p>
<FormGroup>
<ButtonGroup>
<Link
to={`/login?redirect=${encodeURIComponent(url)}`}
className="usa-button"
>
Log in and take me there
</Link>
<Link to="/" className="usa-button usa-button--outline">
Go home
</Link>
</ButtonGroup>
</FormGroup>
</GridContainer>
</Document>
)
}

function ErrorNotFound() {
return (
<Document>
<GridContainer className="usa-section">
<h1>Page not found</h1>
<p className="usa-intro">
We're sorry, we can't find the page you're looking for. It might have
been removed, changed its name, or is otherwise unavailable.
</p>
<p className="usa-paragraph">
Visit our homepage for helpful tools and resources, or contact us and
we'll point you in the right direction.
</p>
<FormGroup>
<ButtonGroup>
<Link to="/" className="usa-button">
Visit homepage
</Link>
<Link to="/contact" className="usa-button usa-button--outline">
Contact us
</Link>
</ButtonGroup>
</FormGroup>
</GridContainer>
</Document>
)
}

export function ErrorBoundary() {
const error = useRouteError()
if (isRouteErrorResponse(error)) {
switch (error.status) {
case 403:
return <ErrorUnauthorized />
case 404:
return <ErrorNotFound />
default:
return <ErrorUnexpected>HTTP {error.status}</ErrorUnexpected>
}
} else {
console.error(error)
return <ErrorUnexpected />
}
}

export default function () {
return (
<Document>
<Outlet />
</Document>
)
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions app/routes/_gcn._auth.login.ts → app/routes/_auth.login.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import { redirect } from '@remix-run/node'
import { generators } from 'openid-client'
import invariant from 'tiny-invariant'

import { getOpenIDClient, oidcStorage, storage } from './_gcn._auth/auth.server'
import { parseTokenSet, updateSession } from './_gcn._auth/user.server'
import { getOpenIDClient, oidcStorage, storage } from './_auth/auth.server'
import { parseTokenSet, updateSession } from './_auth/user.server'
import { origin } from '~/lib/env.server'

function ensureSameOrigin(url: string) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import type { LoaderFunction } from '@remix-run/node'
import { redirect } from '@remix-run/node'

import { getOpenIDClient } from './_gcn._auth/auth.server'
import { getOpenIDClient } from './_auth/auth.server'

export const loader: LoaderFunction = async ({ request: { url } }) => {
const client = await getOpenIDClient()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
ModalHeading,
} from '@trussworks/react-uswds'

import { storage } from './_gcn._auth/auth.server'
import { storage } from './_auth/auth.server'

export const handle: SEOHandle = {
getSitemapEntries: () => null,
Expand Down
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 18ebf5d

Please sign in to comment.