Add playground button to flow cards in MainPage (#1752)
* Add playground button to flow cards in MainPage * Add IOModal component for playground functionality * Update playground button styling not working yet
This commit is contained in:
parent
09fd88a0d0
commit
ec0af06573
2 changed files with 37 additions and 6 deletions
|
|
@ -25,11 +25,13 @@ export default function CollectionCardComponent({
|
||||||
disabled = false,
|
disabled = false,
|
||||||
button,
|
button,
|
||||||
onDelete,
|
onDelete,
|
||||||
|
playground
|
||||||
}: {
|
}: {
|
||||||
data: storeComponent;
|
data: storeComponent;
|
||||||
authorized?: boolean;
|
authorized?: boolean;
|
||||||
disabled?: boolean;
|
disabled?: boolean;
|
||||||
button?: JSX.Element;
|
button?: JSX.Element;
|
||||||
|
playground?:JSX.Element;
|
||||||
onDelete?: () => void;
|
onDelete?: () => void;
|
||||||
}) {
|
}) {
|
||||||
const addFlow = useFlowsManagerStore((state) => state.addFlow);
|
const addFlow = useFlowsManagerStore((state) => state.addFlow);
|
||||||
|
|
@ -345,6 +347,7 @@ export default function CollectionCardComponent({
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
{button && button}
|
{button && button}
|
||||||
|
{playground && playground}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</CardFooter>
|
</CardFooter>
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@ import {
|
||||||
import useAlertStore from "../../../../stores/alertStore";
|
import useAlertStore from "../../../../stores/alertStore";
|
||||||
import useFlowsManagerStore from "../../../../stores/flowsManagerStore";
|
import useFlowsManagerStore from "../../../../stores/flowsManagerStore";
|
||||||
import { FlowType } from "../../../../types/flow";
|
import { FlowType } from "../../../../types/flow";
|
||||||
|
import IOModal from "../../../../modals/IOModal";
|
||||||
|
|
||||||
export default function ComponentsComponent({
|
export default function ComponentsComponent({
|
||||||
is_component = true,
|
is_component = true,
|
||||||
|
|
@ -21,6 +22,7 @@ export default function ComponentsComponent({
|
||||||
is_component?: boolean;
|
is_component?: boolean;
|
||||||
}) {
|
}) {
|
||||||
const addFlow = useFlowsManagerStore((state) => state.addFlow);
|
const addFlow = useFlowsManagerStore((state) => state.addFlow);
|
||||||
|
const setCurrentFlowId = useFlowsManagerStore((state) => state.setCurrentFlowId);
|
||||||
const uploadFlow = useFlowsManagerStore((state) => state.uploadFlow);
|
const uploadFlow = useFlowsManagerStore((state) => state.uploadFlow);
|
||||||
const removeFlow = useFlowsManagerStore((state) => state.removeFlow);
|
const removeFlow = useFlowsManagerStore((state) => state.removeFlow);
|
||||||
const isLoading = useFlowsManagerStore((state) => state.isLoading);
|
const isLoading = useFlowsManagerStore((state) => state.isLoading);
|
||||||
|
|
@ -31,6 +33,7 @@ export default function ComponentsComponent({
|
||||||
const [pageSize, setPageSize] = useState(20);
|
const [pageSize, setPageSize] = useState(20);
|
||||||
const [pageIndex, setPageIndex] = useState(1);
|
const [pageIndex, setPageIndex] = useState(1);
|
||||||
const [loadingScreen, setLoadingScreen] = useState(true);
|
const [loadingScreen, setLoadingScreen] = useState(true);
|
||||||
|
const [openPlayground, setOpenPlayground] = useState(false);
|
||||||
|
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
|
||||||
|
|
@ -75,9 +78,8 @@ export default function ComponentsComponent({
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
setSuccessData({
|
setSuccessData({
|
||||||
title: `${
|
title: `${is_component ? "Component" : "Flow"
|
||||||
is_component ? "Component" : "Flow"
|
} uploaded successfully`,
|
||||||
} uploaded successfully`,
|
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
|
|
@ -142,9 +144,8 @@ export default function ComponentsComponent({
|
||||||
onDelete={() => {
|
onDelete={() => {
|
||||||
removeFlow(item.id);
|
removeFlow(item.id);
|
||||||
setSuccessData({
|
setSuccessData({
|
||||||
title: `${
|
title: `${item.is_component ? "Component" : "Flow"
|
||||||
item.is_component ? "Component" : "Flow"
|
} deleted successfully!`,
|
||||||
} deleted successfully!`,
|
|
||||||
});
|
});
|
||||||
resetFilter();
|
resetFilter();
|
||||||
}}
|
}}
|
||||||
|
|
@ -174,6 +175,33 @@ export default function ComponentsComponent({
|
||||||
<></>
|
<></>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
playground={
|
||||||
|
!is_component ? (
|
||||||
|
<IOModal open={openPlayground} setOpen={setOpenPlayground}>
|
||||||
|
<Button
|
||||||
|
tabIndex={-1}
|
||||||
|
variant="outline"
|
||||||
|
size="sm"
|
||||||
|
className="whitespace-nowrap "
|
||||||
|
data-testid={
|
||||||
|
"playground-flow-button-" + item.id + "-" + idx
|
||||||
|
}
|
||||||
|
onClick={() => {
|
||||||
|
setCurrentFlowId(item.id);
|
||||||
|
setOpenPlayground(true);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<IconComponent
|
||||||
|
name="ExternalLink"
|
||||||
|
className="main-page-nav-button select-none"
|
||||||
|
/>
|
||||||
|
Playground
|
||||||
|
</Button>
|
||||||
|
</IOModal>
|
||||||
|
) : (
|
||||||
|
<></>
|
||||||
|
)
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
))
|
))
|
||||||
) : (
|
) : (
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue