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

Function ApiBuilder

client/src/sources/api/api-builder.jsx:81–1114  ·  view source on GitHub ↗
(props)

Source from the content-addressed store, hash-verified

79 The API Data Request builder
80*/
81function ApiBuilder(props) {
82 const [apiRequest, setApiRequest] = useState({
83 method: "GET",
84 route: "",
85 useGlobalHeaders: true,
86 formattedHeaders: [{
87 id: uuid(),
88 key: "",
89 value: "",
90 }]
91 });
92 const [result, setResult] = useState("");
93 const [activeMenu, setActiveMenu] = useState("headers");
94 const [requestSuccess, setRequestSuccess] = useState(false);
95 const [requestLoading, setRequestLoading] = useState(false);
96 const [requestError, setRequestError] = useState("");
97 const [invalidateCache, setInvalidateCache] = useState(false);
98 const [builderMetadata, setBuilderMetadata] = useState({
99 host: "",
100 globalHeaders: [],
101 hasGlobalHeaders: false,
102 });
103 const [saveLoading, setSaveLoading] = useState(false);
104 const [showTransform, setShowTransform] = useState(false);
105 const [variableSettings, setVariableSettings] = useState(null);
106 const [variableLoading, setVariableLoading] = useState(false);
107 const [variables, setVariables] = useState({
108 startDate: {
109 value: startOfDay(sub(new Date(), { months: 1 })),
110 type: "date",
111 },
112 endDate: {
113 value: endOfDay(new Date()),
114 type: "date",
115 },
116 dateFormat: {
117 value: "YYYY-MM-DD",
118 type: "string",
119 },
120 });
121
122 const { isDark } = useTheme();
123 const params = useParams();
124 const dispatch = useDispatch();
125 const initRef = useRef(false);
126
127 const stateDrs = useSelector((state) => selectDataRequests(state, params.datasetId));
128 const team = useSelector(selectTeam);
129
130 const {
131 dataRequest = null, onChangeRequest, connection, onSave, onDelete,
132 } = props;
133
134 const _normalizeGlobalHeaders = (headers = [], includeSensitive = true) => {
135 if (!Array.isArray(headers)) return [];
136
137 return headers.map((header) => {
138 if (header?.key !== undefined) {

Callers

nothing calls this directly

Calls 15

useThemeFunction · 0.90
selectDataRequestsFunction · 0.90
getConnectionFunction · 0.90
_normalizeGlobalHeadersFunction · 0.85
_renderUrlVariablesFunction · 0.85
_onSaveVariablesFunction · 0.85
_onChangeHeaderFunction · 0.85
_onChangeHeaderValueFunction · 0.85
_removeHeaderFunction · 0.85
_onChangeBodyFunction · 0.85
_changeMethodFunction · 0.85

Tested by

no test coverage detected