From d9b92837ba5b2a591bdc6310f3652b4ad0b8bb06 Mon Sep 17 00:00:00 2001 From: Roni Choudhury Date: Mon, 2 Oct 2023 13:08:01 -0400 Subject: [PATCH 1/2] Use DANDI download link with external services for embargoed assets --- web/src/views/FileBrowserView/FileBrowser.vue | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/web/src/views/FileBrowserView/FileBrowser.vue b/web/src/views/FileBrowserView/FileBrowser.vue index 8907f9ba9..e2a04a1e5 100644 --- a/web/src/views/FileBrowserView/FileBrowser.vue +++ b/web/src/views/FileBrowserView/FileBrowser.vue @@ -370,6 +370,7 @@ const updating = ref(false); // Computed const owners = computed(() => store.owners?.map((u) => u.username) || null); const currentDandiset = computed(() => store.dandiset); +const embargoed = computed(() => currentDandiset.value && currentDandiset.value.dandiset.embargo_status === 'EMBARGOED'); const splitLocation = computed(() => location.value.split('/')); const isAdmin = computed(() => dandiRest.user?.admin || false); const isOwner = computed(() => !!( @@ -384,11 +385,16 @@ function getExternalServices(path: AssetPath) { && _path.aggregate_size <= service.maxsize ); + const baseApiUrl = process.env.VUE_APP_DANDI_API_ROOT; + const assetURL = () => (embargoed.value + ? `${baseApiUrl}assets/${path.asset?.asset_id}/download/` + : trimEnd((path.asset as AssetFile).url, '/')); + return EXTERNAL_SERVICES .filter((service) => servicePredicate(service, path)) .map((service) => ({ name: service.name, - url: `${service.endpoint}${trimEnd((path.asset as AssetFile).url, '/')}`, + url: `${service.endpoint}${assetURL()}`, })); } From cc0c5457b6dae543cef685fa0105bba08a04b39e Mon Sep 17 00:00:00 2001 From: Roni Choudhury <2903332+waxlamp@users.noreply.github.com> Date: Wed, 4 Oct 2023 09:37:54 -0400 Subject: [PATCH 2/2] Use optional chaining instead of traditional nullish check Co-authored-by: Jacob Nesbitt --- web/src/views/FileBrowserView/FileBrowser.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/src/views/FileBrowserView/FileBrowser.vue b/web/src/views/FileBrowserView/FileBrowser.vue index e2a04a1e5..247916b5e 100644 --- a/web/src/views/FileBrowserView/FileBrowser.vue +++ b/web/src/views/FileBrowserView/FileBrowser.vue @@ -370,7 +370,7 @@ const updating = ref(false); // Computed const owners = computed(() => store.owners?.map((u) => u.username) || null); const currentDandiset = computed(() => store.dandiset); -const embargoed = computed(() => currentDandiset.value && currentDandiset.value.dandiset.embargo_status === 'EMBARGOED'); +const embargoed = computed(() => currentDandiset.value?.dandiset.embargo_status === 'EMBARGOED'); const splitLocation = computed(() => location.value.split('/')); const isAdmin = computed(() => dandiRest.user?.admin || false); const isOwner = computed(() => !!(