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

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
6e786a9
Add variables to handle API errors
Aritra8438 Apr 19, 2023
f56d5c5
Add buttons to refetch data
Aritra8438 Apr 19, 2023
35ab59f
Fix lint issues
Aritra8438 Apr 19, 2023
c4c2b48
Merge branch 'develop' into handle-API-errors-on-schema-page
Aritra8438 Apr 20, 2023
1cb4442
Merge branch 'develop' into handle-API-errors-on-schema-page
Aritra8438 Apr 20, 2023
10200bb
Merge branch 'develop' into handle-API-errors-on-schema-page
Aritra8438 Apr 21, 2023
bab4b39
Merge branch 'develop' into handle-API-errors-on-schema-page
Aritra8438 Apr 25, 2023
8eb25a9
Merge branch 'develop' into handle-API-errors-on-schema-page
Aritra8438 May 9, 2023
3e81b4b
Merge branch 'develop' into handle-API-errors-on-schema-page
Aritra8438 May 13, 2023
3d6be61
Merge branch 'develop' into handle-API-errors-on-schema-page
Aritra8438 May 25, 2023
b379939
Merge branch 'develop' into handle-API-errors-on-schema-page
Aritra8438 Jun 21, 2023
39770f5
Add design to the error states
Aritra8438 Jun 22, 2023
f51070e
Merge branch 'develop' into handle-API-errors-on-schema-page
Aritra8438 Jun 24, 2023
2760918
Merge branch 'develop' into handle-API-errors-on-schema-page
Aritra8438 Jun 26, 2023
25bb241
Merge branch 'develop' into handle-API-errors-on-schema-page
Aritra8438 Jun 27, 2023
b01534d
Merge branch 'develop' into handle-API-errors-on-schema-page
Aritra8438 Jul 27, 2023
41320ba
Merge branch 'develop' into handle-API-errors-on-schema-page
Aritra8438 Sep 11, 2023
b78b154
Merge branch 'develop' into handle-API-errors-on-schema-page
rajatvijay Sep 15, 2023
85ca6f2
Merge branch 'develop' into handle-API-errors-on-schema-page
rajatvijay Sep 19, 2023
74fb1b0
Merge branch 'develop' into handle-API-errors-on-schema-page
Aritra8438 Sep 24, 2023
cb20159
Merge branch 'develop' into handle-API-errors-on-schema-page
Aritra8438 Nov 18, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions mathesar_ui/src/icons/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ import {
faCircleInfo,
faUserGear,
faFilterCircleXmark,
faExclamationCircle,
faMicroscope,
faDiagramNext,
faWandSparkles,
Expand Down Expand Up @@ -183,6 +184,7 @@ export const iconUrl: IconProps = { data: faLink };

export const iconNotEditable: IconProps = { data: faLock };
export const iconUnsavedChanges: IconProps = { data: faCircleExclamation };
export const iconWarning: IconProps = { data: faExclamationCircle };

// UI TYPES

Expand Down
100 changes: 99 additions & 1 deletion mathesar_ui/src/pages/schema/SchemaOverview.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
import type { Database, SchemaEntry } from '@mathesar/AppTypes';
import { AnchorButton } from '@mathesar-component-library';
import { getDataExplorerPageUrl } from '@mathesar/routes/urls';
import { refetchQueriesForSchema } from '@mathesar/stores/queries';
import { refetchTablesForSchema } from '@mathesar/stores/tables';
import { currentSchemaId } from '@mathesar/stores/schemas';
import { Button, Icon } from '@mathesar-component-library';
import { iconRefresh, iconWarning } from '@mathesar/icons';
import OverviewHeader from './OverviewHeader.svelte';
import TablesList from './TablesList.svelte';
import ExplorationsList from './ExplorationsList.svelte';
Expand All @@ -16,7 +21,9 @@
export let tablesMap: Map<number, TableEntry>;
export let explorationsMap: Map<number, QueryInstance>;
export let isTablesLoading = false;
export let isTablesUnfetchable = false;
export let isExplorationsLoading = false;
export let isExplorationsUnfetchable = false;

export let canExecuteDDL: boolean;
export let canEditMetadata: boolean;
Expand All @@ -30,7 +37,11 @@
$: showExplorationTutorial = hasTables && !hasExplorations && canEditMetadata;

// Viewers can explore, they cannot save explorations
$: canExplore = hasTables && hasExplorations && !isExplorationsLoading;
$: canExplore =
hasTables &&
hasExplorations &&
!isExplorationsLoading &&
!isExplorationsUnfetchable;
</script>

<div class="container">
Expand All @@ -44,6 +55,30 @@
</OverviewHeader>
{#if isTablesLoading}
<TableSkeleton numTables={schema.num_tables} />
{:else if isTablesUnfetchable}
<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>
Comment on lines +59 to +81
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

{:else if showTableCreationTutorial}
<CreateNewTableTutorial {database} {schema} />
{:else}
Expand All @@ -60,6 +95,30 @@
<OverviewHeader title="Saved Explorations" />
{#if isExplorationsLoading}
<ExplorationSkeleton />
{:else if isExplorationsUnfetchable}
<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>
Comment on lines +99 to +121
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

{:else if showExplorationTutorial}
<CreateNewExplorationTutorial {database} {schema} />
{:else}
Expand Down Expand Up @@ -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

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.

display: flex;
flex-direction: column;
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.

width: 616px;
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 max-width and provide width in rem instead of px

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

background: #fdeeed;
border: 1px solid #f9cdc8;
Comment on lines +187 to +188
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.

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

flex: none;
order: 1;
align-self: stretch;
flex-grow: 0;
}

.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;
}
Comment on lines +196 to +213
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)


@media screen and (min-width: 64rem) {
.container {
flex-direction: row;
Expand Down
4 changes: 4 additions & 0 deletions mathesar_ui/src/pages/schema/SchemaPage.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@
$: tablesMap = canExecuteDDL ? $tablesStore.data : $importVerifiedTablesStore;
$: explorationsMap = $queries.data;
$: isTablesLoading = $tablesStore.state === States.Loading;
$: isTablesUnfetchable = $tablesStore.state === States.Error;
$: isExplorationsLoading = $queries.requestStatus.state === 'processing';
$: isExplorationsUnfetchable = $queries.requestStatus.state === 'failure';
Comment on lines 61 to +64
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 .


$: tabs = [
{
Expand Down Expand Up @@ -154,7 +156,9 @@
{canExecuteDDL}
{canEditMetadata}
{isTablesLoading}
{isTablesUnfetchable}
{isExplorationsLoading}
{isExplorationsUnfetchable}
{tablesMap}
{explorationsMap}
{database}
Expand Down
Loading