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

Fix UI render error inside repo error #4301

Merged
merged 1 commit into from
Oct 3, 2022
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
12 changes: 6 additions & 6 deletions webui/src/lib/api/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,44 +80,44 @@ const apiRequest = async (uri, requestData = {}, additionalHeaders = {}) => {
export class NotFoundError extends Error {
constructor(message) {
super(message)
this.name = "NotFoundError"
this.name = this.constructor.name;
}
}

export class BadRequestError extends Error {
constructor(message) {
super(message)
this.name = "BadRequestError"
this.name = this.constructor.name;
}
}

export class AuthorizationError extends Error {
constructor(message) {
super(message);
this.name = "AuthorizationError"
this.name = this.constructor.name;
}
}

export class AuthenticationError extends Error {
constructor(message, status) {
super(message);
this.status = status;
this.name = "AuthenticationError"
this.name = this.constructor.name;
}
}

export class MergeError extends Error {
constructor(message, payload) {
super(message);
this.name = "MergeError";
this.name = this.constructor.name;
this.payload = payload;
}
}

export class RepositoryDeletionError extends Error {
constructor(message, repoId) {
super(message);
this.name = "RepositoryDeletionError";
this.name = this.constructor.name;
this.repoId = repoId;
}
}
Expand Down
4 changes: 2 additions & 2 deletions webui/src/lib/components/controls.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export const Error = ({error, onDismiss = null, className = null}) => {
return (
<Alert className={className} variant="danger">{content}</Alert>
);
}
};

export const FormattedDate = ({ dateValue, format = "MM/DD/YYYY HH:mm:ss" }) => {
if (typeof dateValue === 'number') {
Expand Down Expand Up @@ -402,4 +402,4 @@ export const ExitConfirmationDialog = ({dialogAlert, dialogDescription, onExit,
</DialogActions>
</Dialog>
)
}
};
25 changes: 13 additions & 12 deletions webui/src/pages/repositories/repository/error.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,23 @@ import {TrashIcon} from "@primer/octicons-react";
import React from "react";
import {Error} from "../../../lib/components/controls";

const RepositoryInDeletionContainer = (repoId) => {
const RepositoryInDeletionContainer = ({repoId}) => {
const router = useRouter();
return (
<Alert variant="warning">
<Alert.Heading>Repository is undergoing deletion</Alert.Heading>
This may take several seconds. You can retry the deletion process by pressing the delete button again.
<hr />
<div className="d-flex justify-content-end">
<Button variant="danger" className="mt-3" onClick={ async () => {
try {
await repositories.delete(repoId);
} catch {
// continue regardless of error
}
return router.push('/repositories')
}}>
<Button variant="danger" className="mt-3" onClick={
async () => {
try {
await repositories.delete(repoId);
} catch {
// continue regardless of error
}
return router.push('/repositories')
}}>
<TrashIcon/> Delete Repository
</Button>
</div>
Expand All @@ -31,7 +32,7 @@ const RepositoryInDeletionContainer = (repoId) => {

export const RepoError = ({error}) => {
if (error instanceof RepositoryDeletionError) {
return RepositoryInDeletionContainer(error.repoId);
return <RepositoryInDeletionContainer repoId={error.repoId}/>;
}
return Error(error)
}
return <Error error={error}/>;
};
2 changes: 1 addition & 1 deletion webui/src/pages/repositories/repository/objects.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ const ObjectsBrowser = ({config, configError}) => {
const refresh = () => setRefreshToken(!refreshToken);

if (loading) return <Loading/>;
if (!!error || configError) return <RepoError error={error || configError}/>;
if (error || configError) return <RepoError error={error || configError}/>;

return (
<>
Expand Down