Skip to content
This repository was archived by the owner on Mar 25, 2021. It is now read-only.

Start error reporting#42

Merged
Ladsgroup merged 3 commits into
masterfrom
errors
Nov 9, 2020
Merged

Start error reporting#42
Ladsgroup merged 3 commits into
masterfrom
errors

Conversation

@Ladsgroup
Copy link
Copy Markdown
Contributor

This is basic error reporting, the message component is not yet released
so it can't be used but most of the work of showing the user is done
now.

Bug: T266788
Bug: T266787

@Ladsgroup
Copy link
Copy Markdown
Contributor Author

Tests needed

@Ladsgroup
Copy link
Copy Markdown
Contributor Author

Tests needed

Test added.

@micgro42
Copy link
Copy Markdown
Collaborator

micgro42 commented Nov 4, 2020

🤔 This adds the store infrastructure, but is not actually using it? Or am I missing something?

@Ladsgroup
Copy link
Copy Markdown
Contributor Author

thinking This adds the store infrastructure, but is not actually using it? Or am I missing something?

It does. It's a computed property passed around using mapState(). You can check out the PR and try it yourself (just don't write anything and click on Run query)

@micgro42
Copy link
Copy Markdown
Collaborator

micgro42 commented Nov 4, 2020

thinking This adds the store infrastructure, but is not actually using it? Or am I missing something?

It does. It's a computed property passed around using mapState(). You can check out the PR and try it yourself (just don't write anything and click on Run query)

This is very strange magic. That helper just plainly assumes that setErrors actions and such exist? 🙃

But it works 🤷

@micgro42
Copy link
Copy Markdown
Collaborator

micgro42 commented Nov 4, 2020

That being said, this still needs more work for setting the validation/error states for each input field.

@Ladsgroup
Copy link
Copy Markdown
Contributor Author

thinking This adds the store infrastructure, but is not actually using it? Or am I missing something?

It does. It's a computed property passed around using mapState(). You can check out the PR and try it yourself (just don't write anything and click on Run query)

This is very strange magic. That helper just plainly assumes that setErrors actions and such exist? upside_down_face

But it works shrug

The validate method dispatches setErrors: this.$store.dispatch( 'setErrors', [] );

That being said, this still needs more work for setting the validation/error states for each input field.

I think that's different in nature and needs to be done in a follow up (I will do it, just don't want to make this PR super big)

This is basic error reporting, the message component is not yet released
so it can't be used but most of the work of showing the user is done
now.

Bug: T266788
Bug: T266787
@micgro42
Copy link
Copy Markdown
Collaborator

micgro42 commented Nov 6, 2020

Hey, with the recently merged PRs, some nasty merge conflicts were introduced. I rebased your PR (since I also broke it :p). Please check that everything is still alright

@micgro42
Copy link
Copy Markdown
Collaborator

micgro42 commented Nov 6, 2020

thinking This adds the store infrastructure, but is not actually using it? Or am I missing something?

It does. It's a computed property passed around using mapState(). You can check out the PR and try it yourself (just don't write anything and click on Run query)

Mh, but that could do just as well without the store and only with a local state called error, since the validation is done in a method and not an action. Though, I think it works for this pull request. We can move it when dealing with setting the error states on the individual inputs in the next PR.

methods: {
validate(): boolean {
this.errors = [];
this.$store.dispatch( 'setErrors', [] );
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

this.errors = [];
this.$store.dispatch( 'setErrors', [] );

Those two lines together are strange. Since we are mapping the state to errors, shouldn't be one enough?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

IIRC, this is an issue with proxies in Vue2 (setting arrays) and can be removed in Vue3.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

We should look into migrating to Vue3. Probably, better sooner than later.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think it was a deliberate choice to go with vue2, I think it was because of consistency across the whole wmde codebase (and we can't migrate mediawiki micron frontends yet). Jakob knows the details.

@Ladsgroup
Copy link
Copy Markdown
Contributor Author

thinking This adds the store infrastructure, but is not actually using it? Or am I missing something?

It does. It's a computed property passed around using mapState(). You can check out the PR and try it yourself (just don't write anything and click on Run query)

Mh, but that could do just as well without the store and only with a local state called error, since the validation is done in a method and not an action. Though, I think it works for this pull request. We can move it when dealing with setting the error states on the individual inputs in the next PR.

My reasoning is that with this app getting bigger and bigger (and the need to introduce more components), we certainly need the error state into Vuex

@micgro42
Copy link
Copy Markdown
Collaborator

micgro42 commented Nov 9, 2020

thinking This adds the store infrastructure, but is not actually using it? Or am I missing something?

It does. It's a computed property passed around using mapState(). You can check out the PR and try it yourself (just don't write anything and click on Run query)

Mh, but that could do just as well without the store and only with a local state called error, since the validation is done in a method and not an action. Though, I think it works for this pull request. We can move it when dealing with setting the error states on the individual inputs in the next PR.

My reasoning is that with this app getting bigger and bigger (and the need to introduce more components), we certainly need the error state into Vuex

Yeah, and that is probably true for the actual validation code as well, that should move into an action. But we can do that later.

@micgro42 micgro42 self-requested a review November 9, 2020 09:36
@Ladsgroup Ladsgroup merged commit 3ca2faf into master Nov 9, 2020
@Ladsgroup Ladsgroup deleted the errors branch November 9, 2020 10:18
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants