MCPcopy Index your code
hub / github.com/chartbrew/chartbrew / ApiConnectionForm

Function ApiConnectionForm

client/src/sources/api/api-connection-form.jsx:50–582  ·  view source on GitHub ↗
(props)

Source from the content-addressed store, hash-verified

48 The Form used to create API connections
49*/
50function ApiConnectionForm(props) {
51 const {
52 editConnection, onComplete, addError,
53 } = props;
54
55 const [loading, setLoading] = useState(false);
56 const [testLoading, setTestLoading] = useState(false);
57 const [connection, setConnection] = useState({
58 type: "api", subType: "api", optionsArray: []
59 });
60 const [errors, setErrors] = useState({});
61 const [menuType, setMenuType] = useState(
62 new URLSearchParams(window.location.search).get("tab") === "aiContext"
63 ? "aiContext"
64 : "authentication"
65 );
66 const [testResult, setTestResult] = useState(null);
67 const [passwordVisible, setPasswordVisible] = useState(false);
68
69 const { isDark } = useTheme();
70 const initRef = useRef(null);
71 const dispatch = useDispatch();
72 const team = useSelector(selectTeam);
73
74 useEffect(() => {
75 if (!initRef.current) {
76 initRef.current = true;
77 _addOption();
78 _init();
79 }
80 }, []);
81
82 const _init = () => {
83 if (editConnection) {
84 const newConnection = editConnection;
85 // format the options
86 if (newConnection.options && newConnection.options.length > 0) {
87 const formattedOptions = [];
88 for (let i = 0; i < newConnection.options.length; i++) {
89 if (newConnection.options[i]) {
90 formattedOptions.push({
91 id: uuid(),
92 key: Object.keys(newConnection.options[i])[0],
93 value: newConnection.options[i][Object.keys(newConnection.options[i])[0]],
94 });
95 }
96 }
97
98 newConnection.optionsArray = formattedOptions;
99 } else {
100 newConnection.optionsArray = [];
101 }
102
103 setConnection(newConnection);
104 }
105 };
106
107 const _onTestRequest = (data) => {

Callers

nothing calls this directly

Calls 9

useThemeFunction · 0.90
_onChangeAiContextFunction · 0.85
_addOptionFunction · 0.70
_initFunction · 0.70
_onChangeAuthParamsFunction · 0.70
_onChangeOptionFunction · 0.70
_removeOptionFunction · 0.70
_onCreateConnectionFunction · 0.70
getMethod · 0.45

Tested by

no test coverage detected