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

Add missing handling API errors on UI #1115

Merged
merged 22 commits into from
Dec 13, 2021

Conversation

jerabekjiri
Copy link
Contributor

Issue: AAH-517

  • A few Examples of error alerts:
    (ignore the alert description "Request failed with status code 403", just for testing purposes :))
    Screenshot from 2021-10-18 13-50-03
    Screenshot from 2021-10-18 14-42-48
    Screenshot from 2021-10-14 19-44-25
    Screenshot from 2021-10-17 15-43-30

  • show success alert after editing namespace (after the redirect to namespace-detail). This wasn't possible before, because of local state alerts and local component AlertList
    Screenshot from 2021-10-17 19-52-08

I was thinking maybe it would be a better idea to move from local alerts in every component to push alerts to global state (context) and display it from one place always? in this case I added it to App component. As I mentioned before, this would make it easier to show alerts after changing URL (redirecting). What do you think about this? @himdel @ZitaNemeckova

Also if there's an API error in fetching table list, currently I just show an empty state and display error alert. I guess this might be confusing for users, this would be probably solved by the 500 error screen, so maybe I should do follow-up PR for that (since we already have UI mockups for it) and later add 500 error screen to all table list responses?
Screenshot from 2021-10-17 19-21-01

@jerabekjiri
Copy link
Contributor Author

The question is should we let the user finish the action (create a new namespace for example) even if this field isn't mandatory (group field is optional, therefore possibly he could create a new namespace and set this later in the app)? or never let user finish the action and keep the create button disabled if an error occurred? @himdel @ZitaNemeckova
Screenshot from 2021-11-05 11-36-51

@himdel
Copy link
Collaborator

himdel commented Nov 8, 2021

@jerabekjiri I think we can keep this simple ... the error itself shouldn't stop the user from finishing actions.

If the field is required, the group will never be selected, so the user will not be able to save anyway.

@jerabekjiri
Copy link
Contributor Author

If the field is required, the group will never be selected, so the user will not be able to save anyway.

makes sense, fixed :)

@jerabekjiri
Copy link
Contributor Author

@himdel thanks for pointing out mistakes, I completely forgot about l10n here, sorry about that

@himdel
Copy link
Collaborator

himdel commented Nov 22, 2021

No worries, looks like it's all fixed now, not seeing any new issues 👍 :)

@jerabekjiri
Copy link
Contributor Author

@himdel Resolved conflicts, could you review one more before merging, please? :)

@jerabekjiri
Copy link
Contributor Author

jerabekjiri commented Nov 29, 2021

I must have messed it up during the conflict resolving, should be fixed and updated now

@awcrosby
Copy link
Contributor

awcrosby commented Dec 1, 2021

(adding this to a few recently updated PRs…) We need CI in this repo that enforces this, but for now please:

  • Add a line to at least one of your commits that says Issue: AAH-#### (in the future it is best to be the first commit as it gets included in the initial PR description by default)
  • Ensure when merging that the Issue: AAH-#### is part of commit message via the “Squash ‘n’ Merge” description

Issue: AAH-517
@jerabekjiri
Copy link
Contributor Author

Added Issue: AAH-517 to the latest commit description

Copy link
Member

@ZitaNemeckova ZitaNemeckova left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@himdel himdel merged commit 446c384 into ansible:master Dec 13, 2021
@himdel himdel added the backport-4.4 This PR should be backported to stable-4.4 (2.1) label Jan 11, 2022
@himdel
Copy link
Collaborator

himdel commented Jan 11, 2022

backporting #1220 (via #1497) depends on this one, backporting as well (#1496)

himdel pushed a commit to himdel/ansible-hub-ui that referenced this pull request Jan 11, 2022
* add group and colleciton-info missing erros

* add EE catch alerts

* add more catch alerts

* fix double alert popup

move alerts from local state to context state

* catch errors for (my)namespace

* catch alerts in editing namespace

catch alerts if something goes wrong while editing namespace

+ add success alert on edit namespace to global context alerts

* show alert on load group error

* add more context catch alerts

* add catch alert on loading token err

* remove global alert

* drop about modal alerts

* add inline form errors to repository modal

* add namespace form errors and rename to onError

* add namespace form errors

* move alerts to collection detail

* rollback context alerts to local

* add insights alerts

* remove disabling button on error

* add l10n to alerts

* remove dead code

* remove useless alert code

* remove isDisabled attr

Issue: AAH-517
(cherry picked from commit 446c384)
@ansible ansible deleted a comment from patchback bot Jan 11, 2022
himdel added a commit that referenced this pull request Jan 11, 2022
* add group and colleciton-info missing erros

* add EE catch alerts

* add more catch alerts

* fix double alert popup

move alerts from local state to context state

* catch errors for (my)namespace

* catch alerts in editing namespace

catch alerts if something goes wrong while editing namespace

+ add success alert on edit namespace to global context alerts

* show alert on load group error

* add more context catch alerts

* add catch alert on loading token err

* remove global alert

* drop about modal alerts

* add inline form errors to repository modal

* add namespace form errors and rename to onError

* add namespace form errors

* move alerts to collection detail

* rollback context alerts to local

* add insights alerts

* remove disabling button on error

* add l10n to alerts

* remove dead code

* remove useless alert code

* remove isDisabled attr

Issue: AAH-517
(cherry picked from commit 446c384)

Co-authored-by: Jiří Jeřábek <Jerabekjirka@email.cz>
@github-actions github-actions bot added the backported-4.4 This PR has been backported to stable-4.4 (2.1) label Jan 11, 2022
@hendersonreed
Copy link
Contributor

@himdel I'm trying to move this to Done in Jira, and was interested in your thoughts about adding tests for error handling down the line. I think we can stub 500 network responses using https://docs.cypress.io/guides/guides/network-requests#Stub-Responses and then verify that errors appear as they ought to.

I don't think it's something that we need to necessarily add to this in order to consider this work done but wanted to mention it here and get your thoughts on it.

@himdel
Copy link
Collaborator

himdel commented Feb 27, 2022

@hendersonreed Great idea, I agree we should be testing these as well, and stubbing the responses sounds like a perfect solution. (I guess if we should also test a couple of real failure states where we can, but stubbing allows us to test everything.)

(I've at least added a link from himdel#1 for now.)

himdel added a commit to himdel/ansible-hub-ui that referenced this pull request Mar 11, 2022
The error handling was added in ansible#1115, but in this case, this will always error the first time.

The expected flow is:
* TokenPage loads, componentDidMount runs getOfflineToken() and fails, render displays a "{{ user_token }}" placeholder
* user clicks the "Load token" button, loadToken() calls doOffline() which triggers a reload
* TokenPage loads, componentDidMount runs getOfflineToken() and succeds, render displays the token

If there's a way of doing this without a full page reload, or of telling that doOffline just happened successfully but getOfflineToken still fails, we should keep the error. But I don't know of either right now. (Short of a double redirect maybe.)

No-Issue
himdel added a commit to himdel/ansible-hub-ui that referenced this pull request Mar 14, 2022
The error handling was added in ansible#1115, but in this case, this will always error the first time.

The expected flow is:
* TokenPage loads, componentDidMount runs getOfflineToken() and fails, render displays a "{{ user_token }}" placeholder
* user clicks the "Load token" button, loadToken() calls doOffline() which triggers a reload
* TokenPage loads, componentDidMount runs getOfflineToken() and succeds, render displays the token

If there's a way of doing this without a full page reload, or of telling that doOffline just happened successfully but getOfflineToken still fails, we should keep the error. But I don't know of either right now. (Short of a double redirect maybe.)

No-Issue
himdel added a commit that referenced this pull request Mar 24, 2022
…or (#1739)

The error handling was added in #1115, but in this case, this will always error the first time.

The expected flow is:
* TokenPage loads, componentDidMount runs getOfflineToken() and fails, render displays a "{{ user_token }}" placeholder
* user clicks the "Load token" button, loadToken() calls doOffline() which triggers a reload
* TokenPage loads, componentDidMount runs getOfflineToken() and succeds, render displays the token

If there's a way of doing this without a full page reload, or of telling that doOffline just happened successfully but getOfflineToken still fails, we should keep the error. But I don't know of either right now. (Short of a double redirect maybe.)

No-Issue
himdel added a commit to himdel/ansible-hub-ui that referenced this pull request Jul 13, 2022
the code has been there from the start, only makes sense in insights mode, and unused since ansible#183

used to be just getUser->setState->loadNamespace, before ansible#1115 added error handling, changing to just loadNamespace
himdel added a commit to himdel/ansible-hub-ui that referenced this pull request Jul 21, 2022
the code has been there from the start, only makes sense in insights mode, and unused since ansible#183

used to be just getUser->setState->loadNamespace, before ansible#1115 added error handling, changing to just loadNamespace
himdel added a commit to himdel/ansible-hub-ui that referenced this pull request Jul 21, 2022
the code has been there from the start, only makes sense in insights mode, and unused since ansible#183

used to be just getUser->setState->loadNamespace, before ansible#1115 added error handling, changing to just loadNamespace
himdel added a commit that referenced this pull request Jul 24, 2022
* translate sync alert

* RepoSelector: move insights mode switch to BaseHeader, fix extra top padding in insights mode

because BaseHeader wraps RepoSelector when present, but not rendering is still present

* insights-loader: drop older nav event type support

(comes from #715, pre-chrome 2.0)

* ActiveUserAPI: simplify getUser, return getActiveUser.data

* insights-loader: add FeatureFlagsAPI call; move insights and standalone a step closer

* UI to use feature flags in insights mode

Issue: AAH-1800

* edit-namespace, namespace-form: drop unused userId, extra getUser call

the code has been there from the start, only makes sense in insights mode, and unused since #183

used to be just getUser->setState->loadNamespace, before #1115 added error handling, changing to just loadNamespace

* InsightsUserType is unused, index.d.ts has a conflicting type for getUser, update and move there

* ActiveUserAPI.getUser, getActiveUser - merge into getUser, no users of these functions can really deal with the insights version

* insights-loader - drop auth.getUser wait, already happening in api base *before* getUser

* remove extra border in collections documentation navitems in insights mode

* convert src/loaders/insights/ to typescript

* standalone-loader: sort context params

* insights-loader: change activeUser to user

* loadContext: shared code to load alerts, featureFlags, settings, user

* insights-loader: update title using identifyApp instead of document.title

as per https://github.com/RedHatInsights/insights-chrome/blob/master/docs/api.md#update-document-title

* ActiveAPI: type getToken, simplify promises
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-4.4 This PR should be backported to stable-4.4 (2.1) backported-4.4 This PR has been backported to stable-4.4 (2.1)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants