Skip to content

Commit

Permalink
change subpackage to selected download when selected
Browse files Browse the repository at this point in the history
  • Loading branch information
fiskus committed Oct 16, 2024
1 parent 8cf98bd commit 0a4e7d3
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 6 deletions.
1 change: 1 addition & 0 deletions .github/workflows/deploy-catalog.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
push:
branches:
- master
- selective-package-download
paths:
- '.github/workflows/deploy-catalog.yaml'
- 'catalog/**'
Expand Down
15 changes: 13 additions & 2 deletions catalog/app/containers/Bucket/Download.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,23 @@ import mkStorage from 'utils/storage'
import * as Buttons from 'components/Buttons'

import * as FileView from './FileView'
import * as Selection from './Selection'

Check warning on line 9 in catalog/app/containers/Bucket/Download.tsx

View check run for this annotation

Codecov / codecov/patch/informational

catalog/app/containers/Bucket/Download.tsx#L9

Added line #L9 was not covered by tests

interface DownloadButtonProps {
className: string
label: string
onClick: () => void
path?: string
selection: Selection.ListingSelection
}

export function DownloadButton({ className, label, onClick, path }: DownloadButtonProps) {
export function DownloadButton({
className,
selection,
label,
onClick,
path,
}: DownloadButtonProps) {

Check warning on line 25 in catalog/app/containers/Bucket/Download.tsx

View check run for this annotation

Codecov / codecov/patch/informational

catalog/app/containers/Bucket/Download.tsx#L19-L25

Added lines #L19 - L25 were not covered by tests
if (cfg.noDownload) return null

if (cfg.desktop) {
Expand All @@ -30,7 +38,10 @@ export function DownloadButton({ className, label, onClick, path }: DownloadButt
}

return (
<FileView.ZipDownloadForm suffix={path}>
<FileView.ZipDownloadForm
suffix={path}
files={Selection.toHandlesList(selection).map(({ key }) => key)}

Check warning on line 43 in catalog/app/containers/Bucket/Download.tsx

View check run for this annotation

Codecov / codecov/patch/informational

catalog/app/containers/Bucket/Download.tsx#L43

Added line #L43 was not covered by tests
>
<Buttons.Iconized
className={className}
label={label}
Expand Down
15 changes: 11 additions & 4 deletions catalog/app/containers/Bucket/PackageTree/PackageTree.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -387,9 +387,15 @@ function DirDisplay({
)
.filter(Boolean)

const downloadPath = path
? `package/${bucket}/${name}/${hash}/${path}`
: `package/${bucket}/${name}/${hash}`
const downloadLabel = !slt.isEmpty // eslint-disable-line no-nested-ternary
? 'Download selected'

Check warning on line 391 in catalog/app/containers/Bucket/PackageTree/PackageTree.tsx

View check run for this annotation

Codecov / codecov/patch/informational

catalog/app/containers/Bucket/PackageTree/PackageTree.tsx#L391

Added line #L391 was not covered by tests
: path
? 'Download sub-package'
: 'Download package'

Check warning on line 394 in catalog/app/containers/Bucket/PackageTree/PackageTree.tsx

View check run for this annotation

Codecov / codecov/patch/informational

catalog/app/containers/Bucket/PackageTree/PackageTree.tsx#L393-L394

Added lines #L393 - L394 were not covered by tests
const downloadPath =
path && slt.isEmpty
? `package/${bucket}/${name}/${hash}/${path}`
: `package/${bucket}/${name}/${hash}`

Check warning on line 398 in catalog/app/containers/Bucket/PackageTree/PackageTree.tsx

View check run for this annotation

Codecov / codecov/patch/informational

catalog/app/containers/Bucket/PackageTree/PackageTree.tsx#L397-L398

Added lines #L397 - L398 were not covered by tests

return (
<>
Expand Down Expand Up @@ -430,9 +436,10 @@ function DirDisplay({
{actions.downloadPackage && (
<Download.DownloadButton
className={classes.button}
label={path ? 'Download sub-package' : 'Download package'}
label={downloadLabel}
onClick={openInDesktopState.confirm}
path={downloadPath}
selection={slt.selection}
/>
)}
<RevisionMenu
Expand Down

0 comments on commit 0a4e7d3

Please sign in to comment.