Skip to content

Commit

Permalink
loading state
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewazores committed Apr 24, 2024
1 parent a990df6 commit 4410aaf
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/app/SecurityPanel/ImportCertificate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import {
PanelMain,
PanelMainBody,
Popover,
Spinner,
Text,
TextContent,
TextVariants,
Expand All @@ -37,21 +38,31 @@ import {
import { OutlinedQuestionCircleIcon } from '@patternfly/react-icons';
import * as React from 'react';
import { SecurityCard } from './types';
import { tap } from 'rxjs/operators';

Check warning on line 41 in src/app/SecurityPanel/ImportCertificate.tsx

View workflow job for this annotation

GitHub Actions / eslint-check (16.x)

`rxjs/operators` import should occur before import of `./types`

Check warning on line 41 in src/app/SecurityPanel/ImportCertificate.tsx

View workflow job for this annotation

GitHub Actions / eslint-check (18.x)

`rxjs/operators` import should occur before import of `./types`

export const CertificateImport: React.FC = () => {
const context = React.useContext(ServiceContext);
const addSubscription = useSubscriptions();
const [loading, setLoading] = React.useState(true);
const [certs, setCerts] = React.useState([] as string[]);

React.useEffect(() => {
addSubscription(context.api.doGet('tls/certs', 'v3').subscribe(setCerts));
}, [addSubscription, context.api, setCerts]);
setLoading(true);
addSubscription(
context.api
.doGet('tls/certs', 'v3')
.pipe(tap((_) => setLoading(false)))
.subscribe(setCerts),
);
}, [setLoading, addSubscription, context.api, setCerts]);

return (
<Panel isScrollable>
<PanelMain>
<PanelMainBody>
{certs.length ? (
{loading ? (
<Spinner />
) : certs.length ? (
<List isPlain isBordered>
{certs.map((cert) => (
<ListItem key={cert}>
Expand Down

0 comments on commit 4410aaf

Please sign in to comment.