Skip to content

Commit 2ffd7d0

Browse files
authored
Merge pull request #154 from terminusdb/review_documents_hook
fix call
2 parents 8fee0f1 + 982ae10 commit 2ffd7d0

File tree

2 files changed

+6
-46
lines changed

2 files changed

+6
-46
lines changed

packages/tdb-dashboard/src/hooks/DocumentControlContext.js

Lines changed: 2 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,8 @@ export const DocumentControlProvider = ({children}) => {
127127
// only if I'm in change request mode
128128
// I do not need to reload because the schema can not change
129129
if(!currentChangeRequest || frames===null)getUpdatedFrames()
130+
// we need in edit/insert
131+
if(!currentChangeRequest || documentTablesConfig === null) getGraphqlTableConfig()
130132
if(id) {
131133
let documentID=decodeUrl(id)
132134
getDocument(documentID)
@@ -253,51 +255,6 @@ export const DocumentControlProvider = ({children}) => {
253255
}finally{setLoading(false)}
254256
}
255257

256-
// function to format and display errors in document Interface
257-
/* function formatErrorMessages (error) {
258-
259-
if(!error.hasOwnProperty("api:message")) return error
260-
261-
let message = error["api:message"]
262-
let errorElements = []
263-
if(error["api:error"]) {
264-
if(Array.isArray(error["api:error"]["api:witnesses"])) {
265-
error["api:error"]["api:witnesses"].map(err => {
266-
267-
if(err.hasOwnProperty("constraint_name")) {
268-
// CONSTRAINT ERRORS
269-
let propertyName = err["constraint_name"]
270-
let errorType = `${err["@type"]} on `
271-
let message = err.message
272-
273-
errorElements.push(
274-
<DisplayErrorPerProperty propertyName={propertyName} message={message} errorType={errorType}/>
275-
)
276-
}
277-
else {
278-
if(err.hasOwnProperty("@type")) {
279-
errorElements.push(
280-
<pre>{JSON.stringify(err, null, 2)}</pre>
281-
)
282-
}
283-
else {
284-
// OTHER TYPE ERRORS
285-
for(let items in err) {
286-
let propertyName = items
287-
let errorType = err[propertyName].hasOwnProperty("@type") ? `${err[propertyName]["@type"]} on ` : `Error occured on`
288-
let message = JSON.stringify(err[propertyName], null, 2)
289-
errorElements.push(
290-
<DisplayErrorPerProperty propertyName={propertyName} message={message} errorType={errorType}/>
291-
)
292-
}
293-
}
294-
}
295-
})
296-
}
297-
}
298-
return <ErrorDisplay errorData={errorElements} message={message} css={CONST.ERROR_MORE_INFO_CLASSNAME}/>
299-
}*/
300-
301258
return (
302259
<DocumentControlContext.Provider
303260
value={{

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,17 @@ const DisplayDocumentBody = () => {
2121
// setJsonContent,
2222
frames,
2323
getUpdatedFrames,
24-
createDocument
24+
createDocument,
25+
getGraphqlTableConfig,
26+
documentTablesConfig
2527
} = DocumentControlObj()
2628

2729

2830
useEffect(() => {
2931
if(!currentChangeRequest || frames===null) {
3032
getUpdatedFrames()
3133
}
34+
if(!currentChangeRequest || documentTablesConfig === null) getGraphqlTableConfig()
3235
},[])
3336

3437
const callCreateDocument = async (jsonDocument) =>{

0 commit comments

Comments
 (0)