PromucFlow_constructor/app/client/src/components/editorComponents/ApiResponseView.tsx

445 lines
12 KiB
TypeScript
Raw Normal View History

import React, { useRef, RefObject, useCallback } from "react";
import { connect, useDispatch } from "react-redux";
import { withRouter, RouteComponentProps } from "react-router";
import styled from "styled-components";
2019-11-25 05:07:27 +00:00
import { AppState } from "reducers";
import { ActionResponse } from "api/ActionAPI";
import { formatBytes } from "utils/helpers";
2019-11-22 17:04:40 +00:00
import { APIEditorRouteParams } from "constants/routes";
2019-12-11 15:14:38 +00:00
import LoadingOverlayScreen from "components/editorComponents/LoadingOverlayScreen";
import ReadOnlyEditor from "components/editorComponents/ReadOnlyEditor";
2020-01-30 13:23:04 +00:00
import { getActionResponses } from "selectors/entitiesSelector";
import { Colors } from "constants/Colors";
2020-06-04 13:49:22 +00:00
import _ from "lodash";
import {
CHECK_REQUEST_BODY,
createMessage,
DEBUGGER_ERRORS,
DEBUGGER_LOGS,
[Feature] Unified New Nav (#5558) * temp commit * using onsubmit to continue using action on form * added recaptcha site key to env example file * moved the recaptcha lib loading logic to signup page * removed unnecessary edit * handle the case where the recaptcha token is not provided as env var * added proper env var config for client * recaptcha config for ansible * recaptcha config for heroku * recaptcha config for k8s * updated app.json * fixed the typos * added more description for env vars * removed api key * minor typo fix * added new integration button * updated the add int default link * added active and create new tabs * added the empty components to tabs. will control the section manually. * added proper grid for integrations page * added vertical tabs * Added secondary tabs to integrations page * added separate page for new apis * classname changes * added new components for active queries, new queries etc. * added a separate component for data source list * adding screen component conditionally, to be showing upon user's choice * 1. Added grid styling to datasource home 2. Added connect buttons to em * fixed data source security banner * updated the styling for new api page * added tertiary menu for active integrations * updated styling for active connections * updated collapse component to work properly * added show more option to active data sources * Slash commands feature init commit * Added more commands * Introduced JSX to render custom commands * Merge conflict fix * Spacing changes * removed apis/db tabs and replaced em with integrations tab * removed the unnecessary + integrations btn * Added slash commands button * Adjust styles for better ui * Ordered the action entries under integrations * Added new datasource command * updated the getURL with proper params * updated the link of create datasource btn * updated the back btn link from data source editor * Show connect data cta in property pane * Styling fixes * Fix margin * added scrollable content to create new * added on click scroll to create new page * fixed a bug, creating new datasource twice * added new action creator for integrations. * Minor changes to add new bindings command. Changed ui behaviour of / button * UI style change * updated the query editor to match the over all theme * updated the query editor tabs * Added the run btn to empty response screens * minor fix * updated the bg color of api type drop down * updated the url being visited after delete api/query * removed log * Insert binding command UI change * More UI changes * removed unnecessary junk from integrations editor index * clean up, removed unnecessary files * removed useless routes * for debugger only checking if integrations editor * Removed all the links for api/query home pages * Move command actions to a saga Added support to binding the data back to the widget when are new API is created from widget * Added reverse binding for DB queries * Show / button only on hover * not routing to integrations on create query/api * Hide actions from suggestions in action pages * removed the query/datasource/api home pages * Changes widget.data to widget in slash commands * Show dependencies in property pane * Fix warning * fixed scrolling issue * will show a list of queries and apis for action picker * showing icons for each action under integrations * Fix dropdown not showing up * Minor refactoring. Changed commands * added a way to list data sources in action creators * Update query page url * cam show icons for datasources * Removed unused code * Feature/slash commands (#5002) * Slash commands feature init commit * Added more commands * Introduced JSX to render custom commands * Merge conflict fix * Spacing changes * Added slash commands button * Adjust styles for better ui * Added new datasource command * Minor changes to add new bindings command. Changed ui behaviour of / button * UI style change * Insert binding command UI change * More UI changes * Move command actions to a saga Added support to binding the data back to the widget when are new API is created from widget * Added reverse binding for DB queries * Show / button only on hover * Hide actions from suggestions in action pages * Changes widget.data to widget in slash commands * Minor refactoring. Changed commands * Removed unused code * remove more unusued code * Added support to generate new api from a datasource in quick commands * Code correction to use types * Refactored commands code * Minor bug fixes * Remove new integrations command for actions. Fixed autocomplete not showing up * Changes to prevent autocomplete trigger for navigation commands * Prevent hinter execution when show hint is open already. * Show hinter on focus * Update text to be called in the omnibar * updated the copy for empty active datasources * Update url * Fix text decoration * updated the redirection for back btns * Use themes * Add cypress test * fixed back btn nav * fetching form configs for datasources * a callback fixed * Fix slash command not executed on click (#5540) * Replace the value if not a string else append * Log commands menu events * updated mock data base navigation * updated mock data base navigation * updated the close editors and back buttons * All back btns from editors will go back to data sources and back from data source will go back to canvas * fixed bg colors * minor styled updates * removed margin from header of generic datasource * warnings fixes * If user is already on the location not redirecting em * when editing, will check if the coming from data source and redirect accordingly * updated redirection for newly created api/queries * updated back btn for newly created datasources * back for new curl goes to data sources * Revert "[Fix] revert new nav (#5533)" This reverts commit 1647815d * remaining original reverted chagnes * fixed the width of incoming/outgoing entity bar in property pane * removing residue from resolved merge conflicts * Fix widget icons not visible in dropdown menu * minor fix to use proper integration URL * updated the URLs for unified datasources * converted back and close to btns from banners * on accessing data source from sidebar, it'll always go to view mode * updated the edit path for saas editors * Added saved state for google sheet * on google sheet delete redirecting to create new * minor fix * fixed the redirection call on saving a datasource * removed save and test cmd as it wasn't needed * Removing test cases to be fixed by Arun * commenting more tests to be fixed by Arun * updated call api cy command * Fix extra margin issue * fixed the update datasource saga * fixed video spec * Revert "commenting more tests to be fixed by Arun" This reverts commit 42087a95ad77107401a1619e4c2d4c541a81d6c3. * Revert "Removing test cases to be fixed by Arun" This reverts commit f6fad67e558d22045114a90409428ef9b737478f. * fixed the entity explorer query datasource spec * cautious fix * update widget locators * fixed leave org test * fixes for FormWidgets * updated the image spec * Use memo * Fix debugger url checks * for copy and delete widget pointing directly to svgs * Fix entity text * Fix styling and show tooltip for property pane dependencies * removed the unnecessary callback * added a separate saga to to redirect to new integrations using onSuccess * Bug Fixes - New nav (#5629) * will show scrollbar only on hover * made mock data cards clickable * fixed the grid view * fixed the cursor position when clicking on / btn * updated the hint for `/` command * binding prompt will close on focus change * hiding / command for api body * hiding / command for query pane * Added 2 new icons * Fix cursor position on selecting a binding and clicking on the slash menu button * trying out fix to copyWidget cy command * removing zero width space characters from the property pane text Co-authored-by: arunvjn <arun@appsmith.com> Co-authored-by: Akash N <akash@codemonk.in> Co-authored-by: arunvjn <32433245+arunvjn@users.noreply.github.com> Co-authored-by: Rishabh Saxena <rishabh.robben@gmail.com>
2021-07-07 03:46:16 +00:00
EMPTY_RESPONSE_FIRST_HALF,
EMPTY_RESPONSE_LAST_HALF,
INSPECT_ENTITY,
refactor: admin settings (#9906) * refactor admin settings feature * separated save-restart bar to separate component * created new CE dir to facilitate code split * created separate ee dir and exporting everything we have in ce file. * little mod * minor fix * splitting settings types config * using object literals for category types instead of enums * CE: support use of component for each category * minor style fix * authentication page UI changes implemented * github signup doc url added back * removed comments * routing updates * made subcategories listing in left pane optional * added muted saml to auth listing * added breadcrumbs and enabled button * created separate component for auth page and auth config * added callout and disconnect components * updated breadcrumbs component * minor updates to common components * updated warning callout and added icon * ce: test cases fixed * updated test file name * warning banner callout added on auth page * updated callout banner for form login * CE: Split config files * CE: moved the window declaration in EE file as its dependency will be updated in EE * CE: Splitting ApiConstants and SocialLogin constants * CE: split login page * CE: moved getSocialLoginButtonProps func to EE file as it's dependencies will be updated in EE * added key icon * CE: created a factory class to share social auths list * Minor style fix for social btns * Updated the third party auth styles * Small fixes to styling * ce: splitting forms constants * breadcrumbs implemented for all pages in admin settings * Settings breadcrumbs separated * splitted settings breadcrumbs between ce and ee * renamed default import * minor style fix * added login form config. * updated login/signup pages to use form login disabled config * removed common functionality outside * implemented breadcrumb component from scratch without using blueprint * removed unwanted code * Small style update * updated breadcrumb categories file name and breadcrumb icon * added cypress tests for admin settings auth page * added comments * update locator for upgrade button * added link for intercom on upgrade button * removed unnecessary file * minor style fix * style fix for auth option cards * split messages constant * fixed imports for message constants splitting. * added message constants * updated unit test cases * fixed messages import in cypress index * fixed messages import again, cypress fails to read re-exported objs. * added OIDC auth method on authentication page * updated import statements from ee to @appsmith * removed dead code * updated read more link UI * PR comments fixes * some UI fixes * used color and fonts from theme * fixed some imports * fixed some imports * removed warning imports * updated OIDC logo and auth method desc copies * css changes * css changes * css changes * updated cypress test for breadcrumb * moved callout component to ads as calloutv2 * UI changes for form fields * updated css for spacing between form fields * added sub-text on auth pages * added active class for breadcrumb item * added config for disable signup toggle and fixed UI issues of restart banner * fixed admin settings page bugs * assigned true as default state for signup * fixed messages import statements * updated code for PR comments related suggestions * reverted file path change in cypress support * updated cypress test * updated cypress test Co-authored-by: Ankita Kinger <ankita@appsmith.com>
2022-02-11 18:08:46 +00:00
} from "@appsmith/constants/messages";
2021-04-23 13:50:55 +00:00
import Text, { TextType } from "components/ads/Text";
import { Text as BlueprintText } from "@blueprintjs/core";
import Icon from "components/ads/Icon";
import { Classes, Variant } from "components/ads/common";
import { EditorTheme } from "./CodeEditor/EditorConfig";
import Callout from "components/ads/Callout";
2021-04-23 13:50:55 +00:00
import DebuggerLogs from "./Debugger/DebuggerLogs";
import ErrorLogs from "./Debugger/Errors";
import Resizer, { ResizerCSS } from "./Debugger/Resizer";
import AnalyticsUtil from "utils/AnalyticsUtil";
import { DebugButton } from "./Debugger/DebugCTA";
import EntityDeps from "./Debugger/EntityDependecies";
[Feature] Unified New Nav (#5558) * temp commit * using onsubmit to continue using action on form * added recaptcha site key to env example file * moved the recaptcha lib loading logic to signup page * removed unnecessary edit * handle the case where the recaptcha token is not provided as env var * added proper env var config for client * recaptcha config for ansible * recaptcha config for heroku * recaptcha config for k8s * updated app.json * fixed the typos * added more description for env vars * removed api key * minor typo fix * added new integration button * updated the add int default link * added active and create new tabs * added the empty components to tabs. will control the section manually. * added proper grid for integrations page * added vertical tabs * Added secondary tabs to integrations page * added separate page for new apis * classname changes * added new components for active queries, new queries etc. * added a separate component for data source list * adding screen component conditionally, to be showing upon user's choice * 1. Added grid styling to datasource home 2. Added connect buttons to em * fixed data source security banner * updated the styling for new api page * added tertiary menu for active integrations * updated styling for active connections * updated collapse component to work properly * added show more option to active data sources * Slash commands feature init commit * Added more commands * Introduced JSX to render custom commands * Merge conflict fix * Spacing changes * removed apis/db tabs and replaced em with integrations tab * removed the unnecessary + integrations btn * Added slash commands button * Adjust styles for better ui * Ordered the action entries under integrations * Added new datasource command * updated the getURL with proper params * updated the link of create datasource btn * updated the back btn link from data source editor * Show connect data cta in property pane * Styling fixes * Fix margin * added scrollable content to create new * added on click scroll to create new page * fixed a bug, creating new datasource twice * added new action creator for integrations. * Minor changes to add new bindings command. Changed ui behaviour of / button * UI style change * updated the query editor to match the over all theme * updated the query editor tabs * Added the run btn to empty response screens * minor fix * updated the bg color of api type drop down * updated the url being visited after delete api/query * removed log * Insert binding command UI change * More UI changes * removed unnecessary junk from integrations editor index * clean up, removed unnecessary files * removed useless routes * for debugger only checking if integrations editor * Removed all the links for api/query home pages * Move command actions to a saga Added support to binding the data back to the widget when are new API is created from widget * Added reverse binding for DB queries * Show / button only on hover * not routing to integrations on create query/api * Hide actions from suggestions in action pages * removed the query/datasource/api home pages * Changes widget.data to widget in slash commands * Show dependencies in property pane * Fix warning * fixed scrolling issue * will show a list of queries and apis for action picker * showing icons for each action under integrations * Fix dropdown not showing up * Minor refactoring. Changed commands * added a way to list data sources in action creators * Update query page url * cam show icons for datasources * Removed unused code * Feature/slash commands (#5002) * Slash commands feature init commit * Added more commands * Introduced JSX to render custom commands * Merge conflict fix * Spacing changes * Added slash commands button * Adjust styles for better ui * Added new datasource command * Minor changes to add new bindings command. Changed ui behaviour of / button * UI style change * Insert binding command UI change * More UI changes * Move command actions to a saga Added support to binding the data back to the widget when are new API is created from widget * Added reverse binding for DB queries * Show / button only on hover * Hide actions from suggestions in action pages * Changes widget.data to widget in slash commands * Minor refactoring. Changed commands * Removed unused code * remove more unusued code * Added support to generate new api from a datasource in quick commands * Code correction to use types * Refactored commands code * Minor bug fixes * Remove new integrations command for actions. Fixed autocomplete not showing up * Changes to prevent autocomplete trigger for navigation commands * Prevent hinter execution when show hint is open already. * Show hinter on focus * Update text to be called in the omnibar * updated the copy for empty active datasources * Update url * Fix text decoration * updated the redirection for back btns * Use themes * Add cypress test * fixed back btn nav * fetching form configs for datasources * a callback fixed * Fix slash command not executed on click (#5540) * Replace the value if not a string else append * Log commands menu events * updated mock data base navigation * updated mock data base navigation * updated the close editors and back buttons * All back btns from editors will go back to data sources and back from data source will go back to canvas * fixed bg colors * minor styled updates * removed margin from header of generic datasource * warnings fixes * If user is already on the location not redirecting em * when editing, will check if the coming from data source and redirect accordingly * updated redirection for newly created api/queries * updated back btn for newly created datasources * back for new curl goes to data sources * Revert "[Fix] revert new nav (#5533)" This reverts commit 1647815d * remaining original reverted chagnes * fixed the width of incoming/outgoing entity bar in property pane * removing residue from resolved merge conflicts * Fix widget icons not visible in dropdown menu * minor fix to use proper integration URL * updated the URLs for unified datasources * converted back and close to btns from banners * on accessing data source from sidebar, it'll always go to view mode * updated the edit path for saas editors * Added saved state for google sheet * on google sheet delete redirecting to create new * minor fix * fixed the redirection call on saving a datasource * removed save and test cmd as it wasn't needed * Removing test cases to be fixed by Arun * commenting more tests to be fixed by Arun * updated call api cy command * Fix extra margin issue * fixed the update datasource saga * fixed video spec * Revert "commenting more tests to be fixed by Arun" This reverts commit 42087a95ad77107401a1619e4c2d4c541a81d6c3. * Revert "Removing test cases to be fixed by Arun" This reverts commit f6fad67e558d22045114a90409428ef9b737478f. * fixed the entity explorer query datasource spec * cautious fix * update widget locators * fixed leave org test * fixes for FormWidgets * updated the image spec * Use memo * Fix debugger url checks * for copy and delete widget pointing directly to svgs * Fix entity text * Fix styling and show tooltip for property pane dependencies * removed the unnecessary callback * added a separate saga to to redirect to new integrations using onSuccess * Bug Fixes - New nav (#5629) * will show scrollbar only on hover * made mock data cards clickable * fixed the grid view * fixed the cursor position when clicking on / btn * updated the hint for `/` command * binding prompt will close on focus change * hiding / command for api body * hiding / command for query pane * Added 2 new icons * Fix cursor position on selecting a binding and clicking on the slash menu button * trying out fix to copyWidget cy command * removing zero width space characters from the property pane text Co-authored-by: arunvjn <arun@appsmith.com> Co-authored-by: Akash N <akash@codemonk.in> Co-authored-by: arunvjn <32433245+arunvjn@users.noreply.github.com> Co-authored-by: Rishabh Saxena <rishabh.robben@gmail.com>
2021-07-07 03:46:16 +00:00
import Button, { Size } from "components/ads/Button";
import EntityBottomTabs from "./EntityBottomTabs";
import { DEBUGGER_TAB_KEYS } from "./Debugger/helpers";
import { setCurrentTab } from "actions/debuggerActions";
type TextStyleProps = {
accent: "primary" | "secondary" | "error";
};
export const BaseText = styled(BlueprintText)<TextStyleProps>``;
const ResponseContainer = styled.div`
2021-04-23 13:50:55 +00:00
${ResizerCSS}
// Initial height of bottom tabs
height: ${(props) => props.theme.actionsBottomTabInitialHeight};
width: 100%;
2021-04-23 13:50:55 +00:00
// Minimum height of bottom tabs as it can be resized
min-height: 36px;
background-color: ${(props) => props.theme.colors.apiPane.responseBody.bg};
.react-tabs__tab-panel {
overflow: hidden;
}
`;
const ResponseMetaInfo = styled.div`
display: flex;
${BaseText} {
color: #768896;
margin-left: ${(props) => props.theme.spaces[9]}px;
}
`;
const ResponseMetaWrapper = styled.div`
align-items: center;
display: flex;
position: absolute;
right: ${(props) => props.theme.spaces[12]}px;
top: ${(props) => props.theme.spaces[4]}px;
`;
const ResponseTabWrapper = styled.div`
display: flex;
flex-direction: column;
height: 100%;
width: 100%;
`;
const TabbedViewWrapper = styled.div`
height: 100%;
&&& {
ul.react-tabs__tab-list {
padding: 0px ${(props) => props.theme.spaces[12]}px;
}
}
& {
.react-tabs__tab-panel {
height: calc(100% - 32px);
}
}
`;
const SectionDivider = styled.div`
height: 2px;
2020-06-23 03:58:42 +00:00
width: 100%;
background: ${(props) => props.theme.colors.apiPane.dividerBg};
`;
const Flex = styled.div`
display: flex;
align-items: center;
margin-left: 20px;
span:first-child {
margin-right: ${(props) => props.theme.spaces[1] + 1}px;
2020-06-23 03:58:42 +00:00
}
`;
const NoResponseContainer = styled.div`
flex: 1;
width: 100%;
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
.${Classes.ICON} {
margin-right: 0px;
svg {
width: 150px;
height: 150px;
}
}
.${Classes.TEXT} {
margin-top: ${(props) => props.theme.spaces[9]}px;
}
2020-06-12 03:54:12 +00:00
`;
const FailedMessage = styled.div`
display: flex;
align-items: center;
2021-04-23 13:50:55 +00:00
margin-left: 5px;
.api-debugcta {
margin-top: 0px;
}
`;
const StyledCallout = styled(Callout)`
.${Classes.TEXT} {
line-height: normal;
}
2020-06-23 03:58:42 +00:00
`;
[Feature] Unified New Nav (#5558) * temp commit * using onsubmit to continue using action on form * added recaptcha site key to env example file * moved the recaptcha lib loading logic to signup page * removed unnecessary edit * handle the case where the recaptcha token is not provided as env var * added proper env var config for client * recaptcha config for ansible * recaptcha config for heroku * recaptcha config for k8s * updated app.json * fixed the typos * added more description for env vars * removed api key * minor typo fix * added new integration button * updated the add int default link * added active and create new tabs * added the empty components to tabs. will control the section manually. * added proper grid for integrations page * added vertical tabs * Added secondary tabs to integrations page * added separate page for new apis * classname changes * added new components for active queries, new queries etc. * added a separate component for data source list * adding screen component conditionally, to be showing upon user's choice * 1. Added grid styling to datasource home 2. Added connect buttons to em * fixed data source security banner * updated the styling for new api page * added tertiary menu for active integrations * updated styling for active connections * updated collapse component to work properly * added show more option to active data sources * Slash commands feature init commit * Added more commands * Introduced JSX to render custom commands * Merge conflict fix * Spacing changes * removed apis/db tabs and replaced em with integrations tab * removed the unnecessary + integrations btn * Added slash commands button * Adjust styles for better ui * Ordered the action entries under integrations * Added new datasource command * updated the getURL with proper params * updated the link of create datasource btn * updated the back btn link from data source editor * Show connect data cta in property pane * Styling fixes * Fix margin * added scrollable content to create new * added on click scroll to create new page * fixed a bug, creating new datasource twice * added new action creator for integrations. * Minor changes to add new bindings command. Changed ui behaviour of / button * UI style change * updated the query editor to match the over all theme * updated the query editor tabs * Added the run btn to empty response screens * minor fix * updated the bg color of api type drop down * updated the url being visited after delete api/query * removed log * Insert binding command UI change * More UI changes * removed unnecessary junk from integrations editor index * clean up, removed unnecessary files * removed useless routes * for debugger only checking if integrations editor * Removed all the links for api/query home pages * Move command actions to a saga Added support to binding the data back to the widget when are new API is created from widget * Added reverse binding for DB queries * Show / button only on hover * not routing to integrations on create query/api * Hide actions from suggestions in action pages * removed the query/datasource/api home pages * Changes widget.data to widget in slash commands * Show dependencies in property pane * Fix warning * fixed scrolling issue * will show a list of queries and apis for action picker * showing icons for each action under integrations * Fix dropdown not showing up * Minor refactoring. Changed commands * added a way to list data sources in action creators * Update query page url * cam show icons for datasources * Removed unused code * Feature/slash commands (#5002) * Slash commands feature init commit * Added more commands * Introduced JSX to render custom commands * Merge conflict fix * Spacing changes * Added slash commands button * Adjust styles for better ui * Added new datasource command * Minor changes to add new bindings command. Changed ui behaviour of / button * UI style change * Insert binding command UI change * More UI changes * Move command actions to a saga Added support to binding the data back to the widget when are new API is created from widget * Added reverse binding for DB queries * Show / button only on hover * Hide actions from suggestions in action pages * Changes widget.data to widget in slash commands * Minor refactoring. Changed commands * Removed unused code * remove more unusued code * Added support to generate new api from a datasource in quick commands * Code correction to use types * Refactored commands code * Minor bug fixes * Remove new integrations command for actions. Fixed autocomplete not showing up * Changes to prevent autocomplete trigger for navigation commands * Prevent hinter execution when show hint is open already. * Show hinter on focus * Update text to be called in the omnibar * updated the copy for empty active datasources * Update url * Fix text decoration * updated the redirection for back btns * Use themes * Add cypress test * fixed back btn nav * fetching form configs for datasources * a callback fixed * Fix slash command not executed on click (#5540) * Replace the value if not a string else append * Log commands menu events * updated mock data base navigation * updated mock data base navigation * updated the close editors and back buttons * All back btns from editors will go back to data sources and back from data source will go back to canvas * fixed bg colors * minor styled updates * removed margin from header of generic datasource * warnings fixes * If user is already on the location not redirecting em * when editing, will check if the coming from data source and redirect accordingly * updated redirection for newly created api/queries * updated back btn for newly created datasources * back for new curl goes to data sources * Revert "[Fix] revert new nav (#5533)" This reverts commit 1647815d * remaining original reverted chagnes * fixed the width of incoming/outgoing entity bar in property pane * removing residue from resolved merge conflicts * Fix widget icons not visible in dropdown menu * minor fix to use proper integration URL * updated the URLs for unified datasources * converted back and close to btns from banners * on accessing data source from sidebar, it'll always go to view mode * updated the edit path for saas editors * Added saved state for google sheet * on google sheet delete redirecting to create new * minor fix * fixed the redirection call on saving a datasource * removed save and test cmd as it wasn't needed * Removing test cases to be fixed by Arun * commenting more tests to be fixed by Arun * updated call api cy command * Fix extra margin issue * fixed the update datasource saga * fixed video spec * Revert "commenting more tests to be fixed by Arun" This reverts commit 42087a95ad77107401a1619e4c2d4c541a81d6c3. * Revert "Removing test cases to be fixed by Arun" This reverts commit f6fad67e558d22045114a90409428ef9b737478f. * fixed the entity explorer query datasource spec * cautious fix * update widget locators * fixed leave org test * fixes for FormWidgets * updated the image spec * Use memo * Fix debugger url checks * for copy and delete widget pointing directly to svgs * Fix entity text * Fix styling and show tooltip for property pane dependencies * removed the unnecessary callback * added a separate saga to to redirect to new integrations using onSuccess * Bug Fixes - New nav (#5629) * will show scrollbar only on hover * made mock data cards clickable * fixed the grid view * fixed the cursor position when clicking on / btn * updated the hint for `/` command * binding prompt will close on focus change * hiding / command for api body * hiding / command for query pane * Added 2 new icons * Fix cursor position on selecting a binding and clicking on the slash menu button * trying out fix to copyWidget cy command * removing zero width space characters from the property pane text Co-authored-by: arunvjn <arun@appsmith.com> Co-authored-by: Akash N <akash@codemonk.in> Co-authored-by: arunvjn <32433245+arunvjn@users.noreply.github.com> Co-authored-by: Rishabh Saxena <rishabh.robben@gmail.com>
2021-07-07 03:46:16 +00:00
const InlineButton = styled(Button)`
display: inline-flex;
margin: 0 4px;
`;
const HelpSection = styled.div`
padding-bottom: 5px;
padding-top: 10px;
`;
interface ReduxStateProps {
responses: Record<string, ActionResponse | undefined>;
isRunning: Record<string, boolean>;
}
type Props = ReduxStateProps &
2021-04-23 13:50:55 +00:00
RouteComponentProps<APIEditorRouteParams> & {
theme?: EditorTheme;
apiName: string;
[Feature] Unified New Nav (#5558) * temp commit * using onsubmit to continue using action on form * added recaptcha site key to env example file * moved the recaptcha lib loading logic to signup page * removed unnecessary edit * handle the case where the recaptcha token is not provided as env var * added proper env var config for client * recaptcha config for ansible * recaptcha config for heroku * recaptcha config for k8s * updated app.json * fixed the typos * added more description for env vars * removed api key * minor typo fix * added new integration button * updated the add int default link * added active and create new tabs * added the empty components to tabs. will control the section manually. * added proper grid for integrations page * added vertical tabs * Added secondary tabs to integrations page * added separate page for new apis * classname changes * added new components for active queries, new queries etc. * added a separate component for data source list * adding screen component conditionally, to be showing upon user's choice * 1. Added grid styling to datasource home 2. Added connect buttons to em * fixed data source security banner * updated the styling for new api page * added tertiary menu for active integrations * updated styling for active connections * updated collapse component to work properly * added show more option to active data sources * Slash commands feature init commit * Added more commands * Introduced JSX to render custom commands * Merge conflict fix * Spacing changes * removed apis/db tabs and replaced em with integrations tab * removed the unnecessary + integrations btn * Added slash commands button * Adjust styles for better ui * Ordered the action entries under integrations * Added new datasource command * updated the getURL with proper params * updated the link of create datasource btn * updated the back btn link from data source editor * Show connect data cta in property pane * Styling fixes * Fix margin * added scrollable content to create new * added on click scroll to create new page * fixed a bug, creating new datasource twice * added new action creator for integrations. * Minor changes to add new bindings command. Changed ui behaviour of / button * UI style change * updated the query editor to match the over all theme * updated the query editor tabs * Added the run btn to empty response screens * minor fix * updated the bg color of api type drop down * updated the url being visited after delete api/query * removed log * Insert binding command UI change * More UI changes * removed unnecessary junk from integrations editor index * clean up, removed unnecessary files * removed useless routes * for debugger only checking if integrations editor * Removed all the links for api/query home pages * Move command actions to a saga Added support to binding the data back to the widget when are new API is created from widget * Added reverse binding for DB queries * Show / button only on hover * not routing to integrations on create query/api * Hide actions from suggestions in action pages * removed the query/datasource/api home pages * Changes widget.data to widget in slash commands * Show dependencies in property pane * Fix warning * fixed scrolling issue * will show a list of queries and apis for action picker * showing icons for each action under integrations * Fix dropdown not showing up * Minor refactoring. Changed commands * added a way to list data sources in action creators * Update query page url * cam show icons for datasources * Removed unused code * Feature/slash commands (#5002) * Slash commands feature init commit * Added more commands * Introduced JSX to render custom commands * Merge conflict fix * Spacing changes * Added slash commands button * Adjust styles for better ui * Added new datasource command * Minor changes to add new bindings command. Changed ui behaviour of / button * UI style change * Insert binding command UI change * More UI changes * Move command actions to a saga Added support to binding the data back to the widget when are new API is created from widget * Added reverse binding for DB queries * Show / button only on hover * Hide actions from suggestions in action pages * Changes widget.data to widget in slash commands * Minor refactoring. Changed commands * Removed unused code * remove more unusued code * Added support to generate new api from a datasource in quick commands * Code correction to use types * Refactored commands code * Minor bug fixes * Remove new integrations command for actions. Fixed autocomplete not showing up * Changes to prevent autocomplete trigger for navigation commands * Prevent hinter execution when show hint is open already. * Show hinter on focus * Update text to be called in the omnibar * updated the copy for empty active datasources * Update url * Fix text decoration * updated the redirection for back btns * Use themes * Add cypress test * fixed back btn nav * fetching form configs for datasources * a callback fixed * Fix slash command not executed on click (#5540) * Replace the value if not a string else append * Log commands menu events * updated mock data base navigation * updated mock data base navigation * updated the close editors and back buttons * All back btns from editors will go back to data sources and back from data source will go back to canvas * fixed bg colors * minor styled updates * removed margin from header of generic datasource * warnings fixes * If user is already on the location not redirecting em * when editing, will check if the coming from data source and redirect accordingly * updated redirection for newly created api/queries * updated back btn for newly created datasources * back for new curl goes to data sources * Revert "[Fix] revert new nav (#5533)" This reverts commit 1647815d * remaining original reverted chagnes * fixed the width of incoming/outgoing entity bar in property pane * removing residue from resolved merge conflicts * Fix widget icons not visible in dropdown menu * minor fix to use proper integration URL * updated the URLs for unified datasources * converted back and close to btns from banners * on accessing data source from sidebar, it'll always go to view mode * updated the edit path for saas editors * Added saved state for google sheet * on google sheet delete redirecting to create new * minor fix * fixed the redirection call on saving a datasource * removed save and test cmd as it wasn't needed * Removing test cases to be fixed by Arun * commenting more tests to be fixed by Arun * updated call api cy command * Fix extra margin issue * fixed the update datasource saga * fixed video spec * Revert "commenting more tests to be fixed by Arun" This reverts commit 42087a95ad77107401a1619e4c2d4c541a81d6c3. * Revert "Removing test cases to be fixed by Arun" This reverts commit f6fad67e558d22045114a90409428ef9b737478f. * fixed the entity explorer query datasource spec * cautious fix * update widget locators * fixed leave org test * fixes for FormWidgets * updated the image spec * Use memo * Fix debugger url checks * for copy and delete widget pointing directly to svgs * Fix entity text * Fix styling and show tooltip for property pane dependencies * removed the unnecessary callback * added a separate saga to to redirect to new integrations using onSuccess * Bug Fixes - New nav (#5629) * will show scrollbar only on hover * made mock data cards clickable * fixed the grid view * fixed the cursor position when clicking on / btn * updated the hint for `/` command * binding prompt will close on focus change * hiding / command for api body * hiding / command for query pane * Added 2 new icons * Fix cursor position on selecting a binding and clicking on the slash menu button * trying out fix to copyWidget cy command * removing zero width space characters from the property pane text Co-authored-by: arunvjn <arun@appsmith.com> Co-authored-by: Akash N <akash@codemonk.in> Co-authored-by: arunvjn <32433245+arunvjn@users.noreply.github.com> Co-authored-by: Rishabh Saxena <rishabh.robben@gmail.com>
2021-07-07 03:46:16 +00:00
onRunClick: () => void;
2021-04-23 13:50:55 +00:00
};
export const EMPTY_RESPONSE: ActionResponse = {
statusCode: "",
duration: "",
body: {},
headers: {},
request: {
headers: {},
body: {},
httpMethod: "",
url: "",
},
size: "",
};
const StatusCodeText = styled(BaseText)<{ code: string }>`
color: ${(props) =>
props.code.startsWith("2") ? props.theme.colors.primaryOld : Colors.RED};
cursor: pointer;
width: 38px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
&:hover {
width: 100%;
}
`;
const ResponseDataContainer = styled.div`
flex: 1;
overflow: auto;
display: flex;
margin-bottom: 10px;
flex-direction: column;
& .CodeEditorTarget {
overflow: hidden;
}
`;
function ApiResponseView(props: Props) {
2019-11-22 17:04:40 +00:00
const {
match: {
params: { apiId },
},
responses,
} = props;
let response: ActionResponse = EMPTY_RESPONSE;
2019-12-11 15:14:38 +00:00
let isRunning = false;
let hasFailed = false;
2019-11-22 17:04:40 +00:00
if (apiId && apiId in responses) {
2020-01-30 13:23:04 +00:00
response = responses[apiId] || EMPTY_RESPONSE;
isRunning = props.isRunning[apiId];
hasFailed = response.statusCode ? response.statusCode[0] !== "2" : false;
2019-11-22 17:04:40 +00:00
}
2021-04-23 13:50:55 +00:00
const panelRef: RefObject<HTMLDivElement> = useRef(null);
const dispatch = useDispatch();
2021-04-23 13:50:55 +00:00
const onDebugClick = useCallback(() => {
AnalyticsUtil.logEvent("OPEN_DEBUGGER", {
source: "API",
});
dispatch(setCurrentTab(DEBUGGER_TAB_KEYS.ERROR_TAB));
2021-04-23 13:50:55 +00:00
}, []);
const onRunClick = () => {
props.onRunClick();
AnalyticsUtil.logEvent("RESPONSE_TAB_RUN_ACTION_CLICK", {
source: "API_PANE",
});
};
const messages = response?.messages;
let responseHeaders;
// if no headers are present in the response, use the default body text.
if (response.headers) {
responseHeaders = response.headers;
} else {
responseHeaders = {}; // if the response headers is empty show an empty object.
}
const tabs = [
{
key: "body",
title: "Body",
panelComponent: (
<ResponseTabWrapper>
{Array.isArray(messages) && messages.length > 0 && (
<HelpSection>
{messages.map((msg, i) => (
<Callout fill key={i} text={msg} variant={Variant.warning} />
))}
</HelpSection>
)}
{hasFailed && !isRunning && (
<StyledCallout
fill
label={
<FailedMessage>
<DebugButton
className="api-debugcta"
onClick={onDebugClick}
/>
</FailedMessage>
}
text={createMessage(CHECK_REQUEST_BODY)}
variant={Variant.danger}
/>
)}
<ResponseDataContainer>
{_.isEmpty(response.statusCode) ? (
<NoResponseContainer>
<Icon name="no-response" />
<Text type={TextType.P1}>
{EMPTY_RESPONSE_FIRST_HALF()}
<InlineButton
isLoading={isRunning}
onClick={onRunClick}
size={Size.medium}
tag="button"
text="Run"
type="button"
/>
{EMPTY_RESPONSE_LAST_HALF()}
</Text>
</NoResponseContainer>
) : (
<ReadOnlyEditor
folding
height={"100%"}
input={{
value: response.body
? JSON.stringify(response.body, null, 2)
: "",
}}
/>
)}
</ResponseDataContainer>
</ResponseTabWrapper>
),
},
{
key: "headers",
title: "Headers",
panelComponent: (
<ResponseTabWrapper>
{hasFailed && !isRunning && (
<StyledCallout
fill
label={
<FailedMessage>
<DebugButton
className="api-debugcta"
onClick={onDebugClick}
/>
</FailedMessage>
}
text={createMessage(CHECK_REQUEST_BODY)}
variant={Variant.danger}
/>
)}
<ResponseDataContainer>
{_.isEmpty(response.statusCode) ? (
<NoResponseContainer>
<Icon name="no-response" />
<Text type={TextType.P1}>
{EMPTY_RESPONSE_FIRST_HALF()}
<InlineButton
isLoading={isRunning}
onClick={onRunClick}
size={Size.medium}
tag="button"
text="Run"
type="button"
/>
{EMPTY_RESPONSE_LAST_HALF()}
</Text>
</NoResponseContainer>
) : (
<ReadOnlyEditor
folding
height={"100%"}
input={{
value: response.body
? JSON.stringify(responseHeaders, null, 2)
: "",
}}
/>
)}
</ResponseDataContainer>
</ResponseTabWrapper>
),
},
{
key: DEBUGGER_TAB_KEYS.ERROR_TAB,
title: createMessage(DEBUGGER_ERRORS),
2021-04-23 13:50:55 +00:00
panelComponent: <ErrorLogs />,
},
{
key: DEBUGGER_TAB_KEYS.LOGS_TAB,
title: createMessage(DEBUGGER_LOGS),
2021-04-23 13:50:55 +00:00
panelComponent: <DebuggerLogs searchQuery={props.apiName} />,
},
{
key: DEBUGGER_TAB_KEYS.INSPECT_TAB,
title: createMessage(INSPECT_ENTITY),
panelComponent: <EntityDeps />,
},
];
return (
2021-04-23 13:50:55 +00:00
<ResponseContainer ref={panelRef}>
<Resizer panelRef={panelRef} />
<SectionDivider />
2019-12-11 15:14:38 +00:00
{isRunning && (
<LoadingOverlayScreen theme={props.theme}>
Sending Request
</LoadingOverlayScreen>
2019-12-11 15:14:38 +00:00
)}
<TabbedViewWrapper>
{response.statusCode && (
<ResponseMetaWrapper>
{response.statusCode && (
<Flex>
<Text type={TextType.P3}>Status: </Text>
<StatusCodeText
accent="secondary"
code={response.statusCode.toString()}
>
{response.statusCode}
</StatusCodeText>
</Flex>
)}
<ResponseMetaInfo>
{response.duration && (
<Flex>
<Text type={TextType.P3}>Time: </Text>
<Text type={TextType.H5}>{response.duration} ms</Text>
</Flex>
)}
{response.size && (
<Flex>
<Text type={TextType.P3}>Size: </Text>
<Text type={TextType.H5}>
{formatBytes(parseInt(response.size))}
</Text>
</Flex>
)}
{!_.isEmpty(response.body) && Array.isArray(response.body) && (
<Flex>
<Text type={TextType.P3}>Result: </Text>
<Text type={TextType.H5}>
{`${response.body.length} Record${
response.body.length > 1 ? "s" : ""
}`}
</Text>
</Flex>
)}
</ResponseMetaInfo>
</ResponseMetaWrapper>
)}
<EntityBottomTabs defaultIndex={0} tabs={tabs} />
2020-06-12 03:54:12 +00:00
</TabbedViewWrapper>
</ResponseContainer>
);
}
const mapStateToProps = (state: AppState): ReduxStateProps => {
return {
responses: getActionResponses(state),
isRunning: state.ui.apiPane.isRunning,
};
};
export default connect(mapStateToProps)(withRouter(ApiResponseView));