diff --git a/.changeset/nice-lobsters-wink.md b/.changeset/nice-lobsters-wink.md new file mode 100644 index 000000000..bf1b23104 --- /dev/null +++ b/.changeset/nice-lobsters-wink.md @@ -0,0 +1,7 @@ +--- +'hostd': patch +'renterd': patch +'walletd': patch +--- + +The page layout is now persisted between page transitions. diff --git a/apps/hostd/components/Config/Layout.tsx b/apps/hostd/components/Config/Layout.tsx new file mode 100644 index 000000000..c1e620f46 --- /dev/null +++ b/apps/hostd/components/Config/Layout.tsx @@ -0,0 +1,47 @@ +import { Text } from '@siafoundation/design-system' +import { Warning16, CheckmarkFilled16 } from '@siafoundation/react-icons' +import { HostdSidenav } from '../HostdSidenav' +import { routes } from '../../config/routes' +import { useDialog } from '../../contexts/dialog' +import { + HostdAuthedLayout, + HostdAuthedPageLayoutProps, +} from '../HostdAuthedLayout' +import { useConfig } from '../../contexts/config' +import { ConfigNav } from './ConfigNav' +import { ConfigActions } from './ConfigActions' + +export const Layout = HostdAuthedLayout +export function useLayoutProps(): HostdAuthedPageLayoutProps { + const { openDialog } = useDialog() + const { settings, dynDNSCheck } = useConfig() + return { + title: 'Configuration', + routes, + nav: , + sidenav: , + stats: + settings.data?.ddns.provider && !dynDNSCheck.isValidating ? ( + dynDNSCheck.error ? ( + <> + + + + + Error with dynamic DNS configuration: {dynDNSCheck.error.message} + + + ) : ( + <> + + + + Dynamic DNS enabled + + ) + ) : null, + actions: , + openSettings: () => openDialog('settings'), + size: '3', + } +} diff --git a/apps/hostd/components/Config/index.tsx b/apps/hostd/components/Config/index.tsx index f3f3900b4..7dedf3e67 100644 --- a/apps/hostd/components/Config/index.tsx +++ b/apps/hostd/components/Config/index.tsx @@ -10,342 +10,299 @@ import { ConfigurationSiacoin, ConfigurationFiat, } from '@siafoundation/design-system' -import { Warning16, CheckmarkFilled16 } from '@siafoundation/react-icons' -import { HostdSidenav } from '../HostdSidenav' -import { routes } from '../../config/routes' -import { useDialog } from '../../contexts/dialog' -import { HostdAuthedLayout } from '../../components/HostdAuthedLayout' import { useConfig } from '../../contexts/config' -import { ConfigNav } from './ConfigNav' import { StateConnError } from './StateConnError' -import { ConfigActions } from './ConfigActions' export function Config() { - const { openDialog } = useDialog() - const { fields, settings, dynDNSCheck, form, remoteError, configRef } = - useConfig() + const { fields, form, remoteError, configRef } = useConfig() const shouldPinStoragePrice = form.watch('shouldPinStoragePrice') const shouldPinEgressPrice = form.watch('shouldPinEgressPrice') const shouldPinIngressPrice = form.watch('shouldPinIngressPrice') const shouldPinMaxCollateral = form.watch('shouldPinMaxCollateral') const pinnedCurrency = form.watch('pinnedCurrency') - return ( - } - sidenav={} - stats={ - settings.data?.ddns.provider && !dynDNSCheck.isValidating ? ( - dynDNSCheck.error ? ( - <> - - - - - Error with dynamic DNS configuration:{' '} - {dynDNSCheck.error.message} - - - ) : ( - <> - - - - Dynamic DNS enabled - - ) - ) : null - } - actions={} - openSettings={() => openDialog('settings')} - size="3" - > - {remoteError ? ( - - ) : ( -
- - - - - - {shouldShowField({ - form, - fields, - name: 'shouldPinStoragePrice', - }) && ( - -
- - Pin - - -
-
- )} - {shouldShowField({ - form, - fields, - name: 'shouldPinStoragePrice', - }) && shouldPinStoragePrice ? ( - - ) : ( - - )} -
- } - /> - - {shouldShowField({ - form, - fields, - name: 'shouldPinEgressPrice', - }) && ( - -
- - Pin - - -
-
- )} - {shouldShowField({ - form, - fields, - name: 'shouldPinEgressPrice', - }) && shouldPinEgressPrice ? ( - - ) : ( - + ) : ( +
+ + + + + + {shouldShowField({ + form, + fields, + name: 'shouldPinStoragePrice', + }) && ( + +
+ + Pin + + - )} -
- } - /> - - {shouldShowField({ - form, - fields, - name: 'shouldPinIngressPrice', - }) && ( - -
- - Pin - - -
-
- )} - {shouldShowField({ - form, - fields, - name: 'shouldPinIngressPrice', - }) && shouldPinIngressPrice ? ( - +
+ )} + {shouldShowField({ + form, + fields, + name: 'shouldPinStoragePrice', + }) && shouldPinStoragePrice ? ( + + ) : ( + + )} +
+ } + /> + + {shouldShowField({ + form, + fields, + name: 'shouldPinEgressPrice', + }) && ( + +
+ + Pin + + - ) : ( - + + )} + {shouldShowField({ + form, + fields, + name: 'shouldPinEgressPrice', + }) && shouldPinEgressPrice ? ( + + ) : ( + + )} +
+ } + /> + + {shouldShowField({ + form, + fields, + name: 'shouldPinIngressPrice', + }) && ( + +
+ + Pin + + - )} -
- } - /> - - {shouldShowField({ - form, - fields, - name: 'maxCollateral', - }) && ( - - {shouldShowField({ - form, - fields, - name: 'shouldPinMaxCollateral', - }) && ( - -
- - Pin - - -
-
- )} - {shouldShowField({ - form, - fields, - name: 'shouldPinMaxCollateral', - }) && shouldPinMaxCollateral ? ( - - ) : ( - +
+ )} + {shouldShowField({ + form, + fields, + name: 'shouldPinIngressPrice', + }) && shouldPinIngressPrice ? ( + + ) : ( + + )} + + } + /> + + {shouldShowField({ + form, + fields, + name: 'maxCollateral', + }) && ( + + {shouldShowField({ + form, + fields, + name: 'shouldPinMaxCollateral', + }) && ( + +
+ + Pin + + - )} -
- } - /> - )} - - - - - - - - - +
+ )} + {shouldShowField({ + form, + fields, + name: 'shouldPinMaxCollateral', + }) && shouldPinMaxCollateral ? ( + + ) : ( + + )} + + } /> - - )} -
+ )} + + + + + + + + + + ) } diff --git a/apps/hostd/components/Contracts/Layout.tsx b/apps/hostd/components/Contracts/Layout.tsx new file mode 100644 index 000000000..1dfd2c3b4 --- /dev/null +++ b/apps/hostd/components/Contracts/Layout.tsx @@ -0,0 +1,23 @@ +import { HostdSidenav } from '../HostdSidenav' +import { routes } from '../../config/routes' +import { useDialog } from '../../contexts/dialog' +import { + HostdAuthedLayout, + HostdAuthedPageLayoutProps, +} from '../HostdAuthedLayout' +import { ContractsActionsMenu } from './ContractsActionsMenu' +import { ContractsFiltersBar } from './ContractsFiltersBar' + +export const Layout = HostdAuthedLayout +export function useLayoutProps(): HostdAuthedPageLayoutProps { + const { openDialog } = useDialog() + return { + title: 'Contracts', + routes, + sidenav: , + openSettings: () => openDialog('settings'), + actions: , + stats: , + size: 'full', + } +} diff --git a/apps/hostd/components/Contracts/index.tsx b/apps/hostd/components/Contracts/index.tsx index 275ac1596..a25e017d4 100644 --- a/apps/hostd/components/Contracts/index.tsx +++ b/apps/hostd/components/Contracts/index.tsx @@ -1,17 +1,10 @@ -import { HostdSidenav } from '../HostdSidenav' -import { routes } from '../../config/routes' import { Table } from '@siafoundation/design-system' -import { useDialog } from '../../contexts/dialog' import { useContracts } from '../../contexts/contracts' -import { HostdAuthedLayout } from '../HostdAuthedLayout' import { StateNoneMatching } from './StateNoneMatching' import { StateNoneYet } from './StateNoneYet' import { StateError } from './StateError' -import { ContractsActionsMenu } from './ContractsActionsMenu' -import { ContractsFiltersBar } from './ContractsFiltersBar' export function Contracts() { - const { openDialog } = useDialog() const { columns, dataset, @@ -25,37 +18,27 @@ export function Contracts() { } = useContracts() return ( - } - openSettings={() => openDialog('settings')} - actions={} - stats={} - size="full" - > -
- - ) : dataState === 'noneYet' ? ( - - ) : dataState === 'error' ? ( - - ) : null - } - pageSize={limit} - data={dataset} - columns={columns} - sortableColumns={sortableColumns} - sortDirection={sortDirection} - sortField={sortField} - toggleSort={toggleSort} - /> - - +
+
+ ) : dataState === 'noneYet' ? ( + + ) : dataState === 'error' ? ( + + ) : null + } + pageSize={limit} + data={dataset} + columns={columns} + sortableColumns={sortableColumns} + sortDirection={sortDirection} + sortField={sortField} + toggleSort={toggleSort} + /> + ) } diff --git a/apps/hostd/components/Home/Layout.tsx b/apps/hostd/components/Home/Layout.tsx new file mode 100644 index 000000000..f168ae90f --- /dev/null +++ b/apps/hostd/components/Home/Layout.tsx @@ -0,0 +1,110 @@ +import { + Button, + ControlGroup, + Text, + Tooltip, + Select, + Option, +} from '@siafoundation/design-system' +import { CalendarHeatMap16, Ruler16 } from '@siafoundation/react-icons' +import { useMetrics } from '../../contexts/metrics' +import { + HostdAuthedLayout, + HostdAuthedPageLayoutProps, +} from '../HostdAuthedLayout' +import { routes } from '../../config/routes' +import { HostdSidenav } from '../HostdSidenav' +import { useDialog } from '../../contexts/dialog' +import { DataTimeSpan, dataTimeSpanOptions } from '../../contexts/metrics/types' +import { humanDate } from '@siafoundation/units' + +export const Layout = HostdAuthedLayout +export function useLayoutProps(): HostdAuthedPageLayoutProps { + const { openDialog } = useDialog() + const { timeRange, dataTimeSpan, setDataTimeSpan, dataInterval } = + useMetrics() + + return { + title: 'Overview', + routes, + sidenav: , + openSettings: () => openDialog('settings'), + nav: ( +
+ + + + + +
+ ), + size: 'full', + actions: ( + <> + {/* */} + +
+ +
+
+ +
+ +
+
+ + ), + } +} diff --git a/apps/hostd/components/Home/index.tsx b/apps/hostd/components/Home/index.tsx index 7dc3bb98a..517514c18 100644 --- a/apps/hostd/components/Home/index.tsx +++ b/apps/hostd/components/Home/index.tsx @@ -1,125 +1,21 @@ -import { - Button, - ControlGroup, - Text, - Tooltip, - Select, - Option, -} from '@siafoundation/design-system' -import { CalendarHeatMap16, Ruler16 } from '@siafoundation/react-icons' -import { useMetrics } from '../../contexts/metrics' import { HomeRevenue } from './HomeRevenue' import { HomeStorage } from './HomeStorage' import { HomeContracts } from './HomeContracts' import { HomePricing } from './HomePricing' -import { HostdAuthedLayout } from '../HostdAuthedLayout' -import { routes } from '../../config/routes' -import { HostdSidenav } from '../HostdSidenav' -import { useDialog } from '../../contexts/dialog' -import { DataTimeSpan, dataTimeSpanOptions } from '../../contexts/metrics/types' import { HomeOperations } from './HomeOperations' import { HomeBandwidth } from './HomeBandwidth' -import { humanDate } from '@siafoundation/units' import { HomeCollateral } from './HomeCollateral' export function Home() { - const { openDialog } = useDialog() - const { timeRange, dataTimeSpan, setDataTimeSpan, dataInterval } = - useMetrics() - return ( - } - openSettings={() => openDialog('settings')} - nav={ -
- - - - - -
- } - size="full" - actions={ - <> - {/* */} - -
- -
-
- -
- -
-
- - } - > -
- - - - - - - -
-
+
+ + + + + + + +
) } diff --git a/apps/hostd/components/HostdAuthedLayout.tsx b/apps/hostd/components/HostdAuthedLayout.tsx index 005c7289a..7dd9f1bdd 100644 --- a/apps/hostd/components/HostdAuthedLayout.tsx +++ b/apps/hostd/components/HostdAuthedLayout.tsx @@ -6,14 +6,12 @@ import { useSyncStatus } from '../hooks/useSyncStatus' import { HostdTestnetWarningBanner } from './HostdTestnetWarningBanner' import { Profile } from './Profile' -type Props = React.ComponentProps +type Props = Omit< + React.ComponentProps, + 'appName' | 'connectivityRoute' | 'walletBalance' | 'profile' | 'isSynced' +> -export function HostdAuthedLayout( - props: Omit< - Props, - 'appName' | 'connectivityRoute' | 'walletBalance' | 'profile' | 'isSynced' - > -) { +export function HostdAuthedLayout(props: Props) { const wallet = useWallet() const { isSynced } = useSyncStatus() return ( @@ -35,3 +33,5 @@ export function HostdAuthedLayout( /> ) } + +export type HostdAuthedPageLayoutProps = Omit diff --git a/apps/hostd/components/HostdPublicLayout.tsx b/apps/hostd/components/HostdPublicLayout.tsx index 223886241..c58084eab 100644 --- a/apps/hostd/components/HostdPublicLayout.tsx +++ b/apps/hostd/components/HostdPublicLayout.tsx @@ -1,7 +1,9 @@ import { AppPublicLayout } from '@siafoundation/design-system' -type Props = React.ComponentProps +type Props = Omit, 'appName'> -export function HostdPublicLayout(props: Omit) { +export function HostdPublicLayout(props: Props) { return } + +export type HostdPublicPageLayoutProps = Omit diff --git a/apps/hostd/components/Login/Layout.tsx b/apps/hostd/components/Login/Layout.tsx new file mode 100644 index 000000000..43456623b --- /dev/null +++ b/apps/hostd/components/Login/Layout.tsx @@ -0,0 +1,9 @@ +import { + HostdPublicLayout, + HostdPublicPageLayoutProps, +} from '../HostdPublicLayout' + +export const Layout = HostdPublicLayout +export function useLayoutProps(): HostdPublicPageLayoutProps { + return {} +} diff --git a/apps/hostd/components/Login/index.tsx b/apps/hostd/components/Login/index.tsx index e2dc5ee4b..509c12c0c 100644 --- a/apps/hostd/components/Login/index.tsx +++ b/apps/hostd/components/Login/index.tsx @@ -1,11 +1,6 @@ import { AppLogin } from '@siafoundation/design-system' import { connectivityRoute, routes } from '../../config/routes' -import { HostdPublicLayout } from '../HostdPublicLayout' export function Login() { - return ( - - - - ) + return } diff --git a/apps/hostd/components/Node/Layout.tsx b/apps/hostd/components/Node/Layout.tsx new file mode 100644 index 000000000..450153ccb --- /dev/null +++ b/apps/hostd/components/Node/Layout.tsx @@ -0,0 +1,18 @@ +import { routes } from '../../config/routes' +import { useDialog } from '../../contexts/dialog' +import { HostdSidenav } from '../HostdSidenav' +import { + HostdAuthedLayout, + HostdAuthedPageLayoutProps, +} from '../HostdAuthedLayout' + +export const Layout = HostdAuthedLayout +export function useLayoutProps(): HostdAuthedPageLayoutProps { + const { openDialog } = useDialog() + return { + title: 'Node', + routes, + sidenav: , + openSettings: () => openDialog('settings'), + } +} diff --git a/apps/hostd/components/Node/index.tsx b/apps/hostd/components/Node/index.tsx index e7b105b52..c9f2c3ae4 100644 --- a/apps/hostd/components/Node/index.tsx +++ b/apps/hostd/components/Node/index.tsx @@ -1,9 +1,6 @@ import { DatumCard, PeerList } from '@siafoundation/design-system' import { useSyncerPeers } from '@siafoundation/hostd-react' -import { routes } from '../../config/routes' import { useDialog } from '../../contexts/dialog' -import { HostdSidenav } from '../HostdSidenav' -import { HostdAuthedLayout } from '../HostdAuthedLayout' import { useMemo } from 'react' import { orderBy } from '@technically/lodash' import { useSyncStatus } from '../../hooks/useSyncStatus' @@ -21,35 +18,28 @@ export function Node() { }, [peers.data]) return ( - } - openSettings={() => openDialog('settings')} - title="Node" - > -
-
- - -
- openDialog('connectPeer')} +
+
+ +
- + openDialog('connectPeer')} + /> +
) } diff --git a/apps/hostd/components/Volumes/Layout.tsx b/apps/hostd/components/Volumes/Layout.tsx new file mode 100644 index 000000000..a8fc56562 --- /dev/null +++ b/apps/hostd/components/Volumes/Layout.tsx @@ -0,0 +1,53 @@ +import { Button, Text, Separator } from '@siafoundation/design-system' +import { Add20 } from '@siafoundation/react-icons' +import { humanBytes } from '@siafoundation/units' +import { + HostdAuthedLayout, + HostdAuthedPageLayoutProps, +} from '../HostdAuthedLayout' +import { useDialog } from '../../contexts/dialog' +import { HostdSidenav } from '../HostdSidenav' +import { routes } from '../../config/routes' +import { useVolumes } from '../../contexts/volumes' +import { VolumesViewDropdownMenu } from './VolumesViewDropdownMenu' + +export const Layout = HostdAuthedLayout +export function useLayoutProps(): HostdAuthedPageLayoutProps { + const { openDialog } = useDialog() + + const { dataset } = useVolumes() + + const total = dataset?.reduce((acc, i) => acc + i.totalBytes, 0) + const used = dataset?.reduce((acc, i) => acc + i.usedBytes, 0) + const free = total - used + return { + title: 'Volumes', + routes, + sidenav: , + openSettings: () => openDialog('settings'), + actions: ( + <> + + + + ), + stats: ( +
+ {`${humanBytes( + used + )} used`} + + {`${humanBytes( + free + )} free`} + + {`${humanBytes( + total + )} total`} +
+ ), + } +} diff --git a/apps/hostd/components/Volumes/index.tsx b/apps/hostd/components/Volumes/index.tsx index e74f9a845..ec0358316 100644 --- a/apps/hostd/components/Volumes/index.tsx +++ b/apps/hostd/components/Volumes/index.tsx @@ -1,64 +1,19 @@ -import { Button, Table, Text, Separator } from '@siafoundation/design-system' -import { Add20 } from '@siafoundation/react-icons' -import { humanBytes } from '@siafoundation/units' -import { HostdAuthedLayout } from '../HostdAuthedLayout' -import { useDialog } from '../../contexts/dialog' -import { HostdSidenav } from '../HostdSidenav' -import { routes } from '../../config/routes' +import { Table } from '@siafoundation/design-system' import { useVolumes } from '../../contexts/volumes' -import { VolumesViewDropdownMenu } from './VolumesViewDropdownMenu' import { StateNoneYet } from './StateNoneYet' export function Volumes() { - const { openDialog } = useDialog() - const { dataset, isLoading, columns } = useVolumes() - - const total = dataset?.reduce((acc, i) => acc + i.totalBytes, 0) - const used = dataset?.reduce((acc, i) => acc + i.usedBytes, 0) - const free = total - used - return ( - } - openSettings={() => openDialog('settings')} - actions={ - <> - - - - } - stats={ -
- {`${humanBytes( - used - )} used`} - - {`${humanBytes( - free - )} free`} - - {`${humanBytes( - total - )} total`} -
- } - > -
-
} - /> - - +
+
} + /> + ) } diff --git a/apps/hostd/components/Wallet/Layout.tsx b/apps/hostd/components/Wallet/Layout.tsx new file mode 100644 index 000000000..6596ad016 --- /dev/null +++ b/apps/hostd/components/Wallet/Layout.tsx @@ -0,0 +1,48 @@ +import { WalletLayoutActions } from '@siafoundation/design-system' +import { useWallet } from '@siafoundation/hostd-react' +import { useDialog } from '../../contexts/dialog' +import { routes } from '../../config/routes' +import BigNumber from 'bignumber.js' +import { HostdSidenav } from '../HostdSidenav' +import { + HostdAuthedLayout, + HostdAuthedPageLayoutProps, +} from '../HostdAuthedLayout' +import { useSyncStatus } from '../../hooks/useSyncStatus' +import { WalletFilterBar } from './WalletFilterBar' + +export const Layout = HostdAuthedLayout +export function useLayoutProps(): HostdAuthedPageLayoutProps { + const { openDialog } = useDialog() + const wallet = useWallet() + const { isSynced, isWalletSynced, syncPercent, walletScanPercent } = + useSyncStatus() + + return { + title: 'Wallet', + routes, + sidenav: , + openSettings: () => openDialog('settings'), + actions: ( + openDialog('addressDetails')} + sendSiacoin={() => openDialog('sendSiacoin')} + /> + ), + stats: , + } +} diff --git a/apps/hostd/components/Wallet/index.tsx b/apps/hostd/components/Wallet/index.tsx index 18535239b..72b6b0d75 100644 --- a/apps/hostd/components/Wallet/index.tsx +++ b/apps/hostd/components/Wallet/index.tsx @@ -1,27 +1,10 @@ -import { - WalletLayoutActions, - BalanceEvolution, - Table, -} from '@siafoundation/design-system' -import { useWallet } from '@siafoundation/hostd-react' -import { useDialog } from '../../contexts/dialog' -import { routes } from '../../config/routes' -import BigNumber from 'bignumber.js' -import { HostdSidenav } from '../HostdSidenav' -import { HostdAuthedLayout } from '../HostdAuthedLayout' -import { useSyncStatus } from '../../hooks/useSyncStatus' +import { BalanceEvolution, Table } from '@siafoundation/design-system' import { useTransactions } from '../../contexts/transactions' -import { WalletFilterBar } from './WalletFilterBar' import { StateNoneMatching } from './StateNoneMatching' import { StateNoneYet } from './StateNoneYet' import { StateError } from './StateError' export function Wallet() { - const { openDialog } = useDialog() - const wallet = useWallet() - const { isSynced, isWalletSynced, syncPercent, walletScanPercent } = - useSyncStatus() - const { balances, metrics, @@ -37,62 +20,34 @@ export function Wallet() { } = useTransactions() return ( - } - openSettings={() => openDialog('settings')} - title="Wallet" - actions={ - openDialog('addressDetails')} - sendSiacoin={() => openDialog('sendSiacoin')} - /> - } - stats={} - > -
- {balances?.length && balances.find((b) => b.sc) ? ( - - ) : null} -
- ) : dataState === 'noneYet' ? ( - - ) : dataState === 'error' ? ( - - ) : null - } - pageSize={defaultPageSize} - data={dataset} - context={cellContext} - columns={columns} - sortableColumns={sortableColumns} - sortDirection={sortDirection} - sortField={sortField} - toggleSort={toggleSort} +
+ {balances?.length && balances.find((b) => b.sc) ? ( + -
- + ) : null} +
+ ) : dataState === 'noneYet' ? ( + + ) : dataState === 'error' ? ( + + ) : null + } + pageSize={defaultPageSize} + data={dataset} + context={cellContext} + columns={columns} + sortableColumns={sortableColumns} + sortDirection={sortDirection} + sortField={sortField} + toggleSort={toggleSort} + /> + ) } diff --git a/apps/hostd/config/providers.tsx b/apps/hostd/config/providers.tsx index fe1fd8086..be4754034 100644 --- a/apps/hostd/config/providers.tsx +++ b/apps/hostd/config/providers.tsx @@ -3,7 +3,6 @@ import { MetricsProvider } from '../contexts/metrics' import { DialogProvider, Dialogs } from '../contexts/dialog' import { VolumesProvider } from '../contexts/volumes' import { ConfigProvider } from '../contexts/config' -import { OnboardingBar } from '../components/OnboardingBar' import { TransactionsProvider } from '../contexts/transactions' type Props = { @@ -21,7 +20,6 @@ export function Providers({ children }: Props) { {/* this is here so that dialogs can use all the other providers, and the other providers can trigger dialogs */} - {children} diff --git a/apps/hostd/pages/_app.tsx b/apps/hostd/pages/_app.tsx index 4d885bfef..3bcc5f40d 100644 --- a/apps/hostd/pages/_app.tsx +++ b/apps/hostd/pages/_app.tsx @@ -5,24 +5,41 @@ import { Providers } from '../config/providers' import { routes } from '../config/routes' import { rootFontClasses } from '@siafoundation/fonts' import { hostStateRoute } from '@siafoundation/hostd-types' +import { NextPage } from 'next' -export default function App({ - Component, - pageProps, -}: AppProps<{ +type NextPageWithLayout = NextPage & { + Layout: ({ children }: { children: React.ReactElement }) => React.ReactNode + useLayoutProps: () => Record +} + +type AppPropsWithLayout = AppProps<{ fallback?: Record -}>) { +}> & { + Component: NextPageWithLayout +} + +export default function App(props: AppPropsWithLayout) { return ( - + ) } +function AppCore({ Component, pageProps }: AppPropsWithLayout) { + const Layout = Component.Layout + const layoutProps = Component.useLayoutProps() + const { fallback, ...rest } = pageProps + return ( + + + + ) +} diff --git a/apps/hostd/pages/config/index.tsx b/apps/hostd/pages/config/index.tsx index 121c85011..c9116dbb8 100644 --- a/apps/hostd/pages/config/index.tsx +++ b/apps/hostd/pages/config/index.tsx @@ -1,5 +1,9 @@ import { Config } from '../../components/Config' +import { Layout, useLayoutProps } from '../../components/Config/Layout' -export default function ConfigPage() { +export default function Page() { return } + +Page.Layout = Layout +Page.useLayoutProps = useLayoutProps diff --git a/apps/hostd/pages/contracts/index.tsx b/apps/hostd/pages/contracts/index.tsx index 35ffbe5a1..b20b2a162 100644 --- a/apps/hostd/pages/contracts/index.tsx +++ b/apps/hostd/pages/contracts/index.tsx @@ -1,5 +1,9 @@ import { Contracts } from '../../components/Contracts' +import { Layout, useLayoutProps } from '../../components/Contracts/Layout' -export default function ContractsPage() { +export default function Page() { return } + +Page.Layout = Layout +Page.useLayoutProps = useLayoutProps diff --git a/apps/hostd/pages/index.tsx b/apps/hostd/pages/index.tsx index 31ad74ec7..c847bcc29 100644 --- a/apps/hostd/pages/index.tsx +++ b/apps/hostd/pages/index.tsx @@ -1,5 +1,9 @@ import { Home } from '../components/Home' +import { Layout, useLayoutProps } from '../components/Home/Layout' -export default function HomePage() { +export default function Page() { return } + +Page.Layout = Layout +Page.useLayoutProps = useLayoutProps diff --git a/apps/hostd/pages/login.tsx b/apps/hostd/pages/login.tsx index 4d416fb2b..cf237134d 100644 --- a/apps/hostd/pages/login.tsx +++ b/apps/hostd/pages/login.tsx @@ -1,5 +1,9 @@ import { Login } from '../components/Login' +import { Layout, useLayoutProps } from '../components/Login/Layout' -export default function LoginPage() { +export default function Page() { return } + +Page.Layout = Layout +Page.useLayoutProps = useLayoutProps diff --git a/apps/hostd/pages/node/index.tsx b/apps/hostd/pages/node/index.tsx index 1e780e299..95577b5cf 100644 --- a/apps/hostd/pages/node/index.tsx +++ b/apps/hostd/pages/node/index.tsx @@ -1,5 +1,9 @@ import { Node } from '../../components/Node' +import { Layout, useLayoutProps } from '../../components/Node/Layout' -export default function NodePage() { +export default function Page() { return } + +Page.Layout = Layout +Page.useLayoutProps = useLayoutProps diff --git a/apps/hostd/pages/volumes/index.tsx b/apps/hostd/pages/volumes/index.tsx index f5037fabf..61ee328e8 100644 --- a/apps/hostd/pages/volumes/index.tsx +++ b/apps/hostd/pages/volumes/index.tsx @@ -1,5 +1,9 @@ import { Volumes } from '../../components/Volumes' +import { Layout, useLayoutProps } from '../../components/Volumes/Layout' -export default function VolumesPage() { +export default function Page() { return } + +Page.Layout = Layout +Page.useLayoutProps = useLayoutProps diff --git a/apps/hostd/pages/wallet/index.tsx b/apps/hostd/pages/wallet/index.tsx index 557afd573..371377b30 100644 --- a/apps/hostd/pages/wallet/index.tsx +++ b/apps/hostd/pages/wallet/index.tsx @@ -1,5 +1,9 @@ import { Wallet } from '../../components/Wallet' +import { Layout, useLayoutProps } from '../../components/Wallet/Layout' -export default function WalletView() { +export default function Page() { return } + +Page.Layout = Layout +Page.useLayoutProps = useLayoutProps diff --git a/apps/renterd/components/Alerts/Layout.tsx b/apps/renterd/components/Alerts/Layout.tsx new file mode 100644 index 000000000..6e8404ac3 --- /dev/null +++ b/apps/renterd/components/Alerts/Layout.tsx @@ -0,0 +1,22 @@ +import { RenterdSidenav } from '../RenterdSidenav' +import { routes } from '../../config/routes' +import { useDialog } from '../../contexts/dialog' +import { + RenterdAuthedLayout, + RenterdAuthedPageLayoutProps, +} from '../RenterdAuthedLayout' +import { AlertsActionsMenu } from './AlertsActionsMenu' +import { AlertsFilterMenu } from './AlertsFilterMenu' + +export const Layout = RenterdAuthedLayout +export function useLayoutProps(): RenterdAuthedPageLayoutProps { + const { openDialog } = useDialog() + return { + title: 'Alerts', + routes, + sidenav: , + openSettings: () => openDialog('settings'), + actions: , + stats: , + } +} diff --git a/apps/renterd/components/Alerts/index.tsx b/apps/renterd/components/Alerts/index.tsx index a77dd45c5..45fee41db 100644 --- a/apps/renterd/components/Alerts/index.tsx +++ b/apps/renterd/components/Alerts/index.tsx @@ -1,17 +1,10 @@ -import { RenterdSidenav } from '../RenterdSidenav' -import { routes } from '../../config/routes' import { Table } from '@siafoundation/design-system' -import { useDialog } from '../../contexts/dialog' -import { RenterdAuthedLayout } from '../RenterdAuthedLayout' import { StateNoneMatching } from './StateNoneMatching' import { StateNoneYet } from './StateNoneYet' -import { AlertsActionsMenu } from './AlertsActionsMenu' import { StateError } from './StateError' import { useAlerts } from '../../contexts/alerts' -import { AlertsFilterMenu } from './AlertsFilterMenu' export function Alerts() { - const { openDialog } = useDialog() const { columns, datasetPage, @@ -24,36 +17,27 @@ export function Alerts() { } = useAlerts() return ( - } - openSettings={() => openDialog('settings')} - actions={} - stats={} - > -
-
- ) : dataState === 'noneYet' ? ( - - ) : dataState === 'error' ? ( - - ) : null - } - sortableColumns={sortableColumns} - pageSize={limit} - data={datasetPage} - columns={columns} - sortDirection={sortDirection} - sortField={sortField} - toggleSort={toggleSort} - rowSize="auto" - /> - - +
+
+ ) : dataState === 'noneYet' ? ( + + ) : dataState === 'error' ? ( + + ) : null + } + sortableColumns={sortableColumns} + pageSize={limit} + data={datasetPage} + columns={columns} + sortDirection={sortDirection} + sortField={sortField} + toggleSort={toggleSort} + rowSize="auto" + /> + ) } diff --git a/apps/renterd/components/Config/Layout.tsx b/apps/renterd/components/Config/Layout.tsx new file mode 100644 index 000000000..de496aa63 --- /dev/null +++ b/apps/renterd/components/Config/Layout.tsx @@ -0,0 +1,27 @@ +import { RenterdSidenav } from '../RenterdSidenav' +import { routes } from '../../config/routes' +import { useDialog } from '../../contexts/dialog' +import { + RenterdAuthedLayout, + RenterdAuthedPageLayoutProps, +} from '../RenterdAuthedLayout' +import { ConfigStats } from './ConfigStats' +import { ConfigActions } from './ConfigActions' +import { ConfigNav } from './ConfigNav' +import { Recommendations } from './Recommendations' + +export const Layout = RenterdAuthedLayout +export function useLayoutProps(): RenterdAuthedPageLayoutProps { + const { openDialog } = useDialog() + return { + title: 'Configuration', + routes, + nav: , + sidenav: , + stats: , + actions: , + after: , + openSettings: () => openDialog('settings'), + size: '3', + } +} diff --git a/apps/renterd/components/Config/index.tsx b/apps/renterd/components/Config/index.tsx index 0555c35bf..8f3794042 100644 --- a/apps/renterd/components/Config/index.tsx +++ b/apps/renterd/components/Config/index.tsx @@ -6,22 +6,13 @@ import { PanelMenuSection, PanelMenuSetting, } from '@siafoundation/design-system' -import { RenterdSidenav } from '../RenterdSidenav' -import { routes } from '../../config/routes' -import { useDialog } from '../../contexts/dialog' -import { RenterdAuthedLayout } from '../RenterdAuthedLayout' import { useConfig } from '../../contexts/config' -import { ConfigStats } from './ConfigStats' -import { ConfigActions } from './ConfigActions' -import { ConfigNav } from './ConfigNav' import { StateConnError } from './StateConnError' -import { Recommendations } from './Recommendations' import { ShouldPinSwitch } from './ShouldPinSwitch' import { PinnedCurrencyWarning } from './PinnedCurrencyWarning' import { useExchangeRate } from '@siafoundation/react-core' export function Config() { - const { openDialog } = useDialog() const { form, fields, remoteError, configRef } = useConfig() const pinnedCurrency = form.watch('pinnedCurrency') @@ -35,294 +26,280 @@ export function Config() { }) const canUseExchangeRates = !!rate - return ( - } - sidenav={} - stats={} - actions={} - after={} - openSettings={() => openDialog('settings')} - size="3" - > - {remoteError ? ( - - ) : ( -
- - - - - - + ) : ( +
+ + + + + + + {shouldPinAllowance ? ( + canUseExchangeRates ? ( + - {shouldPinAllowance ? ( - canUseExchangeRates ? ( - - ) : ( - - ) - ) : ( - - )} -
- } - /> - - - - - -
- - - + ) + ) : ( + + )} +
+ } + /> + + + + + + + + + + {shouldPinMaxStoragePrice ? ( + canUseExchangeRates ? ( + + ) : ( + - {shouldPinMaxStoragePrice ? ( - canUseExchangeRates ? ( - - ) : ( - - ) - ) : ( - - )} - - } - /> - - + )} + + } + /> + + + {shouldPinMaxUploadPrice ? ( + canUseExchangeRates ? ( + - {shouldPinMaxUploadPrice ? ( - canUseExchangeRates ? ( - - ) : ( - - ) - ) : ( - - )} - - } - /> - - + ) + ) : ( + + )} + + } + /> + + + {shouldPinMaxDownloadPrice ? ( + canUseExchangeRates ? ( + + ) : ( + - {shouldPinMaxDownloadPrice ? ( - canUseExchangeRates ? ( - - ) : ( - - ) - ) : ( - - )} - - } - /> - - - - - - - - - - - - - - - - )} -
+ ) + ) : ( + + )} + + } + /> + + + + + + + + + + + + + + + ) } diff --git a/apps/renterd/components/Contracts/Layout.tsx b/apps/renterd/components/Contracts/Layout.tsx new file mode 100644 index 000000000..381364aa2 --- /dev/null +++ b/apps/renterd/components/Contracts/Layout.tsx @@ -0,0 +1,24 @@ +import { RenterdSidenav } from '../RenterdSidenav' +import { routes } from '../../config/routes' +import { useDialog } from '../../contexts/dialog' +import { + RenterdAuthedLayout, + RenterdAuthedPageLayoutProps, +} from '../RenterdAuthedLayout' +import { ContractsActionsMenu } from './ContractsActionsMenu' +import { ContractsFilterBar } from './ContractsFilterBar' + +export const Layout = RenterdAuthedLayout +export function useLayoutProps(): RenterdAuthedPageLayoutProps { + const { openDialog } = useDialog() + return { + title: 'Active contracts', + routes, + sidenav: , + openSettings: () => openDialog('settings'), + actions: , + stats: , + size: 'full', + scroll: false, + } +} diff --git a/apps/renterd/components/Contracts/index.tsx b/apps/renterd/components/Contracts/index.tsx index cf36beb8a..af3978c82 100644 --- a/apps/renterd/components/Contracts/index.tsx +++ b/apps/renterd/components/Contracts/index.tsx @@ -1,19 +1,12 @@ -import { RenterdSidenav } from '../RenterdSidenav' -import { routes } from '../../config/routes' import { ScrollArea, Table } from '@siafoundation/design-system' -import { useDialog } from '../../contexts/dialog' import { useContracts } from '../../contexts/contracts' -import { RenterdAuthedLayout } from '../RenterdAuthedLayout' import { StateNoneMatching } from './StateNoneMatching' import { StateNoneYet } from './StateNoneYet' -import { ContractsActionsMenu } from './ContractsActionsMenu' import { StateError } from './StateError' -import { ContractsFilterBar } from './ContractsFilterBar' import { cx } from 'class-variance-authority' import { ContractMetrics } from './ContractMetrics' export function Contracts() { - const { openDialog } = useDialog() const { columns, datasetPage, @@ -39,72 +32,61 @@ export function Contracts() { : '100%' return ( - } - openSettings={() => openDialog('settings')} - stats={} - actions={} - size="full" - scroll={false} - > -
-
- {showDetailView ? : null} -
-
- -
-
- ) : dataState === 'noneYet' ? ( - - ) : dataState === 'error' ? ( - - ) : null - } - sortableColumns={sortableColumns} - pageSize={limit} - data={datasetPage} - columns={columns} - sortDirection={sortDirection} - sortField={sortField} - toggleSort={toggleSort} - focusId={selectedContract?.id} - rowSize="default" - /> - - - +
+
+ {showDetailView ? : null}
- +
+ +
+
+ ) : dataState === 'noneYet' ? ( + + ) : dataState === 'error' ? ( + + ) : null + } + sortableColumns={sortableColumns} + pageSize={limit} + data={datasetPage} + columns={columns} + sortDirection={sortDirection} + sortField={sortField} + toggleSort={toggleSort} + focusId={selectedContract?.id} + rowSize="default" + /> + + + + ) } diff --git a/apps/renterd/components/Files/Layout.tsx b/apps/renterd/components/Files/Layout.tsx new file mode 100644 index 000000000..6badb2439 --- /dev/null +++ b/apps/renterd/components/Files/Layout.tsx @@ -0,0 +1,37 @@ +import { RenterdSidenav } from '../RenterdSidenav' +import { routes } from '../../config/routes' +import { useDialog } from '../../contexts/dialog' +import { FilesBreadcrumbMenu } from '../FilesDirectory/FilesBreadcrumbMenu' +import { FilesFlatBreadcrumbMenu } from '../FilesFlat/FilesFlatBreadcrumbMenu' +import { + RenterdAuthedLayout, + RenterdAuthedPageLayoutProps, +} from '../RenterdAuthedLayout' +import { FilesActionsMenu } from '../FilesDirectory/FilesActionsMenu' +import { FilesStatsMenu } from '../FilesDirectory/FilesStatsMenu' +import { useFilesManager } from '../../contexts/filesManager' + +export const Layout = RenterdAuthedLayout +export function useLayoutProps(): RenterdAuthedPageLayoutProps { + const { openDialog } = useDialog() + const { isViewingBuckets, activeExplorerMode } = useFilesManager() + const activeMode = + activeExplorerMode === 'directory' || isViewingBuckets + ? 'directory' + : 'flat' + return { + title: 'Files', + navTitle: null, + routes, + sidenav: , + openSettings: () => openDialog('settings'), + nav: + activeMode === 'directory' ? ( + + ) : ( + + ), + stats: , + actions: , + } +} diff --git a/apps/renterd/components/FilesDirectory/index.tsx b/apps/renterd/components/FilesDirectory/index.tsx index f7feb0a1c..6418d0c08 100644 --- a/apps/renterd/components/FilesDirectory/index.tsx +++ b/apps/renterd/components/FilesDirectory/index.tsx @@ -1,29 +1,9 @@ -import { RenterdSidenav } from '../RenterdSidenav' -import { routes } from '../../config/routes' -import { useDialog } from '../../contexts/dialog' -import { FilesBreadcrumbMenu } from './FilesBreadcrumbMenu' -import { RenterdAuthedLayout } from '../RenterdAuthedLayout' -import { FilesActionsMenu } from './FilesActionsMenu' -import { FilesStatsMenu } from './FilesStatsMenu' import { FilesExplorer } from './FilesExplorer' export function FilesDirectory() { - const { openDialog } = useDialog() - return ( - } - nav={} - stats={} - actions={} - openSettings={() => openDialog('settings')} - > -
- -
-
+
+ +
) } diff --git a/apps/renterd/components/FilesFlat/index.tsx b/apps/renterd/components/FilesFlat/index.tsx index 9b6c50f36..b9e1126a2 100644 --- a/apps/renterd/components/FilesFlat/index.tsx +++ b/apps/renterd/components/FilesFlat/index.tsx @@ -1,29 +1,9 @@ -import { RenterdSidenav } from '../RenterdSidenav' -import { routes } from '../../config/routes' -import { useDialog } from '../../contexts/dialog' -import { FilesFlatBreadcrumbMenu } from './FilesFlatBreadcrumbMenu' -import { RenterdAuthedLayout } from '../RenterdAuthedLayout' -import { FilesActionsMenu } from './FilesActionsMenu' -import { FilesStatsMenu } from './FilesStatsMenu' import { FilesExplorer } from './FilesExplorer' export function FilesFlat() { - const { openDialog } = useDialog() - return ( - } - nav={} - stats={} - actions={} - openSettings={() => openDialog('settings')} - > -
- -
-
+
+ +
) } diff --git a/apps/renterd/components/Home/Layout.tsx b/apps/renterd/components/Home/Layout.tsx new file mode 100644 index 000000000..0ee3f7c82 --- /dev/null +++ b/apps/renterd/components/Home/Layout.tsx @@ -0,0 +1,18 @@ +import { + RenterdAuthedLayout, + RenterdAuthedPageLayoutProps, +} from '../RenterdAuthedLayout' +import { RenterdSidenav } from '../RenterdSidenav' +import { routes } from '../../config/routes' +import { useDialog } from '../../contexts/dialog' + +export const Layout = RenterdAuthedLayout +export function useLayoutProps(): RenterdAuthedPageLayoutProps { + const { openDialog } = useDialog() + return { + title: 'Dashboard', + routes, + sidenav: , + openSettings: () => openDialog('settings'), + } +} diff --git a/apps/renterd/components/Home/index.tsx b/apps/renterd/components/Home/index.tsx index 66876bab0..e2d5990eb 100644 --- a/apps/renterd/components/Home/index.tsx +++ b/apps/renterd/components/Home/index.tsx @@ -1,26 +1,13 @@ -import { RenterdAuthedLayout } from '../RenterdAuthedLayout' -import { RenterdSidenav } from '../RenterdSidenav' import { routes } from '../../config/routes' -import { useDialog } from '../../contexts/dialog' import { useEffect } from 'react' import { useRouter } from 'next/router' export function Home() { const router = useRouter() - const { openDialog } = useDialog() useEffect(() => { router.replace(routes.buckets.index) }, [router]) - return ( - } - openSettings={() => openDialog('settings')} - > -
- - ) + return
} diff --git a/apps/renterd/components/Hosts/Layout.tsx b/apps/renterd/components/Hosts/Layout.tsx new file mode 100644 index 000000000..b0531fffe --- /dev/null +++ b/apps/renterd/components/Hosts/Layout.tsx @@ -0,0 +1,24 @@ +import { RenterdSidenav } from '../RenterdSidenav' +import { routes } from '../../config/routes' +import { useDialog } from '../../contexts/dialog' +import { + RenterdAuthedLayout, + RenterdAuthedPageLayoutProps, +} from '../RenterdAuthedLayout' +import { HostsActionsMenu } from './HostsActionsMenu' +import { HostsFilterBar } from './HostsFilterBar' + +export const Layout = RenterdAuthedLayout +export function useLayoutProps(): RenterdAuthedPageLayoutProps { + const { openDialog } = useDialog() + return { + title: 'Hosts', + routes, + sidenav: , + openSettings: () => openDialog('settings'), + size: 'full', + actions: , + stats: , + scroll: false, + } +} diff --git a/apps/renterd/components/Hosts/index.tsx b/apps/renterd/components/Hosts/index.tsx index c548fa951..58aac72cb 100644 --- a/apps/renterd/components/Hosts/index.tsx +++ b/apps/renterd/components/Hosts/index.tsx @@ -1,18 +1,11 @@ -import { RenterdSidenav } from '../RenterdSidenav' -import { routes } from '../../config/routes' import { ScrollArea, Table } from '@siafoundation/design-system' -import { useDialog } from '../../contexts/dialog' import { useHosts } from '../../contexts/hosts' -import { RenterdAuthedLayout } from '../RenterdAuthedLayout' import { StateEmpty } from './StateEmpty' -import { HostsActionsMenu } from './HostsActionsMenu' -import { HostsFilterBar } from './HostsFilterBar' import { HostMap } from './HostMap' import { cx } from 'class-variance-authority' import { getHostStatus } from '../../contexts/hosts/status' export function Hosts() { - const { openDialog } = useDialog() const { dataset, activeHost, @@ -24,67 +17,56 @@ export function Hosts() { } = useHosts() return ( - } - openSettings={() => openDialog('settings')} - size="full" - actions={} - stats={} - scroll={false} - > -
-
- -
-
- -
-
} - context={tableContext} - pageSize={limit} - data={dataset} - columns={columns} - rowSize="default" - /> - - - +
+
+
- +
+ +
+
} + context={tableContext} + pageSize={limit} + data={dataset} + columns={columns} + rowSize="default" + /> + + + + ) } diff --git a/apps/renterd/components/Keys/Layout.tsx b/apps/renterd/components/Keys/Layout.tsx new file mode 100644 index 000000000..83e3b1a5b --- /dev/null +++ b/apps/renterd/components/Keys/Layout.tsx @@ -0,0 +1,22 @@ +import { RenterdSidenav } from '../RenterdSidenav' +import { routes } from '../../config/routes' +import { useDialog } from '../../contexts/dialog' +import { + RenterdAuthedLayout, + RenterdAuthedPageLayoutProps, +} from '../RenterdAuthedLayout' +import { KeysActionsMenu } from './KeysActionsMenu' +import { KeysStatsMenu } from './KeysStatsMenu' + +export const Layout = RenterdAuthedLayout +export function useLayoutProps(): RenterdAuthedPageLayoutProps { + const { openDialog } = useDialog() + return { + title: 'Keys', + routes, + sidenav: , + openSettings: () => openDialog('settings'), + actions: , + stats: , + } +} diff --git a/apps/renterd/components/Keys/index.tsx b/apps/renterd/components/Keys/index.tsx index 14edfb85c..59b88784c 100644 --- a/apps/renterd/components/Keys/index.tsx +++ b/apps/renterd/components/Keys/index.tsx @@ -1,18 +1,11 @@ -import { RenterdSidenav } from '../RenterdSidenav' -import { routes } from '../../config/routes' import { Table } from '@siafoundation/design-system' -import { useDialog } from '../../contexts/dialog' -import { RenterdAuthedLayout } from '../RenterdAuthedLayout' import { StateNoneMatching } from './StateNoneMatching' import { StateNoneYet } from './StateNoneYet' -import { KeysActionsMenu } from './KeysActionsMenu' import { StateError } from './StateError' import { useKeys } from '../../contexts/keys' import { KeysBatchMenu } from './KeysBatchMenu' -import { KeysStatsMenu } from './KeysStatsMenu' export function Keys() { - const { openDialog } = useDialog() const { columns, datasetPage, @@ -26,39 +19,30 @@ export function Keys() { } = useKeys() return ( - } - openSettings={() => openDialog('settings')} - actions={} - stats={} - > -
- -
- ) : dataState === 'noneYet' ? ( - - ) : dataState === 'error' ? ( - - ) : null - } - sortableColumns={sortableColumns} - pageSize={limit} - data={datasetPage} - context={cellContext} - columns={columns} - sortDirection={sortDirection} - sortField={sortField} - toggleSort={toggleSort} - rowSize="default" - /> - - +
+ +
+ ) : dataState === 'noneYet' ? ( + + ) : dataState === 'error' ? ( + + ) : null + } + sortableColumns={sortableColumns} + pageSize={limit} + data={datasetPage} + context={cellContext} + columns={columns} + sortDirection={sortDirection} + sortField={sortField} + toggleSort={toggleSort} + rowSize="default" + /> + ) } diff --git a/apps/renterd/components/Login/Layout.tsx b/apps/renterd/components/Login/Layout.tsx new file mode 100644 index 000000000..672592187 --- /dev/null +++ b/apps/renterd/components/Login/Layout.tsx @@ -0,0 +1,9 @@ +import { + RenterdPublicLayout, + RenterdPublicPageLayoutProps, +} from '../RenterdPublicLayout' + +export const Layout = RenterdPublicLayout +export function useLayoutProps(): RenterdPublicPageLayoutProps { + return {} +} diff --git a/apps/renterd/components/Login/index.tsx b/apps/renterd/components/Login/index.tsx index 47be00d4a..b074c060a 100644 --- a/apps/renterd/components/Login/index.tsx +++ b/apps/renterd/components/Login/index.tsx @@ -1,11 +1,8 @@ import { AppLogin } from '@siafoundation/design-system' import { connectivityRoute, routes } from '../../config/routes' -import { RenterdPublicLayout } from '../RenterdPublicLayout' export function Login() { return ( - - - + ) } diff --git a/apps/renterd/components/Node/Layout.tsx b/apps/renterd/components/Node/Layout.tsx new file mode 100644 index 000000000..dff2c72ee --- /dev/null +++ b/apps/renterd/components/Node/Layout.tsx @@ -0,0 +1,18 @@ +import { routes } from '../../config/routes' +import { useDialog } from '../../contexts/dialog' +import { RenterdSidenav } from '../RenterdSidenav' +import { + RenterdAuthedLayout, + RenterdAuthedPageLayoutProps, +} from '../RenterdAuthedLayout' + +export const Layout = RenterdAuthedLayout +export function useLayoutProps(): RenterdAuthedPageLayoutProps { + const { openDialog } = useDialog() + return { + title: 'Node', + routes, + sidenav: , + openSettings: () => openDialog('settings'), + } +} diff --git a/apps/renterd/components/Node/index.tsx b/apps/renterd/components/Node/index.tsx index c5cb79391..30535e654 100644 --- a/apps/renterd/components/Node/index.tsx +++ b/apps/renterd/components/Node/index.tsx @@ -4,10 +4,7 @@ import { useSyncerPeers, useTxPoolTransactions, } from '@siafoundation/renterd-react' -import { routes } from '../../config/routes' import { useDialog } from '../../contexts/dialog' -import { RenterdSidenav } from '../RenterdSidenav' -import { RenterdAuthedLayout } from '../RenterdAuthedLayout' export function Node() { const peers = useSyncerPeers() @@ -28,32 +25,25 @@ export function Node() { const { openDialog } = useDialog() return ( - } - openSettings={() => openDialog('settings')} - title="Node" - > -
-
- - - -
- openDialog('connectPeer')} +
+
+ + +
- + openDialog('connectPeer')} + /> +
) } diff --git a/apps/renterd/components/RenterdAuthedLayout.tsx b/apps/renterd/components/RenterdAuthedLayout.tsx index eef2b6298..c9d6a21b1 100644 --- a/apps/renterd/components/RenterdAuthedLayout.tsx +++ b/apps/renterd/components/RenterdAuthedLayout.tsx @@ -6,14 +6,12 @@ import { useSyncStatus } from '../hooks/useSyncStatus' import { Profile } from './Profile' import { RenterdTestnetWarningBanner } from './RenterdTestnetWarningBanner' -type Props = React.ComponentProps +type Props = Omit< + React.ComponentProps, + 'appName' | 'connectivityRoute' | 'walletBalance' | 'profile' | 'isSynced' +> -export function RenterdAuthedLayout( - props: Omit< - Props, - 'appName' | 'connectivityRoute' | 'walletBalance' | 'profile' | 'isSynced' - > -) { +export function RenterdAuthedLayout(props: Props) { const wallet = useWallet() const { isSynced } = useSyncStatus() return ( @@ -35,3 +33,5 @@ export function RenterdAuthedLayout( /> ) } + +export type RenterdAuthedPageLayoutProps = Omit diff --git a/apps/renterd/components/RenterdPublicLayout.tsx b/apps/renterd/components/RenterdPublicLayout.tsx index 22e2da53f..1378d7367 100644 --- a/apps/renterd/components/RenterdPublicLayout.tsx +++ b/apps/renterd/components/RenterdPublicLayout.tsx @@ -1,7 +1,9 @@ import { AppPublicLayout } from '@siafoundation/design-system' -type Props = React.ComponentProps +type Props = Omit, 'appName'> -export function RenterdPublicLayout(props: Omit) { +export function RenterdPublicLayout(props: Props) { return } + +export type RenterdPublicPageLayoutProps = Omit diff --git a/apps/renterd/components/Uploads/Layout.tsx b/apps/renterd/components/Uploads/Layout.tsx new file mode 100644 index 000000000..af658224e --- /dev/null +++ b/apps/renterd/components/Uploads/Layout.tsx @@ -0,0 +1,25 @@ +import { RenterdSidenav } from '../RenterdSidenav' +import { routes } from '../../config/routes' +import { useDialog } from '../../contexts/dialog' +import { + RenterdAuthedLayout, + RenterdAuthedPageLayoutProps, +} from '../RenterdAuthedLayout' +import { UploadsActionsMenu } from './UploadsActionsMenu' +import { UploadsStatsMenu } from './UploadsStatsMenu' +import { UploadsBreadcrumbMenu } from './UploadsBreadcrumbMenu' + +export const Layout = RenterdAuthedLayout +export function useLayoutProps(): RenterdAuthedPageLayoutProps { + const { openDialog } = useDialog() + return { + title: 'Uploads', + navTitle: null, + routes, + sidenav: , + openSettings: () => openDialog('settings'), + actions: , + stats: , + nav: , + } +} diff --git a/apps/renterd/components/Uploads/index.tsx b/apps/renterd/components/Uploads/index.tsx index db4d7b226..c1b62cd30 100644 --- a/apps/renterd/components/Uploads/index.tsx +++ b/apps/renterd/components/Uploads/index.tsx @@ -1,29 +1,9 @@ -import { RenterdSidenav } from '../RenterdSidenav' -import { routes } from '../../config/routes' -import { useDialog } from '../../contexts/dialog' -import { RenterdAuthedLayout } from '../RenterdAuthedLayout' -import { UploadsActionsMenu } from './UploadsActionsMenu' -import { UploadsStatsMenu } from './UploadsStatsMenu' import { UploadsTable } from './UploadsTable' -import { UploadsBreadcrumbMenu } from './UploadsBreadcrumbMenu' export function Uploads() { - const { openDialog } = useDialog() - return ( - } - nav={} - stats={} - actions={} - openSettings={() => openDialog('settings')} - > -
- -
-
+
+ +
) } diff --git a/apps/renterd/components/Wallet/Layout.tsx b/apps/renterd/components/Wallet/Layout.tsx new file mode 100644 index 000000000..e20137f4a --- /dev/null +++ b/apps/renterd/components/Wallet/Layout.tsx @@ -0,0 +1,47 @@ +import { WalletLayoutActions } from '@siafoundation/design-system' +import { useWallet } from '@siafoundation/renterd-react' +import { useDialog } from '../../contexts/dialog' +import { routes } from '../../config/routes' +import BigNumber from 'bignumber.js' +import { RenterdSidenav } from '../RenterdSidenav' +import { + RenterdAuthedLayout, + RenterdAuthedPageLayoutProps, +} from '../RenterdAuthedLayout' +import { useSyncStatus } from '../../hooks/useSyncStatus' +import { WalletFilterBar } from './WalletFilterBar' + +export const Layout = RenterdAuthedLayout +export function useLayoutProps(): RenterdAuthedPageLayoutProps { + const { openDialog } = useDialog() + const wallet = useWallet() + const { isSynced, isWalletSynced, syncPercent, walletScanPercent } = + useSyncStatus() + return { + title: 'Wallet', + routes, + sidenav: , + openSettings: () => openDialog('settings'), + actions: ( + openDialog('addressDetails')} + sendSiacoin={() => openDialog('sendSiacoin')} + /> + ), + stats: , + } +} diff --git a/apps/renterd/components/Wallet/index.tsx b/apps/renterd/components/Wallet/index.tsx index 741cfe588..921d636b6 100644 --- a/apps/renterd/components/Wallet/index.tsx +++ b/apps/renterd/components/Wallet/index.tsx @@ -1,27 +1,10 @@ -import { - BalanceEvolution, - Table, - WalletLayoutActions, -} from '@siafoundation/design-system' -import { useWallet } from '@siafoundation/renterd-react' -import { useDialog } from '../../contexts/dialog' -import { routes } from '../../config/routes' -import BigNumber from 'bignumber.js' -import { RenterdSidenav } from '../RenterdSidenav' -import { RenterdAuthedLayout } from '../RenterdAuthedLayout' -import { useSyncStatus } from '../../hooks/useSyncStatus' +import { BalanceEvolution, Table } from '@siafoundation/design-system' import { useTransactions } from '../../contexts/transactions' -import { WalletFilterBar } from './WalletFilterBar' import { StateNoneMatching } from './StateNoneMatching' import { StateNoneYet } from './StateNoneYet' import { StateError } from './StateError' export function Wallet() { - const { openDialog } = useDialog() - const wallet = useWallet() - const { isSynced, isWalletSynced, syncPercent, walletScanPercent } = - useSyncStatus() - const { balances, metrics, @@ -37,64 +20,36 @@ export function Wallet() { } = useTransactions() return ( - } - openSettings={() => openDialog('settings')} - title="Wallet" - actions={ - openDialog('addressDetails')} - sendSiacoin={() => openDialog('sendSiacoin')} - /> - } - stats={} - > -
- {balances?.length ? ( - - ) : null} -
- ) : dataState === 'noneYet' ? ( - - ) : dataState === 'error' ? ( - - ) : null - } - pageSize={defaultPageSize} - data={dataset} - context={cellContext} - columns={columns} - sortableColumns={sortableColumns} - sortDirection={sortDirection} - sortField={sortField} - toggleSort={toggleSort} +
+ {balances?.length ? ( + -
- + ) : null} +
+ ) : dataState === 'noneYet' ? ( + + ) : dataState === 'error' ? ( + + ) : null + } + pageSize={defaultPageSize} + data={dataset} + context={cellContext} + columns={columns} + sortableColumns={sortableColumns} + sortDirection={sortDirection} + sortField={sortField} + toggleSort={toggleSort} + /> + ) } diff --git a/apps/renterd/pages/_app.tsx b/apps/renterd/pages/_app.tsx index 8db223837..57173c7dc 100644 --- a/apps/renterd/pages/_app.tsx +++ b/apps/renterd/pages/_app.tsx @@ -5,24 +5,41 @@ import { Providers } from '../config/providers' import { routes } from '../config/routes' import { rootFontClasses } from '@siafoundation/fonts' import { busStateRoute } from '@siafoundation/renterd-types' +import { NextPage } from 'next' -export default function App({ - Component, - pageProps, -}: AppProps<{ +type NextPageWithLayout = NextPage & { + Layout: ({ children }: { children: React.ReactElement }) => React.ReactNode + useLayoutProps: () => Record +} + +type AppPropsWithLayout = AppProps<{ fallback?: Record -}>) { +}> & { + Component: NextPageWithLayout +} + +export default function App(props: AppPropsWithLayout) { return ( - + ) } +function AppCore({ Component, pageProps }: AppPropsWithLayout) { + const Layout = Component.Layout + const layoutProps = Component.useLayoutProps() + const { fallback, ...rest } = pageProps + return ( + + + + ) +} diff --git a/apps/renterd/pages/alerts/index.tsx b/apps/renterd/pages/alerts/index.tsx index aa65cb8d1..14b18fd76 100644 --- a/apps/renterd/pages/alerts/index.tsx +++ b/apps/renterd/pages/alerts/index.tsx @@ -1,5 +1,9 @@ import { Alerts } from '../../components/Alerts' +import { Layout, useLayoutProps } from '../../components/Alerts/Layout' -export default function AlertsPage() { +export default function Page() { return } + +Page.Layout = Layout +Page.useLayoutProps = useLayoutProps diff --git a/apps/renterd/pages/buckets/[bucket]/files/[[...path]].tsx b/apps/renterd/pages/buckets/[bucket]/files/[[...path]].tsx index 627904628..a98ac0b99 100644 --- a/apps/renterd/pages/buckets/[bucket]/files/[[...path]].tsx +++ b/apps/renterd/pages/buckets/[bucket]/files/[[...path]].tsx @@ -1,5 +1,9 @@ import { Files } from '../../../../components/Files' +import { Layout, useLayoutProps } from '../../../../components/Files/Layout' -export default function FilesPage() { +export default function Page() { return } + +Page.Layout = Layout +Page.useLayoutProps = useLayoutProps diff --git a/apps/renterd/pages/buckets/[bucket]/uploads/index.tsx b/apps/renterd/pages/buckets/[bucket]/uploads/index.tsx index 50d1a997f..74262c529 100644 --- a/apps/renterd/pages/buckets/[bucket]/uploads/index.tsx +++ b/apps/renterd/pages/buckets/[bucket]/uploads/index.tsx @@ -1,5 +1,9 @@ import { Uploads } from '../../../../components/Uploads' +import { Layout, useLayoutProps } from '../../../../components/Uploads/Layout' -export default function UploadsPage() { +export default function Page() { return } + +Page.Layout = Layout +Page.useLayoutProps = useLayoutProps diff --git a/apps/renterd/pages/buckets/index.tsx b/apps/renterd/pages/buckets/index.tsx index 1f29ab039..cefc47caf 100644 --- a/apps/renterd/pages/buckets/index.tsx +++ b/apps/renterd/pages/buckets/index.tsx @@ -1,5 +1,9 @@ import { Files } from '../../components/Files' +import { Layout, useLayoutProps } from '../../components/Files/Layout' -export default function FilesPage() { +export default function Page() { return } + +Page.Layout = Layout +Page.useLayoutProps = useLayoutProps diff --git a/apps/renterd/pages/config/index.tsx b/apps/renterd/pages/config/index.tsx index 121c85011..c9116dbb8 100644 --- a/apps/renterd/pages/config/index.tsx +++ b/apps/renterd/pages/config/index.tsx @@ -1,5 +1,9 @@ import { Config } from '../../components/Config' +import { Layout, useLayoutProps } from '../../components/Config/Layout' -export default function ConfigPage() { +export default function Page() { return } + +Page.Layout = Layout +Page.useLayoutProps = useLayoutProps diff --git a/apps/renterd/pages/contracts/index.tsx b/apps/renterd/pages/contracts/index.tsx index 35ffbe5a1..b20b2a162 100644 --- a/apps/renterd/pages/contracts/index.tsx +++ b/apps/renterd/pages/contracts/index.tsx @@ -1,5 +1,9 @@ import { Contracts } from '../../components/Contracts' +import { Layout, useLayoutProps } from '../../components/Contracts/Layout' -export default function ContractsPage() { +export default function Page() { return } + +Page.Layout = Layout +Page.useLayoutProps = useLayoutProps diff --git a/apps/renterd/pages/hosts/index.tsx b/apps/renterd/pages/hosts/index.tsx index 0d57e9d27..ff6c27252 100644 --- a/apps/renterd/pages/hosts/index.tsx +++ b/apps/renterd/pages/hosts/index.tsx @@ -1,5 +1,9 @@ import { Hosts } from '../../components/Hosts' +import { Layout, useLayoutProps } from '../../components/Hosts/Layout' -export default function HostsPage() { +export default function Page() { return } + +Page.Layout = Layout +Page.useLayoutProps = useLayoutProps diff --git a/apps/renterd/pages/index.tsx b/apps/renterd/pages/index.tsx index 31ad74ec7..c847bcc29 100644 --- a/apps/renterd/pages/index.tsx +++ b/apps/renterd/pages/index.tsx @@ -1,5 +1,9 @@ import { Home } from '../components/Home' +import { Layout, useLayoutProps } from '../components/Home/Layout' -export default function HomePage() { +export default function Page() { return } + +Page.Layout = Layout +Page.useLayoutProps = useLayoutProps diff --git a/apps/renterd/pages/keys/index.tsx b/apps/renterd/pages/keys/index.tsx index 5e8cbd6e4..d68938925 100644 --- a/apps/renterd/pages/keys/index.tsx +++ b/apps/renterd/pages/keys/index.tsx @@ -1,5 +1,9 @@ import { Keys } from '../../components/Keys' +import { Layout, useLayoutProps } from '../../components/Keys/Layout' -export default function KeysPage() { +export default function Page() { return } + +Page.Layout = Layout +Page.useLayoutProps = useLayoutProps diff --git a/apps/renterd/pages/login.tsx b/apps/renterd/pages/login.tsx index 4d416fb2b..cf237134d 100644 --- a/apps/renterd/pages/login.tsx +++ b/apps/renterd/pages/login.tsx @@ -1,5 +1,9 @@ import { Login } from '../components/Login' +import { Layout, useLayoutProps } from '../components/Login/Layout' -export default function LoginPage() { +export default function Page() { return } + +Page.Layout = Layout +Page.useLayoutProps = useLayoutProps diff --git a/apps/renterd/pages/node/index.tsx b/apps/renterd/pages/node/index.tsx index 1e780e299..95577b5cf 100644 --- a/apps/renterd/pages/node/index.tsx +++ b/apps/renterd/pages/node/index.tsx @@ -1,5 +1,9 @@ import { Node } from '../../components/Node' +import { Layout, useLayoutProps } from '../../components/Node/Layout' -export default function NodePage() { +export default function Page() { return } + +Page.Layout = Layout +Page.useLayoutProps = useLayoutProps diff --git a/apps/renterd/pages/wallet/index.tsx b/apps/renterd/pages/wallet/index.tsx index 557afd573..371377b30 100644 --- a/apps/renterd/pages/wallet/index.tsx +++ b/apps/renterd/pages/wallet/index.tsx @@ -1,5 +1,9 @@ import { Wallet } from '../../components/Wallet' +import { Layout, useLayoutProps } from '../../components/Wallet/Layout' -export default function WalletView() { +export default function Page() { return } + +Page.Layout = Layout +Page.useLayoutProps = useLayoutProps diff --git a/apps/walletd/components/Login/Layout.tsx b/apps/walletd/components/Login/Layout.tsx new file mode 100644 index 000000000..5bb608ec4 --- /dev/null +++ b/apps/walletd/components/Login/Layout.tsx @@ -0,0 +1,9 @@ +import { + WalletdPublicLayout, + WalletdPublicPageLayoutProps, +} from '../WalletdPublicLayout' + +export const Layout = WalletdPublicLayout +export function useLayoutProps(): WalletdPublicPageLayoutProps { + return {} +} diff --git a/apps/walletd/components/Login/index.tsx b/apps/walletd/components/Login/index.tsx index 5c20d73a1..0f822887f 100644 --- a/apps/walletd/components/Login/index.tsx +++ b/apps/walletd/components/Login/index.tsx @@ -1,11 +1,8 @@ import { AppLogin } from '@siafoundation/design-system' import { connectivityRoute, routes } from '../../config/routes' -import { WalletdPublicLayout } from '../WalletdPublicLayout' export function Login() { return ( - - - + ) } diff --git a/apps/walletd/components/Node/Layout.tsx b/apps/walletd/components/Node/Layout.tsx new file mode 100644 index 000000000..dc56a7c45 --- /dev/null +++ b/apps/walletd/components/Node/Layout.tsx @@ -0,0 +1,18 @@ +import { routes } from '../../config/routes' +import { useDialog } from '../../contexts/dialog' +import { WalletdSidenav } from '../WalletdSidenav' +import { + WalletdAuthedLayout, + WalletdAuthedPageLayoutProps, +} from '../WalletdAuthedLayout' + +export const Layout = WalletdAuthedLayout +export function useLayoutProps(): WalletdAuthedPageLayoutProps { + const { openDialog } = useDialog() + return { + title: 'Node', + routes, + sidenav: , + openSettings: () => openDialog('settings'), + } +} diff --git a/apps/walletd/components/Node/index.tsx b/apps/walletd/components/Node/index.tsx index 9e023c96e..006e30ec9 100644 --- a/apps/walletd/components/Node/index.tsx +++ b/apps/walletd/components/Node/index.tsx @@ -4,10 +4,7 @@ import { useSyncerPeers, useTxPoolTransactions, } from '@siafoundation/walletd-react' -import { routes } from '../../config/routes' import { useDialog } from '../../contexts/dialog' -import { WalletdSidenav } from '../WalletdSidenav' -import { WalletdAuthedLayout } from '../WalletdAuthedLayout' export function Node() { const peers = useSyncerPeers() @@ -33,41 +30,32 @@ export function Node() { : 0 return ( - } - openSettings={() => openDialog('settings')} - title="Node" - > -
-
- +
+ + + +
+
+
+ p.addr)} + connectPeer={() => openDialog('connectPeer')} /> - -
-
-
- p.addr)} - connectPeer={() => openDialog('connectPeer')} - /> -
- {/*
+ {/*
*/} -
- +
) } diff --git a/apps/walletd/components/Wallet/Layout.tsx b/apps/walletd/components/Wallet/Layout.tsx new file mode 100644 index 000000000..9f941bb09 --- /dev/null +++ b/apps/walletd/components/Wallet/Layout.tsx @@ -0,0 +1,27 @@ +import { routes } from '../../config/routes' +import { useDialog } from '../../contexts/dialog' +import { + WalletdAuthedLayout, + WalletdAuthedPageLayoutProps, +} from '../WalletdAuthedLayout' +import { WalletdSidenav } from '../WalletdSidenav' +import { WalletActionsMenu } from './WalletActionsMenu' +import { useWallets } from '../../contexts/wallets' +import { WalletNavMenu } from './WalletNavMenu' +import { EventsFilterBar } from './EventsFilterBar' + +export const Layout = WalletdAuthedLayout +export function useLayoutProps(): WalletdAuthedPageLayoutProps { + const { openDialog } = useDialog() + const { wallet } = useWallets() + return { + routes, + sidenav: , + openSettings: () => openDialog('settings'), + title: wallet?.name, + nav: , + actions: , + stats: , + size: 'full', + } +} diff --git a/apps/walletd/components/Wallet/index.tsx b/apps/walletd/components/Wallet/index.tsx index 9772cbf16..37b35e13a 100644 --- a/apps/walletd/components/Wallet/index.tsx +++ b/apps/walletd/components/Wallet/index.tsx @@ -1,20 +1,10 @@ import { Table } from '@siafoundation/design-system' -import { routes } from '../../config/routes' -import { useDialog } from '../../contexts/dialog' -import { WalletdAuthedLayout } from '../WalletdAuthedLayout' -import { WalletdSidenav } from '../WalletdSidenav' -import { WalletActionsMenu } from './WalletActionsMenu' import { useEvents } from '../../contexts/events' import { StateNoneMatching } from './StateNoneMatching' import { StateNoneYet } from './StateNoneYet' import { StateError } from './StateError' -import { useWallets } from '../../contexts/wallets' -import { WalletNavMenu } from './WalletNavMenu' -import { EventsFilterBar } from './EventsFilterBar' export function Wallet() { - const { openDialog } = useDialog() - const { wallet } = useWallets() const { dataset, dataState, @@ -27,39 +17,28 @@ export function Wallet() { } = useEvents() return ( - } - openSettings={() => openDialog('settings')} - title={wallet?.name} - nav={} - actions={} - stats={} - size="full" - > -
-
- ) : dataState === 'noneYet' ? ( - - ) : dataState === 'error' ? ( - - ) : null - } - pageSize={6} - data={dataset} - context={cellContext} - columns={columns} - sortableColumns={sortableColumns} - sortDirection={sortDirection} - sortField={sortField} - toggleSort={toggleSort} - /> - - +
+
+ ) : dataState === 'noneYet' ? ( + + ) : dataState === 'error' ? ( + + ) : null + } + pageSize={6} + data={dataset} + context={cellContext} + columns={columns} + sortableColumns={sortableColumns} + sortDirection={sortDirection} + sortField={sortField} + toggleSort={toggleSort} + /> + ) } diff --git a/apps/walletd/components/WalletAddresses/Layout.tsx b/apps/walletd/components/WalletAddresses/Layout.tsx new file mode 100644 index 000000000..81c669ac6 --- /dev/null +++ b/apps/walletd/components/WalletAddresses/Layout.tsx @@ -0,0 +1,53 @@ +import { Link, Text, truncate } from '@siafoundation/design-system' +import { routes } from '../../config/routes' +import { useDialog } from '../../contexts/dialog' +import { + WalletdAuthedLayout, + WalletdAuthedPageLayoutProps, +} from '../WalletdAuthedLayout' +import { WalletdSidenav } from '../WalletdSidenav' +import { AddressesActionsMenu } from './AddressesActionsMenu' +import { useRouter } from 'next/router' +import { useWallets } from '../../contexts/wallets' +import { AddressesFiltersBar } from './AddressesFilterBar' + +export const Layout = WalletdAuthedLayout +export function useLayoutProps(): WalletdAuthedPageLayoutProps { + const router = useRouter() + const id = router.query.id as string + const { openDialog } = useDialog() + const { wallet } = useWallets() + return { + routes, + sidenav: , + openSettings: () => openDialog('settings'), + title: wallet?.name, + navTitle: ( +
+ + {truncate(wallet?.name, 20)} + + + / + + + Addresses + +
+ ), + actions: , + stats: , + size: '3', + } +} diff --git a/apps/walletd/components/WalletAddresses/index.tsx b/apps/walletd/components/WalletAddresses/index.tsx index 17a2ba68e..0bea96982 100644 --- a/apps/walletd/components/WalletAddresses/index.tsx +++ b/apps/walletd/components/WalletAddresses/index.tsx @@ -1,22 +1,10 @@ -import { Link, Table, Text, truncate } from '@siafoundation/design-system' -import { routes } from '../../config/routes' -import { useDialog } from '../../contexts/dialog' -import { WalletdAuthedLayout } from '../WalletdAuthedLayout' -import { WalletdSidenav } from '../WalletdSidenav' -import { AddressesActionsMenu } from './AddressesActionsMenu' -import { useRouter } from 'next/router' +import { Table } from '@siafoundation/design-system' import { useAddresses } from '../../contexts/addresses' import { StateNoneMatching } from './StateNoneMatching' import { StateNoneYet } from './StateNoneYet' import { StateError } from './StateError' -import { useWallets } from '../../contexts/wallets' -import { AddressesFiltersBar } from './AddressesFilterBar' export function WalletAddresses() { - const router = useRouter() - const id = router.query.id as string - const { openDialog } = useDialog() - const { wallet } = useWallets() const { dataset, dataState, @@ -29,61 +17,27 @@ export function WalletAddresses() { } = useAddresses() return ( - } - openSettings={() => openDialog('settings')} - title={wallet?.name} - navTitle={ -
- - {truncate(wallet?.name, 20)} - - - / - - - Addresses - -
- } - actions={} - stats={} - size="3" - > -
-
- ) : dataState === 'noneYet' ? ( - - ) : dataState === 'error' ? ( - - ) : null - } - pageSize={6} - data={dataset} - context={cellContext} - columns={columns} - sortableColumns={sortableColumns} - sortDirection={sortDirection} - sortField={sortField} - toggleSort={toggleSort} - /> - - +
+
+ ) : dataState === 'noneYet' ? ( + + ) : dataState === 'error' ? ( + + ) : null + } + pageSize={6} + data={dataset} + context={cellContext} + columns={columns} + sortableColumns={sortableColumns} + sortDirection={sortDirection} + sortField={sortField} + toggleSort={toggleSort} + /> + ) } diff --git a/apps/walletd/components/WalletdAuthedLayout.tsx b/apps/walletd/components/WalletdAuthedLayout.tsx index da787cc2f..128143fcb 100644 --- a/apps/walletd/components/WalletdAuthedLayout.tsx +++ b/apps/walletd/components/WalletdAuthedLayout.tsx @@ -4,14 +4,12 @@ import { useSyncStatus } from '../hooks/useSyncStatus' import { Profile } from './Profile' import { WalletdTestnetWarningBanner } from './WalletdTestnetWarningBanner' -type Props = React.ComponentProps +type Props = Omit< + React.ComponentProps, + 'appName' | 'connectivityRoute' | 'walletBalance' | 'profile' | 'isSynced' +> -export function WalletdAuthedLayout( - props: Omit< - Props, - 'appName' | 'connectivityRoute' | 'walletBalance' | 'profile' | 'isSynced' - > -) { +export function WalletdAuthedLayout(props: Props) { const { isSynced } = useSyncStatus() return ( ) } + +export type WalletdAuthedPageLayoutProps = Omit diff --git a/apps/walletd/components/WalletdPublicLayout.tsx b/apps/walletd/components/WalletdPublicLayout.tsx index 0f2a90200..0b492d735 100644 --- a/apps/walletd/components/WalletdPublicLayout.tsx +++ b/apps/walletd/components/WalletdPublicLayout.tsx @@ -1,7 +1,9 @@ import { AppPublicLayout } from '@siafoundation/design-system' -type Props = React.ComponentProps +type Props = Omit, 'appName'> -export function WalletdPublicLayout(props: Omit) { +export function WalletdPublicLayout(props: Props) { return } + +export type WalletdPublicPageLayoutProps = Omit diff --git a/apps/walletd/components/WalletsList/Layout.tsx b/apps/walletd/components/WalletsList/Layout.tsx new file mode 100644 index 000000000..8f084482d --- /dev/null +++ b/apps/walletd/components/WalletsList/Layout.tsx @@ -0,0 +1,23 @@ +import { routes } from '../../config/routes' +import { useDialog } from '../../contexts/dialog' +import { + WalletdAuthedLayout, + WalletdAuthedPageLayoutProps, +} from '../WalletdAuthedLayout' +import { WalletdSidenav } from '../WalletdSidenav' +import { WalletsActionsMenu } from './WalletsActionsMenu' +import { WalletsFiltersBar } from './WalletsFiltersBar' + +export const Layout = WalletdAuthedLayout +export function useLayoutProps(): WalletdAuthedPageLayoutProps { + const { openDialog } = useDialog() + return { + title: 'Wallets', + routes, + sidenav: , + openSettings: () => openDialog('settings'), + actions: , + stats: , + size: '3', + } +} diff --git a/apps/walletd/components/WalletsList/index.tsx b/apps/walletd/components/WalletsList/index.tsx index 989eb532a..16b0cb4b7 100644 --- a/apps/walletd/components/WalletsList/index.tsx +++ b/apps/walletd/components/WalletsList/index.tsx @@ -1,17 +1,10 @@ import { Table } from '@siafoundation/design-system' import { useWallets } from '../../contexts/wallets' -import { routes } from '../../config/routes' -import { useDialog } from '../../contexts/dialog' -import { WalletdAuthedLayout } from '../WalletdAuthedLayout' -import { WalletdSidenav } from '../WalletdSidenav' -import { WalletsActionsMenu } from './WalletsActionsMenu' -import { WalletsFiltersBar } from './WalletsFiltersBar' import { StateNoneYet } from './StateNoneYet' import { StateNoneMatching } from './StateNoneMatching' import { StateError } from './StateError' export function WalletsList() { - const { openDialog } = useDialog() const { dataset, dataState, @@ -24,39 +17,29 @@ export function WalletsList() { } = useWallets() return ( - } - openSettings={() => openDialog('settings')} - title="Wallets" - actions={} - stats={} - size="3" - > -
- {dataState === 'noneYet' && } - {dataState !== 'noneYet' && ( -
- ) : dataState === 'error' ? ( - - ) : null - } - pageSize={6} - data={dataset} - context={context} - columns={columns} - sortableColumns={sortableColumns} - sortDirection={sortDirection} - sortField={sortField} - toggleSort={toggleSort} - /> - )} - - +
+ {dataState === 'noneYet' && } + {dataState !== 'noneYet' && ( +
+ ) : dataState === 'error' ? ( + + ) : null + } + pageSize={6} + data={dataset} + context={context} + columns={columns} + sortableColumns={sortableColumns} + sortDirection={sortDirection} + sortField={sortField} + toggleSort={toggleSort} + /> + )} + ) } diff --git a/apps/walletd/pages/_app.tsx b/apps/walletd/pages/_app.tsx index 654a84a22..02790f645 100644 --- a/apps/walletd/pages/_app.tsx +++ b/apps/walletd/pages/_app.tsx @@ -4,23 +4,40 @@ import { AppProps } from 'next/app' import { Providers } from '../config/providers' import { routes } from '../config/routes' import { rootFontClasses } from '@siafoundation/fonts' +import { NextPage } from 'next' -export default function App({ - Component, - pageProps, -}: AppProps<{ +type NextPageWithLayout = NextPage & { + Layout: ({ children }: { children: React.ReactElement }) => React.ReactNode + useLayoutProps: () => Record +} + +type AppPropsWithLayout = AppProps<{ fallback?: Record -}>) { +}> & { + Component: NextPageWithLayout +} + +export default function App(props: AppPropsWithLayout) { return ( - + ) } +function AppCore({ Component, pageProps }: AppPropsWithLayout) { + const Layout = Component.Layout + const layoutProps = Component.useLayoutProps() + const { fallback, ...rest } = pageProps + return ( + + + + ) +} diff --git a/apps/walletd/pages/index.tsx b/apps/walletd/pages/index.tsx index 0c37a8f7e..a105609ac 100644 --- a/apps/walletd/pages/index.tsx +++ b/apps/walletd/pages/index.tsx @@ -1,5 +1,9 @@ import { WalletsList } from '../components/WalletsList' +import { Layout, useLayoutProps } from '../components/WalletsList/Layout' -export default function HomePage() { +export default function Page() { return } + +Page.Layout = Layout +Page.useLayoutProps = useLayoutProps diff --git a/apps/walletd/pages/login.tsx b/apps/walletd/pages/login.tsx index 4d416fb2b..cf237134d 100644 --- a/apps/walletd/pages/login.tsx +++ b/apps/walletd/pages/login.tsx @@ -1,5 +1,9 @@ import { Login } from '../components/Login' +import { Layout, useLayoutProps } from '../components/Login/Layout' -export default function LoginPage() { +export default function Page() { return } + +Page.Layout = Layout +Page.useLayoutProps = useLayoutProps diff --git a/apps/walletd/pages/node/index.tsx b/apps/walletd/pages/node/index.tsx index 1e780e299..95577b5cf 100644 --- a/apps/walletd/pages/node/index.tsx +++ b/apps/walletd/pages/node/index.tsx @@ -1,5 +1,9 @@ import { Node } from '../../components/Node' +import { Layout, useLayoutProps } from '../../components/Node/Layout' -export default function NodePage() { +export default function Page() { return } + +Page.Layout = Layout +Page.useLayoutProps = useLayoutProps diff --git a/apps/walletd/pages/wallets/[id]/addresses.tsx b/apps/walletd/pages/wallets/[id]/addresses.tsx index 23a5e75f6..ac31e3fdd 100644 --- a/apps/walletd/pages/wallets/[id]/addresses.tsx +++ b/apps/walletd/pages/wallets/[id]/addresses.tsx @@ -1,5 +1,12 @@ import { WalletAddresses } from '../../../components/WalletAddresses' +import { + Layout, + useLayoutProps, +} from '../../../components/WalletAddresses/Layout' -export default function WalletAddressesPage() { +export default function Page() { return } + +Page.Layout = Layout +Page.useLayoutProps = useLayoutProps diff --git a/apps/walletd/pages/wallets/[id]/index.tsx b/apps/walletd/pages/wallets/[id]/index.tsx index 5ad746d7c..b31155fb8 100644 --- a/apps/walletd/pages/wallets/[id]/index.tsx +++ b/apps/walletd/pages/wallets/[id]/index.tsx @@ -1,5 +1,9 @@ import { Wallet } from '../../../components/Wallet' +import { Layout, useLayoutProps } from '../../../components/Wallet/Layout' -export default function WalletPage() { +export default function Page() { return } + +Page.Layout = Layout +Page.useLayoutProps = useLayoutProps