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

[#4019] Mapping file uploads in Object API registration (frontend) #4036

Merged
merged 2 commits into from
Mar 22, 2024

Conversation

SilviaAmAm
Copy link
Contributor

Fixes #4019 (partially)

@SilviaAmAm SilviaAmAm marked this pull request as draft March 21, 2024 10:25
Copy link

codecov bot commented Mar 21, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.06%. Comparing base (63ab6e5) to head (a5a4d5d).
Report is 2 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #4036   +/-   ##
=======================================
  Coverage   96.06%   96.06%           
=======================================
  Files         728      728           
  Lines       22847    22854    +7     
  Branches     2648     2650    +2     
=======================================
+ Hits        21947    21954    +7     
  Misses        637      637           
  Partials      263      263           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Comment on lines 58 to 64
if (componentDefinition && componentDefinition.type === 'file') {
// If it is, and it has multiple == True, then type is array
if (componentDefinition.multiple) return {type: 'array'};
// Otherwise it's string (URL of the document)
return {type: 'string', format: 'uri'};
}
Copy link
Contributor Author

@SilviaAmAm SilviaAmAm Mar 21, 2024

Choose a reason for hiding this comment

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

I made this as a 'special case'. I thought that if in the future we have more special cases we can refactor this.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm wondering if this special case should be moved in the ObjectsApiVariableConfigurationEditor component instead 🤔, as it is purely hardcoding a json schema.

Or maybe instead of passing the array of components, only pass the relevant component to this function?

Copy link
Member

Choose a reason for hiding this comment

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

more accurate would also be:

type: array
items:
  type: string
  format: uri

Copy link
Member

Choose a reason for hiding this comment

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

I think leaving it in here is more appropriate, it fits the idea of providing the json schema for a given variable. The fact that the schema is hard coded doesn't really matter, it's the same how your fallback is a hardcoded type: string, no?

@SilviaAmAm SilviaAmAm marked this pull request as ready for review March 21, 2024 14:00
@SilviaAmAm SilviaAmAm requested a review from Viicos March 21, 2024 14:00
The variable for file components has type 'array', but if only one file can be uploaded we want to be able to map it to attributes of type 'string' in the JSON schema. If multiple files can be uploaded, then we map it to 'array' attributes
@SilviaAmAm SilviaAmAm force-pushed the feature/4019-map-file-fields branch from cb06a67 to a5a4d5d Compare March 21, 2024 16:22
@sergei-maertens sergei-maertens merged commit 1d922e5 into master Mar 22, 2024
23 checks passed
@sergei-maertens sergei-maertens deleted the feature/4019-map-file-fields branch March 22, 2024 12:03
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.

Objects API "contract" feature - release blockers
3 participants