Skip to content

Commit 59a8f72

Browse files
committed
update package.json
1 parent 8082caf commit 59a8f72

File tree

4 files changed

+60
-51
lines changed

4 files changed

+60
-51
lines changed

packages/tdb-dashboard/package-lock.json

Lines changed: 16 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/tdb-dashboard/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@
4343
},
4444
"dependencies": {
4545
"@auth0/auth0-spa-js": "^1.19.3",
46-
"@terminusdb/terminusdb-access-control-component": "^0.0.8",
47-
"@terminusdb/terminusdb-client": "^10.0.13",
46+
"@terminusdb/terminusdb-access-control-component": "^0.0.9",
47+
"@terminusdb/terminusdb-client": "^10.0.14",
4848
"@terminusdb/terminusdb-documents-ui": "^1.0.7",
4949
"axios": "^0.21.1",
5050
"classnames": "^2.2.5",

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,14 @@ export function getBaseUrl(){
2121
remote_url += process.env.FEEDBACK_URL.endsWith('/') ? process.env.FEEDBACK_URL : process.env.FEEDBACK_URL+'/'
2222
}
2323
return `${remote_url}api`
24+
}
25+
26+
export function formatErrorMessage (err){
27+
let message = err.message
28+
if(err.data && err.data["api:message"]){
29+
message = err.data["api:message"]
30+
}else if (message.indexOf("Network Error")>-1){
31+
message = "Network Error"
32+
}
33+
return message
2434
}

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

Lines changed: 32 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {executeQueryHook} from "./hooks/executeQueryHook"
77
import {AccessControlDashboard} from "@terminusdb/terminusdb-access-control-component"
88
import {useLocation} from "react-router-dom"
99
import {createClientUser,formatSchema} from "./clientUtils"
10-
10+
import { formatErrorMessage } from './hooks/hookUtils'
1111
export const WOQLContext = React.createContext()
1212
export const WOQLClientObj = () => useContext(WOQLContext)
1313

@@ -128,13 +128,7 @@ export const WOQLClientProvider = ({children, params}) => {
128128
setAccessControl(clientAccessControl)
129129
setWoqlClient(dbClient)
130130
} catch (err) {
131-
let message = err.message
132-
if(err.data && err.data["api:message"]){
133-
message = err.data["api:message"]
134-
console.log("ERROR_DATA",message)
135-
}else if (message.indexOf("Network Error")>-1){
136-
message = "Network Error"
137-
}
131+
const message = formatErrorMessage(err)
138132
setError(message)
139133
}finally {
140134
setLoadingServer(false)
@@ -307,32 +301,37 @@ export const WOQLClientProvider = ({children, params}) => {
307301

308302
// review
309303
async function changeOrganization (orgName,setDataP, hubClient,accessControlDash){
310-
hubClient = hubClient || woqlClient
311-
accessControlDash = accessControlDash || accessControlDashboard
312-
//this set the organization name and reset the databases list to empty
313-
hubClient.organization(orgName)
314-
// this failed if the organization does not exists
315-
await accessControlDash.callGetUserTeamRole(clientUser.user,orgName)
316-
317-
//I use this for now to not call getDatabases
318-
if(hubClient.userOrganizations().length>0){
319-
const hh= hubClient.userOrganizations();
320-
const dbs = hubClient.userOrganizations().find(element => element['name'] === orgName )
321-
//console.log("DATABASES", dbs)
322-
const dbList = dbs && dbs.databases ? dbs.databases : []
323-
hubClient.databases(dbList)
324-
}
325-
//this is for change the base url api for the proxy
326-
if(opts.connection_type!== "LOCAL"){
327-
hubClient.connectionConfig.api_extension = `${orgName}/api/`
328-
//load the list of system roles
329-
accessControlDash.callGetRolesList()
304+
try{
305+
hubClient = hubClient || woqlClient
306+
accessControlDash = accessControlDash || accessControlDashboard
307+
//this set the organization name and reset the databases list to empty
308+
hubClient.organization(orgName)
309+
// this failed if the organization does not exists
310+
await accessControlDash.callGetUserTeamRole(clientUser.user,orgName)
311+
312+
//I use this for now to not call getDatabases
313+
if(hubClient.userOrganizations().length>0){
314+
const hh= hubClient.userOrganizations();
315+
const dbs = hubClient.userOrganizations().find(element => element['name'] === orgName )
316+
//console.log("DATABASES", dbs)
317+
const dbList = dbs && dbs.databases ? dbs.databases : []
318+
hubClient.databases(dbList)
319+
}
320+
//this is for change the base url api for the proxy
321+
if(opts.connection_type!== "LOCAL"){
322+
hubClient.connectionConfig.api_extension = `${orgName}/api/`
323+
//load the list of system roles
324+
accessControlDash.callGetRolesList()
325+
}
326+
327+
localStorage.setItem("Org", orgName)
328+
const dataP = setDataP || false
329+
//reset database and commit head
330+
setDataProduct(dataP,hubClient,accessControlDash)
331+
}catch(err){
332+
const message = formatErrorMessage(err)
333+
setError(message)
330334
}
331-
332-
localStorage.setItem("Org", orgName)
333-
const dataP = setDataP || false
334-
//reset database and commit head
335-
setDataProduct(dataP,hubClient,accessControlDash)
336335
}
337336

338337
//get the list of databases

0 commit comments

Comments
 (0)