Skip to content

Commit 58e63a9

Browse files
committed
review changerequest and indexing
1 parent ee9f4e0 commit 58e63a9

File tree

12 files changed

+138
-41
lines changed

12 files changed

+138
-41
lines changed

packages/tdb-dashboard/src/components/DisplayNoIndexingAction.js

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,12 @@ const StepDetail = ({ stepNumber, stepComponent, icon}) => {
2626
}
2727

2828

29+
2930
function getStep(stepNumber,supMode) {
3031
let { organization,dataProduct } = useParams()
3132
const stepOptions= {
32-
"step1":<>
33-
Visit <NavLink href="https://platform.openai.com/account/api-keys" className={"mr-1"}>Open AI</NavLink>
34-
and create a your Secret API Key
35-
</>,
33+
"step1":<>Visit <a href="https://platform.openai.com/account/api-keys" target="_blank" className={"mr-1"}>Open AI</a>
34+
and create a your Secret API Key</>,
3635
"step2": {"LOCAL":<>
3736
Copy and paste your generated OpenAI API Key in your environment variables, restart the application
3837
</>,
@@ -42,12 +41,17 @@ function getStep(stepNumber,supMode) {
4241
},
4342
"step3":<>
4443
Go to <NavLink to={`/${organization}/${dataProduct}/openai_configuration`} className={"mr-1"}>Open AI configuration </NavLink> page
45-
to add a graphql query and an handlebar template for every Document
44+
to add a graphql query and an handlebar template for every Document you like to index
4645
</>,
47-
"step4": <>
46+
"step4": {"REMOTE":<>
4847
In your profile turn on the Indexing button next to the OpenAI Key field.
4948
All data products in your team will begin to index.
5049
</>,
50+
"LOCAL":<>
51+
Use VectorLink to Semantically search your data products and use the vector embeddings to talk to OpenAI.
52+
Click <NavLink href="https://terminusdb.com/docs/" className={"mr-1"}>here</NavLink>for more info on how to use VectorLink.
53+
</>},
54+
5155
"step5": <>
5256
Use VectorLink to Semantically search your data products and use the vector embeddings to talk to OpenAI.
5357
Click <NavLink href="https://terminusdb.com/docs/" className={"mr-1"}>here</NavLink>for more info on how to use VectorLink.
@@ -77,8 +81,8 @@ export const DisplayNoIndexingAction = ({ helpDescription }) => {
7781
<StepDetail stepNumber={1} stepComponent={getStep(1)} icon={<BsKey/>}/>
7882
<StepDetail stepNumber={2} stepComponent={getStep(2, connection_type)} icon={<RiUserFollowFill/>}/>
7983
<StepDetail stepNumber={3} stepComponent={getStep(3)} icon={<SiHandlebarsdotjs/>}/>
80-
<StepDetail stepNumber={4} stepComponent={getStep(4)} icon={<RxCheckbox/>}/>
81-
<StepDetail stepNumber={5} stepComponent={getStep(5)} icon={<BsSearch/>}/>
84+
<StepDetail stepNumber={4} stepComponent={getStep(4, connection_type)} icon={<RxCheckbox/>}/>
85+
{connection_type === "REMOTE" && <StepDetail stepNumber={5} stepComponent={getStep(5)} icon={<BsSearch/>}/>}
8286
</Col>
8387
<Col md={3}></Col>
8488
</Row>

packages/tdb-dashboard/src/components/DocumentSearchComponent.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import React, {useEffect} from "react"
22
import {DocumentsGraphqlTable} from "@terminusdb/terminusdb-documents-ui-template"
3-
import {gql} from "@apollo/client"
43
import {useTDBDocuments} from "@terminusdb/terminusdb-documents-ui-template"
54
import {WOQLClientObj} from '../init-woql-client'
65
import { Loading } from "./Loading"
6+
import {getGqlQuery} from "../pages/utils"
77
/**
88
*
99
* @param {*} setSelected function to get selected document link by user
@@ -22,7 +22,7 @@ export const DocumentSearchComponent = ({setSelected, doctype}) => {
2222
}
2323
},[doctype]);
2424
const querystr = documentTablesConfig && documentTablesConfig.objQuery ? documentTablesConfig.objQuery[doctype].query : null
25-
const gqlQuery = querystr ? gql`${querystr}` : null
25+
const gqlQuery = querystr ? getGqlQuery(querystr) : null
2626
const tableConfig = documentTablesConfig && documentTablesConfig.tablesColumnsConfig ? documentTablesConfig.tablesColumnsConfig[doctype] : []
2727
const advancedSearchConfig = documentTablesConfig && documentTablesConfig.advancedSearchObj ? documentTablesConfig.advancedSearchObj[doctype] : null
2828

packages/tdb-dashboard/src/components/SubmitChangeRequestModal.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,12 @@ export const SubmitChangeRequestModal = ({showModal, setShowModal , updateParent
88

99
const closeModal = () => setShowModal(false)
1010

11+
const titleObj= {"Submitted":'Submit the Change Request for review',
12+
"Open" : "Reopen the change request",
13+
"Close" : <Alert variant="danger">You are Closing this change request. You can not undo this operation</Alert>}
14+
1115
const statusUpdate = operation || "Submitted"
12-
const title = statusUpdate === "Submitted" ? 'Submit the Change Request for review' : `Reopen the change request`
16+
const title = titleObj[statusUpdate]
1317

1418
const runCreate = async () => {
1519
const message = messageRef.current.value

packages/tdb-dashboard/src/components/constants.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -492,6 +492,7 @@ export const OPEN="Open"
492492
export const MERGED="Merged"
493493
export const SUBMITTED="Submitted"
494494
export const REJECTED="Rejected"
495+
export const CLOSE = "Close"
495496

496497
// CR actions
497498
export const COMMENT="Comment"

packages/tdb-dashboard/src/components/utils.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,17 @@ import {format, subSeconds} from "date-fns"
55
import {FiCopy} from "react-icons/fi"
66
import React, {useState} from "react"
77
import {VscGitPullRequestDraft} from "react-icons/vsc"
8-
import {AiOutlineDeleteRow} from "react-icons/ai"
8+
import {AiOutlineDeleteRow,AiOutlineClose} from "react-icons/ai"
99
import {VscGitPullRequest} from "react-icons/vsc"
1010
import {VscCheck} from "react-icons/vsc"
11-
import {AiOutlineCheck} from "react-icons/ai"
12-
import Stack from 'react-bootstrap/Stack';
1311
import Badge from "react-bootstrap/Badge"
1412
import Button from "react-bootstrap/Button"
1513
import {
1614
OPEN,
1715
REJECTED,
1816
MERGED,
19-
SUBMITTED
17+
SUBMITTED,
18+
CLOSE
2019
} from "./constants"
2120

2221
export const isArray = (arr) => {
@@ -290,7 +289,8 @@ export const iconTypes={
290289
[OPEN]:<VscGitPullRequestDraft className="text-muted mb-1 mr-1"/>,
291290
[SUBMITTED]:<VscGitPullRequest className="text-warning mb-1 mr-1"/>,
292291
[REJECTED]:<AiOutlineDeleteRow className="text-danger mb-1 mr-1"/>,
293-
[MERGED] :<VscCheck className="success__color mb-1 mr-1"/>
292+
[MERGED] :<VscCheck className="success__color mb-1 mr-1"/>,
293+
[CLOSE] :<AiOutlineClose className="text-danger mb-1 mr-1"/>
294294
}
295295

296296

@@ -299,6 +299,7 @@ export const status = {
299299
[SUBMITTED]: <Badge bg="warning text-dark">Review required</Badge>,
300300
[REJECTED]: <Badge bg="danger text-dark">{REJECTED}</Badge>,
301301
[MERGED]: <Badge bg="success text-dark">{MERGED}</Badge>,
302+
[CLOSE]: <Badge bg="danger text-dark">{CLOSE}</Badge>
302303
}
303304

304305
/** just get change request ID, remove "Changerequest/" from ID */

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,9 @@ export function useOpenAI(){
101101
localStorage.setItem(`${location.pathname}___SEARCH__RESULT`,JSON.stringify(result))
102102
setSearchResult(result)
103103
}catch(err){
104-
setError(err.data || err.message)
104+
console.log(err.data)
105+
const errValue = err.data && err.data.error ? err.data.error : err.message
106+
setError(errValue)
105107
}finally{
106108
setLoading(false)
107109
}

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

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ import {
1212
OPEN,
1313
REJECTED,
1414
MERGED,
15-
SUBMITTED
15+
SUBMITTED,
16+
CLOSE
1617
} from "../components/constants"
1718
import ProgressBar from 'react-bootstrap/ProgressBar'
1819
import {extractID, status, iconTypes, getDays} from "../components/utils"
@@ -71,12 +72,13 @@ export const ChangeRequestsPage = () => {
7172
}
7273

7374

74-
const countType = {[OPEN] : 0 , [SUBMITTED]:0, [REJECTED]:0, [MERGED]:0 }
75+
const countType = {[OPEN] : 0 , [SUBMITTED]:0, [REJECTED]:0, [MERGED]:0, [CLOSE]:0 }
7576
const activeClassNameType = {
7677
[OPEN] : "text-decoration-underline text-light" ,
7778
[SUBMITTED]: "text-decoration-underline text-warning",
7879
[REJECTED]: "text-decoration-underline text-danger",
79-
[MERGED]: "text-decoration-underline success__color"
80+
[MERGED]: "text-decoration-underline success__color",
81+
[CLOSE]: "text-decoration-underline text-danger",
8082
}
8183

8284
function getActiveClassName (filter, status) {
@@ -120,6 +122,12 @@ export const ChangeRequestsPage = () => {
120122
<span className={`${getActiveClassName (filter, REJECTED)}`}>{countType[REJECTED]} {REJECTED}</span>
121123
</small>
122124
</Button>
125+
<Button variant="dark" onClick={(e) => displayCRs(CLOSE)} className="btn bg-transparent border-0 text-gray">
126+
<small className="text-gray fw-bold">
127+
{iconTypes[CLOSE]}
128+
<span className={`${getActiveClassName (filter, CLOSE)}`}>{countType[CLOSE]} {CLOSE}</span>
129+
</small>
130+
</Button>
123131
</Stack>
124132
</React.Fragment>
125133
}
@@ -142,6 +150,11 @@ export const ChangeRequestsPage = () => {
142150
setShowUpdateChangeRequestID(id)
143151
}
144152

153+
const closeCR = (id)=>{
154+
setUpdateOperation(CLOSE)
155+
setShowUpdateChangeRequestID(id)
156+
}
157+
145158
const reopenCR = (id)=>{
146159
setUpdateOperation(OPEN)
147160
setShowUpdateChangeRequestID(id)
@@ -165,12 +178,14 @@ export const ChangeRequestsPage = () => {
165178
</Button>
166179
<Button className="bg-success text-dark mr-4 btn btn-sm" onClick={()=>goToDiffPage(item)}>
167180
View Diff</Button>
181+
<Button className="bg-danger text-dark mr-4 btn btn-sm" title="you are closing your CR" onClick={()=>closeCR(id)}>Close</Button>
168182

169183
</React.Fragment>
170184
case SUBMITTED:
171185
return <React.Fragment>
172186
<Button title="go to diff page to review" className="btn btn-warning mr-2 btn-sm text-dark" onClick={()=>goToDiffPage(item)} >Review</Button>
173187
<Button className="bg-light text-dark mr-4 btn btn-sm" onClick={()=>reopenCR(id)}>Reopen</Button>
188+
<Button className="bg-danger text-dark mr-4 btn btn-sm" title="you are closing your CR" onClick={()=>closeCR(id)}>Close</Button>
174189
</React.Fragment>
175190
case REJECTED:
176191
return <React.Fragment>
@@ -182,6 +197,8 @@ export const ChangeRequestsPage = () => {
182197
<Button className="bg-success text-dark mr-4 btn btn-sm" onClick={()=>goToDiffPage(item)}>View Approved Diff</Button>
183198
<Button className="bg-light text-dark mr-4 btn btn-sm" onClick={()=>reopenCR(id)}>Reopen</Button>
184199
</React.Fragment>
200+
case CLOSE :
201+
return ""
185202
}
186203
}
187204

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import React, {useState} from "react";
22
import {useParams, useNavigate} from "react-router-dom";
33
import {NEW_DOC,EDIT_DOC, EXAMPLES_PRODUCTS} from "../routing/constants"
4-
import {gql} from "@apollo/client";
54
import { ListDocumentsComponent, useTDBDocuments } from "@terminusdb/terminusdb-documents-ui-template";
65
import {WOQLClientObj} from '../init-woql-client'
76
import {CreateChangeRequestModal} from '../components/CreateChangeRequestModal'
87
import { DeleteDocumentModal } from "../components/DeleteDocumentModal";
98
import {ErrorMessageReport} from "../components/ErrorMessageReport"
9+
import {getGqlQuery} from "./utils"
1010

1111
// I pass this so I'm sure it exists before loading the component
1212
export const DocumentsGraphqlList = ({documentTablesConfig}) => {
@@ -20,7 +20,7 @@ export const DocumentsGraphqlList = ({documentTablesConfig}) => {
2020
const navigate = useNavigate()
2121

2222
const querystr = documentTablesConfig.objQuery[type].query
23-
const query = gql`${querystr}`
23+
const query = getGqlQuery(querystr,setError)
2424
const tableConfig = documentTablesConfig.tablesColumnsConfig[type]
2525
const advancedSearchConfig = documentTablesConfig.advancedSearchObj[type]
2626

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ import { BsSearch } from "react-icons/bs"
1717
import InputGroup from 'react-bootstrap/InputGroup';
1818
import {FiAlertTriangle} from 'react-icons/fi'
1919
import { WOQLClientObj } from "../init-woql-client";
20+
import { formatError } from "./utils";
21+
import {Alerts} from "../components/Alerts"
22+
import {TERMINUS_DANGER} from "../components/constants"
2023

2124
export function FreeTextSearch() {
2225
const {branch} = WOQLClientObj()
@@ -106,8 +109,7 @@ export function FreeTextSearch() {
106109
<p>if you haven't already done it, Go to <NavLink to={`/${organization}/profile`}>Profile page</NavLink> and add an OpenAi Key to your team,</p>
107110
after you can start to index your data using the change request workflow
108111
</Alert>*/}
109-
{error && <ErrorMessageReport error={error} setError={setError}/> }
110-
112+
{error && <Alerts message={formatError(error,organization,dataProduct)} type={TERMINUS_DANGER} onCancel={setError}/>}
111113
{searchResult &&
112114
<React.Fragment>
113115
<div className="w-100 d-flex justify-content-center">

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import Form from "react-bootstrap/Form";
88
import ListGroup from "react-bootstrap/ListGroup";
99
import Card from "react-bootstrap/Card"
1010
import { format } from 'graphql-formatter'
11-
import {gql} from "@apollo/client"
1211
import { useParams, NavLink } from "react-router-dom"
1312
import { useTDBDocuments } from "@terminusdb/terminusdb-documents-ui-template";
1413
import {WOQLClientObj} from '../init-woql-client'
@@ -25,6 +24,7 @@ import {CopyButton} from "../components/utils"
2524
import {ErrorMessageReport} from "../components/ErrorMessageReport"
2625
import { Loading } from "../components/Loading";
2726
import {PROGRESS_BAR_COMPONENT} from "../components/constants"
27+
import {getGqlQuery} from "./utils"
2828

2929
export function GraphqlHandlerbarsPage({}) {
3030
const {woqlClient} = WOQLClientObj()
@@ -67,8 +67,10 @@ export function GraphqlHandlerbarsPage({}) {
6767
const classObj= documentClasses.find(item=>item['@id']===classId)
6868
if(classObj){
6969
if(classObj['@metadata'] && classObj['@metadata']['embedding']){
70-
const query = gql(`${classObj['@metadata']['embedding']['query']}`)
71-
setGraphqlQuery(format(query.loc.source.body))
70+
const query = getGqlQuery(classObj['@metadata']['embedding']['query'],setError)
71+
const value = query ? format(query.loc.source.body) : ''
72+
setGraphqlQuery(value)
73+
7274
setHandlebarTemplate(classObj['@metadata']['embedding']['template'])
7375
}else if(documentTablesConfig && documentTablesConfig.objQueryOpenAI && documentTablesConfig.objQueryOpenAI[classId]){
7476
setGraphqlQuery(format(documentTablesConfig.objQueryOpenAI[classId].query))
@@ -96,8 +98,8 @@ export function GraphqlHandlerbarsPage({}) {
9698
return <Alert type="Info">There are no document of type {currentType}</Alert>
9799
}
98100
return <ListGroup >
99-
{queryResultPreview && queryResultPreview.map(item=>{
100-
return <ListGroup.Item><pre className="preview_pre">{item}</pre></ListGroup.Item>
101+
{queryResultPreview && queryResultPreview.map((item, key)=>{
102+
return <ListGroup.Item key={`item__${key}`}><pre className="preview_pre">{item}</pre></ListGroup.Item>
101103
})}
102104
</ListGroup>
103105
}

0 commit comments

Comments
 (0)