Skip to content

Commit

Permalink
Merge pull request #294 from terminusdb/add-change-request-optional
Browse files Browse the repository at this point in the history
fix change request new
  • Loading branch information
KittyJose authored Aug 3, 2023
2 parents 6751618 + c62d12f commit c312632
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 17 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
/// <reference types="cypress" />

Cypress.on('uncaught:exception', (err, runnable) => {
return false;
});

describe('visit dashboard local', () => {
const dashboard = "http://localhost:6364/dashboard"

Expand Down
4 changes: 4 additions & 0 deletions packages/tdb-dashboard/cypress/e2e/dashboard/login.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

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

Cypress.on('uncaught:exception', (err, runnable) => {
return false;
});

///8MmY%*2q
//[email protected]

Expand Down
4 changes: 4 additions & 0 deletions packages/tdb-dashboard/cypress/e2e/dashboard/workflow.cy.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@

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

Cypress.on('uncaught:exception', (err, runnable) => {
return false;
});

///8MmY%*2q
//[email protected]

Expand Down
4 changes: 2 additions & 2 deletions packages/tdb-dashboard/src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
-->
<link rel="icon" type="image/png" href="https://assets.terminusdb.com/images/terminusx-color.png"/>
<!--<link rel="stylesheet" src="https://unpkg.com/[email protected]/dist/index.css"/>-->
<script src='/assets/leaflet.fullscreenv1.0.1.min.js'></script>
<link href='/assets/leaflet.fullscreenv1.0.1.css' rel='stylesheet' />
<!-- <script src='/assets/leaflet.fullscreenv1.0.1.min.js'></script>
<link href='/assets/leaflet.fullscreenv1.0.1.css' rel='stylesheet' /> -->
</style>
</head>
<body>
Expand Down
6 changes: 4 additions & 2 deletions packages/tdb-dashboard/src/init-woql-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions packages/tdb-dashboard/src/pages/DocumentEdit.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export const DocumentEdit = () => {
}
getDocumentFrames()
getSelectedDocument(documentID)
},[branch])
},[branch,useChangeRequest])

const closeButtonClick = () =>{
navigate(-1)
Expand All @@ -53,7 +53,7 @@ export const DocumentEdit = () => {
return <React.Fragment>
{error && <ErrorMessageReport error={error} setError={setError}/>}
{showModal && <CreateChangeRequestModal showModal={showModal} type={type} setShowModal={setShowModal} updateViewMode={setChangeRequestBranch}/>}
{(!useChangeRequest || currentChangeRequest) &&
{(useChangeRequest === false|| currentChangeRequest) &&
<EditDocumentComponent
SearchComponent={DocumentSearchComponent}
documentID={documentID}
Expand Down
4 changes: 2 additions & 2 deletions packages/tdb-dashboard/src/pages/DocumentNew.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export const DocumentNew = () => {
setShowModal(true)
}
getDocumentFrames()
},[branch])
},[branch,useChangeRequest])

const callCreateDocument = async (jsonDocument) =>{
const created = await createDocument(jsonDocument)
Expand All @@ -50,7 +50,7 @@ export const DocumentNew = () => {
return <React.Fragment>
{showModal && <CreateChangeRequestModal showModal={showModal} type={type} setShowModal={setShowModal} updateViewMode={setChangeRequestBranch}/>}
{error && <ErrorMessageReport error={error} setError={setError}/>}
{(!useChangeRequest || currentChangeRequest) && frames &&
{(useChangeRequest === false || currentChangeRequest) && frames &&
<NewDocumentComponent
SearchComponent={DocumentSearchComponent}
frames={frames}
Expand Down
33 changes: 24 additions & 9 deletions packages/tdb-dashboard/src/pages/DocumentsGraphqlList.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, {useState} from "react";
import React, {useEffect, useState} from "react";
import {useParams, useNavigate} from "react-router-dom";
import {NEW_DOC,EDIT_DOC, EXAMPLES_PRODUCTS} from "../routing/constants"
import { ListDocumentsComponent, useTDBDocuments } from "@terminusdb/terminusdb-documents-ui-template";
Expand All @@ -24,24 +24,39 @@ export const DocumentsGraphqlList = ({documentTablesConfig}) => {
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)
Expand All @@ -61,14 +76,14 @@ export const DocumentsGraphqlList = ({documentTablesConfig}) => {
return <React.Fragment>
{showCRModal &&
<CreateChangeRequestModal showModal={showCRModal}
type={type} setShowModal={setShowCRModal}
type={type} setShowModal={closeModal}
updateViewMode={setChangeRequestBranch}/>}
{showDeleteModal && <DeleteDocumentModal
loading={loading}
deleteDocument={callDeleteDocument}
documentID={tobeDeleted}
showDeleteModal={showDeleteModal}
handleClose={()=>setShowDeleteModal(false)}
handleClose={()=>resetShowDelete()}
/> }
{error && <ErrorMessageReport error={error} setError={setError}/>}
{!showDeleteModal && <ListDocumentsComponent type={type}
Expand Down

0 comments on commit c312632

Please sign in to comment.