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

Handle API errors on schema page #2829

Conversation

Aritra8438
Copy link
Member

@Aritra8438 Aritra8438 commented Apr 19, 2023

This PR is related to #2644.

Technical details:

Currently, when one of the APIs

  • Fetching tables,
  • Fetching queries (explorations).

fails, the schema page shows no errors, assuming no results with success state. This PR will,

  • add support to refetch data once again in case the failure was temporary.
  • add support to redirect to the database page.

Screencast:

Schema_fetch_failure.mp4

Design Reference:
Figma link: https://www.figma.com/file/xHb5oIqye3fnXtb2heRH34/Styling?type=design&node-id=5807%3A31921&t=O8X0oEtOLpfjubpU-1

image

Checklist

  • My pull request has a descriptive title (not a vague title like Update index.md).
  • My pull request targets the develop branch of the repository
  • My commit messages follow best practices.
  • My code follows the established code style of the repository.
  • I added tests for the changes I made (if applicable).
  • I added or updated documentation (if applicable).
  • I tried running the project locally and verified that there are no
    visible errors.

Developer Certificate of Origin

Developer Certificate of Origin
Developer Certificate of Origin
Version 1.1

Copyright (C) 2004, 2006 The Linux Foundation and its contributors.
1 Letterman Drive
Suite D4700
San Francisco, CA, 94129

Everyone is permitted to copy and distribute verbatim copies of this
license document, but changing it is not allowed.


Developer's Certificate of Origin 1.1

By making a contribution to this project, I certify that:

(a) The contribution was created in whole or in part by me and I
    have the right to submit it under the open source license
    indicated in the file; or

(b) The contribution is based upon previous work that, to the best
    of my knowledge, is covered under an appropriate open source
    license and I have the right under that license to submit that
    work with modifications, whether created in whole or in part
    by me, under the same open source license (unless I am
    permitted to submit under a different license), as indicated
    in the file; or

(c) The contribution was provided directly to me by some other
    person who certified (a), (b) or (c) and I have not modified
    it.

(d) I understand and agree that this project and the contribution
    are public and that a record of the contribution (including all
    personal information I submit with it, including my sign-off) is
    maintained indefinitely and may be redistributed consistent with
    this project or the open source license(s) involved.

@Aritra8438
Copy link
Member Author

Hi, @rajatvijay, this PR needs to be modified accordingly once the design is available.

Did I address the problem correctly? Let me know your views on this.

@Aritra8438 Aritra8438 changed the title Add variables to handle API errors Handle API errors on schema page Apr 19, 2023
@rajatvijay rajatvijay self-assigned this Apr 20, 2023
@rajatvijay rajatvijay added the pr-status: review A PR awaiting review label Apr 20, 2023
@rajatvijay
Copy link
Contributor

@Aritra8438 I am assigning this to myself until I reply to you back with the design questions that you asked.

@rajatvijay rajatvijay added this to the Backlog milestone Apr 20, 2023
@rajatvijay rajatvijay added needs: unblocking Blocked by other work and removed pr-status: review A PR awaiting review labels May 25, 2023
@rajatvijay rajatvijay assigned Aritra8438 and unassigned rajatvijay May 25, 2023
@rajatvijay
Copy link
Contributor

rajatvijay commented May 25, 2023

This is blocked on the work design, recorded under the concerned issue.

@ghislaineguerin
Copy link
Contributor

@Aritra8438 I have updated the description to include the design. It also contains a link to the figma file

@rajatvijay rajatvijay added pr-status: revision A PR awaiting follow-up work from its author after review and removed needs: unblocking Blocked by other work labels Jun 6, 2023
@Aritra8438 Aritra8438 added the pr-status: review A PR awaiting review label Jun 22, 2023
@Aritra8438
Copy link
Member Author

Hi, @rajatvijay. I have completed adding the design.
PTAL!

@rajatvijay rajatvijay assigned rajatvijay and unassigned Aritra8438 Jun 26, 2023
@rajatvijay
Copy link
Contributor

@Aritra8438 thanks, I will review this between today and tomorrow.

@github-actions
Copy link

This pull request has not been updated in 45 days and is being marked as stale. It will automatically be closed in 30 days if not updated by then.

@Aritra8438
Copy link
Member Author

@rajatvijay! A friendly ping.

Copy link
Contributor

@rajatvijay rajatvijay left a comment

Choose a reason for hiding this comment

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

@Aritra8438 Apologies for the delay. I have added some review comments, let me know if you need more clarity on any of them.

Comment on lines +59 to +81
<div class="table-fetch-error">
<div>
<Icon {...iconWarning} />
<span>Error fetching tables</span>
</div>
<div>
<Button
on:click={() => {
if ($currentSchemaId) {
void refetchTablesForSchema($currentSchemaId);
}
}}
>
<Icon {...iconRefresh} />
<span>Retry</span>
</Button>
<a href="../">
<Button>
<span>Go to Database</span>
</Button>
</a>
</div>
</div>
Copy link
Contributor

@rajatvijay rajatvijay Sep 15, 2023

Choose a reason for hiding this comment

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

We should use ErrorBox component for this. This might lead to a minor difference in the UI as compared to the figma but that is fine

Comment on lines +99 to +121
<div class="exploration-fetch-error">
<div>
<Icon {...iconWarning} />
<span>Error fetching explorations</span>
</div>
<div>
<Button
on:click={() => {
if ($currentSchemaId) {
void refetchQueriesForSchema($currentSchemaId);
}
}}
>
<Icon {...iconRefresh} />
<span>Retry</span>
</Button>
<a href="../">
<Button>
<span>Go to Database</span>
</Button>
</a>
</div>
</div>
Copy link
Contributor

@rajatvijay rajatvijay Sep 15, 2023

Choose a reason for hiding this comment

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

We should use ErrorBox component for this. This might lead to a minor difference in the UI as compared to the figma but that is fine

justify-content: center;
align-items: flex-start;
padding: 16px;
gap: 16px;
Copy link
Contributor

Choose a reason for hiding this comment

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

This does not have good browser support. You can use :global(* + *). You can also do a global search for this code piece to see how it's being used at other places.

@@ -114,6 +173,45 @@
}
}

.table-fetch-error {
font-weight: 600;
box-sizing: border-box;
Copy link
Contributor

Choose a reason for hiding this comment

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

This is added to all elements by default in base.html no need here again.

@@ -114,6 +173,45 @@
}
}

.table-fetch-error {
font-weight: 600;
Copy link
Contributor

Choose a reason for hiding this comment

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

This makes it look unnecessarily bold(I have removed it from the left box in the SS). font-weight can be omitted completely.
Screenshot 2023-09-15 at 4 50 29 PM

padding: 16px;
gap: 16px;
width: 616px;
height: 105px;
Copy link
Contributor

@rajatvijay rajatvijay Sep 15, 2023

Choose a reason for hiding this comment

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

no need for a fixed height

Comment on lines +187 to +188
background: #fdeeed;
border: 1px solid #f9cdc8;
Copy link
Contributor

Choose a reason for hiding this comment

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

please use css variables for colors.

height: 105px;
background: #fdeeed;
border: 1px solid #f9cdc8;
border-radius: 8px;
Copy link
Contributor

Choose a reason for hiding this comment

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

please use css variables for this. --border-radius-l

Comment on lines +196 to +213
.exploration-fetch-error {
font-weight: 600;
box-sizing: border-box;
display: flex;
flex-direction: column;
justify-content: center;
align-items: flex-start;
padding: 16px;
gap: 16px;
width: 304px;
height: 105px;
background: #fdeeed;
border: 1px solid #f9cdc8;
border-radius: 8px;
flex: none;
order: 1;
align-self: stretch;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

look at the comments in the similar CSS above (table-fetch-error class)

Comment on lines 61 to +64
$: isTablesLoading = $tablesStore.state === States.Loading;
$: isTablesUnfetchable = $tablesStore.state === States.Error;
$: isExplorationsLoading = $queries.requestStatus.state === 'processing';
$: isExplorationsUnfetchable = $queries.requestStatus.state === 'failure';
Copy link
Contributor

Choose a reason for hiding this comment

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

instead of passing separate variables for loading & error, please use RequestStatus (refer: mathesar_ui/src/api/utils/requestUtils.ts). This will let you pass error message too to the child component.
You can then use the error string to show on the UI instead a generic message("Error fetching tables") from Figma. This give more information to the user and help him/her to report better errors .

@rajatvijay rajatvijay assigned Aritra8438 and unassigned rajatvijay Sep 19, 2023
@rajatvijay rajatvijay added pr-status: revision A PR awaiting follow-up work from its author after review and removed pr-status: review A PR awaiting review labels Sep 19, 2023
@Aritra8438
Copy link
Member Author

Thanks, @rajatvijay. However, my scary mid-sem is going on. It will take one week and a half for me to get back to this.

@seancolsen
Copy link
Contributor

@Aritra8438 are you still planning to finish this PR?

@Aritra8438
Copy link
Member Author

Yes, @seancolsen.

@seancolsen
Copy link
Contributor

I'm closing this because it's not been updated in a while, and the issue now seems to have been solved by #3323.

@seancolsen seancolsen closed this Dec 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr-status: revision A PR awaiting follow-up work from its author after review
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

4 participants