NodeSelector.tsx 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /*
  2. * Copyright 2021-2024 Avaiga Private Limited
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
  5. * the License. You may obtain a copy of the License at
  6. *
  7. * http://www.apache.org/licenses/LICENSE-2.0
  8. *
  9. * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
  10. * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
  11. * specific language governing permissions and limitations under the License.
  12. */
  13. import React from "react";
  14. import Box from "@mui/material/Box";
  15. import { MainTreeBoxSx, useClassNames } from "./utils";
  16. import { Cycles, DataNodes, NodeType, Scenarios } from "./utils/types";
  17. import CoreSelector from "./CoreSelector";
  18. interface NodeSelectorProps {
  19. id?: string;
  20. updateVarName?: string;
  21. innerDatanodes?: Cycles | Scenarios | DataNodes;
  22. coreChanged?: Record<string, unknown>;
  23. updateVars: string;
  24. onChange?: string;
  25. error?: string;
  26. displayCycles: boolean;
  27. showPrimaryFlag: boolean;
  28. propagate?: boolean;
  29. value?: string;
  30. defaultValue?: string;
  31. height: string;
  32. libClassName?: string;
  33. className?: string;
  34. dynamicClassName?: string;
  35. showPins?: boolean;
  36. multiple?: boolean;
  37. updateDnVars?: string;
  38. filter?: string;
  39. sort?: string;
  40. showSearch?: boolean;
  41. }
  42. const NodeSelector = (props: NodeSelectorProps) => {
  43. const { showPins = true, multiple = false, updateDnVars = "", showSearch = true } = props;
  44. const className = useClassNames(props.libClassName, props.dynamicClassName, props.className);
  45. return (
  46. <Box sx={MainTreeBoxSx} id={props.id} className={className}>
  47. <CoreSelector
  48. {...props}
  49. entities={props.innerDatanodes}
  50. leafType={NodeType.NODE}
  51. lovPropertyName="innerDatanodes"
  52. showPins={showPins}
  53. multiple={multiple}
  54. showSearch={showSearch}
  55. updateCoreVars={updateDnVars}
  56. />
  57. <Box>{props.error}</Box>
  58. </Box>
  59. );
  60. };
  61. export default NodeSelector;