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

Limit file extensions to be imported into a document #1520

Merged
merged 3 commits into from
Mar 18, 2025

Conversation

jordigh
Copy link
Contributor

@jordigh jordigh commented Mar 17, 2025

Context

Users have tried using the importer to add tables to an existing document, but without any indication of which file types are available for import, users may upload an incompatible file type and hit an error message.

Proposed solution

Limit the file picker to only the table-level importable file types, analogous to the limits imposed on the document-level importable types.

Original commit messages:

  • d917f5f uploads: add new constant, IMPORTABLE_TABLE_EXTENSIONS

    What makes sense to import into a document isn't the same as what
    makes sense for importing as a whole document.

  • 28191b0 Importer: limit list of acceptable files to IMPORTABLE_TABLE_EXTENSIONS

    This should reduce the possibility that our users will attempt to
    import the wrong kind of file.

Has this been tested?

  • 👍 yes, I added tests to the test suite
  • 💭 no, because this PR is a draft and still needs work
  • 🙅 no, because this is not relevant here
  • 🙋 no, because I need help

We don't have tests for OS-level dialogues that the web browser could open, so instead I did some manual testing to ensure that the dialogue only allows uploading this restricted set of file types.

Screenshots / Screencasts

uploads.mp4

…ONS`

This should reduce the possibility that our users will attempt to
import the wrong kind of file.
@jordigh jordigh force-pushed the jordigh/importable-types branch from 28191b0 to 9b17781 Compare March 17, 2025 22:31
Copy link
Member

@paulfitz paulfitz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, just a naming comment.

@@ -31,6 +31,9 @@ export interface SelectFileOptions extends UploadOptions {
// e.g. [".jpg", ".png"]
}

// This list coincides with the extensions defined in core/plugins/manifest.yml
export const IMPORTABLE_TABLE_EXTENSIONS = [".xlsx", ".json", ".csv", ".tsv", "dsv"];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The relationship between IMPORTABLE_EXTENSIONS and IMPORTABLE_TABLE_EXTENSIONS is a bit confusing. The word TABLE suggests one of them might be for single table imports, but that isn't the case for .xlsx and .json

Maybe the distinction is more like IMPORTABLE_AS_DOC_EXTENSIONS and IMPORTABLE_WITHIN_DOC_EXTENSIONS?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, I've made that change.

jordigh added 2 commits March 17, 2025 18:43
…DOC`

We're going to have two different kinds of importable extensions, so
let's rename these to be more consistent with their purpose
What makes sense to import into a document isn't the same as what
makes sense for importing as a whole document.
@jordigh jordigh force-pushed the jordigh/importable-types branch 3 times, most recently from e1f5b27 to 0289e3d Compare March 18, 2025 00:47
Copy link
Collaborator

@fflorent fflorent left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems almost good to me!
There just seem to be a typo (as file specifiers using extensions should always start with dots).

Copy link
Member

@paulfitz paulfitz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @jordigh !

@jordigh jordigh force-pushed the jordigh/importable-types branch from c5e193d to dd73feb Compare March 18, 2025 16:52
@jordigh jordigh merged commit 8ae0477 into main Mar 18, 2025
12 checks passed
@jordigh jordigh deleted the jordigh/importable-types branch March 18, 2025 19:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants