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
Required meta fields UI #3285
Required meta fields UI #3285
Conversation
packages/@uppy/core/src/Uppy.js
Outdated
class AggregateRestrictionError extends AggregateError { | ||
constructor (...args) { | ||
super(...args) | ||
this.isRestriction = true | ||
} | ||
} |
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.
Why are we removing this? I think we should keep it.
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.
Because it’s unused, how do you suggest we use it? We used to show an error info message with all the missing meta fields errors — but not anymore. I thought to log it maybe.
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 it can be quite useful for debugging, and in any case it's really cheap to keep it.
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.
The linter was complaining that it was unused, do you suggest we log with it?
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 suggest to revert https://github.com/transloadit/uppy/pull/3285/files#diff-e522340b6dabc4b8f14b055b742c5c1adca74d15a06f06467956a59b7e106cc2L580-R589 and keep using it 😅 EDIT: see https://github.com/transloadit/uppy/pull/3285/files#r741085087
packages/@uppy/core/src/Uppy.js
Outdated
* | ||
*/ | ||
#checkRequiredMetaFields (files) { | ||
const errors = Object.keys(files).map((fileID) => { |
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.
You need to flatten the result, otherwise errors.length === Object.keys(files).length
.
const errors = Object.keys(files).map((fileID) => { | |
const errors = Object.keys(files).flatMap((fileID) => { |
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.
Thanks for the flatMap tip!
const metaFieldsString = missingRequiredMetaFields.map(field => ( | ||
field.charAt(0).toUpperCase() + field.slice(1) | ||
)).join(', ') |
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.
Is there a way to get the label
instead of the name
here by any chance?
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.
Only through Dashboard options, right? Which is not ideal, as in theory Core is independent of Dashboard and doesn’t know about it.
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.
But as you are making the UI for the dashboard and not for core, would it be possible to match ids of requiredMetaFields
to metaFields
and then use the name
property from the latter?
const metaFieldsString = missingRequiredMetaFields.map(field => ( | ||
field.charAt(0).toUpperCase() + field.slice(1) | ||
)).join(', ') |
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.
But as you are making the UI for the dashboard and not for core, would it be possible to match ids of requiredMetaFields
to metaFields
and then use the name
property from the latter?
const err = new RestrictionError(`${this.i18n('missingRequiredMetaFieldOnFile', { fileName: file.name })}`) | ||
errors.push(err) | ||
missingFields.push(requiredMetaFields[i]) | ||
this.#showOrLogErrorAndThrow(err, { file, showInformer: false, throwErr: false }) |
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.
are we still logging required fields in informer even with the new UI?
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.
No, showInformer: false
.
packages/@uppy/core/src/Uppy.js
Outdated
|
||
if (errors.length) { | ||
throw new AggregateRestrictionError(`${this.i18n('missingRequiredMetaField')}`, errors) | ||
throw new RestrictionError(`${this.i18n('missingRequiredMetaField')}`) |
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.
throw new RestrictionError(`${this.i18n('missingRequiredMetaField')}`) | |
throw new AggregateRestrictionError(errors, `${this.i18n('missingRequiredMetaField')}`) |
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.
But this is going to show that huge informer bubble to the users?
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.
Not it should be exactly the same. The reason we saw a huge informer before because the arguments were written the other way around (so the errors
array was used in place of the error message). If we put everything where it belongs, it should be fine.
* main: @uppy/aws-s3: use `Promise.allSettled` insead of custom utils (#3079) Convert sets to arrays prior to using spread operator to enable transpilation to ES5 (#3297) Add showRecordingLength to webcam types (#3303) Required meta fields UI (#3285) Update BACKLOG.md Release uppy@2.2.2 @uppy/provider-views@2.0.5
* main: Remove references of incorrect `options` argument for `companion.socket` (#3307) Upgrade linting to 2.0.0-0 (#3280) Release uppy@2.1.2, @uppy/robodog@2.1.3 @uppy/core@2.1.2 meta: update version references in docs Release @uppy/robodog@2.1.2 @uppy/unsplash@2.0.3 @uppy/aws-s3: use `Promise.allSettled` insead of custom utils (#3079) Convert sets to arrays prior to using spread operator to enable transpilation to ES5 (#3297) Add showRecordingLength to webcam types (#3303) Required meta fields UI (#3285) Update BACKLOG.md Release uppy@2.2.2 @uppy/provider-views@2.0.5 fix: @uppy/utils - `getFileType()` always returns a string (#3294) Remove yarn file @uppy/companion: fix Dockerfiles (#3291) @uppy/companion: use Node.js 16.x for Dockerfile (#3289) if an item is checked, it can’t be disabled (#3288)
* main: (30 commits) Refactor locale scripts & generate types and docs (#3276) Remove references of incorrect `options` argument for `companion.socket` (#3307) Upgrade linting to 2.0.0-0 (#3280) Release uppy@2.1.2, @uppy/robodog@2.1.3 @uppy/core@2.1.2 meta: update version references in docs Release @uppy/robodog@2.1.2 @uppy/unsplash@2.0.3 @uppy/aws-s3: use `Promise.allSettled` insead of custom utils (#3079) Convert sets to arrays prior to using spread operator to enable transpilation to ES5 (#3297) Add showRecordingLength to webcam types (#3303) Required meta fields UI (#3285) Update BACKLOG.md Release uppy@2.2.2 @uppy/provider-views@2.0.5 fix: @uppy/utils - `getFileType()` always returns a string (#3294) Remove yarn file @uppy/companion: fix Dockerfiles (#3291) @uppy/companion: use Node.js 16.x for Dockerfile (#3289) if an item is checked, it can’t be disabled (#3288) ...
* main: (30 commits) Refactor locale scripts & generate types and docs (transloadit#3276) Remove references of incorrect `options` argument for `companion.socket` (transloadit#3307) Upgrade linting to 2.0.0-0 (transloadit#3280) Release uppy@2.1.2, @uppy/robodog@2.1.3 @uppy/core@2.1.2 meta: update version references in docs Release @uppy/robodog@2.1.2 @uppy/unsplash@2.0.3 @uppy/aws-s3: use `Promise.allSettled` insead of custom utils (transloadit#3079) Convert sets to arrays prior to using spread operator to enable transpilation to ES5 (transloadit#3297) Add showRecordingLength to webcam types (transloadit#3303) Required meta fields UI (transloadit#3285) Update BACKLOG.md Release uppy@2.2.2 @uppy/provider-views@2.0.5 fix: @uppy/utils - `getFileType()` always returns a string (transloadit#3294) Remove yarn file @uppy/companion: fix Dockerfiles (transloadit#3291) @uppy/companion: use Node.js 16.x for Dockerfile (transloadit#3289) if an item is checked, it can’t be disabled (transloadit#3288) ...
Better UI for #2896
Added
uppy.#checkRequiredMetaFieldsOnFile
to check if the error has been fixed after a single file was edited and update the UI.Mockups from @nqst: