mirror of
https://github.com/coder/coder.git
synced 2025-07-12 00:14:10 +00:00
feat: Add Footer to every page with nav (#1009)
* Add Footer to AuthAndNav, rename * Fix in preferences layout * Remove double footer
This commit is contained in:
@ -1,6 +1,7 @@
|
|||||||
import React from "react"
|
import React from "react"
|
||||||
import { Route, Routes } from "react-router-dom"
|
import { Route, Routes } from "react-router-dom"
|
||||||
import { AuthAndNav, RequireAuth } from "./components"
|
import { RequireAuth } from "./components"
|
||||||
|
import { AuthAndFrame } from "./components/AuthAndFrame/AuthAndFrame"
|
||||||
import { PreferencesLayout } from "./components/Preferences/Layout"
|
import { PreferencesLayout } from "./components/Preferences/Layout"
|
||||||
import { IndexPage } from "./pages"
|
import { IndexPage } from "./pages"
|
||||||
import { NotFoundPage } from "./pages/404"
|
import { NotFoundPage } from "./pages/404"
|
||||||
@ -39,18 +40,18 @@ export const AppRouter: React.FC = () => (
|
|||||||
<Route
|
<Route
|
||||||
index
|
index
|
||||||
element={
|
element={
|
||||||
<AuthAndNav>
|
<AuthAndFrame>
|
||||||
<TemplatesPage />
|
<TemplatesPage />
|
||||||
</AuthAndNav>
|
</AuthAndFrame>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
<Route path=":organization/:template">
|
<Route path=":organization/:template">
|
||||||
<Route
|
<Route
|
||||||
index
|
index
|
||||||
element={
|
element={
|
||||||
<AuthAndNav>
|
<AuthAndFrame>
|
||||||
<TemplatePage />
|
<TemplatePage />
|
||||||
</AuthAndNav>
|
</AuthAndFrame>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
<Route
|
<Route
|
||||||
@ -68,9 +69,9 @@ export const AppRouter: React.FC = () => (
|
|||||||
<Route
|
<Route
|
||||||
path=":workspace"
|
path=":workspace"
|
||||||
element={
|
element={
|
||||||
<AuthAndNav>
|
<AuthAndFrame>
|
||||||
<WorkspacePage />
|
<WorkspacePage />
|
||||||
</AuthAndNav>
|
</AuthAndFrame>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
</Route>
|
</Route>
|
||||||
@ -78,25 +79,25 @@ export const AppRouter: React.FC = () => (
|
|||||||
<Route
|
<Route
|
||||||
path="users"
|
path="users"
|
||||||
element={
|
element={
|
||||||
<AuthAndNav>
|
<AuthAndFrame>
|
||||||
<UsersPage />
|
<UsersPage />
|
||||||
</AuthAndNav>
|
</AuthAndFrame>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
<Route
|
<Route
|
||||||
path="orgs"
|
path="orgs"
|
||||||
element={
|
element={
|
||||||
<AuthAndNav>
|
<AuthAndFrame>
|
||||||
<OrganizationsPage />
|
<OrganizationsPage />
|
||||||
</AuthAndNav>
|
</AuthAndFrame>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
<Route
|
<Route
|
||||||
path="settings"
|
path="settings"
|
||||||
element={
|
element={
|
||||||
<AuthAndNav>
|
<AuthAndFrame>
|
||||||
<SettingsPage />
|
<SettingsPage />
|
||||||
</AuthAndNav>
|
</AuthAndFrame>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
21
site/src/components/AuthAndFrame/AuthAndFrame.tsx
Normal file
21
site/src/components/AuthAndFrame/AuthAndFrame.tsx
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
import React from "react"
|
||||||
|
import { Navbar } from "../Navbar"
|
||||||
|
import { Footer } from "../Page/Footer"
|
||||||
|
import { RequireAuth } from "../Page/RequireAuth"
|
||||||
|
|
||||||
|
interface AuthAndFrameProps {
|
||||||
|
children: JSX.Element
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Wraps page in RequireAuth and renders it between Navbar and Footer
|
||||||
|
*/
|
||||||
|
export const AuthAndFrame: React.FC<AuthAndFrameProps> = ({ children }) => (
|
||||||
|
<RequireAuth>
|
||||||
|
<>
|
||||||
|
<Navbar />
|
||||||
|
{children}
|
||||||
|
<Footer />
|
||||||
|
</>
|
||||||
|
</RequireAuth>
|
||||||
|
)
|
@ -1,12 +0,0 @@
|
|||||||
import React from "react"
|
|
||||||
import { Navbar } from "../Navbar"
|
|
||||||
import { RequireAuth, RequireAuthProps } from "./RequireAuth"
|
|
||||||
|
|
||||||
export const AuthAndNav: React.FC<RequireAuthProps> = ({ children }) => (
|
|
||||||
<RequireAuth>
|
|
||||||
<>
|
|
||||||
<Navbar />
|
|
||||||
{children}
|
|
||||||
</>
|
|
||||||
</RequireAuth>
|
|
||||||
)
|
|
@ -1,3 +1,2 @@
|
|||||||
export * from "./AuthAndNav"
|
|
||||||
export * from "./Footer"
|
export * from "./Footer"
|
||||||
export * from "./RequireAuth"
|
export * from "./RequireAuth"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import Box from "@material-ui/core/Box"
|
import Box from "@material-ui/core/Box"
|
||||||
import React from "react"
|
import React from "react"
|
||||||
import { Outlet } from "react-router-dom"
|
import { Outlet } from "react-router-dom"
|
||||||
import { AuthAndNav } from "../Page"
|
import { AuthAndFrame } from "../AuthAndFrame/AuthAndFrame"
|
||||||
import { TabPanel } from "../TabPanel"
|
import { TabPanel } from "../TabPanel"
|
||||||
|
|
||||||
export const Language = {
|
export const Language = {
|
||||||
@ -21,7 +21,7 @@ const menuItems = [
|
|||||||
|
|
||||||
export const PreferencesLayout: React.FC = () => {
|
export const PreferencesLayout: React.FC = () => {
|
||||||
return (
|
return (
|
||||||
<AuthAndNav>
|
<AuthAndFrame>
|
||||||
<Box display="flex" flexDirection="column">
|
<Box display="flex" flexDirection="column">
|
||||||
<Box style={{ maxWidth: "1380px", margin: "1em auto" }}>
|
<Box style={{ maxWidth: "1380px", margin: "1em auto" }}>
|
||||||
<TabPanel title={Language.preferencesLabel} menuItems={menuItems}>
|
<TabPanel title={Language.preferencesLabel} menuItems={menuItems}>
|
||||||
@ -29,6 +29,6 @@ export const PreferencesLayout: React.FC = () => {
|
|||||||
</TabPanel>
|
</TabPanel>
|
||||||
</Box>
|
</Box>
|
||||||
</Box>
|
</Box>
|
||||||
</AuthAndNav>
|
</AuthAndFrame>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,6 @@ import { EmptyState } from "../../../../components/EmptyState"
|
|||||||
import { ErrorSummary } from "../../../../components/ErrorSummary"
|
import { ErrorSummary } from "../../../../components/ErrorSummary"
|
||||||
import { Header } from "../../../../components/Header"
|
import { Header } from "../../../../components/Header"
|
||||||
import { FullScreenLoader } from "../../../../components/Loader/FullScreenLoader"
|
import { FullScreenLoader } from "../../../../components/Loader/FullScreenLoader"
|
||||||
import { Footer } from "../../../../components/Page"
|
|
||||||
import { Column, Table } from "../../../../components/Table"
|
import { Column, Table } from "../../../../components/Table"
|
||||||
import { unsafeSWRArgument } from "../../../../util"
|
import { unsafeSWRArgument } from "../../../../util"
|
||||||
import { firstOrItem } from "../../../../util/array"
|
import { firstOrItem } from "../../../../util/array"
|
||||||
@ -98,7 +97,6 @@ export const TemplatePage: React.FC = () => {
|
|||||||
<Paper style={{ maxWidth: "1380px", margin: "1em auto", width: "100%" }}>
|
<Paper style={{ maxWidth: "1380px", margin: "1em auto", width: "100%" }}>
|
||||||
<Table {...tableProps} />
|
<Table {...tableProps} />
|
||||||
</Paper>
|
</Paper>
|
||||||
<Footer />
|
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,6 @@ import { CodeExample } from "../../components/CodeExample/CodeExample"
|
|||||||
import { ErrorSummary } from "../../components/ErrorSummary"
|
import { ErrorSummary } from "../../components/ErrorSummary"
|
||||||
import { Header } from "../../components/Header"
|
import { Header } from "../../components/Header"
|
||||||
import { FullScreenLoader } from "../../components/Loader/FullScreenLoader"
|
import { FullScreenLoader } from "../../components/Loader/FullScreenLoader"
|
||||||
import { Footer } from "../../components/Page"
|
|
||||||
import { Column, Table } from "../../components/Table"
|
import { Column, Table } from "../../components/Table"
|
||||||
|
|
||||||
export const TemplatesPage: React.FC = () => {
|
export const TemplatesPage: React.FC = () => {
|
||||||
@ -74,7 +73,6 @@ export const TemplatesPage: React.FC = () => {
|
|||||||
<Paper style={{ maxWidth: "1380px", margin: "1em auto", width: "100%" }}>
|
<Paper style={{ maxWidth: "1380px", margin: "1em auto", width: "100%" }}>
|
||||||
<Table {...tableProps} />
|
<Table {...tableProps} />
|
||||||
</Paper>
|
</Paper>
|
||||||
<Footer />
|
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,6 @@ import useSWR from "swr"
|
|||||||
import * as Types from "../../api/types"
|
import * as Types from "../../api/types"
|
||||||
import { ErrorSummary } from "../../components/ErrorSummary"
|
import { ErrorSummary } from "../../components/ErrorSummary"
|
||||||
import { FullScreenLoader } from "../../components/Loader/FullScreenLoader"
|
import { FullScreenLoader } from "../../components/Loader/FullScreenLoader"
|
||||||
import { Footer } from "../../components/Page"
|
|
||||||
import { Workspace } from "../../components/Workspace"
|
import { Workspace } from "../../components/Workspace"
|
||||||
import { unsafeSWRArgument } from "../../util"
|
import { unsafeSWRArgument } from "../../util"
|
||||||
import { firstOrItem } from "../../util/array"
|
import { firstOrItem } from "../../util/array"
|
||||||
@ -50,8 +49,6 @@ export const WorkspacePage: React.FC = () => {
|
|||||||
<div className={styles.inner}>
|
<div className={styles.inner}>
|
||||||
<Workspace organization={organization} template={template} workspace={workspace} />
|
<Workspace organization={organization} template={template} workspace={workspace} />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<Footer />
|
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user