Skip to content

Commit

Permalink
Disable GUI unembargo button if there are active uploads
Browse files Browse the repository at this point in the history
  • Loading branch information
jjnesbitt committed Aug 27, 2024
1 parent 1ce8a91 commit 33f167c
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 2 deletions.
7 changes: 7 additions & 0 deletions dandiapi/api/models/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,13 @@ def size(self):
or 0
)

@property
def active_uploads(self):
if self.version != 'draft':
return 0

return self.dandiset.uploads.count()

@property
def publishable(self) -> bool:
if self.status != Version.Status.VALID:
Expand Down
1 change: 1 addition & 0 deletions dandiapi/api/views/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ class Meta:
'version',
'name',
'asset_count',
'active_uploads',
'size',
'status',
'created',
Expand Down
1 change: 1 addition & 0 deletions web/src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export interface Version {
version: string,
name: string,
asset_count: number,
active_uploads: number
size: number,
status: 'Pending' | 'Validating' | 'Valid' | 'Invalid' | 'Published',
validation_error?: string,
Expand Down
6 changes: 4 additions & 2 deletions web/src/views/DandisetLandingView/DandisetUnembargo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
>
<v-tooltip
left
:disabled="!unembargo_in_progress"
:disabled="!unembargoDisabled"
>
<template #activator="{ on }">
<div
Expand All @@ -77,7 +77,7 @@
block
color="info"
depressed
:disabled="unembargo_in_progress"
:disabled="unembargoDisabled"
@click="unembargo()"
>
{{ unembargo_in_progress ? 'Unembargoing' : 'Unembargo' }}
Expand All @@ -87,6 +87,7 @@
</div>
</template>
<span v-if="unembargo_in_progress">This dandiset is being unembargoed, please wait.</span>
<span v-else-if="currentDandiset.active_uploads">This dandiset has active uploads. Please complete or clear these uploads before proceeding.</span>
</v-tooltip>
</v-row>
<v-row>
Expand Down Expand Up @@ -127,6 +128,7 @@ const store = useDandisetStore();
const currentDandiset = computed(() => store.dandiset);
const unembargo_in_progress = computed(() => currentDandiset.value?.dandiset.embargo_status === 'UNEMBARGOING');
const unembargoDisabled = computed(() => !!(unembargo_in_progress.value || currentDandiset.value === null || currentDandiset.value.active_uploads));
const showWarningDialog = ref(false);
const confirmationPhrase = ref('');
Expand Down

0 comments on commit 33f167c

Please sign in to comment.