-
-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(backend): Make parsing background task (#304)
* refactor(backend): Make parsing background task * lint * change test_api to fit with new import_from_github * fix add_task to background * delete useless lines * fix(backend):tempfile created in background task * refactor(backend):clean code * fix(backend): parser works for upload * refactor(backend,taxonomy-editor-frontend): Handle background task on frontend * refactor(backend): Make parsing background task * lint * change test_api to fit with new import_from_github * fix add_task to background * delete useless lines * fix(backend):tempfile created in background task * refactor(backend):clean code * fix(backend): parser works for upload * refactor(backend):Simplify import and upload functions * refactor(backend): lint * refactor(backend): add an error node when parsing raises an exception * fix(backend):create errors node in exception * fix(backend): base_uri works and project status is set * refactor(backend,taxonomy-editor-frontend): Handle background task on frontend * refactor(backend): remove duplicated code with upload taxonomy * refactor(backend): fix checks * refactor(backend):add context manager to get taxonomy file * feature(frontend): add warning message when taxonomy has parsing errors --------- Co-authored-by: alice.juan <alice.juan@student-cs.fr>
- Loading branch information
Showing
9 changed files
with
295 additions
and
185 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import React from "react"; | ||
import Alert from "@mui/material/Alert"; | ||
import AlertTitle from "@mui/material/AlertTitle"; | ||
import useFetch from "./useFetch"; | ||
|
||
interface CustomAlertProps { | ||
severity: "error" | "warning" | "info" | "success"; | ||
title?: string; | ||
message: string; | ||
} | ||
|
||
interface WarningParsingErrorsProps { | ||
baseUrl: string; | ||
} | ||
|
||
interface ParsingErrorsType { | ||
errors: string[]; | ||
} | ||
|
||
const CustomAlert: React.FC<CustomAlertProps> = ({ | ||
severity, | ||
title, | ||
message, | ||
}) => { | ||
return ( | ||
<Alert severity={severity}> | ||
{title && <AlertTitle>{title}</AlertTitle>} | ||
{message} | ||
</Alert> | ||
); | ||
}; | ||
|
||
// warning users the taxonomy had parsing errors, so should not edit it | ||
export const WarningParsingErrors: React.FC<WarningParsingErrorsProps> = ({ | ||
baseUrl, | ||
}) => { | ||
console.log("in WarningParsingErrors"); | ||
const { data: parsingErrors, isPending: isPendingParsingErrors } = | ||
useFetch<ParsingErrorsType>(`${baseUrl}parsing_errors`); | ||
if (!isPendingParsingErrors) { | ||
return ( | ||
<> | ||
{parsingErrors && parsingErrors.errors.length !== 0 && ( | ||
<CustomAlert | ||
severity="warning" | ||
title="Parsing errors" | ||
message="This taxonomy has encountered parsing errors, preventing further editing. | ||
Please review the errors on the dedicated Errors page for resolution, ensuring the | ||
taxonomy can be edited once the issues are addressed." | ||
/> | ||
)} | ||
</> | ||
); | ||
} else { | ||
return null; | ||
} | ||
}; | ||
|
||
export default WarningParsingErrors; | ||
|
||
<CustomAlert | ||
severity="warning" | ||
title="Parsing errors" | ||
message="This taxonomy has encountered parsing errors, preventing further editing. | ||
Please review the errors on the dedicated error page for resolution, ensuring the | ||
taxonomy can be edited once the issues are addressed." | ||
/>; |
Oops, something went wrong.