Skip to content

Commit

Permalink
Don't show download button if the dataFileUri is empty (including an …
Browse files Browse the repository at this point in the history
…empty string, which is what we get in production). (#1577)
  • Loading branch information
bbpennel authored Jun 13, 2023
1 parent 9006fd0 commit 1aeb276
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,20 @@
<div v-if="hasPermission(recordData, 'editDescription')" class="actionlink">
<a class="edit button" :href="editDescriptionUrl(recordData.briefObject.id)"><i class="fa fa-edit"></i> {{ $t('full_record.edit') }}</a>
</div>
<template v-if="fieldExists(recordData.dataFileUrl) && hasPermission(recordData, 'viewOriginal')">
<div class="actionlink download">
<a class="download button" :href="downloadLink"><i class="fa fa-download"></i> {{ $t('full_record.download') }}</a>
</div>
<div v-if="recordData.resourceType === 'File'" class="actionlink">
<a class="button view" :href="recordData.dataFileUrl">
<i class="fa fa-search" aria-hidden="true"></i> View</a>
<template v-if="recordData.dataFileUrl">
<template v-if="hasPermission(recordData, 'viewOriginal')">
<div class="actionlink download">
<a class="download button" :href="downloadLink"><i class="fa fa-download"></i> {{ $t('full_record.download') }}</a>
</div>
<div v-if="recordData.resourceType === 'File'" class="actionlink">
<a class="button view" :href="recordData.dataFileUrl">
<i class="fa fa-search" aria-hidden="true"></i> View</a>
</div>
</template>
<div v-else-if="fieldExists(recordData.briefObject.embargoDate)" class="noaction">
{{ $t('full_record.available_date', { available_date: formatDate(recordData.briefObject.embargoDate) }) }}
</div>
</template>
<div v-else-if="fieldExists(recordData.briefObject.embargoDate) && fieldExists(recordData.dataFileUrl)" class="noaction">
{{ $t('full_record.available_date', { available_date: formatDate(recordData.briefObject.embargoDate) }) }}
</div>
</div>
</template>

Expand Down
10 changes: 10 additions & 0 deletions static/js/vue-cdr-access/tests/unit/restrictedContent.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,16 @@ describe('restrictedContent.vue', () => {
expect(wrapper.find('a.download').exists()).toBe(true);
});

it('does not show download or embargo buttons if there is no dataFileUrl', async () => {
const updated_data = cloneDeep(record);
updated_data.dataFileUrl = "";
await wrapper.setProps({
recordData: updated_data
});
expect(wrapper.find('a.download').exists()).toBe(false);
expect(wrapper.find('.noaction').exists()).toBe(false);
});

it('does not show a download option does not have download permissions', async () => {
const updated_data = cloneDeep(record);
updated_data.briefObject.permissions = [];
Expand Down

0 comments on commit 1aeb276

Please sign in to comment.