Skip to content

Commit 405d2e9

Browse files
authored
Merge pull request #136 from terminusdb/fix_graphiql
Fix graphiql interface
2 parents ef01619 + e64e158 commit 405d2e9

File tree

6 files changed

+86
-26
lines changed

6 files changed

+86
-26
lines changed

packages/tdb-dashboard/src/App.css

Lines changed: 56 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -721,27 +721,41 @@ input {
721721
.mandatory-icon {
722722
font-size: 10px;
723723
}
724+
/* to be review */
725+
.model-builder-code-mirror {
726+
height: auto !important;
727+
}
724728

729+
.model-builder-code-mirror .CodeMirror{
730+
min-height: 400px !important;
731+
}
725732

726-
.model-builder-code-mirror {
733+
.model-builder-code-mirror .CodeMirror-scroll {
734+
min-height: 400px !important;
735+
}
736+
737+
.model-builder-code-mirror > .qp-CodeMirror {
727738
height: auto !important;
739+
min-height: 400px !important;
728740
}
729741

730-
.CodeMirror {
731-
min-height: 400px !important;/*150px !important;*/
742+
743+
744+
745+
.editor-pallet .CodeMirror {
746+
min-height: 400px !important;
732747
height: auto !important;
733748
}
734749

735-
.CodeMirror-scroll {
750+
.editor-pallet .CodeMirror-scroll {
736751
min-height: 400px !important;
737752
}
738753

739754
pre.CodeMirror-line > span > span.cm-string {
740755
word-break: break-all !important;
741756
}
742757

743-
744-
.qp-CodeMirror {
758+
.editor-pallet > .qp-CodeMirror {
745759
height: auto !important;
746760
min-height: 400px !important;
747761
}
@@ -1021,8 +1035,29 @@ pre.CodeMirror-line > span > span.cm-string {
10211035
max-width: 200px;
10221036
}
10231037

1038+
.graphiql-container .graphiql-chevron-icon{
1039+
color:white;
1040+
}
1041+
1042+
button.graphiql-tab-add>svg
1043+
{
1044+
color:white;
1045+
}
1046+
1047+
.graphiql-container .graphiql-logo .graphiql-logo-link {
1048+
color:white;
1049+
}
1050+
10241051
.mainGraphIql{
1025-
height : calc(100% - 60px);
1052+
height : calc(100vh - 80px);
1053+
}
1054+
1055+
.mainGraphIqlCR{
1056+
height : calc(100vh - 150px);
1057+
}
1058+
1059+
.graphiql-session{
1060+
height : 100%;
10261061
}
10271062

10281063
.graphiql-container{
@@ -1033,10 +1068,22 @@ pre.CodeMirror-line > span > span.cm-string {
10331068
color:white !important;
10341069
}
10351070

1036-
10371071
.graphiql-container .graphiql-editors {
10381072
background-color: transparent;
10391073
}
1074+
1075+
.graphiql-editor >.CodeMirror{
1076+
height: 100%;
1077+
position: absolute;
1078+
width: 100%;
1079+
}
1080+
1081+
.result-window >.CodeMirror{
1082+
height: 100% !important;
1083+
position: absolute;
1084+
width: 100%;
1085+
}
1086+
10401087
#json_type_field-warning-box svg {
10411088
height: 15px;
10421089
width: 15px;
@@ -1108,9 +1155,7 @@ pre.CodeMirror-line > span > span.cm-string {
11081155
.rule_group{
11091156
background-color: white;
11101157
}
1111-
.result-window .CodeMirror{
1112-
height: 100%;
1113-
}
1158+
11141159
.MuiButton-text{
11151160
color: rgb(0, 188, 140)!important;
11161161
margin-right: 20px;
@@ -1170,11 +1215,6 @@ pre.CodeMirror-line > span > span.cm-string {
11701215
color: #3450DC;
11711216
}
11721217

1173-
/*enable graph ql response to over flow*/
1174-
.graphiql-response {
1175-
overflow: auto !important;
1176-
}
1177-
11781218
#profile_menu >.dropdown-menu[data-bs-popper] {
11791219
top: 100%;
11801220
right: 0;

packages/tdb-dashboard/src/index.html

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,9 @@
5252
color: #fff;
5353
background-color: #f50057;
5454
}
55-
5655
.rule_group{
5756
background-color: white;
5857
}
59-
.result-window .CodeMirror{
60-
height: 100%;
61-
}
6258
</style>
6359
</body>
6460
</html>

packages/tdb-dashboard/src/init-woql-client.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { formatErrorMessage } from './hooks/hookUtils'
1111
import { createApolloClient } from './routing/ApolloClientConfig'
1212
import {sortAlphabetically} from "./components/utils"
1313
import {getChangesUrl} from "./hooks/hookUtils"
14+
import {cleanGraphiqlCache} from "./pages/utils"
1415

1516
export const WOQLContext = React.createContext()
1617
export const WOQLClientObj = () => useContext(WOQLContext)
@@ -235,6 +236,8 @@ export const WOQLClientProvider = ({children, params}) => {
235236
setHead('main',{commit:false,time:false})
236237

237238
if(dbName){
239+
//clear graphiql interface local storage
240+
cleanGraphiqlCache()
238241
// check if there is a change request related
239242
const {TERMINUSCMS_CR , TERMINUSCMS_CR_ID} = changeRequestName(client)
240243

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
import React from "react";
1+
import React, {useEffect} from "react";
22
import { createGraphiQLFetcher } from "@graphiql/toolkit";
33
import { GraphiQL } from "graphiql";
44
//import {Container} from "react-bootstrap"
55
import { Layout } from "./Layout";
66
import {WOQLClientObj} from '../init-woql-client'
77
//import "./style.css"
88

9-
export function GraphIqlEditor() {
10-
const {woqlClient} = WOQLClientObj()
9+
export function GraphIqlEditor({}) {
10+
const {woqlClient,currentChangeRequest} = WOQLClientObj()
1111
if(!woqlClient) return
1212
const client = woqlClient.copy()
1313
const url = client.connectionConfig.branchBase("graphql")
@@ -20,14 +20,15 @@ export function GraphIqlEditor() {
2020
}
2121
});
2222

23+
const layoutClass = currentChangeRequest ? "container-fluid mainGraphIqlCR" : "container-fluid mainGraphIql"
24+
2325
return (
24-
<Layout mainClassName="container-fluid mainGraphIql" showLeftSideBar={false}>
25-
26+
<Layout mainClassName={layoutClass} showLeftSideBar={false}>
2627
<GraphiQL
2728
editorTheme="shadowfox"
2829
fetcher={fetcher}
30+
2931
/>
30-
3132
</Layout>
3233
);
3334
}

packages/tdb-dashboard/src/pages/utils.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,22 @@ export const timeConverter = (UNIX_timestamp) => {
3232
return time
3333
}
3434

35+
export const cleanGraphiqlCache = () =>{
36+
const localStorageArr =
37+
['graphiql:docExplorerFlex',
38+
'graphiql:editorFlex',
39+
"graphiql:operationName",
40+
"graphiql:queries",
41+
"graphiql:query",
42+
"graphiql:tabState",
43+
"graphiql:variables",
44+
"graphiql:secondaryEditorFlex"]
45+
46+
localStorageArr.forEach(item=>{
47+
localStorage.removeItem(item)
48+
})
49+
}
50+
51+
52+
53+

packages/tdb-documents-ui/src/utils.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -701,6 +701,7 @@ export function getLinkedDocumentClassName (frame, item) {
701701
*/
702702
export function getRowHeight(data) {
703703
if(Array.isArray(data)) return 1
704+
if(typeof data !== "string") return 1
704705
return data.split(/\r\n|\r|\n/).length
705706
}
706707

0 commit comments

Comments
 (0)