Fixed playground name and collection card

This commit is contained in:
Lucas Oliveira 2024-04-30 15:05:03 +02:00
commit 6b72b41b86
3 changed files with 200 additions and 224 deletions

View file

@ -2,6 +2,7 @@ import { useEffect, useState } from "react";
import { getComponent, postLikeComponent } from "../../controllers/API"; import { getComponent, postLikeComponent } from "../../controllers/API";
import DeleteConfirmationModal from "../../modals/DeleteConfirmationModal"; import DeleteConfirmationModal from "../../modals/DeleteConfirmationModal";
import IOModal from "../../modals/IOModal"; import IOModal from "../../modals/IOModal";
import IOModal from "../../modals/IOModal";
import useAlertStore from "../../stores/alertStore"; import useAlertStore from "../../stores/alertStore";
import useFlowStore from "../../stores/flowStore"; import useFlowStore from "../../stores/flowStore";
import useFlowsManagerStore from "../../stores/flowsManagerStore"; import useFlowsManagerStore from "../../stores/flowsManagerStore";
@ -27,12 +28,15 @@ export default function CollectionCardComponent({
authorized = true, authorized = true,
disabled = false, disabled = false,
button, button,
onClick,
onDelete, onDelete,
playground, playground,
playground,
}: { }: {
data: storeComponent; data: storeComponent;
authorized?: boolean; authorized?: boolean;
disabled?: boolean; disabled?: boolean;
onClick?: () => void;
button?: JSX.Element; button?: JSX.Element;
playground?: boolean; playground?: boolean;
onDelete?: () => void; onDelete?: () => void;
@ -165,12 +169,13 @@ export default function CollectionCardComponent({
} }
return ( return (
<>
<Card <Card
className={cn( className={cn(
"group relative flex min-h-[11rem] flex-col justify-between overflow-hidden transition-all hover:shadow-md", "group relative flex min-h-[11rem] flex-col justify-between overflow-hidden transition-all hover:shadow-md",
disabled ? "pointer-events-none opacity-50" : "" disabled ? "pointer-events-none opacity-50" : "",
onClick ? "cursor-pointer" : ""
)} )}
onClick={onClick}
> >
<div> <div>
<CardHeader> <CardHeader>
@ -209,10 +214,7 @@ export default function CollectionCardComponent({
)} )}
<ShadTooltip content="Likes"> <ShadTooltip content="Likes">
<span className="flex items-center gap-1.5 text-xs text-muted-foreground"> <span className="flex items-center gap-1.5 text-xs text-muted-foreground">
<IconComponent <IconComponent name="Heart" className={cn("h-4 w-4 ")} />
name="Heart"
className={cn("h-4 w-4 ")}
/>
<span data-testid={`likes-${data.name}`}> <span data-testid={`likes-${data.name}`}>
{likes_count ?? 0} {likes_count ?? 0}
</span> </span>
@ -220,10 +222,7 @@ export default function CollectionCardComponent({
</ShadTooltip> </ShadTooltip>
<ShadTooltip content="Downloads"> <ShadTooltip content="Downloads">
<span className="flex items-center gap-1.5 text-xs text-muted-foreground"> <span className="flex items-center gap-1.5 text-xs text-muted-foreground">
<IconComponent <IconComponent name="DownloadCloud" className="h-4 w-4" />
name="DownloadCloud"
className="h-4 w-4"
/>
<span data-testid={`downloads-${data.name}`}> <span data-testid={`downloads-${data.name}`}>
{downloads_count ?? 0} {downloads_count ?? 0}
</span> </span>
@ -378,9 +377,7 @@ export default function CollectionCardComponent({
data-testid={`install-${data.name}`} data-testid={`install-${data.name}`}
> >
<IconComponent <IconComponent
name={ name={loading ? "Loader2" : isStore ? "Download" : "Plus"}
loading ? "Loader2" : isStore ? "Download" : "Plus"
}
className={cn( className={cn(
loading ? "h-5 w-5 animate-spin" : "h-5 w-5", loading ? "h-5 w-5 animate-spin" : "h-5 w-5",
!authorized ? " text-ring" : "" !authorized ? " text-ring" : ""
@ -398,9 +395,11 @@ export default function CollectionCardComponent({
tabIndex={-1} tabIndex={-1}
variant="outline" variant="outline"
size="sm" size="sm"
className="whitespace-nowrap " className="whitespace-nowrap gap-2"
data-testid={"playground-flow-button-" + data.id} data-testid={"playground-flow-button-" + data.id}
onClick={() => { onClick={(e) => {
e.preventDefault();
e.stopPropagation();
setLoadingPlayground(true); setLoadingPlayground(true);
if (getFlowById(data.id)) { if (getFlowById(data.id)) {
setCurrentFlowId(data.id); setCurrentFlowId(data.id);
@ -416,23 +415,16 @@ export default function CollectionCardComponent({
}} }}
> >
{!loadingPlayground ? ( {!loadingPlayground ? (
<>
<IconComponent <IconComponent
name="ExternalLink" name="Zap"
className="main-page-nav-button select-none" className="h-4 w-4 select-none fill-current text-medium-indigo"
/> />
Playground
</>
) : ( ) : (
<Loading /> <Loading className="h-4 w-4 text-medium-indigo" />
)} )}
Playground
</Button> </Button>
)} )}
</div>
</div>
</CardFooter>
</Card>
{openPlayground && ( {openPlayground && (
<IOModal <IOModal
cleanOnClose={true} cleanOnClose={true}
@ -442,6 +434,9 @@ export default function CollectionCardComponent({
<></> <></>
</IOModal> </IOModal>
)} )}
</> </div>
</div>
</CardFooter>
</Card>
); );
} }

View file

@ -126,9 +126,9 @@ export default function IOModal({
{/* TODO ADAPT TO ALL TYPES OF INPUTS AND OUTPUTS */} {/* TODO ADAPT TO ALL TYPES OF INPUTS AND OUTPUTS */}
<BaseModal.Header description={CHAT_FORM_DIALOG_SUBTITLE}> <BaseModal.Header description={CHAT_FORM_DIALOG_SUBTITLE}>
<div className="flex items-center"> <div className="flex items-center">
<span className="pr-2">Interaction Panel</span> <span className="pr-2">Playground</span>
<IconComponent <IconComponent
name="prompts" name="Zap"
className="h-6 w-6 pl-1 text-foreground" className="h-6 w-6 pl-1 text-foreground"
aria-hidden="true" aria-hidden="true"
/> />

View file

@ -146,30 +146,11 @@ export default function ComponentsComponent({
}} }}
key={idx} key={idx}
data={item} data={item}
disabled={isLoading}
button={
!is_component ? (
<Link to={"/flow/" + item.id}>
<Button
tabIndex={-1}
variant="outline"
size="sm"
className="whitespace-nowrap "
data-testid={ data-testid={
"edit-flow-button-" + item.id + "-" + idx "edit-flow-button-" + item.id + "-" + idx
} }
> onClick={!is_component ? () => {navigate("/flow/" + item.id);} : undefined}
<IconComponent disabled={isLoading}
name="ExternalLink"
className="main-page-nav-button select-none"
/>
Edit Flow
</Button>
</Link>
) : (
<></>
)
}
playground={!is_component} playground={!is_component}
/> />
)) ))