Skip to content

Commit 0588270

Browse files
committed
2 parents 3f46e18 + 62089c8 commit 0588270

File tree

6 files changed

+73
-119
lines changed

6 files changed

+73
-119
lines changed

packages/tdb-dashboard/src/App.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1101,8 +1101,8 @@ pre.CodeMirror-line > span > span.cm-string {
11011101
}
11021102

11031103
.group {
1104-
background: transparent;
1105-
border: 0px solid #DCC896;
1104+
background: transparent !important;
1105+
border: 1px solid #dee2e6 !important;
11061106
}
11071107

11081108
.rule_group{

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ export const DocumentsGraphqlTable = ({type,onRowClick,showGraphqlTab=true}) =>
6161
let extractedResults = documentResults ? extractDocuments(documentResults[type]) : []
6262

6363
function cleanIdValue(keyName, keyValue){
64+
if(keyValue === "null") return ""
6465
if(keyName!=="_id") return keyValue
6566
try{
6667
const regexp =/(?:\/+.*?\/)(.*$)/g

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
import React, {useState, useEffect} from "react"
22
import {WOQLClientObj} from '../init-woql-client'
33
import Card from 'react-bootstrap/Card'
4+
import Form from 'react-bootstrap/Form'
5+
import {Button} from "react-bootstrap"
6+
import {ChangeRequest} from "../hooks/ChangeRequest"
7+
import { useParams } from "react-router-dom"
48
import {
59
extractID,
610
getDays

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

Lines changed: 56 additions & 116 deletions
Original file line numberDiff line numberDiff line change
@@ -6,122 +6,62 @@ import {WOQLClientObj} from "../init-woql-client"
66
import Stack from "react-bootstrap/Stack"
77
import {status} from "./utils"
88
import {ChangeRequest} from "../hooks/ChangeRequest"
9-
import Spinner from 'react-bootstrap/Spinner';
10-
11-
const ActionButton = ({variant, title, content, onClick, loading, icon}) => {
12-
return <Button
13-
className="text-dark btn btn-sm fw-bold d-flex mt-3 float-end"
14-
variant={variant}
15-
title={title}
16-
onClick={onClick}>
17-
{loading && <Spinner
18-
as="span"
19-
animation="border"
20-
size="sm"
21-
role="status"
22-
className="mr-1 mt-1"
23-
aria-hidden="true"
24-
/>}
25-
<div className="d-flex">
26-
{icon}
27-
<label>{content}</label>
28-
</div>
29-
</Button>
30-
}
31-
32-
/**
33-
* @returns buttons to reject commit or approve based on user action
34-
*/
35-
const Actions = ({checked, message, setKey, setMessage}) => {
36-
37-
const {
38-
woqlClient,
39-
currentCRObject,
40-
setCurrentCRObject,
41-
exitChangeRequestBranch
42-
}= WOQLClientObj()
43-
44-
const {
45-
updateChangeRequestStatus,
46-
getChangeRequestList,
47-
loading
48-
} = ChangeRequest(woqlClient)
49-
50-
const {organization,dataProduct,id} = useParams()
51-
const navigate = useNavigate() // to navigate
52-
53-
/** handle Message */
54-
async function handleMessage() {
55-
let id=extractID(currentCRObject["@id"])
56-
// this call return the changeRequestObj Updated
57-
let res=await updateChangeRequestStatus(message, currentCRObject.status, id)
58-
// we'll see if add need rebase check every time
59-
res.needRebase = currentCRObject.needRebase
60-
setCurrentCRObject(res)
61-
if(setKey) setKey(CONST.MESSAGES)
62-
if(setMessage) setMessage("")
63-
}
64-
65-
/** handle Merge */
66-
async function handleMerge () {
67-
let res=await updateChangeRequestStatus(message, CONST.MERGED, id)
68-
if(res){
69-
setCurrentCRObject(false)
70-
exitChangeRequestBranch()
71-
navigate(`/${organization}/${dataProduct}`)
72-
}
73-
}
74-
75-
/** handle Reject */
76-
async function handleReject () {
77-
let res=await updateChangeRequestStatus(message, CONST.REJECTED, id)
78-
if(res){
79-
setCurrentCRObject(false)
80-
exitChangeRequestBranch()
81-
navigate(`/${organization}/${dataProduct}`)
82-
}
83-
}
84-
85-
let chosen = CONST.REVIEW_OPTIONS.filter(arr => arr.title === checked)
86-
87-
if(checked === CONST.APPROVE) {
88-
return <ActionButton variant="success"
89-
loading={loading}
90-
title={"Approve Changes"}
91-
content={checked}
92-
icon={chosen[0].icon}
93-
onClick={handleMerge}/>
94-
}
95-
else if (checked === CONST.COMMENT) {
96-
return <ActionButton variant="light"
97-
title={"Leave a Comment or message"}
98-
content={checked}
99-
loading={loading}
100-
icon={chosen[0].icon}
101-
onClick={handleMessage}/>
102-
}
103-
else if(checked ===CONST.REJECT) {
104-
return <ActionButton variant="danger"
105-
title={"Reject Changes"}
106-
content={checked}
107-
loading={loading}
108-
icon={chosen[0].icon}
109-
onClick={handleReject}/>
110-
}
111-
return <div/>
112-
}
113-
114-
/**
115-
* @returns help texts
116-
*/
117-
function getHelpText (checked) {
118-
const arr = CONST.REVIEW_OPTIONS.filter(arr => arr.title === checked)
119-
if (!arr) return <div/>
120-
return <small className="fw-light">{arr[0].helpText}</small>
121-
}
122-
123-
function getChecked (checked, id) {
124-
return checked === id ? true : false
9+
import ButtonGroup from 'react-bootstrap/ButtonGroup';
10+
import ToggleButton from 'react-bootstrap/ToggleButton';
11+
import {Loading} from "../components/Loading"
12+
import { MessageBox, MessageComponent } from "./Messages"
13+
import {AiOutlineCheck, AiOutlineClose} from "react-icons/ai"
14+
15+
const ToggleActions = ({ message }) => {
16+
const [action, setAction] = useState(false);
17+
const { setCurrentCRObject, exitChangeRequestBranch }= WOQLClientObj()
18+
const { updateChangeRequestStatus, loading } = ChangeRequest()
19+
const { organization, dataProduct , id} = useParams()
20+
const navigate = useNavigate()
21+
22+
23+
useEffect(() => {
24+
async function doAction() {
25+
let status = action === CONST.APPROVE ? CONST.MERGED : CONST.REJECTED
26+
let res=await updateChangeRequestStatus(message, status, id)
27+
if(res){
28+
setCurrentCRObject(false)
29+
exitChangeRequestBranch()
30+
navigate(`/${organization}/${dataProduct}`)
31+
}
32+
}
33+
if(action) doAction()
34+
}, [action])
35+
36+
const reviewButtons = [
37+
{ name: CONST.APPROVE, value: CONST.APPROVE, className: "rounded-left", variant: "outline-success", icon: <AiOutlineCheck className="mr-1 mb-1 text-success"/> },
38+
{ name: CONST.REJECT, value: CONST.REJECT , className: "rounded-right", variant: "outline-danger", icon: <AiOutlineClose className="mr-1 mb-1 text-danger"/> }
39+
];
40+
41+
if(loading) return <Loading message={action === CONST.APPROVE ? `Approving Change Request ...` : `Rejecting Change Request ...`}/>
42+
43+
return <Stack directtion="horizontal" className="float-right">
44+
<small className="text-muted fst-italic fw-light mr-2 ms-auto">
45+
{`Approve or Reject Change Request`}
46+
</small>
47+
<ButtonGroup>
48+
{reviewButtons.map((button) => (
49+
<ToggleButton
50+
key={button.name}
51+
id={button.name}
52+
type="radio"
53+
variant={button.variant}
54+
name={button.name}
55+
value={button.value}
56+
className={button.className}
57+
checked={action === button.value}
58+
onChange={(e) => setAction(e.currentTarget.value)}
59+
>
60+
{button.icon}{button.name}
61+
</ToggleButton>
62+
))}
63+
</ButtonGroup>
64+
</Stack>
12565
}
12666

12767

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export const Layout = (props) => {
4747

4848
//defaultSize={340}
4949
return <Container fluid className="p-0 flex-row">
50-
{showModal && <SubmitChangeRequestModal showModal={showModal} setShowModal={setShowModal} updateParent={updateParent}/>}
50+
{showModal && <SubmitChangeRequestModal updateChangeRequestID={currentChangeRequest} showModal={showModal} setShowModal={setShowModal} updateParent={updateParent}/>}
5151
<SplitPane split="vertical" minSize={70} defaultSize={defaultSize} primary="first" allowResize={false}>
5252
<div className="side-black h-100 d-flex">
5353
<IconBar setShowFeedbackForm={setShowFeedbackForm} />

packages/tdb-documents-ui/src/documentTypeFrames/documentTypeFrames.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,15 @@ function checkIfCycleExists(property, linked_to_frames, linked_to, docType) {
8787
// checks if linked to is same as the parent document class
8888
if(linked_to === docType) return true
8989
}
90+
for(let props in linked_to_frames) {
91+
if(typeof linked_to_frames[props] === CONST.OBJECT_TYPE &&
92+
linked_to_frames[props].hasOwnProperty("@class")) {
93+
// cycle exists with linked_to document class
94+
if(linked_to_frames[props]["@class"] === linked_to) return true
95+
// cycle exists with docType class
96+
if(linked_to_frames[props]["@class"] === docType) return true
97+
}
98+
}
9099
return false
91100
}
92101

0 commit comments

Comments
 (0)