diff --git a/changelog/unreleased/enhancement-respect-archiver-limits b/changelog/unreleased/enhancement-respect-archiver-limits new file mode 100644 index 00000000000..aa049d27534 --- /dev/null +++ b/changelog/unreleased/enhancement-respect-archiver-limits @@ -0,0 +1,8 @@ +Enhancement: Respect archiver limits + +The archiver service can now announce a limit for both the amount of resources and +the size of the currently selected resources. The web UI now respects those limits +and shows a disabled download button once the limit has been reached. + +https://github.com/owncloud/web/pull/9055 +https://github.com/owncloud/web/issues/8456 diff --git a/packages/design-system/changelog/7.0.0_2021-05-31/bugfix-interactive-oc-tooltip-texts b/packages/design-system/changelog/7.0.0_2021-05-31/bugfix-interactive-oc-tooltip-texts index 3c747b80c35..7a1e74e91fe 100644 --- a/packages/design-system/changelog/7.0.0_2021-05-31/bugfix-interactive-oc-tooltip-texts +++ b/packages/design-system/changelog/7.0.0_2021-05-31/bugfix-interactive-oc-tooltip-texts @@ -1,6 +1,6 @@ Bugfix: Interactive texts in OcTooltips The new tooltip texts would only be initialized once and then didn't offer -the possibility of chaging reactively. By updating the directive, we've changed that. +the possibility of changing reactively. By updating the directive, we've changed that. https://github.com/owncloud/owncloud-design-system/pull/1288 diff --git a/packages/web-app-files/src/composables/actions/files/useFileActionsDownloadArchive.ts b/packages/web-app-files/src/composables/actions/files/useFileActionsDownloadArchive.ts index e5f1c88f835..6603a3d5b86 100644 --- a/packages/web-app-files/src/composables/actions/files/useFileActionsDownloadArchive.ts +++ b/packages/web-app-files/src/composables/actions/files/useFileActionsDownloadArchive.ts @@ -59,6 +59,28 @@ export const useFileActionsDownloadArchive = ({ store }: { store?: Store } }) } + const archiverLimitsExceeded = (resources: Resource[]) => { + const archiverCapabilities = archiverService.capability + if (!archiverCapabilities) { + return + } + + const selectedFilesAmount = resources.length + + // TODO: selectedFilesSize doesn't traverse into folders, so currently limited to directly selected resources + const selectedFilesSize = resources.reduce( + (accumulator, currentValue) => + accumulator + + (typeof currentValue.size === 'string' ? parseInt(currentValue.size) : currentValue.size), + 0 + ) + + return ( + selectedFilesAmount > parseInt(archiverCapabilities.max_num_files) || + selectedFilesSize > parseInt(archiverCapabilities.max_size) + ) + } + const actions = computed((): FileAction[] => { return [ { @@ -68,6 +90,12 @@ export const useFileActionsDownloadArchive = ({ store }: { store?: Store } label: () => { return $gettext('Download') }, + disabledTooltip: ({ resources }) => { + return archiverLimitsExceeded(resources) + ? $gettext('Unable to download that many files at once') + : '' + }, + isDisabled: ({ resources }) => archiverLimitsExceeded(resources), isEnabled: ({ resources }) => { if ( unref(isFilesAppActive) && diff --git a/packages/web-app-files/src/services/archiver.ts b/packages/web-app-files/src/services/archiver.ts index 00f10ad1b8d..0056d5eb853 100644 --- a/packages/web-app-files/src/services/archiver.ts +++ b/packages/web-app-files/src/services/archiver.ts @@ -17,6 +17,8 @@ export interface ArchiverCapability { formats: string[] // eslint-disable-next-line camelcase archiver_url: string + max_num_files: string + max_size: string } interface TriggerDownloadOptions { diff --git a/packages/web-app-files/tests/unit/components/Spaces/__snapshots__/SpaceContextActions.spec.ts.snap b/packages/web-app-files/tests/unit/components/Spaces/__snapshots__/SpaceContextActions.spec.ts.snap index a2ef6dac886..c37e8b58d3e 100644 --- a/packages/web-app-files/tests/unit/components/Spaces/__snapshots__/SpaceContextActions.spec.ts.snap +++ b/packages/web-app-files/tests/unit/components/Spaces/__snapshots__/SpaceContextActions.spec.ts.snap @@ -5,7 +5,7 @@ exports[`SpaceContextActions action handlers renders actions that are always ava
  • -
  • -
  • -