fix(modals): add support for disabling StoreApiKeyModal component when disabled prop is true
fix(pages): add support for disabling StoreApiKeyModal button when loading prop is true feat(types): add disabled prop to StoreApiKeyType to enable/disable StoreApiKeyModal component
This commit is contained in:
parent
4fd5fbaf70
commit
bebaab822b
3 changed files with 19 additions and 8 deletions
|
|
@ -10,7 +10,11 @@ import { addApiKeyStore } from "../../controllers/API";
|
||||||
import { StoreApiKeyType } from "../../types/components";
|
import { StoreApiKeyType } from "../../types/components";
|
||||||
import BaseModal from "../baseModal";
|
import BaseModal from "../baseModal";
|
||||||
|
|
||||||
export default function StoreApiKeyModal({ children }: StoreApiKeyType) {
|
export default function StoreApiKeyModal({
|
||||||
|
children,
|
||||||
|
disabled = false,
|
||||||
|
}: StoreApiKeyType) {
|
||||||
|
if (disabled) return <>{children}</>;
|
||||||
const [open, setOpen] = useState(false);
|
const [open, setOpen] = useState(false);
|
||||||
const { setSuccessData, setErrorData } = useContext(alertContext);
|
const { setSuccessData, setErrorData } = useContext(alertContext);
|
||||||
const { storeApiKey } = useContext(AuthContext);
|
const { storeApiKey } = useContext(AuthContext);
|
||||||
|
|
@ -38,7 +42,7 @@ export default function StoreApiKeyModal({ children }: StoreApiKeyType) {
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<BaseModal size="small-h-full" open={open} setOpen={setOpen}>
|
<BaseModal size="small-h-full" open={open && !disabled} setOpen={setOpen}>
|
||||||
<BaseModal.Trigger>{children}</BaseModal.Trigger>
|
<BaseModal.Trigger>{children}</BaseModal.Trigger>
|
||||||
<BaseModal.Header
|
<BaseModal.Header
|
||||||
description={
|
description={
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ import { StoreContext } from "../../contexts/storeContext";
|
||||||
import { getStoreComponents, getStoreTags } from "../../controllers/API";
|
import { getStoreComponents, getStoreTags } from "../../controllers/API";
|
||||||
import StoreApiKeyModal from "../../modals/StoreApiKeyModal";
|
import StoreApiKeyModal from "../../modals/StoreApiKeyModal";
|
||||||
import { storeComponent } from "../../types/store";
|
import { storeComponent } from "../../types/store";
|
||||||
import { cn } from "../../utils/utils";
|
import { classNames, cn } from "../../utils/utils";
|
||||||
export default function StorePage(): JSX.Element {
|
export default function StorePage(): JSX.Element {
|
||||||
const { validApiKey, setValidApiKey, hasApiKey, loadingApiKey } =
|
const { validApiKey, setValidApiKey, hasApiKey, loadingApiKey } =
|
||||||
useContext(StoreContext);
|
useContext(StoreContext);
|
||||||
|
|
@ -161,11 +161,13 @@ export default function StorePage(): JSX.Element {
|
||||||
Langflow Store
|
Langflow Store
|
||||||
</span>
|
</span>
|
||||||
<div className="community-page-nav-button">
|
<div className="community-page-nav-button">
|
||||||
<StoreApiKeyModal>
|
<StoreApiKeyModal disabled={loading}>
|
||||||
<Button
|
<Button
|
||||||
className={`${
|
disabled={loading}
|
||||||
!validApiKey ? "animate-pulse border-error" : ""
|
className={classNames(
|
||||||
}`}
|
`${!validApiKey ? "animate-pulse border-error" : ""}`,
|
||||||
|
loading ? "cursor-not-allowed" : ""
|
||||||
|
)}
|
||||||
variant="primary"
|
variant="primary"
|
||||||
>
|
>
|
||||||
<IconComponent name="Key" className="main-page-nav-button" />
|
<IconComponent name="Key" className="main-page-nav-button" />
|
||||||
|
|
@ -261,7 +263,11 @@ export default function StorePage(): JSX.Element {
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="flex h-6 items-center gap-2">
|
<div className="flex h-6 items-center gap-2">
|
||||||
<Select onValueChange={setSelectFilter} value={selectFilter}>
|
<Select
|
||||||
|
disabled={loading}
|
||||||
|
onValueChange={setSelectFilter}
|
||||||
|
value={selectFilter}
|
||||||
|
>
|
||||||
<SelectTrigger className="mr-4 w-[160px]">
|
<SelectTrigger className="mr-4 w-[160px]">
|
||||||
<SelectValue placeholder="Filter Values" />
|
<SelectValue placeholder="Filter Values" />
|
||||||
</SelectTrigger>
|
</SelectTrigger>
|
||||||
|
|
|
||||||
|
|
@ -356,6 +356,7 @@ export type ApiKeyType = {
|
||||||
|
|
||||||
export type StoreApiKeyType = {
|
export type StoreApiKeyType = {
|
||||||
children: ReactElement;
|
children: ReactElement;
|
||||||
|
disabled?: boolean;
|
||||||
};
|
};
|
||||||
export type groupedObjType = {
|
export type groupedObjType = {
|
||||||
family: string;
|
family: string;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue