diff --git a/.changeset/dirty-pianos-laugh.md b/.changeset/dirty-pianos-laugh.md new file mode 100644 index 000000000..30a753fab --- /dev/null +++ b/.changeset/dirty-pianos-laugh.md @@ -0,0 +1,7 @@ +--- +'@siafoundation/renterd-js': minor +'@siafoundation/renterd-react': minor +'@siafoundation/renterd-types': minor +--- + +The configured boolean was removed from AutopilotState. diff --git a/.changeset/five-fireants-nail.md b/.changeset/five-fireants-nail.md new file mode 100644 index 000000000..16dfafd4c --- /dev/null +++ b/.changeset/five-fireants-nail.md @@ -0,0 +1,5 @@ +--- +'renterd': minor +--- + +Uploading files is no longer disabled if the user has not configured their settings. diff --git a/.changeset/forty-months-sin.md b/.changeset/forty-months-sin.md new file mode 100644 index 000000000..218096671 --- /dev/null +++ b/.changeset/forty-months-sin.md @@ -0,0 +1,5 @@ +--- +'renterd': minor +--- + +The configuration page navbar now has a switch for enabling or disabling autopilot. diff --git a/.changeset/honest-rats-cough.md b/.changeset/honest-rats-cough.md new file mode 100644 index 000000000..3e40c0cd5 --- /dev/null +++ b/.changeset/honest-rats-cough.md @@ -0,0 +1,5 @@ +--- +'renterd': minor +--- + +The configuration no longer fills Sia Central network averages for max prices during first time configuration. diff --git a/.changeset/selfish-lemons-divide.md b/.changeset/selfish-lemons-divide.md new file mode 100644 index 000000000..e0c6ce15b --- /dev/null +++ b/.changeset/selfish-lemons-divide.md @@ -0,0 +1,5 @@ +--- +'renterd': minor +--- + +The file explorer warnings now include a warning for when autopilot is disabled, the warning relating to configuration status was removed. diff --git a/.changeset/shy-chicken-judge.md b/.changeset/shy-chicken-judge.md new file mode 100644 index 000000000..e8856872e --- /dev/null +++ b/.changeset/shy-chicken-judge.md @@ -0,0 +1,5 @@ +--- +'renterd': minor +--- + +The onboarding bar no longer shows depending on the status of configuration but the first step still suggests configuring settings and enabling autopilot. diff --git a/.changeset/sweet-chicken-suffer.md b/.changeset/sweet-chicken-suffer.md new file mode 100644 index 000000000..92ef99dc3 --- /dev/null +++ b/.changeset/sweet-chicken-suffer.md @@ -0,0 +1,5 @@ +--- +'renterd': minor +--- + +If the autopilot is disabling a warning will appear on the bottom dock. The widget includes a switch for re-enabling the autopilot. diff --git a/apps/renterd/components/Config/ConfigNav.tsx b/apps/renterd/components/Config/ConfigNav.tsx index 338ffea94..f75dd615c 100644 --- a/apps/renterd/components/Config/ConfigNav.tsx +++ b/apps/renterd/components/Config/ConfigNav.tsx @@ -1,3 +1,11 @@ +import { ConfigEnabledSwitch } from '../ConfigEnabledSwitch' + export function ConfigNav() { - return
+ return ( +
+
+ +
+
+ ) } diff --git a/apps/renterd/components/ConfigEnabledSwitch.tsx b/apps/renterd/components/ConfigEnabledSwitch.tsx new file mode 100644 index 000000000..d5f83c8f6 --- /dev/null +++ b/apps/renterd/components/ConfigEnabledSwitch.tsx @@ -0,0 +1,39 @@ +import { Switch, Tooltip } from '@siafoundation/design-system' +import { + useAutopilotConfig, + useAutopilotConfigUpdate, +} from '@siafoundation/renterd-react' +import { useCallback } from 'react' + +type Props = { + size: 'small' | 'medium' +} + +export function ConfigEnabledSwitch({ size }: Props) { + const autopilotConfigUpdate = useAutopilotConfigUpdate() + const autopilotConfig = useAutopilotConfig() + + const toggleEnabled = useCallback(() => { + if (!autopilotConfig.data) { + return + } + autopilotConfigUpdate.put({ + payload: { + ...autopilotConfig.data, + enabled: !autopilotConfig.data?.enabled, + }, + }) + }, [autopilotConfig.data, autopilotConfigUpdate]) + + return ( + +
+ +
+
+ ) +} diff --git a/apps/renterd/components/DockedControls.tsx b/apps/renterd/components/DockedControls.tsx index 81f381999..caa8255ec 100644 --- a/apps/renterd/components/DockedControls.tsx +++ b/apps/renterd/components/DockedControls.tsx @@ -1,6 +1,7 @@ import React from 'react' import { OnboardingBar } from './OnboardingBar' import { TransfersBar } from './TransfersBar' +import { EnabledBar } from './EnabledBar' export function DockedControls({ children }: { children?: React.ReactNode }) { return ( @@ -8,6 +9,7 @@ export function DockedControls({ children }: { children?: React.ReactNode }) { {children} + ) } diff --git a/apps/renterd/components/EnabledBar.tsx b/apps/renterd/components/EnabledBar.tsx new file mode 100644 index 000000000..84eb74e1f --- /dev/null +++ b/apps/renterd/components/EnabledBar.tsx @@ -0,0 +1,38 @@ +import { AppDockedControl, Panel, Text } from '@siafoundation/design-system' +import { useAutopilotConfig } from '@siafoundation/renterd-react' +import { ConfigEnabledSwitch } from './ConfigEnabledSwitch' +import { Warning24 } from '@carbon/icons-react' + +export function EnabledBar() { + const autopilotConfig = useAutopilotConfig() + + if (!autopilotConfig.data) { + return + } + + if (autopilotConfig.data.enabled) { + return + } + + return ( + +
+ +
+ + + + + Autopilot is currently disabled + +
+ +
+ + Enable autopilot to form contracts and maintain files. + + +
+ + ) +} diff --git a/apps/renterd/components/Files/FilesStatsMenuShared/FilesStatsMenuWarnings.tsx b/apps/renterd/components/Files/FilesStatsMenuShared/FilesStatsMenuWarnings.tsx index 0b2a41444..6168338bb 100644 --- a/apps/renterd/components/Files/FilesStatsMenuShared/FilesStatsMenuWarnings.tsx +++ b/apps/renterd/components/Files/FilesStatsMenuShared/FilesStatsMenuWarnings.tsx @@ -1,6 +1,5 @@ import { Button, - Code, Paragraph, Popover, Separator, @@ -9,12 +8,12 @@ import { import { Warning16 } from '@siafoundation/react-icons' import { useMemo } from 'react' import { useSyncStatus } from '../../../hooks/useSyncStatus' -import { useAutopilotNotConfigured } from '../checks/useAutopilotNotConfigured' +import { useAutopilotNotEnabled } from '../checks/useAutopilotNotConfigured' import { useNotEnoughContracts } from '../checks/useNotEnoughContracts' export function FilesStatsMenuWarnings() { const syncStatus = useSyncStatus() - const autopilotNotConfigured = useAutopilotNotConfigured() + const autopilotNotEnabled = useAutopilotNotEnabled() const notEnoughContracts = useNotEnoughContracts() const syncStatusEl = useMemo(() => { @@ -34,24 +33,22 @@ export function FilesStatsMenuWarnings() { return null }, [syncStatus.isSynced]) - const autopilotNotConfiguredEl = useMemo(() => { - if (autopilotNotConfigured.active) { + const autopilotNotEnabledEl = useMemo(() => { + if (autopilotNotEnabled.active) { return (
- Uploads are disabled until settings are configured. + Autopilot is currently disabled. - Before you can upload files you must configure your settings. Once - configured, renterd will find contracts with hosts - based on the settings you choose. renterd will also - repair your data as hosts come and go. + Files and contracts will not be automatically maintained while + autopilot is disabled.
) } return null - }, [autopilotNotConfigured.active]) + }, [autopilotNotEnabled.active]) const notEnoughContractsEl = useMemo(() => { if (notEnoughContracts.active) { @@ -73,10 +70,10 @@ export function FilesStatsMenuWarnings() { const warningList = useMemo( () => - [syncStatusEl, autopilotNotConfiguredEl, notEnoughContractsEl].filter( + [syncStatusEl, autopilotNotEnabledEl, notEnoughContractsEl].filter( Boolean ), - [syncStatusEl, autopilotNotConfiguredEl, notEnoughContractsEl] + [syncStatusEl, autopilotNotEnabledEl, notEnoughContractsEl] ) if (warningList.length) diff --git a/apps/renterd/components/Files/checks/useAutopilotNotConfigured.tsx b/apps/renterd/components/Files/checks/useAutopilotNotConfigured.tsx index 1525f2b73..a474c8be6 100644 --- a/apps/renterd/components/Files/checks/useAutopilotNotConfigured.tsx +++ b/apps/renterd/components/Files/checks/useAutopilotNotConfigured.tsx @@ -1,8 +1,8 @@ -import { useAutopilotState } from '@siafoundation/renterd-react' +import { useAutopilotConfig } from '@siafoundation/renterd-react' -export function useAutopilotNotConfigured() { - const autopilotState = useAutopilotState() +export function useAutopilotNotEnabled() { + const autopilotConfig = useAutopilotConfig() return { - active: !autopilotState.data?.configured, + active: !autopilotConfig.data?.enabled, } } diff --git a/apps/renterd/components/Files/useCanUpload.tsx b/apps/renterd/components/Files/useCanUpload.tsx index d150a27d3..212171865 100644 --- a/apps/renterd/components/Files/useCanUpload.tsx +++ b/apps/renterd/components/Files/useCanUpload.tsx @@ -1,17 +1,10 @@ import { useSyncStatus } from '../../hooks/useSyncStatus' import { useFilesManager } from '../../contexts/filesManager' -import { useAutopilotNotConfigured } from './checks/useAutopilotNotConfigured' import { useNotEnoughContracts } from './checks/useNotEnoughContracts' export function useCanUpload() { const { isViewingABucket } = useFilesManager() const syncStatus = useSyncStatus() - const autopilotNotConfigured = useAutopilotNotConfigured() const notEnoughContracts = useNotEnoughContracts() - return ( - isViewingABucket && - !autopilotNotConfigured.active && - !notEnoughContracts.active && - syncStatus.isSynced - ) + return isViewingABucket && !notEnoughContracts.active && syncStatus.isSynced } diff --git a/apps/renterd/components/FilesDirectory/EmptyState/index.tsx b/apps/renterd/components/FilesDirectory/EmptyState/index.tsx index b3e98fd82..14722c89a 100644 --- a/apps/renterd/components/FilesDirectory/EmptyState/index.tsx +++ b/apps/renterd/components/FilesDirectory/EmptyState/index.tsx @@ -2,7 +2,7 @@ import { Code, LinkButton, Text } from '@siafoundation/design-system' import { CloudUpload32 } from '@siafoundation/react-icons' import { routes } from '../../../config/routes' import { useFilesDirectory } from '../../../contexts/filesDirectory' -import { useAutopilotNotConfigured } from '../../Files/checks/useAutopilotNotConfigured' +import { useAutopilotNotEnabled } from '../../Files/checks/useAutopilotNotConfigured' import { useNotEnoughContracts } from '../../Files/checks/useNotEnoughContracts' import { StateError } from './StateError' import { StateNoneMatching } from './StateNoneMatching' @@ -14,7 +14,7 @@ export function EmptyState() { const { isViewingRootOfABucket, isViewingBuckets } = useFilesManager() const { dataState } = useFilesDirectory() - const autopilotNotConfigured = useAutopilotNotConfigured() + const autopilotNotEnabled = useAutopilotNotEnabled() const notEnoughContracts = useNotEnoughContracts() if (dataState === 'noneMatchingFilters') { @@ -29,7 +29,7 @@ export function EmptyState() { if ( isViewingRootOfABucket && dataState === 'noneYet' && - autopilotNotConfigured.active + autopilotNotEnabled.active ) { return (
@@ -38,9 +38,9 @@ export function EmptyState() {
- Before you can upload files you must configure your settings. Once - configured, renterd will find contracts with hosts - based on the settings you choose. renterd will also + Before you can upload files you must configure and enable your + settings. Once enabled, renterd will find contracts + with hosts based on the settings. renterd will also repair your data as hosts come and go. diff --git a/apps/renterd/components/OnboardingBar.tsx b/apps/renterd/components/OnboardingBar.tsx index 04c311773..1f5532f6b 100644 --- a/apps/renterd/components/OnboardingBar.tsx +++ b/apps/renterd/components/OnboardingBar.tsx @@ -19,7 +19,7 @@ import { useSyncStatus } from '../hooks/useSyncStatus' import { routes } from '../config/routes' import { useDialog } from '../contexts/dialog' import { useNotEnoughContracts } from './Files/checks/useNotEnoughContracts' -import { useAutopilotState, useWallet } from '@siafoundation/renterd-react' +import { useWallet } from '@siafoundation/renterd-react' import BigNumber from 'bignumber.js' import { humanSiacoin } from '@siafoundation/units' import { useAppSettings } from '@siafoundation/react-core' @@ -28,7 +28,6 @@ import { useSpendingEstimate } from '../contexts/config/useSpendingEstimate' export function OnboardingBar() { const { isUnlockedAndAuthedRoute } = useAppSettings() - const autopilotState = useAutopilotState() const { openDialog } = useDialog() const wallet = useWallet() const [maximized, setMaximized] = useLocalStorageState( @@ -50,7 +49,7 @@ export function OnboardingBar() { wallet.data ? wallet.data.confirmed + wallet.data.unconfirmed : 0 ) - const step1Configured = autopilotState.data?.configured + const step1Configured = true const step2Synced = syncStatus.isSynced const step3Funded = walletBalance.gt(0) const step4Contracts = !notEnoughContracts.active @@ -101,23 +100,12 @@ export function OnboardingBar() { } description={ - 'Specify how much data you plan to store and your target price.' + 'Specify your estimated usage and maximum pricing values.' } action={ - step1Configured ? ( - - - - ) : ( - <> - - - - - - - - ) + + + } />
{ describe('down', () => { @@ -30,7 +29,6 @@ describe('tansforms', () => { const { autopilot, gouging, pinned, upload } = buildAllResponses() expect( transformDown({ - hasBeenConfigured: true, autopilot: { ...autopilot, hosts: { @@ -76,56 +74,12 @@ describe('tansforms', () => { pinnedThreshold: new BigNumber(10), } as InputValues) }) - - it('applies first time user overrides', () => { - const { gouging, pinned, upload } = buildAllResponses() - const values = transformDown({ - hasBeenConfigured: false, - autopilot: undefined, - pinned, - gouging, - upload: merge(upload, { - packing: { - enabled: false, - }, - }), - averages: { - settings: { - download_price: (4e24).toString(), - storage_price: (4e24).toString(), - upload_price: (4e24).toString(), - }, - }, - }) - expect(values.maxUploadPriceTB).toEqual(new BigNumber('4000000000000')) - expect(values.maxDownloadPriceTB).toEqual(new BigNumber('4000000000000')) - expect(values.maxStoragePriceTBMonth).toEqual( - new BigNumber('17280000000000000') - ) - }) - - it('does not apply overrides if missing averages', () => { - const { gouging, pinned, upload } = buildAllResponses() - const values = transformDown({ - hasBeenConfigured: false, - autopilot: undefined, - gouging, - pinned, - upload: merge(upload, { - packing: { - enabled: false, - }, - }), - }) - expect(values.maxUploadPriceTB).toEqual(new BigNumber('1000.232323')) - expect(values.maxDownloadPriceTB).toEqual(new BigNumber('1004.31')) - expect(values.maxStoragePriceTBMonth).toEqual(new BigNumber('909.494702')) - }) }) describe('up', () => { describe('autopilot', () => { it('up autopilot', () => { + const { autopilot } = buildAllResponses() expect( transformUpAutopilot( 'mainnet', @@ -143,10 +97,10 @@ describe('tansforms', () => { maxConsecutiveScanFailures: new BigNumber('10'), minProtocolVersion: '', }, - undefined + autopilot ) ).toEqual({ - enabled: true, + enabled: false, hosts: { maxDowntimeHours: 1440, maxConsecutiveScanFailures: 10, @@ -236,6 +190,7 @@ describe('tansforms', () => { minProtocolVersion: '1.7.0', }, { + enabled: true, contracts: { period: 7777, }, @@ -419,11 +374,10 @@ describe('tansforms', () => { autopilotState: { data: autopilotState, }, - autopilot: {}, + autopilot: { data: autopilot }, gouging: { data: gouging }, pinned: { data: pinned }, upload: { data: upload }, - averages: {}, appSettings: { settings: { siaCentral: false, @@ -435,7 +389,6 @@ describe('tansforms', () => { }, } const down = transformDown({ - hasBeenConfigured: true, autopilot: { ...autopilot, contracts: { @@ -457,7 +410,6 @@ describe('tansforms', () => { values: down as SubmitValues, }) const downUpDown = transformDown({ - hasBeenConfigured: true, ...downUp.payloads, }) @@ -515,8 +467,6 @@ describe('tansforms', () => { function buildAllResponses() { return { autopilotState: { - id: 'autopilot', - configured: true, migrating: true, migratingLastStart: new Date().toISOString(), scanning: true, diff --git a/apps/renterd/contexts/config/transformDown.ts b/apps/renterd/contexts/config/transformDown.ts index 19fc1c8bd..e93229cbe 100644 --- a/apps/renterd/contexts/config/transformDown.ts +++ b/apps/renterd/contexts/config/transformDown.ts @@ -79,60 +79,11 @@ export function transformDownAutopilot( } } -function firstTimeGougingData({ - gouging, - averages, - hasBeenConfigured, -}: { - gouging: SettingsGouging - averages?: { - settings: { - download_price: string - storage_price: string - upload_price: string - } - } - hasBeenConfigured: boolean -}): SettingsGouging { - // Already configured, the user has changed the defaults. - if (hasBeenConfigured) { - return gouging - } - // If sia central is disabled, we cant override with averages. - if (!averages) { - return gouging - } - return { - ...gouging, - maxStoragePrice: averages.settings.storage_price, - maxDownloadPrice: new BigNumber( - averages.settings.download_price - ).toString(), - maxUploadPrice: new BigNumber(averages.settings.upload_price).toString(), - } -} - export function transformDownGouging({ - gouging: _gouging, - averages, - hasBeenConfigured, + gouging, }: { gouging: SettingsGouging - averages?: { - settings: { - download_price: string - storage_price: string - upload_price: string - } - } - hasBeenConfigured: boolean }): ValuesGouging { - const gouging = firstTimeGougingData({ - gouging: _gouging, - averages, - hasBeenConfigured, - }) - return { maxStoragePriceTBMonth: toSiacoins( valuePerBytePerBlockToPerTBPerMonth( @@ -198,27 +149,17 @@ export function transformDownUpload(u: SettingsUpload): ValuesUpload { } export type RemoteData = { - hasBeenConfigured: boolean - autopilot: AutopilotConfig | undefined + autopilot: AutopilotConfig gouging: SettingsGouging pinned: SettingsPinned upload: SettingsUpload - averages?: { - settings: { - download_price: string - storage_price: string - upload_price: string - } - } } export function transformDown({ - hasBeenConfigured, autopilot, gouging, pinned, upload, - averages, }: RemoteData): InputValues { return { // autopilot @@ -226,8 +167,6 @@ export function transformDown({ // gouging ...transformDownGouging({ gouging, - averages, - hasBeenConfigured, }), // pinning ...transformDownPinned(pinned), diff --git a/apps/renterd/contexts/config/transformUp.ts b/apps/renterd/contexts/config/transformUp.ts index 087d41e16..fccf41803 100644 --- a/apps/renterd/contexts/config/transformUp.ts +++ b/apps/renterd/contexts/config/transformUp.ts @@ -38,8 +38,7 @@ import { objectEntries } from '@siafoundation/design-system' export function transformUpAutopilot( network: 'mainnet' | 'zen' | 'anagami', values: SubmitValuesAutopilot, - // eslint-disable-next-line @typescript-eslint/no-explicit-any - existingValues: AutopilotConfig | undefined + existingValues: AutopilotConfig ): AutopilotConfig { const v = applyDefaultToAnyEmptyValues( values, @@ -48,8 +47,6 @@ export function transformUpAutopilot( return { ...existingValues, - enabled: - existingValues?.enabled !== undefined ? existingValues.enabled : true, contracts: { ...existingValues?.contracts, amount: Math.round(v.amountHosts.toNumber()), diff --git a/apps/renterd/contexts/config/useAutopilotEvaluations.tsx b/apps/renterd/contexts/config/useAutopilotEvaluations.tsx index bf7b11eeb..1cf2e8b98 100644 --- a/apps/renterd/contexts/config/useAutopilotEvaluations.tsx +++ b/apps/renterd/contexts/config/useAutopilotEvaluations.tsx @@ -53,9 +53,6 @@ export function useAutopilotEvaluations({ if (!renterdState.data) { return false } - if (!loaded.autopilotState.data.configured) { - return false - } return true }, [form.formState.isValid, resources, renterdState.data]) @@ -250,8 +247,6 @@ export function useAutopilotEvaluations({ const recommended = transformDownGouging({ gouging: recommendedGougingSettings, - averages: resources.averages.data, - hasBeenConfigured: true, }) const recommendedPinned = pricesToPinnedPrices({ exchangeRate: rate, @@ -297,7 +292,6 @@ export function useAutopilotEvaluations({ return recs }, [ recommendedGougingSettings, - resources, payloads, currentValuesWithPinnedOverridesAndDefaults, getIsFieldEnabled, diff --git a/apps/renterd/contexts/config/useOnValid.tsx b/apps/renterd/contexts/config/useOnValid.tsx index 305c1ce44..6b808c506 100644 --- a/apps/renterd/contexts/config/useOnValid.tsx +++ b/apps/renterd/contexts/config/useOnValid.tsx @@ -38,7 +38,6 @@ export function useOnValid({ if (!loaded || !renterdState.data) { return } - const firstTimeSettingConfig = !loaded.autopilotState.data?.configured const { payloads } = transformUp({ resources: loaded, @@ -80,17 +79,11 @@ export function useOnValid({ triggerSuccessToast({ title: 'Configuration has been saved' }) - // If autopilot is being configured for the first time, - // revalidate the empty hosts list. - if (firstTimeSettingConfig) { - const refreshHostsAfterDelay = async () => { - await delay(5_000) - mutate((key) => key.startsWith(busHostsRoute)) - await delay(5_000) - mutate((key) => key.startsWith(busHostsRoute)) - } - refreshHostsAfterDelay() + const refreshHostsAfterDelay = async () => { + await delay(5_000) + mutate((key) => key.startsWith(busHostsRoute)) } + refreshHostsAfterDelay() await revalidateAndResetForm() }, diff --git a/apps/renterd/contexts/config/useResources.tsx b/apps/renterd/contexts/config/useResources.tsx index 58c2485f0..095ea2dd0 100644 --- a/apps/renterd/contexts/config/useResources.tsx +++ b/apps/renterd/contexts/config/useResources.tsx @@ -13,8 +13,6 @@ import { useSettingsPinned, useSettingsUpload, } from '@siafoundation/renterd-react' -import { useSiaCentralHostsNetworkAverages } from '@siafoundation/sia-central-react' -import { SiaCentralHostsNetworkAveragesResponse } from '@siafoundation/sia-central-types' import { minutesInMilliseconds } from '@siafoundation/units' import { useMemo } from 'react' @@ -26,16 +24,13 @@ export function useResources() { }, }, }) - // Settings that 404 when empty. const autopilot = useAutopilotConfig({ config: { swr: { - errorRetryCount: 0, refreshInterval: minutesInMilliseconds(1), }, }, }) - // Settings with initial defaults. const gouging = useSettingsGouging({ config: { swr: { @@ -57,13 +52,6 @@ export function useResources() { }, }, }) - const averages = useSiaCentralHostsNetworkAverages({ - config: { - swr: { - revalidateOnFocus: false, - }, - }, - }) const appSettings = useAppSettings() @@ -90,10 +78,6 @@ export function useResources() { data: upload.data, error: upload.error, }, - averages: { - data: averages.data, - error: averages.error, - }, appSettings: { settings: { siaCentral: appSettings.settings.siaCentral, @@ -111,8 +95,6 @@ export function useResources() { pinned.error, upload.data, upload.error, - averages.data, - averages.error, appSettings.settings.siaCentral, ] ) @@ -124,7 +106,6 @@ export function useResources() { gouging, pinned, upload, - averages, appSettings, } } @@ -132,21 +113,16 @@ export function useResources() { export function checkIfAllResourcesLoaded(resources: ResourcesMaybeLoaded) { const { autopilotState, autopilot, gouging, pinned, upload } = resources const loaded = !!( - // These settings have initial daemon values. - ( - autopilotState.data && - !autopilotState.error && - gouging.data && - !gouging.error && - pinned.data && - !pinned.error && - upload.data && - !upload.error && - // These settings are undefined and will error until the user sets them. - (autopilot.data || autopilot.error) - ) - // We do not wait for exchange rate or averages to load, - // in case the third party API is down. + autopilotState.data && + !autopilotState.error && + autopilot.data && + !autopilot.error && + gouging.data && + !gouging.error && + pinned.data && + !pinned.error && + upload.data && + !upload.error ) if (loaded) { return resources as ResourcesRequiredLoaded @@ -186,10 +162,6 @@ export type ResourcesMaybeLoaded = { data?: SettingsUpload error?: SWRError } - averages: { - data?: SiaCentralHostsNetworkAveragesResponse - error?: SWRError - } appSettings: { settings: { siaCentral: boolean @@ -203,7 +175,7 @@ export type ResourcesRequiredLoaded = { error?: SWRError } autopilot: { - data?: AutopilotConfig + data: AutopilotConfig error?: SWRError } gouging: { @@ -218,10 +190,6 @@ export type ResourcesRequiredLoaded = { data: SettingsUpload error?: undefined } - averages: { - data?: SiaCentralHostsNetworkAveragesResponse - error?: SWRError - } appSettings: { settings: { siaCentral: boolean diff --git a/apps/renterd/contexts/hosts/columns.tsx b/apps/renterd/contexts/hosts/columns.tsx index 9301886c7..800377cb5 100644 --- a/apps/renterd/contexts/hosts/columns.tsx +++ b/apps/renterd/contexts/hosts/columns.tsx @@ -120,18 +120,7 @@ export const columns: HostsTableColumn[] = ( id: 'ap_usable', label: 'usable', category: 'autopilot', - render: ({ data, context }) => { - if (!context.isAutopilotConfigured) { - return ( - -
- - - -
-
- ) - } + render: ({ data }) => { return ( { - if (!context.isAutopilotConfigured) { - return ( - -
- - - -
-
- ) - } + render: ({ data }) => { return ( { - if (!context.isAutopilotConfigured) { - return ( - - - - - ) - } + render: ({ data }) => { return ( { - if (!context.isAutopilotConfigured) { - return ( - - - - - ) - } + render: ({ data }) => { return ( { - if (!context.isAutopilotConfigured) { - return ( - - - - - ) - } + render: ({ data }) => { return ( { - if (!context.isAutopilotConfigured) { - return ( - - - - - ) - } + render: ({ data }) => { return ( { - if (!context.isAutopilotConfigured) { - return ( - - - - - ) - } + render: ({ data }) => { return ( { - if (!context.isAutopilotConfigured) { - return ( - - - - - ) - } + render: ({ data }) => { return ( { - if (!context.isAutopilotConfigured) { - return ( - - - - - ) - } + render: ({ data }) => { return ( { - if (!context.isAutopilotConfigured) { - return ( - - - - - ) - } + render: ({ data }) => { return ( - context.isAutopilotConfigured ? '-' : v.toPrecision(2) - } + format={(v) => v.toPrecision(2)} /> ) }, diff --git a/apps/renterd/contexts/hosts/index.tsx b/apps/renterd/contexts/hosts/index.tsx index 924662a3f..caf63aba5 100644 --- a/apps/renterd/contexts/hosts/index.tsx +++ b/apps/renterd/contexts/hosts/index.tsx @@ -7,7 +7,6 @@ import { } from '@siafoundation/design-system' import { useAppSettings } from '@siafoundation/react-core' import { - useAutopilotState, useHostsAllowlist, useHostsBlocklist, useHosts as useHostsSearch, @@ -53,7 +52,6 @@ function useHostsMain() { useServerFilters() const { dataset: allContracts } = useContracts() - const autopilotState = useAutopilotState() const keyIn = useMemo(() => { let keyIn: string[] = [] @@ -213,13 +211,11 @@ function useHostsMain() { const dataState = useDatasetEmptyState(dataset, isValidating, error, filters) const siascanUrl = useSiascanUrl() - const isAutopilotConfigured = !!autopilotState.data?.configured const tableContext: HostContext = useMemo( () => ({ - isAutopilotConfigured, siascanUrl, }), - [isAutopilotConfigured, siascanUrl] + [siascanUrl] ) const hostsWithLocation = useMemo( diff --git a/apps/renterd/contexts/hosts/types.tsx b/apps/renterd/contexts/hosts/types.tsx index 4606035e7..bf05cc423 100644 --- a/apps/renterd/contexts/hosts/types.tsx +++ b/apps/renterd/contexts/hosts/types.tsx @@ -2,7 +2,7 @@ import { HostPriceTable, HostSettings } from '@siafoundation/types' import BigNumber from 'bignumber.js' import { ContractData } from '../contracts/types' -export type HostContext = { isAutopilotConfigured: boolean; siascanUrl: string } +export type HostContext = { siascanUrl: string } export type HostData = { id: string diff --git a/libs/renterd-types/src/autopilot.ts b/libs/renterd-types/src/autopilot.ts index a21570766..ab8125a71 100644 --- a/libs/renterd-types/src/autopilot.ts +++ b/libs/renterd-types/src/autopilot.ts @@ -6,9 +6,8 @@ export const autopilotConfigEvaluateRoute = '/autopilot/config/evaluate' export const autopilotTriggerRoute = '/autopilot/trigger' export const busAutopilotRoute = '/bus/autopilot' -type AutopilotStatus = { - id: string - configured: boolean +export type AutopilotState = { + enabled: boolean migrating: boolean migratingLastStart: string pruning: boolean @@ -17,9 +16,7 @@ type AutopilotStatus = { scanningLastStart: string uptimeMS: string startTime: number -} - -export type AutopilotState = AutopilotStatus & BuildState +} & BuildState export type AutopilotStateParams = void export type AutopilotStatePayload = void