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

Required meta fields UI #3285

Merged
merged 7 commits into from Nov 5, 2021
Merged

Required meta fields UI #3285

merged 7 commits into from Nov 5, 2021

Conversation

arturi
Copy link
Contributor

@arturi arturi commented Nov 1, 2021

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.

Screen Shot 2021-11-01 at 09 06 37

Screen Shot 2021-11-01 at 09 48 01

Mockups from @nqst:

image (2)

image (1)

@arturi arturi requested review from aduh95 and Murderlon and removed request for aduh95 November 1, 2021 09:48
@arturi arturi marked this pull request as draft November 1, 2021 10:34
@arturi arturi requested a review from aduh95 November 1, 2021 10:34
Comment on lines 35 to 40
class AggregateRestrictionError extends AggregateError {
constructor (...args) {
super(...args)
this.isRestriction = true
}
}
Copy link
Member

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.

Copy link
Contributor Author

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.

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 it can be quite useful for debugging, and in any case it's really cheap to keep it.

Copy link
Contributor Author

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?

Copy link
Member

@aduh95 aduh95 Nov 2, 2021

Choose a reason for hiding this comment

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

*
*/
#checkRequiredMetaFields (files) {
const errors = Object.keys(files).map((fileID) => {
Copy link
Member

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.

Suggested change
const errors = Object.keys(files).map((fileID) => {
const errors = Object.keys(files).flatMap((fileID) => {

Copy link
Contributor Author

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!

Comment on lines 9 to 11
const metaFieldsString = missingRequiredMetaFields.map(field => (
field.charAt(0).toUpperCase() + field.slice(1)
)).join(', ')
Copy link
Member

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?

Copy link
Contributor Author

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.

Copy link
Member

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?

Comment on lines 9 to 11
const metaFieldsString = missingRequiredMetaFields.map(field => (
field.charAt(0).toUpperCase() + field.slice(1)
)).join(', ')
Copy link
Member

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 })
Copy link
Member

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, showInformer: false.


if (errors.length) {
throw new AggregateRestrictionError(`${this.i18n('missingRequiredMetaField')}`, errors)
throw new RestrictionError(`${this.i18n('missingRequiredMetaField')}`)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
throw new RestrictionError(`${this.i18n('missingRequiredMetaField')}`)
throw new AggregateRestrictionError(errors, `${this.i18n('missingRequiredMetaField')}`)

Copy link
Contributor Author

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?

Copy link
Member

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.

@arturi arturi marked this pull request as ready for review November 5, 2021 00:55
@arturi arturi merged commit 6e4884f into main Nov 5, 2021
@arturi arturi deleted the required-meta-ui branch November 5, 2021 15:00
Murderlon added a commit that referenced this pull request Nov 8, 2021
* 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
Murderlon added a commit that referenced this pull request Nov 10, 2021
* 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)
Murderlon added a commit that referenced this pull request Nov 11, 2021
* 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)
  ...
vymao pushed a commit to vymao/uppy that referenced this pull request Mar 29, 2022
* 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)
  ...
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.

None yet

3 participants