+
+ {action.name}
+
+
+
+ {
+ if (e.key === "Enter") {
+ if (actionUrl.length === 0) {
+ toast.error("URL cannot be empty");
+ return;
+ }else{
+ setShowResponseLoader(true);
+ setDisableExecuteButton(true)
+ handleRequestWithCustomAction(selectedMethod, baseUrl, path, RequestHeader, RequestBody, RequestParams, info, action);
+ }
+ }}
+ }
+ onClick={(e) => {
+ const clickPosition = e.target.selectionStart;
+ const baseUrlLength = baseUrl.length;
+ if (shouldChageInputFocus) {
+ e.target.setSelectionRange(baseUrlLength + clickPosition, baseUrlLength + clickPosition);
+ setShouldChangeInputFocus(false);
+ }
+ }}
+ onFocus={(e) => {
+ const validParams = RequestParams.filter(param => param.key.trim().length > 0 && param.value.trim().length > 0);
+ const fullUrl = validParams.length > 0 ? `${baseUrl}${path}?${validParams.map(param => `${param.key}=${param.value}`).join("&")}` : `${baseUrl}${path}`;
+ if (fullUrl.length === 0) {
+ setActionUrl(serverurl + action?.url);
+ }else{
+ setActionUrl(fullUrl);
+ }
+ if(!shouldChageInputFocus){
+ setShouldChangeInputFocus(true);
+ }
+ }}
+
+ onBlur={(e) => {
+ if(e.target.value.trim().length === 0) {
+ setActionUrl(path);
+ }else if(path.length === 0){
+ setActionUrl(action?.url);
+ }else if(baseUrl.length === 0){
+ setBaseUrl(serverurl)
+ setActionUrl(path)
+ }else{
+ const validParams = RequestParams.filter(param => param.key.trim().length > 0 && param.value.trim().length > 0);
+ const validPath = validParams?.length > 0 ? `${path}?${validParams.map(param => `${param.key}=${param.value}`).join("&")}` : path;
+ setActionUrl(validPath)
+ }
+ setShouldChangeInputFocus(false);
+ }}
+
+ onChange={(e) => {
+ const newUrl = e.target.value;
+ setActionUrl(newUrl);
+ const params = extractParamsFromText(newUrl);
+ setRequestParams(params);
+
+ if (newUrl.startsWith("http://") || newUrl.startsWith("https://")) {
+ try {
+ const url = new URL(newUrl);
+ setBaseUrl(url.origin);
+ const newPath = decodeURIComponent(url.pathname);;
+
+ setPath(newPath);
+ } catch (error) {
+ console.error("Invalid URL:", error);
+ }
+ }
+ }}
+ />
+
+
+
+ {showResponseLoader? (
+
+ ) : null}
+
+
+
+ handleChangeTab(index, newValue)
+ }
+ aria-label="basic tabs example"
+ >
+
+ Headers
+
+ {...a11yProps(0)}
+ />
+ {shouldShowBodyTab && (
+
+ Body
+
+ {...a11yProps(1)}
+ />
+ )}
+
+ Params
+
+ {...a11yProps(shouldShowBodyTab ? 2 : 1)}
+ />
+ {ConfigurationTab ? (
+
+ Configuration
+
+ {...a11yProps(shouldShowBodyTab ? 3 : 2)}
+ />
+ ) : null}
+
+
+
+
+
+
+
+
+ Key
+
+
+ Value
+
+
+
+
+ {RequestHeader.map((row, rowIndex) => (
+
+
+
+
+
+
+ ))}
+
+
+
+
+
+ {shouldShowBodyTab && (
+
+
+
+ )}
+
+
+
+
+
+
+ Key
+
+
+ Value
+
+
+
+
+ {RequestParams.map((row, rowIndex) => (
+
+
+
+ handleRequestParamsChange(
+ rowIndex,
+ "key",
+ e.target.value
+ )
+ }
+ onKeyDown={(e) => {
+ if (e.key === "Enter") {
+ document.getElementById(
+ `param-value-${index}-${rowIndex}`
+ ).focus();
+ }
+ if (e.key === "Backspace" && row.value.length === 0 && rowIndex !== 0) {
+ setRequestParams(RequestParams.filter((param, i) => i !== rowIndex));
+ document.getElementById(
+ `param-value-${index}-${rowIndex - 1}`
+ ).focus();
+ }
+ }}
+ />
+
+
+
+ handleRequestParamsChange(
+ rowIndex,
+ "value",
+ e.target.value
+ )
+ }
+ onKeyDown={(e) => {
+ if (e.key === "Enter" && !e.ctrlKey) {
+ addRequestParamsRow();
+ setTimeout(() => {
+ document.getElementById(
+ `param-key-${index}-${rowIndex + 1}`
+ ).focus();
+ }, 0);
+ }
+ if (e.ctrlKey && e.key === "Enter") {
+ setShowResponseLoader(true);
+ setDisableExecuteButton(true)
+ handleRequestWithCustomAction(selectedMethod, baseUrl, path, RequestHeader, RequestBody, RequestParams, info, action);
+ }
+
+ if (e.key === "Backspace" && row.value.length === 0 && rowIndex !== 0) {
+ setRequestParams(RequestParams.filter((param, i) => i !== rowIndex));
+ document.getElementById(
+ `param-value-${index}-${rowIndex - 1}`
+ ).focus();
+ e.preventDefault()
+ }
+ }
+ }
+ />
+
+
+ ))}
+
+
+
+
+
+ {(ConfigurationTab && ((shouldShowBodyTab && curTab === 3 ) || (!shouldShowBodyTab && curTab === 2)))? (
+
+ ) : null}
+
+