Skip to content

Commit 9a0a6d4

Browse files
committed
move layout components to @app/client
Moves <SharedLayout /> and everything that depends on it to the @app/client tree. Rationale: <SharedLayout /> needs to read process.env.T_AND_C_URL, which is a detail of the build that @app/components shouldn't know about. When environment variable injection changes with Turbopack, we'll want to limit the blast radius. The other option was passing termsAndConditionsUrl as a prop from @app/client into <SharedLayout /> everywhere we render it. But these layout components aren't logically reusable outside of their new locations in pages/ anyway, so it makes more sense to relocate them. unblocks turbopack
1 parent 20dd98a commit 9a0a6d4

File tree

23 files changed

+82
-95
lines changed

23 files changed

+82
-95
lines changed
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
import { NetworkStatus, useApolloClient } from "@apollo/client";
2+
import { H3, StandardWidth } from "@app/components";
23
import { Skeleton } from "antd";
34
import Router from "next/router";
45
import React, { useEffect } from "react";
56

67
import { SharedLayout } from "./SharedLayout";
7-
import { StandardWidth } from "./StandardWidth";
8-
import { H3 } from "./Text";
98

109
export interface RedirectProps {
1110
href: string;
Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {
44
type QueryResult,
55
useApolloClient,
66
} from "@apollo/client";
7+
import { ErrorAlert, H3, StandardWidth, Warn } from "@app/components";
78
import { companyName, projectName } from "@app/config";
89
import {
910
type SharedLayout_QueryFragment,
@@ -18,22 +19,10 @@ import Router, { useRouter } from "next/router";
1819
import * as React from "react";
1920
import { useCallback } from "react";
2021

21-
import { ErrorAlert, H3, StandardWidth, Warn } from ".";
2222
import { Redirect } from "./Redirect";
2323

2424
const { Header, Content, Footer } = Layout;
2525
const { Text } = Typography;
26-
/*
27-
* For some reason, possibly related to the interaction between
28-
* `babel-plugin-import` and https://github.com/babel/babel/pull/9766, we can't
29-
* directly export these values, but if we reference them and re-export then we
30-
* can.
31-
*
32-
* TODO: change back to `export { Row, Col, Link }` when this issue is fixed.
33-
*/
34-
const _babelHackRow = Row;
35-
const _babelHackCol = Col;
36-
export { _babelHackCol as Col, Link, _babelHackRow as Row };
3726

3827
export const contentMinHeight = "calc(100vh - 64px - 70px)";
3928

@app/client/src/pages/_error.tsx

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,12 @@
1-
import {
2-
ErrorOccurred,
3-
FourOhFour,
4-
H2,
5-
P,
6-
SharedLayout,
7-
} from "@app/components";
1+
import { ErrorOccurred, FourOhFour, H2, P } from "@app/components";
82
import { useSharedQuery } from "@app/graphql";
93
import { Alert, Col, Row } from "antd";
104
import { type NextPage } from "next";
115
import Link from "next/link";
126
import * as React from "react";
137

8+
import { SharedLayout } from "./SharedLayout";
9+
1410
const isDev = process.env.NODE_ENV !== "production";
1511

1612
interface SocialAuthErrorProps {

@app/client/src/pages/create-organization/index.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { PageHeader } from "@ant-design/pro-layout";
22
import { type ApolloError } from "@apollo/client";
3-
import { AuthRestrict, Redirect, SharedLayout } from "@app/components";
43
import {
54
type CreatedOrganizationFragment,
65
useCreateOrganizationMutation,
@@ -20,6 +19,9 @@ import { type Store } from "rc-field-form/lib/interface";
2019
import React, { useCallback, useEffect, useMemo, useState } from "react";
2120
import slugify from "slugify";
2221

22+
import { Redirect } from "../Redirect";
23+
import { AuthRestrict, SharedLayout } from "../SharedLayout";
24+
2325
const { useForm } = Form;
2426
const { Text } = Typography;
2527

@app/client/src/pages/forgot.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { UserOutlined } from "@ant-design/icons";
22
import { type ApolloError } from "@apollo/client";
3-
import { AuthRestrict, SharedLayout } from "@app/components";
43
import { useForgotPasswordMutation, useSharedQuery } from "@app/graphql";
54
import { extractError, getCodeFromError } from "@app/lib";
65
import { Alert, Button, Form, Input, type InputRef } from "antd";
@@ -9,6 +8,8 @@ import Link from "next/link";
98
import { type Store } from "rc-field-form/lib/interface";
109
import React, { useCallback, useEffect, useRef, useState } from "react";
1110

11+
import { AuthRestrict, SharedLayout } from "./SharedLayout";
12+
1213
const { useForm } = Form;
1314

1415
const ForgotPassword: NextPage = () => {

@app/client/src/pages/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import { Button, Col, Divider, Row, Typography } from "antd";
22
import * as React from "react";
33
const { Text, Title, Paragraph } = Typography;
4-
import { SharedLayout } from "@app/components";
54
import { useSharedQuery } from "@app/graphql";
65
import { type NextPage } from "next";
76

7+
import { SharedLayout } from "./SharedLayout";
8+
89
// Convenience helper
910
const Li = ({ children, ...props }: any) => (
1011
<li {...props}>

@app/client/src/pages/invitations/accept.tsx

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,5 @@
11
import { type QueryResult } from "@apollo/client";
2-
import {
3-
AuthRestrict,
4-
ButtonLink,
5-
ErrorAlert,
6-
Redirect,
7-
SharedLayout,
8-
SpinPadded,
9-
} from "@app/components";
2+
import { ButtonLink, ErrorAlert, SpinPadded } from "@app/components";
103
import {
114
type InvitationDetailQuery,
125
type InvitationDetailQueryVariables,
@@ -21,6 +14,9 @@ import Router, { type NextRouter, useRouter } from "next/router";
2114
import * as qs from "querystring";
2215
import React, { type FC } from "react";
2316

17+
import { Redirect } from "../Redirect";
18+
import { AuthRestrict, SharedLayout } from "../SharedLayout";
19+
2420
interface IProps {
2521
id: string | null;
2622
code: string | null;

@app/client/src/pages/login.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
11
import { LockOutlined, UserAddOutlined, UserOutlined } from "@ant-design/icons";
22
import { type ApolloError, useApolloClient } from "@apollo/client";
33
import {
4-
AuthRestrict,
54
ButtonLink,
65
Col,
76
Redirect,
87
Row,
9-
SharedLayout,
10-
type SharedLayoutChildProps,
118
SocialLoginOptions,
129
} from "@app/components";
1310
import { useLoginMutation, useSharedQuery } from "@app/graphql";
@@ -23,6 +20,12 @@ import Router from "next/router";
2320
import { type Store } from "rc-field-form/lib/interface";
2421
import React, { useCallback, useEffect, useRef, useState } from "react";
2522

23+
import {
24+
AuthRestrict,
25+
SharedLayout,
26+
type SharedLayoutChildProps,
27+
} from "./SharedLayout";
28+
2629
interface LoginProps {
2730
next: string | null;
2831
}

@app/client/src/pages/o/[slug]/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { PageHeader } from "@ant-design/pro-layout";
22
import {
33
ButtonLink,
4-
SharedLayout,
54
useOrganizationLoading,
65
useOrganizationSlug,
76
} from "@app/components";
@@ -13,6 +12,8 @@ import { Col, Empty, Row } from "antd";
1312
import { type NextPage } from "next";
1413
import React, { type FC } from "react";
1514

15+
import { SharedLayout } from "../../SharedLayout";
16+
1617
const OrganizationPage: NextPage = () => {
1718
const slug = useOrganizationSlug();
1819
const query = useOrganizationPageQuery({ variables: { slug } });

@app/components/src/OrganizationSettingsLayout.tsx renamed to @app/client/src/pages/o/[slug]/settings/OrganizationSettingsLayout.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1+
import { StandardWidth } from "@app/components";
12
import { type OrganizationPage_OrganizationFragment } from "@app/graphql";
23
import { Layout, Menu, Typography } from "antd";
34
import Link from "next/link";
45
import React, { useMemo } from "react";
56

6-
import { contentMinHeight } from "./SharedLayout";
7-
import { StandardWidth } from "./StandardWidth";
7+
import { contentMinHeight } from "../../../SharedLayout";
88

99
type TextProps = React.ComponentProps<typeof Typography.Text>;
1010
const { Text } = Typography;

0 commit comments

Comments
 (0)