-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(web): download all artifacts as tarball (#108)
* feat9web): download all artifacts as tarball * fix: reset file if on all checkbox toggle Handle reset effects in useHook instead of components' input handlers * refactor: desctructure event.target.value More in line with react conventions * fix: filter `latest` version out of select version options * feat: sort version in descending semantic order * chore: bump `@zk-kit/artifacts` to 1.9.0 where `projects` array const is sorted * refactor: reset ticked download all on version change * refactor: make `reset*` state functions internal to useStore hook
- Loading branch information
Showing
11 changed files
with
84 additions
and
31 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,17 @@ | ||
import { cdnUrl } from '../constants' | ||
import { useStore } from '../hooks' | ||
import { useDownloadUrl, useStore } from '../hooks' | ||
|
||
export function DownloadButton() { | ||
const { selectedFile, selectedProject, selectedVersion } = useStore() | ||
const { selectedFile, tickedDownloadAll } = useStore() | ||
const disabled = !(selectedFile || tickedDownloadAll) | ||
const downloadUrl = useDownloadUrl() | ||
|
||
const onClick = () => { | ||
const url = `${cdnUrl}/${selectedProject}/${selectedVersion}/${selectedFile}` | ||
window.location.href = url | ||
window.location.href = downloadUrl | ||
} | ||
|
||
return <button type='button' onClick={onClick} className='btn btn-primary' disabled={!selectedFile}>Download</button> | ||
return ( | ||
<button type='button' onClick={onClick} className='btn btn-primary' disabled={disabled}> | ||
Download | ||
</button> | ||
) | ||
} |
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
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,4 @@ | ||
export * from './useDownloadUrl' | ||
export * from './useFiles' | ||
export * from './useStore' | ||
export * from './useVersions' |
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,9 @@ | ||
import { cdnUrl, npmRegistryUrl } from '../constants' | ||
import { useStore } from './useStore' | ||
|
||
export const useDownloadUrl = () => { | ||
const { selectedFile, selectedProject, selectedVersion, tickedDownloadAll } = useStore() | ||
return tickedDownloadAll | ||
? `${npmRegistryUrl}/@zk-kit/${selectedProject}-artifacts/-/${selectedProject}-artifacts-${selectedVersion}.tgz` | ||
: `${cdnUrl}/${selectedProject}/${selectedVersion}/${selectedFile}` | ||
} |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.