Refactor the rqbit-web file by breaking it down into components and helper functions. Improve code organization and maintainability
This commit is contained in:
parent
a5e7a5a5f5
commit
f978ad02fe
25 changed files with 1722 additions and 926 deletions
25
crates/librqbit/webui/src/components/ErrorComponent.tsx
Normal file
25
crates/librqbit/webui/src/components/ErrorComponent.tsx
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
import { Alert } from "react-bootstrap";
|
||||
import { Error } from "../rqbit-web";
|
||||
|
||||
export const ErrorComponent = (props: {
|
||||
error: Error | null;
|
||||
remove?: () => void;
|
||||
}) => {
|
||||
let { error, remove } = props;
|
||||
|
||||
if (error == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<Alert variant="danger" onClose={remove} dismissible={remove != null}>
|
||||
<Alert.Heading>{error.text}</Alert.Heading>
|
||||
{error.details?.statusText && (
|
||||
<p>
|
||||
<strong>{error.details?.statusText}</strong>
|
||||
</p>
|
||||
)}
|
||||
<pre>{error.details?.text}</pre>
|
||||
</Alert>
|
||||
);
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue