Skip to content

fix: display error when fetching OAuth2 provider apps #11713

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

Merged
merged 2 commits into from
Jan 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const OAuth2AppsSettingsPage: FC = () => {
<OAuth2AppsSettingsPageView
apps={appsQuery.data}
isLoading={appsQuery.isLoading}
error={appsQuery.error}
isEntitled={
entitlements.features.oauth2_provider.entitlement !== "not_entitled"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ export const Loading: Story = {
},
};

export const Error: Story = {
args: {
isLoading: false,
error: "some error",
},
};

export const Unentitled: Story = {
args: {
isLoading: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
EnterpriseBadge,
EntitledBadge,
} from "components/Badges/Badges";
import { ErrorAlert } from "components/Alert/ErrorAlert";
import { TableLoader } from "components/TableLoader/TableLoader";
import { Stack } from "components/Stack/Stack";
import { useClickableTableRow } from "hooks/useClickableTableRow";
Expand All @@ -28,12 +29,14 @@ type OAuth2AppsSettingsProps = {
apps?: TypesGen.OAuth2ProviderApp[];
isEntitled: boolean;
isLoading: boolean;
error: unknown;
};

const OAuth2AppsSettingsPageView: FC<OAuth2AppsSettingsProps> = ({
apps,
isEntitled,
isLoading,
error,
}) => {
return (
<>
Expand Down Expand Up @@ -62,6 +65,8 @@ const OAuth2AppsSettingsPageView: FC<OAuth2AppsSettingsProps> = ({
</Button>
</Stack>

{error && <ErrorAlert error={error} />}

<TableContainer css={{ marginTop: 32 }}>
<Table>
<TableHead>
Expand All @@ -72,9 +77,8 @@ const OAuth2AppsSettingsPageView: FC<OAuth2AppsSettingsProps> = ({
</TableHead>
<TableBody>
{isLoading && <TableLoader />}
{!isLoading &&
apps?.map((app) => <OAuth2AppRow key={app.id} app={app} />)}
{!isLoading && (!apps || apps?.length === 0) && (
{apps?.map((app) => <OAuth2AppRow key={app.id} app={app} />)}
{apps?.length === 0 && (
<TableRow>
<TableCell colSpan={999}>
<div css={{ textAlign: "center" }}>
Expand Down