Skip to content

Render the dataset file preview's viewer branches #7403

Description

@aglinxinyuan

Task Summary

UserDatasetFileRendererComponent's class is well covered, but its template is not: locally it sits at 25% of statements while the class is at 91%.

The template is a viewer switch — each displayX flag selects exactly one preview — and only the CSV path had ever been rendered:

Flag Should render
isLoading / isFileLoadingError / isFileSizeUnloadable / isFileTypePreviewUnsupported the matching alert, and only that one
displayCSV or displayXlsx the shared nz-table
displayImage an image, clickable into a full-size modal
displayMP4 / displayMP3 a <video> / <audio>
displayMarkdown / displayJson / displayPlainText the matching text viewer

The media branches are guarded by && safeFileURL, which is load-bearing: the flag is set as soon as the MIME type is known, while the object URL is built asynchronously, so rendering on the flag alone emits a source-less <img>/<video>/<audio>.

Notes for whoever picks this up:

  • The first detectChanges() runs ngOnInit, which inspects the empty filePath and settles on "preview unsupported". Flags set before that cycle are silently overwritten — clear the state with the component's own turnOffAllDisplay() afterwards.
  • Binding [src] makes Angular call DomSanitizer.sanitize; the existing stub only provides bypassSecurityTrustUrl and cannot render media.
  • <markdown> needs MarkdownModule.forRoot(), as in agent-chat.component.spec.ts.

Task Type

  • Refactor / Cleanup
  • DevOps / Deployment / CI
  • Testing / QA
  • Documentation
  • Performance
  • Other

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions