Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

refactor config contexts, adjust host metrics intervals #448

Merged
merged 2 commits into from
Dec 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/hot-pots-prove.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'hostd': minor
---

Metrics intervals for 1Y and ALL are now weekly and monthly.
5 changes: 5 additions & 0 deletions .changeset/lovely-moose-fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@siafoundation/design-system': minor
---

Refactor hooks used in server synced configuration features.
21 changes: 21 additions & 0 deletions apps/hostd/components/Config/StateConnError.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { Button, Text } from '@siafoundation/design-system'
import { Warning32 } from '@siafoundation/react-icons'
import { useConfig } from '../../contexts/config'

export function StateConnError() {
const { revalidateAndResetForm } = useConfig()
return (
<div className="flex flex-col gap-10 justify-center items-center h-[400px] cursor-pointer">
<Text>
<Warning32 className="scale-[200%]" />
</Text>
<div className="flex flex-col gap-3 items-center">
<Text color="subtle" className="text-center max-w-[500px]">
Error retrieving settings from daemon. Please check your connection
and try again.
</Text>
<Button onClick={() => revalidateAndResetForm()}>Reload</Button>
</div>
</div>
)
}
86 changes: 46 additions & 40 deletions apps/hostd/components/Config/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { HostdAuthedLayout } from '../../components/HostdAuthedLayout'
import { AnnounceButton } from './AnnounceButton'
import { useConfig } from '../../contexts/config'
import { ConfigNav } from './ConfigNav'
import { StateConnError } from './StateConnError'

export function Config() {
const { openDialog } = useDialog()
Expand All @@ -20,9 +21,10 @@ export function Config() {
settings,
dynDNSCheck,
changeCount,
revalidateAndResetFormData,
revalidateAndResetForm,
form,
onSubmit,
remoteError,
} = useConfig()
return (
<HostdAuthedLayout
Expand Down Expand Up @@ -63,7 +65,7 @@ export function Config() {
tip="Reset all changes"
icon="contrast"
disabled={!changeCount}
onClick={revalidateAndResetFormData}
onClick={revalidateAndResetForm}
>
<Reset16 />
</Button>
Expand All @@ -81,44 +83,48 @@ export function Config() {
}
openSettings={() => openDialog('settings')}
>
<div className="p-6 flex flex-col gap-16 max-w-screen-xl">
<ConfigurationPanel
title="Host"
category="host"
fields={fields}
form={form}
/>
<ConfigurationPanel
title="Pricing"
category="pricing"
fields={fields}
form={form}
/>
<ConfigurationPanel
title="DNS"
category="DNS"
fields={fields}
form={form}
/>
<ConfigurationPanel
title="Bandwidth"
category="bandwidth"
fields={fields}
form={form}
/>
<ConfigurationPanel
title="Registry"
category="registry"
fields={fields}
form={form}
/>
<ConfigurationPanel
title="Accounts"
category="RHP3"
fields={fields}
form={form}
/>
</div>
{remoteError ? (
<StateConnError />
) : (
<div className="p-6 flex flex-col gap-16 max-w-screen-xl">
<ConfigurationPanel
title="Host"
category="host"
fields={fields}
form={form}
/>
<ConfigurationPanel
title="Pricing"
category="pricing"
fields={fields}
form={form}
/>
<ConfigurationPanel
title="DNS"
category="DNS"
fields={fields}
form={form}
/>
<ConfigurationPanel
title="Bandwidth"
category="bandwidth"
fields={fields}
form={form}
/>
<ConfigurationPanel
title="Registry"
category="registry"
fields={fields}
form={form}
/>
<ConfigurationPanel
title="Accounts"
category="RHP3"
fields={fields}
form={form}
/>
</div>
)}
</HostdAuthedLayout>
)
}
Loading