Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable GUI "Unembargo" button if there are active uploads #2015

Merged
merged 1 commit into from
Sep 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions dandiapi/api/models/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ def size(self):
or 0
)

@property
def active_uploads(self):
return self.dandiset.uploads.count() if self.version == 'draft' else 0

@property
def publishable(self) -> bool:
if self.status != Version.Status.VALID:
Expand Down
4 changes: 4 additions & 0 deletions dandiapi/api/tests/test_dandiset.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,7 @@ def test_dandiset_rest_create(api_client, user):
'version': 'draft',
'name': name,
'asset_count': 0,
'active_uploads': 0,
'size': 0,
'dandiset': {
'identifier': DANDISET_ID_RE,
Expand Down Expand Up @@ -436,6 +437,7 @@ def test_dandiset_rest_create_with_identifier(api_client, admin_user):
'version': 'draft',
'name': name,
'asset_count': 0,
'active_uploads': 0,
'size': 0,
'dandiset': {
'identifier': identifier,
Expand Down Expand Up @@ -543,6 +545,7 @@ def test_dandiset_rest_create_with_contributor(api_client, admin_user):
'version': 'draft',
'name': name,
'asset_count': 0,
'active_uploads': 0,
'size': 0,
'dandiset': {
'identifier': identifier,
Expand Down Expand Up @@ -633,6 +636,7 @@ def test_dandiset_rest_create_embargoed(api_client, user):
'version': 'draft',
'name': name,
'asset_count': 0,
'active_uploads': 0,
'size': 0,
'dandiset': {
'identifier': DANDISET_ID_RE,
Expand Down
4 changes: 4 additions & 0 deletions dandiapi/api/tests/test_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,7 @@ def test_version_rest_list(api_client, version, draft_version_factory):
'created': TIMESTAMP_RE,
'modified': TIMESTAMP_RE,
'asset_count': 0,
'active_uploads': 0,
'size': 0,
'status': 'Pending',
}
Expand Down Expand Up @@ -460,6 +461,7 @@ def test_version_rest_info(api_client, version):
'created': TIMESTAMP_RE,
'modified': TIMESTAMP_RE,
'asset_count': 0,
'active_uploads': 0,
'metadata': version.metadata,
'size': version.size,
'status': 'Pending',
Expand Down Expand Up @@ -510,6 +512,7 @@ def test_version_rest_info_with_asset(
'created': TIMESTAMP_RE,
'modified': TIMESTAMP_RE,
'asset_count': 1,
'active_uploads': 0,
'metadata': version.metadata,
'size': version.size,
'status': Asset.Status.VALID,
Expand Down Expand Up @@ -586,6 +589,7 @@ def test_version_rest_update(api_client, user, draft_version):
'created': TIMESTAMP_RE,
'modified': TIMESTAMP_RE,
'asset_count': draft_version.asset_count,
'active_uploads': draft_version.active_uploads,
'metadata': saved_metadata,
'size': draft_version.size,
'status': 'Pending',
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