feat(extraSidebarComponent): add support for passing apiClass prop to SidebarDraggableComponent to enable dynamic rendering of API class components
feat(sideBarDraggableComponent): add support for downloading node on "download" option click in the sidebar fix(sideBarDraggableComponent): fix missing import statements and add missing type annotations
This commit is contained in:
parent
02f2988821
commit
0c513abf24
2 changed files with 15 additions and 0 deletions
|
|
@ -250,6 +250,7 @@ export default function ExtraSidebar(): JSX.Element {
|
||||||
key={index}
|
key={index}
|
||||||
>
|
>
|
||||||
<SidebarDraggableComponent
|
<SidebarDraggableComponent
|
||||||
|
apiClass={dataFilter[SBSectionName][SBItemName]}
|
||||||
key={SBItemName}
|
key={SBItemName}
|
||||||
onDragStart={(event) =>
|
onDragStart={(event) =>
|
||||||
onDragStart(event, {
|
onDragStart(event, {
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,14 @@ import {
|
||||||
SelectItem,
|
SelectItem,
|
||||||
SelectTrigger,
|
SelectTrigger,
|
||||||
} from "../../../../../components/ui/select-custom";
|
} from "../../../../../components/ui/select-custom";
|
||||||
|
import { TabsContext } from "../../../../../contexts/tabsContext";
|
||||||
import { typesContext } from "../../../../../contexts/typesContext";
|
import { typesContext } from "../../../../../contexts/typesContext";
|
||||||
|
import { APIClassType } from "../../../../../types/api";
|
||||||
|
import {
|
||||||
|
createFlowComponent,
|
||||||
|
downloadNode,
|
||||||
|
} from "../../../../../utils/reactflowUtils";
|
||||||
|
import { removeCountFromString } from "../../../../../utils/utils";
|
||||||
|
|
||||||
export default function SidebarDraggableComponent({
|
export default function SidebarDraggableComponent({
|
||||||
display_name,
|
display_name,
|
||||||
|
|
@ -14,7 +21,9 @@ export default function SidebarDraggableComponent({
|
||||||
error,
|
error,
|
||||||
color,
|
color,
|
||||||
onDragStart,
|
onDragStart,
|
||||||
|
apiClass,
|
||||||
}: {
|
}: {
|
||||||
|
apiClass: APIClassType;
|
||||||
display_name: string;
|
display_name: string;
|
||||||
itemName: string;
|
itemName: string;
|
||||||
error: boolean;
|
error: boolean;
|
||||||
|
|
@ -23,12 +32,17 @@ export default function SidebarDraggableComponent({
|
||||||
}) {
|
}) {
|
||||||
const open = useRef(false);
|
const open = useRef(false);
|
||||||
const { deleteComponent } = useContext(typesContext);
|
const { deleteComponent } = useContext(typesContext);
|
||||||
|
const { getNodeId } = useContext(TabsContext);
|
||||||
|
|
||||||
function handleSelectChange(value: string) {
|
function handleSelectChange(value: string) {
|
||||||
switch (value) {
|
switch (value) {
|
||||||
case "share":
|
case "share":
|
||||||
break;
|
break;
|
||||||
case "download":
|
case "download":
|
||||||
|
const type = removeCountFromString(itemName);
|
||||||
|
downloadNode(
|
||||||
|
createFlowComponent({ id: getNodeId(type), type, node: apiClass })
|
||||||
|
);
|
||||||
break;
|
break;
|
||||||
case "delete":
|
case "delete":
|
||||||
deleteComponent(itemName);
|
deleteComponent(itemName);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue