Removed ability to clone component and flow from store

This commit is contained in:
Lucas Oliveira 2023-11-08 17:02:38 -03:00
commit 00c7ff8cd3
2 changed files with 15 additions and 40 deletions

View file

@ -40,7 +40,6 @@ export const MarketCardComponent = ({
const flowData = useRef<FlowType>(); const flowData = useRef<FlowType>();
const [liked_by_user, setLiked_by_user] = useState(data.liked_by_user); const [liked_by_user, setLiked_by_user] = useState(data.liked_by_user);
const [likes_count, setLikes_count] = useState(data.liked_by_count ?? 0); const [likes_count, setLikes_count] = useState(data.liked_by_count ?? 0);
const [hovering, setHovering] = useState(false);
useEffect(() => { useEffect(() => {
setAdded(savedFlows.has(data.id) ? true : false); setAdded(savedFlows.has(data.id) ? true : false);
@ -105,33 +104,12 @@ export const MarketCardComponent = ({
} }
} }
function handleInstall() {
if (flowData.current) {
addFlow(true, flowData.current!).then(() => {
setSuccessData({ title: "Flow Installed" });
});
} else {
getComponent(data.id).then((res) => {
const newFLow = cloneFLowWithParent(res, res.id, data.is_component);
flowData.current = newFLow;
addFlow(true, newFLow);
setSuccessData({ title: "Flow Installed" });
});
}
}
const totalComponentsMetadata = () => { const totalComponentsMetadata = () => {
return data?.metadata ? data.metadata["total"] : 0; return data?.metadata ? data.metadata["total"] : 0;
}; };
return ( return (
<Card <Card
onMouseEnter={() => {
setHovering(true);
}}
onMouseLeave={() => {
setHovering(false);
}}
className={classNames( className={classNames(
"group relative flex flex-col justify-between overflow-hidden transition-all hover:shadow-md", "group relative flex flex-col justify-between overflow-hidden transition-all hover:shadow-md",
disabled ? "pointer-events-none opacity-50" : "" disabled ? "pointer-events-none opacity-50" : ""
@ -145,12 +123,14 @@ export const MarketCardComponent = ({
{data.name} {data.name}
</span> </span>
<div className="flex gap-3"> <div className="flex gap-3">
<ShadTooltip content="Components"> {!data.is_component && (
<span className="flex items-center gap-1.5 text-xs text-muted-foreground"> <ShadTooltip content="Components">
<IconComponent name="ToyBrick" className="h-4 w-4" /> <span className="flex items-center gap-1.5 text-xs text-muted-foreground">
{totalComponentsMetadata()} <IconComponent name="ToyBrick" className="h-4 w-4" />
</span> {totalComponentsMetadata()}
</ShadTooltip> </span>
</ShadTooltip>
)}
<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
@ -222,7 +202,7 @@ export const MarketCardComponent = ({
content={ content={
authorized authorized
? added ? added
? "Clone" ? "Added to Account"
: "Add to Account" : "Add to Account"
: "Please review your API key." : "Please review your API key."
} }
@ -240,23 +220,14 @@ export const MarketCardComponent = ({
} }
if (!added) { if (!added) {
handleAdd(); handleAdd();
} else {
handleInstall();
} }
}} }}
> >
<IconComponent <IconComponent
name={ name={loading ? "Loader2" : added ? "Check" : "Plus"}
loading
? "Loader2"
: added
? hovering
? "GitBranchPlus"
: "Check"
: "Plus"
}
className={classNames( className={classNames(
"h-6 w-6", "h-6 w-6",
added ? "text-chat-send" : "",
loading ? " animate-spin" : "", loading ? " animate-spin" : "",
!authorized ? " text-ring" : "" !authorized ? " text-ring" : ""
)} )}

View file

@ -50,6 +50,7 @@ import {
Link, Link,
Loader2, Loader2,
Lock, Lock,
LogIn,
LucideSend, LucideSend,
Maximize2, Maximize2,
Menu, Menu,
@ -60,6 +61,7 @@ import {
Minus, Minus,
MoonIcon, MoonIcon,
MoreHorizontal, MoreHorizontal,
Network,
Paperclip, Paperclip,
Pencil, Pencil,
Plus, Plus,
@ -265,6 +267,7 @@ export const nodeIconsLucide: iconsType = {
custom_components: GradientSparkles, custom_components: GradientSparkles,
custom: Edit, custom: Edit,
Trash2, Trash2,
Network,
X, X,
XCircle, XCircle,
Info, Info,
@ -326,6 +329,7 @@ export const nodeIconsLucide: iconsType = {
Key, Key,
Unplug, Unplug,
Group, Group,
LogIn,
ChevronUp, ChevronUp,
Ungroup, Ungroup,
BookMarked, BookMarked,