From 447f458656a7134a2cc0ec7fa8d47a7f4c1349ac Mon Sep 17 00:00:00 2001 From: Hetu Nandu Date: Mon, 22 Feb 2021 11:45:02 +0530 Subject: [PATCH] Minor Api pane design and logic fixes (#3091) --- app/client/package.json | 2 +- app/client/src/components/ads/Dropdown.tsx | 2 + .../src/components/ads/EditableText.tsx | 1 - app/client/src/components/ads/Tabs.tsx | 27 ++- .../src/components/ads/TreeDropdown.tsx | 2 +- .../editorComponents/ActionNameEditor.tsx | 1 + .../editorComponents/ApiResponseView.tsx | 172 +++++++----------- .../CodeEditor/BindingPrompt.tsx | 13 +- .../CodeEditor/styledComponents.ts | 34 +++- .../editorComponents/LoadingOverlayScreen.tsx | 4 +- .../form/fields/KeyValueFieldArray.tsx | 24 ++- app/client/src/constants/DefaultTheme.tsx | 31 +++- app/client/src/constants/messages.ts | 2 +- .../src/pages/Editor/APIEditor/Form.tsx | 18 +- .../pages/Editor/APIEditor/PostBodyData.tsx | 48 +++-- .../Explorer/Actions/MoreActionsMenu.tsx | 3 + app/client/src/widgets/DropdownWidget.tsx | 3 +- app/client/yarn.lock | 8 +- 18 files changed, 223 insertions(+), 172 deletions(-) diff --git a/app/client/package.json b/app/client/package.json index 2db914ece2..581f4e07b2 100644 --- a/app/client/package.json +++ b/app/client/package.json @@ -47,7 +47,7 @@ "algoliasearch": "^4.2.0", "axios": "^0.21.1", "chance": "^1.1.3", - "codemirror": "^5.55.0", + "codemirror": "^5.59.2", "copy-to-clipboard": "^3.3.1", "craco-alias": "^2.1.1", "cypress-log-to-output": "^1.1.2", diff --git a/app/client/src/components/ads/Dropdown.tsx b/app/client/src/components/ads/Dropdown.tsx index e42bcb2c36..8adb2a0bed 100644 --- a/app/client/src/components/ads/Dropdown.tsx +++ b/app/client/src/components/ads/Dropdown.tsx @@ -95,6 +95,8 @@ const OptionWrapper = styled.div<{ selected: boolean }>` } &:hover { + background: ${(props) => props.theme.colors.dropdown.hovered.bg}; + color: ${(props) => props.theme.colors.dropdown.hovered.text}; .${Classes.TEXT} { color: ${(props) => props.theme.colors.dropdown.selected.text}; } diff --git a/app/client/src/components/ads/EditableText.tsx b/app/client/src/components/ads/EditableText.tsx index eadbefd189..1fa96ee130 100644 --- a/app/client/src/components/ads/EditableText.tsx +++ b/app/client/src/components/ads/EditableText.tsx @@ -118,7 +118,6 @@ const TextContainer = styled.div<{ border-bottom-style: solid; border-bottom-width: 1px; width: fit-content; - max-width: 194px; ` : null} } diff --git a/app/client/src/components/ads/Tabs.tsx b/app/client/src/components/ads/Tabs.tsx index e6bcc590d6..b5b9b40e80 100644 --- a/app/client/src/components/ads/Tabs.tsx +++ b/app/client/src/components/ads/Tabs.tsx @@ -8,6 +8,7 @@ import { Classes, CommonComponentProps } from "./common"; export type TabProp = { key: string; title: string; + count?: number; panelComponent: JSX.Element; icon?: IconName; }; @@ -100,11 +101,26 @@ const TabsWrapper = styled.div<{ shouldOverflow?: boolean }>` } `; +const TabTitleWrapper = styled.div` + display: flex; + align-items: center; +`; + const TabTitle = styled.span` font-size: ${(props) => props.theme.typography.h5.fontSize}px; font-weight: ${(props) => props.theme.typography.h5.fontWeight}; line-height: ${(props) => props.theme.typography.h5.lineHeight - 3}px; letter-spacing: ${(props) => props.theme.typography.h5.letterSpacing}px; + margin: 0 5px; +`; + +const TabCount = styled.div` + background-color: ${(props) => props.theme.colors.tabs.countBg}; + border-radius: 8px; + width: 17px; + height: 14px; + font-size: 9px; + line-height: 14px; `; type TabbedViewComponentType = CommonComponentProps & { @@ -129,8 +145,15 @@ export const TabComponent = (props: TabbedViewComponentType) => { {props.tabs.map((tab) => ( - {tab.icon ? : null} - {tab.title} + + {tab.icon ? ( + + ) : null} + {tab.title} + {tab.count && tab.count > 0 ? ( + {tab.count} + ) : null} + ))} diff --git a/app/client/src/components/ads/TreeDropdown.tsx b/app/client/src/components/ads/TreeDropdown.tsx index f930014425..6b50d018a0 100644 --- a/app/client/src/components/ads/TreeDropdown.tsx +++ b/app/client/src/components/ads/TreeDropdown.tsx @@ -191,7 +191,7 @@ export default function TreeDropdown(props: TreeDropdownProps) { className={option.className || "single-select"} active={isSelected} key={option.value} - icon={option.id === "create" ? "plus" : undefined} + icon={option.icon} onClick={ option.children ? noop diff --git a/app/client/src/components/editorComponents/ActionNameEditor.tsx b/app/client/src/components/editorComponents/ActionNameEditor.tsx index 840e036bed..fb59e37002 100644 --- a/app/client/src/components/editorComponents/ActionNameEditor.tsx +++ b/app/client/src/components/editorComponents/ActionNameEditor.tsx @@ -159,6 +159,7 @@ export const ActionNameEditor = (props: ActionNameEditorProps) => { editInteractionKind={NewEditInteractionKind.SINGLE} hideEditIcon underline + fill /> ) : (
props.theme.spaces[4]}px; `; -const StatusCodeText = styled(BaseText)<{ code: string }>` - color: ${(props) => - props.code.match(/2\d\d/) ? props.theme.colors.primaryOld : Colors.RED}; +const ResponseTabWrapper = styled.div` + display: flex; + flex-direction: column; + height: 100%; + width: 100%; `; -// const TableWrapper = styled.div` -// &&& { -// table { -// table-layout: fixed; -// width: 100%; -// td { -// font-size: 12px; -// width: 50%; -// white-space: nowrap; -// overflow: hidden; -// text-overflow: ellipsis; -// } -// } -// } -// `; - -interface ReduxStateProps { - responses: Record; - isRunning: Record; -} - -// const ResponseHeadersView = (props: { data: Record }) => { -// if (!props.data) return
; -// return ( -// -// -// -// -// -// -// -// -// -// {Object.keys(props.data).map(k => ( -// -// -// -// -// ))} -// -//
KeyValue
{k}{props.data[k].join(", ")}
-//
-// ); -// }; - -type Props = ReduxStateProps & - RouteComponentProps & { theme?: EditorTheme }; - -export const EMPTY_RESPONSE: ActionResponse = { - statusCode: "", - duration: "", - body: {}, - headers: {}, - request: { - headers: {}, - body: {}, - httpMethod: "", - url: "", - }, - size: "", -}; - const TabbedViewWrapper = styled.div<{ isCentered: boolean }>` height: calc(100% - 30px); @@ -160,6 +95,12 @@ const Flex = styled.div` `; const NoResponseContainer = styled.div` + height: 100%; + width: 100%; + display: flex; + align-items: center; + justify-content: center; + flex-direction: column; .${Classes.ICON} { margin-right: 0px; svg { @@ -176,22 +117,43 @@ const NoResponseContainer = styled.div` const FailedMessage = styled.div` display: flex; align-items: center; - justify-content: space-between; - width: 100%; `; -const ButtonContainer = styled.div` +const ShowRequestText = styled.a` display: flex; - align-items: center; - span { - color: ${Colors.Galliano}; - cursor: pointer; - } - button { - margin-left: ${(props) => props.theme.spaces[9]}px; + margin-left: ${(props) => props.theme.spaces[1] + 1}px; + .${Classes.ICON} { + margin-left: ${(props) => props.theme.spaces[1] + 1}px; } `; +interface ReduxStateProps { + responses: Record; + isRunning: Record; +} + +type Props = ReduxStateProps & + RouteComponentProps & { theme?: EditorTheme }; + +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}; +`; + const ApiResponseView = (props: Props) => { const { match: { @@ -219,38 +181,32 @@ const ApiResponseView = (props: Props) => { key: "body", title: "Response Body", panelComponent: ( - <> + {hasFailed && !isRunning && requestDebugVisible && ( - {CHECK_REQUEST_BODY} - - { - setRequestDebugVisible(false); - }} - > - {DONT_SHOW_THIS_AGAIN} + { + setSelectedIndex(1); + }} + > + + {SHOW_REQUEST} -