-
Notifications
You must be signed in to change notification settings - Fork 10
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
Improve validation error display #1579
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
12a4bb5
Return object for asset validation errors
jjnesbitt 3a23379
Move version/asset validation errors into dialog
jjnesbitt 19ef594
Only group errors if multiple per asset
jjnesbitt 1c43f0f
Fix linting errors
jjnesbitt 5aeacc3
Use flat listing for asset validation errors
jjnesbitt 1ed3f25
Fix showAssetsTab logic
jjnesbitt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,199 @@ | ||
<template> | ||
<v-card | ||
min-height="90vh" | ||
class="pa-2" | ||
> | ||
<v-tabs v-model="tab"> | ||
<v-tab | ||
v-if="showMetadataTab" | ||
key="metadata" | ||
href="#metadata" | ||
> | ||
Metadata | ||
</v-tab> | ||
<v-tab | ||
v-if="showAssetsTab" | ||
key="assets" | ||
href="#assets" | ||
> | ||
Assets | ||
</v-tab> | ||
</v-tabs> | ||
<v-tabs-items v-model="tab"> | ||
<!-- Metadata --> | ||
<v-tab-item | ||
v-if="showMetadataTab" | ||
key="metadata" | ||
value="metadata" | ||
:transition="false" | ||
> | ||
<v-btn | ||
v-if="owner" | ||
class="mt-1" | ||
color="primary" | ||
@click="$emit('openMeditor')" | ||
> | ||
Fix issues | ||
</v-btn> | ||
<v-list | ||
class="overflow-y-auto" | ||
> | ||
<div | ||
v-for="(error, index) in versionValidationErrors" | ||
:key="index" | ||
> | ||
<v-list-item> | ||
<v-list-item-icon> | ||
<v-icon> | ||
{{ getValidationErrorIcon(error.field) }} | ||
</v-icon> | ||
</v-list-item-icon> | ||
|
||
<v-list-item-content> | ||
<template v-if="error.field"> | ||
{{ error.field }}: | ||
</template> | ||
{{ error.message }} | ||
</v-list-item-content> | ||
</v-list-item> | ||
<v-divider /> | ||
</div> | ||
</v-list> | ||
</v-tab-item> | ||
|
||
<!-- Assets --> | ||
<v-tab-item | ||
v-if="showAssetsTab" | ||
key="assets" | ||
value="assets" | ||
:transition="false" | ||
> | ||
<v-list | ||
class="overflow-y-auto" | ||
> | ||
<v-expansion-panels multiple> | ||
<template v-for="(errors, path) in groupedAssetValidationErrors"> | ||
<v-list-item | ||
:key="path" | ||
> | ||
<v-list-item-icon> | ||
<v-icon> | ||
<template v-if="errors.length > 1"> | ||
mdi-alert-plus | ||
</template> | ||
<template v-else> | ||
{{ getValidationErrorIcon(errors[0].field) }} | ||
</template> | ||
</v-icon> | ||
</v-list-item-icon> | ||
|
||
<!-- Inline single errors --> | ||
<template v-if="errors.length === 1"> | ||
<v-list-item-content> | ||
<strong>{{ path }}</strong> | ||
<template v-if="errors[0].field"> | ||
{{ errors[0].field }} - | ||
</template> | ||
{{ errors[0].message }} | ||
</v-list-item-content> | ||
</template> | ||
|
||
<!-- Group multiple asset errors --> | ||
<template v-else> | ||
<v-list-group class="multi-error-list-group"> | ||
<template #activator> | ||
<v-list-item-content> | ||
<strong>{{ path }}</strong> | ||
<v-list-item-subtitle>Click to expand</v-list-item-subtitle> | ||
</v-list-item-content> | ||
</template> | ||
|
||
<v-list-item | ||
v-for="error in errors" | ||
:key="`${error.field}-${error.message}`" | ||
> | ||
<v-list-item-icon> | ||
<v-icon> | ||
{{ getValidationErrorIcon(error.field) }} | ||
</v-icon> | ||
</v-list-item-icon> | ||
<v-list-item-content> | ||
<template v-if="error.field"> | ||
{{ error.field }}: | ||
</template> | ||
{{ error.message }} | ||
</v-list-item-content> | ||
</v-list-item> | ||
</v-list-group> | ||
</template> | ||
</v-list-item> | ||
</template> | ||
</v-expansion-panels> | ||
</v-list> | ||
</v-tab-item> | ||
</v-tabs-items> | ||
</v-card> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import type { ValidationError } from '@/types'; | ||
import type { PropType } from 'vue'; | ||
import { watch, computed, ref } from 'vue'; | ||
|
||
import { VALIDATION_ICONS } from '@/utils/constants'; | ||
|
||
const props = defineProps({ | ||
assetValidationErrors: { | ||
type: Array as PropType<ValidationError[]>, | ||
required: true, | ||
}, | ||
versionValidationErrors: { | ||
type: Array as PropType<ValidationError[]>, | ||
required: true, | ||
}, | ||
selectedTab: { | ||
type: String as PropType<'metadata' | 'assets'>, | ||
required: false, | ||
default: 'metadata', | ||
}, | ||
owner: { | ||
type: Boolean, | ||
required: false, | ||
default: false, | ||
}, | ||
}); | ||
|
||
const tab = ref(props.selectedTab); | ||
watch(() => props.selectedTab, (val) => { | ||
tab.value = val; | ||
}); | ||
|
||
const showMetadataTab = computed(() => !!props.versionValidationErrors.length); | ||
const showAssetsTab = computed(() => !!Object.keys(props.assetValidationErrors).length); | ||
const groupedAssetValidationErrors = computed(() => { | ||
const path_asset_map: Record<string, ValidationError[]> = {}; | ||
props.assetValidationErrors.forEach((err) => { | ||
if (!(err.path in path_asset_map)) { | ||
path_asset_map[err.path] = []; | ||
} | ||
path_asset_map[err.path].push(err); | ||
}); | ||
|
||
return path_asset_map; | ||
}); | ||
|
||
function getValidationErrorIcon(errorField: string): string { | ||
const icons = Object.keys(VALIDATION_ICONS).filter((field) => errorField.includes(field)); | ||
if (icons.length > 0) { | ||
return (VALIDATION_ICONS as any)[icons[0]]; | ||
} | ||
return VALIDATION_ICONS.DEFAULT; | ||
} | ||
|
||
</script> | ||
<style> | ||
.multi-error-list-group .v-list-group__header { | ||
padding-left: 0; | ||
padding-right: 0; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this will be really slow and/or memory intensive if a dandiset has hundreds of thousands of invalid assets. In general, I don't like how we go about storing asset validation errors in the database, but this PR is a strict improvement over the current situation imo. Perhaps related to #1214.