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 the publish button when Zarrs are contained in the Dandiset #1517

Merged
merged 2 commits into from
Mar 7, 2023
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
14 changes: 13 additions & 1 deletion web/src/rest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import Vue from 'vue';
import { mapState } from 'pinia';
import OAuthClient from '@girder/oauth-client';
import {
Asset, Dandiset, Paginated, User, Version, Info, AssetPath,
Asset, Dandiset, Paginated, User, Version, Info, AssetPath, Zarr,
} from '@/types';
import { Dandiset as DandisetMetadata, DandisetContributors, Organization } from '@/types/schema';
// eslint-disable-next-line import/no-cycle
Expand Down Expand Up @@ -115,6 +115,18 @@ const dandiRest = new Vue({
throw error;
}
},
async zarr({ dandiset }: { dandiset?: string }) : Promise<Paginated<Zarr>> {
const data: { dandiset?: string } = {};
if (dandiset !== undefined) {
data.dandiset = dandiset;
}

const resp = await client.get('zarr/', {
data,
});

return resp.data;
},
async assetPaths(
identifier: string,
version: string,
Expand Down
10 changes: 10 additions & 0 deletions web/src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,16 @@ export interface Asset {
version: Version,
}

export interface Zarr {
name: string;
dandiset: string;
zarr_id: string;
status: 'Pending' | 'Ingesting' | 'Complete';
checksum: string;
file_count: number;
size: number;
}

export interface Paginated<T> {
count: number,
next: string,
Expand Down
18 changes: 17 additions & 1 deletion web/src/views/DandisetLandingView/DandisetPublish.vue
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,9 @@
</template>

<script setup lang="ts">
import { computed, ComputedRef, ref } from 'vue';
import {
computed, ComputedRef, ref, watchEffect,
} from 'vue';

import axios from 'axios';
import moment from 'moment';
Expand Down Expand Up @@ -518,6 +520,17 @@ const publishedVersion = ref('');

const alreadyBeingPublishedError = ref(false);

const containsZarr = ref(false);
watchEffect(async () => {
if (currentDandiset.value) {
const zarr = await dandiRest.zarr({
dandiset: currentDandiset.value.dandiset.identifier,
});

containsZarr.value = zarr.count > 0;
}
});

const publishDisabledMessage: ComputedRef<string> = computed(() => {
if (!loggedIn.value) {
return 'You must be logged in to edit.';
Expand All @@ -543,6 +556,9 @@ const publishDisabledMessage: ComputedRef<string> = computed(() => {
if (publishing.value) {
return 'This dandiset is being published, please wait.';
}
if (containsZarr.value) {
return 'Dandisets containing Zarr archives cannot currently be published.';
}
return '';
});

Expand Down