-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixup based on feedback after testing
- Added ApiStatesWrapper for list of react queries - Handle selected vectors when deleting/removing ensembles - Handle selected vectors when selecting new or non-cached ensemble - Fix bug in use effect in settings, was `return` instead of `continue` in for-loop, thus not triggering update of view.
- Loading branch information
1 parent
ca03b4a
commit f5a3db2
Showing
4 changed files
with
90 additions
and
30 deletions.
There are no files selected for viewing
41 changes: 41 additions & 0 deletions
41
frontend/src/lib/components/ApiStatesWrapper/apiStatesWrapper.tsx
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,41 @@ | ||
import React from "react"; | ||
|
||
import { resolveClassNames } from "@lib/utils/resolveClassNames"; | ||
import { QueryObserverResult } from "@tanstack/react-query"; | ||
|
||
export type ApiStatesWrapperProps = { | ||
apiResults: QueryObserverResult[]; | ||
loadingComponent: React.ReactNode; | ||
errorComponent: React.ReactNode; | ||
className?: string; | ||
style?: React.CSSProperties; | ||
children: React.ReactNode; | ||
}; | ||
|
||
export const ApiStatesWrapper: React.FC<ApiStatesWrapperProps> = (props: ApiStatesWrapperProps) => { | ||
return ( | ||
<div | ||
className={resolveClassNames( | ||
"relative rounded", | ||
{ "outline outline-blue-100 outline-offset-2": props.apiResults.some((elm) => elm.isLoading) }, | ||
{ "outline outline-red-100 outline-offset-2": props.apiResults.some((elm) => elm.isError) }, | ||
props.className ?? "" | ||
)} | ||
style={props.style} | ||
> | ||
{props.apiResults.some((elm) => elm.isLoading) && ( | ||
<div className="absolute left-0 right-0 w-full h-full bg-white bg-opacity-80 flex items-center justify-center z-10"> | ||
{props.loadingComponent} | ||
</div> | ||
)} | ||
{props.apiResults.some((elm) => elm.isError) && ( | ||
<div className="absolute left-0 right-0 w-full h-full bg-white bg-opacity-80 flex items-center justify-center z-10"> | ||
{props.errorComponent} | ||
</div> | ||
)} | ||
{props.children} | ||
</div> | ||
); | ||
}; | ||
|
||
ApiStatesWrapper.displayName = "ApiStatesWrapper"; |
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 @@ | ||
export { ApiStatesWrapper } from "./apiStatesWrapper"; |
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