Skip to content

Commit c312632

Browse files
authored
Merge pull request #294 from terminusdb/add-change-request-optional
fix change request new
2 parents 6751618 + c62d12f commit c312632

File tree

8 files changed

+46
-17
lines changed

8 files changed

+46
-17
lines changed

packages/tdb-dashboard/cypress/e2e/dashboard/local_dashboard.cy.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
/// <reference types="cypress" />
22

3+
Cypress.on('uncaught:exception', (err, runnable) => {
4+
return false;
5+
});
6+
37
describe('visit dashboard local', () => {
48
const dashboard = "http://localhost:6364/dashboard"
59

packages/tdb-dashboard/cypress/e2e/dashboard/login.cy.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
import { SiGmail } from "react-icons/si"
44

5+
Cypress.on('uncaught:exception', (err, runnable) => {
6+
return false;
7+
});
8+
59
///8MmY%*2q
610
//tester@terminusdb.com
711

packages/tdb-dashboard/cypress/e2e/dashboard/workflow.cy.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11

22
/// <reference types="cypress" />
33

4+
Cypress.on('uncaught:exception', (err, runnable) => {
5+
return false;
6+
});
7+
48
///8MmY%*2q
59
//tester@terminusdb.com
610

packages/tdb-dashboard/src/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
-->
88
<link rel="icon" type="image/png" href="https://assets.terminusdb.com/images/terminusx-color.png"/>
99
<!--<link rel="stylesheet" src="https://unpkg.com/[email protected]/dist/index.css"/>-->
10-
<script src='/assets/leaflet.fullscreenv1.0.1.min.js'></script>
11-
<link href='/assets/leaflet.fullscreenv1.0.1.css' rel='stylesheet' />
10+
<!-- <script src='/assets/leaflet.fullscreenv1.0.1.min.js'></script>
11+
<link href='/assets/leaflet.fullscreenv1.0.1.css' rel='stylesheet' /> -->
1212
</style>
1313
</head>
1414
<body>

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ export const WOQLClientProvider = ({children, params}) => {
3939
const [currentCRName,setCurrentCRName] = useState(false)
4040
const [currentCRStartBranch,setCurrentCRStartBranch] = useState(false)
4141

42-
const [useChangeRequest,setUseChangeRequest] = useState(true)
42+
// I'm starting with undefined this means no server response
43+
const [useChangeRequest,setUseChangeRequest] = useState(undefined)
4344

4445
// constants to control sidebar collapse
4546
const [collapseSideBar, setCollapseSideBar] = useState(localStorage.getItem(`Terminusdb-SideBar-Collapsed`) === "true" ? true : false)
@@ -172,7 +173,7 @@ export const WOQLClientProvider = ({children, params}) => {
172173
// getStoreChangeRequestDBStatus(client.organization(),dbName,setUseChangeRequest)
173174
//clear graphiql interface local storage
174175
cleanGraphiqlCache()
175-
const changeRequestStatus = getChangeRequestIsActive(client)
176+
const changeRequestStatus = await getChangeRequestIsActive(client)
176177
if(changeRequestStatus.isActive){
177178
// check if there is a change request related
178179
const {TERMINUSCMS_CR , TERMINUSCMS_CR_ID} = changeRequestName(client)
@@ -218,6 +219,7 @@ export const WOQLClientProvider = ({children, params}) => {
218219

219220
function setChangeRequestBranch(branchName,changeRequestId, CRName){
220221
// save the branch from
222+
221223
setCurrentCRStartBranch(woqlClient.checkout())
222224
woqlClient.checkout(branchName)
223225
setBranch(branchName)

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export const DocumentEdit = () => {
4242
}
4343
getDocumentFrames()
4444
getSelectedDocument(documentID)
45-
},[branch])
45+
},[branch,useChangeRequest])
4646

4747
const closeButtonClick = () =>{
4848
navigate(-1)
@@ -53,7 +53,7 @@ export const DocumentEdit = () => {
5353
return <React.Fragment>
5454
{error && <ErrorMessageReport error={error} setError={setError}/>}
5555
{showModal && <CreateChangeRequestModal showModal={showModal} type={type} setShowModal={setShowModal} updateViewMode={setChangeRequestBranch}/>}
56-
{(!useChangeRequest || currentChangeRequest) &&
56+
{(useChangeRequest === false|| currentChangeRequest) &&
5757
<EditDocumentComponent
5858
SearchComponent={DocumentSearchComponent}
5959
documentID={documentID}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export const DocumentNew = () => {
3333
setShowModal(true)
3434
}
3535
getDocumentFrames()
36-
},[branch])
36+
},[branch,useChangeRequest])
3737

3838
const callCreateDocument = async (jsonDocument) =>{
3939
const created = await createDocument(jsonDocument)
@@ -50,7 +50,7 @@ export const DocumentNew = () => {
5050
return <React.Fragment>
5151
{showModal && <CreateChangeRequestModal showModal={showModal} type={type} setShowModal={setShowModal} updateViewMode={setChangeRequestBranch}/>}
5252
{error && <ErrorMessageReport error={error} setError={setError}/>}
53-
{(!useChangeRequest || currentChangeRequest) && frames &&
53+
{(useChangeRequest === false || currentChangeRequest) && frames &&
5454
<NewDocumentComponent
5555
SearchComponent={DocumentSearchComponent}
5656
frames={frames}

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

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, {useState} from "react";
1+
import React, {useEffect, useState} from "react";
22
import {useParams, useNavigate} from "react-router-dom";
33
import {NEW_DOC,EDIT_DOC, EXAMPLES_PRODUCTS} from "../routing/constants"
44
import { ListDocumentsComponent, useTDBDocuments } from "@terminusdb/terminusdb-documents-ui-template";
@@ -24,24 +24,39 @@ export const DocumentsGraphqlList = ({documentTablesConfig}) => {
2424
const tableConfig = documentTablesConfig.tablesColumnsConfig[type]
2525
const advancedSearchConfig = documentTablesConfig.advancedSearchObj[type]
2626

27-
function deleteDocumentHandler(row) {
27+
28+
const deleteDocumentHandler =(row, currentChangeRequest,useChangeRequest )=>{
2829
let fullId = row['id']
2930
setTobeDeleted(fullId)
3031
// I can not change main directly
3132
// I can change other branches creates with create branch interface
32-
if(useChangeRequest && !currentChangeRequest){
33-
setShowCRModal(true)
34-
}else setShowDeleteModal(true)
3533
}
3634

35+
const closeModal =()=>{
36+
setShowCRModal(false)
37+
setShowDeleteModal(true)
38+
}
39+
40+
useEffect(()=>{
41+
if(tobeDeleted){
42+
if(useChangeRequest && currentChangeRequest === false){
43+
setShowCRModal(true)
44+
}else setShowDeleteModal(true)
45+
}
46+
},[tobeDeleted])
47+
3748
async function callDeleteDocument(){
3849
const delCall = await deleteDocument(tobeDeleted)
3950
if(delCall){
40-
setShowDeleteModal(false)
41-
setTobeDeleted(false)
51+
resetShowDelete()
4252
}
4353
}
4454

55+
const resetShowDelete =()=>{
56+
setShowDeleteModal(false)
57+
setTobeDeleted(false)
58+
}
59+
4560
const onViewClick = (row) =>{
4661
let fullId = row['id']
4762
let fullIdEncode = btoa(fullId)
@@ -61,14 +76,14 @@ export const DocumentsGraphqlList = ({documentTablesConfig}) => {
6176
return <React.Fragment>
6277
{showCRModal &&
6378
<CreateChangeRequestModal showModal={showCRModal}
64-
type={type} setShowModal={setShowCRModal}
79+
type={type} setShowModal={closeModal}
6580
updateViewMode={setChangeRequestBranch}/>}
6681
{showDeleteModal && <DeleteDocumentModal
6782
loading={loading}
6883
deleteDocument={callDeleteDocument}
6984
documentID={tobeDeleted}
7085
showDeleteModal={showDeleteModal}
71-
handleClose={()=>setShowDeleteModal(false)}
86+
handleClose={()=>resetShowDelete()}
7287
/> }
7388
{error && <ErrorMessageReport error={error} setError={setError}/>}
7489
{!showDeleteModal && <ListDocumentsComponent type={type}

0 commit comments

Comments
 (0)