-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(renterd): autopilot move from configured to enabled
- Loading branch information
1 parent
74f1f28
commit e5ed0df
Showing
27 changed files
with
195 additions
and
350 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
'@siafoundation/renterd-js': minor | ||
'@siafoundation/renterd-react': minor | ||
'@siafoundation/renterd-types': minor | ||
--- | ||
|
||
The configured boolean was removed from AutopilotState. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'renterd': minor | ||
--- | ||
|
||
Uploading files is no longer disabled if the user has not configured their settings. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'renterd': minor | ||
--- | ||
|
||
The configuration page navbar now has a switch for enabling or disabling autopilot. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'renterd': minor | ||
--- | ||
|
||
The configuration no longer fills Sia Central network averages for max prices during first time configuration. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,11 @@ | ||
import { ConfigEnabledSwitch } from '../ConfigEnabledSwitch' | ||
|
||
export function ConfigNav() { | ||
return <div className="pl-1"></div> | ||
return ( | ||
<div className="pl-1"> | ||
<div className="flex items-center gap-2"> | ||
<ConfigEnabledSwitch size="small" /> | ||
</div> | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 ( | ||
<Tooltip content="Enable or disable the system autopilot which handles forming contracts and maintaining files."> | ||
<div> | ||
<Switch | ||
size={size} | ||
checked={!!autopilotConfig.data?.enabled} | ||
onCheckedChange={toggleEnabled} | ||
/> | ||
</div> | ||
</Tooltip> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,15 @@ | ||
import React from 'react' | ||
import { OnboardingBar } from './OnboardingBar' | ||
import { TransfersBar } from './TransfersBar' | ||
import { EnabledBar } from './EnabledBar' | ||
|
||
export function DockedControls({ children }: { children?: React.ReactNode }) { | ||
return ( | ||
<div className="flex flex-col gap-2"> | ||
{children} | ||
<TransfersBar /> | ||
<OnboardingBar /> | ||
<EnabledBar /> | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 <AppDockedControl /> | ||
} | ||
|
||
if (autopilotConfig.data.enabled) { | ||
return <AppDockedControl /> | ||
} | ||
|
||
return ( | ||
<AppDockedControl> | ||
<div className="flex justify-center"> | ||
<Panel className="w-[400px] flex flex-col gap-2 max-h-[600px] p-3"> | ||
<div className="flex gap-1 items-center"> | ||
<Text size="18" weight="medium" color="contrast"> | ||
<Warning24 /> | ||
</Text> | ||
<Text size="18" weight="medium" color="contrast"> | ||
Autopilot is currently disabled | ||
</Text> | ||
<div className="flex-1" /> | ||
<ConfigEnabledSwitch size="medium" /> | ||
</div> | ||
<Text size="12" color="subtle"> | ||
Enable autopilot to form contracts and maintain files. | ||
</Text> | ||
</Panel> | ||
</div> | ||
</AppDockedControl> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 4 additions & 4 deletions
8
apps/renterd/components/Files/checks/useAutopilotNotConfigured.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.