From c62d12f22ddf5cdd1cd6c47b0f2dcfdbe720ef43 Mon Sep 17 00:00:00 2001 From: Francesca-Bit Date: Thu, 3 Aug 2023 15:38:43 +0200 Subject: [PATCH] fix change request new --- .../e2e/dashboard/local_dashboard.cy.js | 4 +++ .../cypress/e2e/dashboard/login.cy.js | 4 +++ .../cypress/e2e/dashboard/workflow.cy.js | 4 +++ packages/tdb-dashboard/src/index.html | 4 +-- .../tdb-dashboard/src/init-woql-client.js | 6 ++-- .../tdb-dashboard/src/pages/DocumentEdit.js | 4 +-- .../tdb-dashboard/src/pages/DocumentNew.js | 4 +-- .../src/pages/DocumentsGraphqlList.js | 33 ++++++++++++++----- 8 files changed, 46 insertions(+), 17 deletions(-) diff --git a/packages/tdb-dashboard/cypress/e2e/dashboard/local_dashboard.cy.js b/packages/tdb-dashboard/cypress/e2e/dashboard/local_dashboard.cy.js index 52019141..35e1b8ff 100644 --- a/packages/tdb-dashboard/cypress/e2e/dashboard/local_dashboard.cy.js +++ b/packages/tdb-dashboard/cypress/e2e/dashboard/local_dashboard.cy.js @@ -1,5 +1,9 @@ /// +Cypress.on('uncaught:exception', (err, runnable) => { + return false; +}); + describe('visit dashboard local', () => { const dashboard = "http://localhost:6364/dashboard" diff --git a/packages/tdb-dashboard/cypress/e2e/dashboard/login.cy.js b/packages/tdb-dashboard/cypress/e2e/dashboard/login.cy.js index bf6259be..c969ef2e 100644 --- a/packages/tdb-dashboard/cypress/e2e/dashboard/login.cy.js +++ b/packages/tdb-dashboard/cypress/e2e/dashboard/login.cy.js @@ -2,6 +2,10 @@ import { SiGmail } from "react-icons/si" +Cypress.on('uncaught:exception', (err, runnable) => { + return false; +}); + ///8MmY%*2q //tester@terminusdb.com diff --git a/packages/tdb-dashboard/cypress/e2e/dashboard/workflow.cy.js b/packages/tdb-dashboard/cypress/e2e/dashboard/workflow.cy.js index 94a0550e..c174bcab 100644 --- a/packages/tdb-dashboard/cypress/e2e/dashboard/workflow.cy.js +++ b/packages/tdb-dashboard/cypress/e2e/dashboard/workflow.cy.js @@ -1,6 +1,10 @@ /// +Cypress.on('uncaught:exception', (err, runnable) => { + return false; +}); + ///8MmY%*2q //tester@terminusdb.com diff --git a/packages/tdb-dashboard/src/index.html b/packages/tdb-dashboard/src/index.html index bb760f89..6931448b 100644 --- a/packages/tdb-dashboard/src/index.html +++ b/packages/tdb-dashboard/src/index.html @@ -7,8 +7,8 @@ --> - - + diff --git a/packages/tdb-dashboard/src/init-woql-client.js b/packages/tdb-dashboard/src/init-woql-client.js index afca56c5..6e50b148 100644 --- a/packages/tdb-dashboard/src/init-woql-client.js +++ b/packages/tdb-dashboard/src/init-woql-client.js @@ -39,7 +39,8 @@ export const WOQLClientProvider = ({children, params}) => { const [currentCRName,setCurrentCRName] = useState(false) const [currentCRStartBranch,setCurrentCRStartBranch] = useState(false) - const [useChangeRequest,setUseChangeRequest] = useState(true) + // I'm starting with undefined this means no server response + const [useChangeRequest,setUseChangeRequest] = useState(undefined) // constants to control sidebar collapse const [collapseSideBar, setCollapseSideBar] = useState(localStorage.getItem(`Terminusdb-SideBar-Collapsed`) === "true" ? true : false) @@ -172,7 +173,7 @@ export const WOQLClientProvider = ({children, params}) => { // getStoreChangeRequestDBStatus(client.organization(),dbName,setUseChangeRequest) //clear graphiql interface local storage cleanGraphiqlCache() - const changeRequestStatus = getChangeRequestIsActive(client) + const changeRequestStatus = await getChangeRequestIsActive(client) if(changeRequestStatus.isActive){ // check if there is a change request related const {TERMINUSCMS_CR , TERMINUSCMS_CR_ID} = changeRequestName(client) @@ -218,6 +219,7 @@ export const WOQLClientProvider = ({children, params}) => { function setChangeRequestBranch(branchName,changeRequestId, CRName){ // save the branch from + setCurrentCRStartBranch(woqlClient.checkout()) woqlClient.checkout(branchName) setBranch(branchName) diff --git a/packages/tdb-dashboard/src/pages/DocumentEdit.js b/packages/tdb-dashboard/src/pages/DocumentEdit.js index e67cc824..74aa4404 100644 --- a/packages/tdb-dashboard/src/pages/DocumentEdit.js +++ b/packages/tdb-dashboard/src/pages/DocumentEdit.js @@ -42,7 +42,7 @@ export const DocumentEdit = () => { } getDocumentFrames() getSelectedDocument(documentID) - },[branch]) + },[branch,useChangeRequest]) const closeButtonClick = () =>{ navigate(-1) @@ -53,7 +53,7 @@ export const DocumentEdit = () => { return {error && } {showModal && } - {(!useChangeRequest || currentChangeRequest) && + {(useChangeRequest === false|| currentChangeRequest) && { setShowModal(true) } getDocumentFrames() - },[branch]) + },[branch,useChangeRequest]) const callCreateDocument = async (jsonDocument) =>{ const created = await createDocument(jsonDocument) @@ -50,7 +50,7 @@ export const DocumentNew = () => { return {showModal && } {error && } - {(!useChangeRequest || currentChangeRequest) && frames && + {(useChangeRequest === false || currentChangeRequest) && frames && { const tableConfig = documentTablesConfig.tablesColumnsConfig[type] const advancedSearchConfig = documentTablesConfig.advancedSearchObj[type] - function deleteDocumentHandler(row) { + + const deleteDocumentHandler =(row, currentChangeRequest,useChangeRequest )=>{ let fullId = row['id'] setTobeDeleted(fullId) // I can not change main directly // I can change other branches creates with create branch interface - if(useChangeRequest && !currentChangeRequest){ - setShowCRModal(true) - }else setShowDeleteModal(true) } + const closeModal =()=>{ + setShowCRModal(false) + setShowDeleteModal(true) + } + + useEffect(()=>{ + if(tobeDeleted){ + if(useChangeRequest && currentChangeRequest === false){ + setShowCRModal(true) + }else setShowDeleteModal(true) + } + },[tobeDeleted]) + async function callDeleteDocument(){ const delCall = await deleteDocument(tobeDeleted) if(delCall){ - setShowDeleteModal(false) - setTobeDeleted(false) + resetShowDelete() } } + const resetShowDelete =()=>{ + setShowDeleteModal(false) + setTobeDeleted(false) + } + const onViewClick = (row) =>{ let fullId = row['id'] let fullIdEncode = btoa(fullId) @@ -61,14 +76,14 @@ export const DocumentsGraphqlList = ({documentTablesConfig}) => { return {showCRModal && } {showDeleteModal && setShowDeleteModal(false)} + handleClose={()=>resetShowDelete()} /> } {error && } {!showDeleteModal &&