Skip to content

Commit

Permalink
Merge pull request #1810 from aaronkanzer/aaronkanzer-staging-command
Browse files Browse the repository at this point in the history
For staging environment, include dynamic text for `dandi download` command
  • Loading branch information
waxlamp authored Sep 20, 2024
2 parents 5358002 + 8b846b3 commit 117b7ef
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 13 deletions.
10 changes: 9 additions & 1 deletion web/src/components/FileBrowser/FileUploadInstructions.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
width="60%"
class="white--text pl-2 py-1 text-left"
>
<div>> dandi download https://dandiarchive.org/dandiset/{{ dandisetIdentifier }}/draft</div>
<div>> {{ downloadCommand }}</div>
<div>> cd {{ dandisetIdentifier }}</div>
<div>> dandi organize &lt;source_folder&gt; -f dry</div>
<div>> dandi organize &lt;source_folder&gt;</div>
Expand Down Expand Up @@ -53,4 +53,12 @@ import { useDandisetStore } from '@/stores/dandiset';
const store = useDandisetStore();
const dandisetIdentifier = computed(() => store.dandiset?.dandiset.identifier);
if (dandisetIdentifier.value === undefined) {
throw new Error('store.dandiset must be defined');
}
const downloadCommand = computed(() => {
return `dandi download ${window.location.origin}/dandiset/${dandisetIdentifier.value}/draft`
});
</script>
26 changes: 14 additions & 12 deletions web/src/views/DandisetLandingView/DownloadDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -120,14 +120,16 @@ import { computed, ref } from 'vue';
import { useDandisetStore } from '@/stores/dandiset';
import CopyText from '@/components/CopyText.vue';
function formatDownloadCommand(identifier: string, version: string): string {
if (version === 'draft') {
return `dandi download https://dandiarchive.org/dandiset/${identifier}/draft`;
}
if (!version) {
return `dandi download DANDI:${identifier}`;
}
return `dandi download DANDI:${identifier}/${version}`;
function downloadCommand(identifier: string, version: string): string {
// Use the special 'DANDI:' url prefix if appropriate.
const generalUrl = `${window.location.origin}/dandiset/${identifier}`;
const dandiUrl = `DANDI:${identifier}`;
const url = window.location.origin == 'https://dandiarchive.org' ? dandiUrl : generalUrl;
// Prepare a url suffix to specify a specific version (or not).
const versionPath = version ? `/${version}` : '';
return `dandi download ${url}${versionPath}`;
}
const store = useDandisetStore();
Expand All @@ -147,19 +149,19 @@ const availableVersions = computed(
);
const defaultDownloadText = computed(
() => (identifier.value ? formatDownloadCommand(identifier.value, currentVersion.value) : ''),
() => (identifier.value ? downloadCommand(identifier.value, currentVersion.value) : ''),
);
const customDownloadText = computed(() => {
if (!identifier.value) {
return '';
}
if (selectedDownloadOption.value === 'draft') {
return formatDownloadCommand(identifier.value, 'draft');
return downloadCommand(identifier.value, 'draft');
} if (selectedDownloadOption.value === 'latest') {
return formatDownloadCommand(identifier.value, '');
return downloadCommand(identifier.value, '');
} if (selectedDownloadOption.value === 'other') {
return formatDownloadCommand(
return downloadCommand(
identifier.value,
availableVersions.value[selectedVersion.value].version,
);
Expand Down

0 comments on commit 117b7ef

Please sign in to comment.