diff --git a/.changeset/dull-readers-sit.md b/.changeset/dull-readers-sit.md new file mode 100644 index 000000000..bc4f2da89 --- /dev/null +++ b/.changeset/dull-readers-sit.md @@ -0,0 +1,5 @@ +--- +'renterd': minor +--- + +File upload and directory creation are now disabled until enough contracts are formed. diff --git a/.changeset/odd-pillows-try.md b/.changeset/odd-pillows-try.md new file mode 100644 index 000000000..dc077238c --- /dev/null +++ b/.changeset/odd-pillows-try.md @@ -0,0 +1,5 @@ +--- +'renterd': minor +--- + +New users are now more clearly instructed to configure autopilot and to wait for enough contracts before files can be uploaded. diff --git a/apps/renterd/components/Files/EmptyState.tsx b/apps/renterd/components/Files/EmptyState.tsx new file mode 100644 index 000000000..18175ca67 --- /dev/null +++ b/apps/renterd/components/Files/EmptyState.tsx @@ -0,0 +1,79 @@ +import { CloudUpload32, LinkButton, Text } from '@siafoundation/design-system' +import { routes } from '../../config/routes' +import { useFiles } from '../../contexts/files' +import { useAutopilotNotConfigured } from './checks/useAutopilotNotConfigured' +import { useNotEnoughContracts } from './checks/useNotEnoughContracts' +import { StateError } from './StateError' +import { StateNoneMatching } from './StateNoneMatching' +import { StateNoneYet } from './StateNoneYet' + +export function EmptyState() { + const { dataState, activeDirectoryPath } = useFiles() + + const autopilotNotConfigured = useAutopilotNotConfigured() + const notEnoughContracts = useNotEnoughContracts() + + if (dataState === 'noneMatchingFilters') { + return + } + + if (dataState === 'error') { + return + } + + // only show on root directory and when there are no files + if ( + activeDirectoryPath === '/' && + dataState === 'noneYet' && + autopilotNotConfigured.active + ) { + return ( +
+ + + +
+ + Before you can upload files you must configure autopilot. Autopilot + finds contracts with hosts based on the settings you choose. + Autopilot also repairs your data as hosts come and go. + + + Configure autopilot → + +
+
+ ) + } + + // only show on root directory and when there are no files + if ( + activeDirectoryPath === '/' && + dataState === 'noneYet' && + notEnoughContracts.active + ) { + return ( +
+ + + +
+ + There are not enough contracts to upload data yet. Redundancy is + configured to use {notEnoughContracts.required} shards which means + at least that many contracts are required. + + + {notEnoughContracts.count}/{notEnoughContracts.required} + +
+
+ ) + } + + if (dataState === 'noneYet') { + return + } + + return null +} diff --git a/apps/renterd/components/Files/FilesActionsMenu.tsx b/apps/renterd/components/Files/FilesActionsMenu.tsx index aeab2e015..8694f8482 100644 --- a/apps/renterd/components/Files/FilesActionsMenu.tsx +++ b/apps/renterd/components/Files/FilesActionsMenu.tsx @@ -8,13 +8,17 @@ import { useFiles } from '../../contexts/files' import { useDropzone } from 'react-dropzone' import { FilesViewDropdownMenu } from './FilesViewDropdownMenu' import { useDialog } from '../../contexts/dialog' +import { useCanUpload } from './useCanUpload' export function FilesActionsMenu() { const { openDialog } = useDialog() const { uploadFiles } = useFiles() + const canUpload = useCanUpload() + const { getRootProps, getInputProps } = useDropzone({ noDrag: true, + noClick: !canUpload, onDrop: uploadFiles, }) @@ -23,11 +27,12 @@ export function FilesActionsMenu() { -