From e8a330c053091589671da0abf1d1d8c5054456f0 Mon Sep 17 00:00:00 2001 From: Shekar Siri Date: Wed, 16 Feb 2022 17:06:08 +0100 Subject: [PATCH] GraphQL UI and Navigation (#335) * chore(http): check for custom endpoint for caching Signed-off-by: --global <--global> * fix(ui) - typo * fix(migration): template file variable values * fix(install): minio download path Signed-off-by: rjshrjndrn * chore(nginx): precedence x-forward-for ip for geo location tagging Signed-off-by: rjshrjndrn * chore(kafka): change retention to 4 days Signed-off-by: rjshrjndrn * feat(ui) - graphql ui and navigation Co-authored-by: --global <--global> Co-authored-by: Mehdi Osman Co-authored-by: rjshrjndrn --- .../app/components/Session_/Fetch/Fetch.js | 4 - .../components/Session_/GraphQL/GQLDetails.js | 73 ++++++++++---- .../components/Session_/GraphQL/GraphQL.js | 97 +++++++++++++------ 3 files changed, 122 insertions(+), 52 deletions(-) diff --git a/frontend/app/components/Session_/Fetch/Fetch.js b/frontend/app/components/Session_/Fetch/Fetch.js index 2db36f76f..dd3c79711 100644 --- a/frontend/app/components/Session_/Fetch/Fetch.js +++ b/frontend/app/components/Session_/Fetch/Fetch.js @@ -127,10 +127,6 @@ export default class Fetch extends React.PureComponent {

Fetch

- {/*
-
Prev
-
Next
-
*/} -
- { variables && variables !== "{}" && -
-
-
{ 'Variables'}
- { jsonVars === undefined - ?
{ variables }
- : - } +
+
{ 'Operation Name'}
+
{ operationName }
+ +
+
+
Operation Kind
+
{operationKind}
+
+
+
Duration
+
{parseInt(duration)} ms
+
+
+ +
+
{ 'Response' }
+
+
+ { variables && variables !== "{}" && +
+
+
{ 'Variables'}
+ { jsonVars === undefined + ?
{ variables }
+ : + } +
+
-
-
- } -
-
-
{ 'Response' }
-
- { jsonResponse === undefined - ?
{ response }
- : } +
+ { jsonResponse === undefined + ?
{ response }
+ : + } +
+
+ +
+ +
); diff --git a/frontend/app/components/Session_/GraphQL/GraphQL.js b/frontend/app/components/Session_/GraphQL/GraphQL.js index 0fedbb85e..0b2765b58 100644 --- a/frontend/app/components/Session_/GraphQL/GraphQL.js +++ b/frontend/app/components/Session_/GraphQL/GraphQL.js @@ -1,8 +1,6 @@ -//import cn from 'classnames'; -import { Icon, NoContent, Input, SlideModal } from 'UI'; +import { Label, Icon, NoContent, Input, SlideModal, CloseButton } from 'UI'; import { getRE } from 'App/utils'; -import { connectPlayer } from 'Player'; -import Autoscroll from '../Autoscroll'; +import { connectPlayer, pause, jump } from 'Player'; import BottomBlock from '../BottomBlock'; import TimeTable from '../TimeTable'; import GQLDetails from './GQLDetails'; @@ -10,60 +8,105 @@ import GQLDetails from './GQLDetails'; function renderDefaultStatus() { return "2xx-3xx"; } - @connectPlayer(state => ({ list: state.graphqlListNow, + livePlay: state.livePlay, })) export default class GraphQL extends React.PureComponent { state = { - filter: "", + filter: "", + filteredList: this.props.list, current: null, + currentIndex: 0, + showFetchDetails: false, + hasNextError: false, + hasPreviousError: false, } - onFilterChange = (e, { value }) => this.setState({ filter: value }) - setCurrent = (item) => { - this.setState({ current: item }); + onFilterChange = (e, { value }) => { + const { list } = this.props; + const filterRE = getRE(value, 'i'); + const filtered = list + .filter((r) => filterRE.test(r.name) || filterRE.test(r.url) || filterRE.test(r.method) || filterRE.test(r.status)); + this.setState({ filter: value, filteredList: value ? filtered : list, currentIndex: 0 }); + } + + setCurrent = (item, index) => { + if (!this.props.livePlay) { + pause(); + jump(item.time) + } + this.setState({ current: item, currentIndex: index }); + } + + closeModal = () => this.setState({ current: null, showFetchDetails: false }); + + static getDerivedStateFromProps(nextProps, prevState) { + const { filteredList } = prevState; + if (nextProps.timelinePointer) { + let activeItem = filteredList.find((r) => r.time >= nextProps.timelinePointer.time); + activeItem = activeItem || filteredList[filteredList.length - 1]; + return { + current: activeItem, + currentIndex: filteredList.indexOf(activeItem), + }; + } } - closeModal = () => this.setState({ current: null}) render() { const { list } = this.props; - const { filter, current } = this.state; - const filterRE = getRE(filter, 'i'); - const filtered = list - .filter(({ operationName = "", operationKind = "" }) => filterRE.test(operationName) || filterRE.test(operationKind)); - + const { current, currentIndex, filteredList } = this.state; + return ( {current.operationKind} {current.operationName} } + right + title = { +
+

GraphQL

+
+ +
+
+ } isDisplayed={ current != null } content={ current && - + } onClose={ this.closeModal } /> - +

GraphQL

+
+ +
{[ {