Skip to content

Commit 93dc9ae

Browse files
committed
Merge branch 'reviewCR' of https://github.com/terminusdb/terminusdb-dashboard into reviewCR
2 parents 96f8fd1 + 40dd8f3 commit 93dc9ae

File tree

7 files changed

+175
-84
lines changed

7 files changed

+175
-84
lines changed

packages/tdb-dashboard/src/App.css

Lines changed: 7 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1154,6 +1154,13 @@ pre.CodeMirror-line > span > span.cm-string {
11541154
}
11551155

11561156
/** card border for change request component */
1157+
.update__change__request__card {
1158+
height: 20em;
1159+
display: flex;
1160+
align-items: center;
1161+
justify-content: center;
1162+
}
1163+
11571164
.tdb__change__request__card {
11581165
border-color: #3450DC !important;
11591166
}
@@ -1195,31 +1202,3 @@ pre.CodeMirror-line > span > span.cm-string {
11951202
width: 100px;
11961203
height: 100px;
11971204
}
1198-
1199-
.free_button_text_color {
1200-
color: #664d03 !important;
1201-
}
1202-
1203-
.free {
1204-
border: 1px solid rgb(254, 216, 147);
1205-
color: rgb(254, 216, 147);
1206-
}
1207-
1208-
.professional {
1209-
border: 1px solid rgb(232, 124, 214);
1210-
color: rgb(232, 124, 214);
1211-
}
1212-
1213-
.scale {
1214-
border: 1px solid rgb(134, 89, 250);
1215-
color: rgb(134, 89, 250);
1216-
}
1217-
1218-
.enterprise {
1219-
border: 1px solid rgb(52, 80, 220);
1220-
color: rgb(52, 80, 220);
1221-
}
1222-
1223-
.verify__email {
1224-
background : linear-gradient(122deg,#fed893 0,#e87cd6 48%,#4058d0 100%);
1225-
}

packages/tdb-dashboard/src/Colors.css

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@
44
:root {
55
--color-pink: #de7dd8;
66
--text-contrast-pink: #002856;
7+
--color-indigo: rgb(52, 80, 220);
78
--color-purple: #855afc;
89
--color-purple-hover: #8f75d8;
910
--text-contrast-purple: #fff;
1011
--color-yellow: #f9d891;
12+
--text-yellow: #664d03 ;
1113
--color-contrast-yellow: #002856;
1214
--color-border-yellow: #d7a12f;
1315

@@ -23,6 +25,51 @@
2325
--badge-border-color: var(--color-border-yellow);
2426
}
2527

28+
/** subscription css */
29+
.free_button_text_color {
30+
color: var(--text-yellow) !important;
31+
}
32+
33+
.free {
34+
border: 1px solid var(--color-yellow);
35+
color: var(--color-yellow);
36+
}
37+
38+
.badge-free {
39+
background-color: var(--color-yellow);
40+
}
41+
42+
.professional {
43+
border: 1px solid var(--color-pink);
44+
color: var(--color-pink);
45+
}
46+
47+
.badge-professional {
48+
background-color: var(--color-pink);
49+
}
50+
51+
.scale {
52+
border: 1px solid var(--color-purple);
53+
color: var(--color-purple);
54+
}
55+
56+
.badge-scale {
57+
background-color: var(--color-purple);
58+
}
59+
60+
.enterprise {
61+
border: 1px solid var(--color-indigo);
62+
color: var(--color-indigo)
63+
}
64+
65+
.badge-enterprise {
66+
background-color: var(--color-indigo);
67+
}
68+
69+
.verify__email {
70+
background : linear-gradient(122deg,var(--color-yellow) 0,var(--color-pink) 48%, var(--color-indigo) 100%);
71+
}
72+
2673
.text-success,
2774
h3.text-success,
2875
h4.text-success,

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

Lines changed: 34 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ const DocumentModifiedCount = ({documentModifiedCount}) => {
3131
</h6>
3232
}
3333

34-
const BranchCRMessage = ({css, branch}) => {
34+
export const BranchCRMessage = ({css, branch}) => {
3535
return <React.Fragment>
3636
<Badge bg={css} className="fw-bold mr-2 text-dark">
3737
<BiGitBranch className=" mr-1"/>{branch}
@@ -88,40 +88,41 @@ export const ChangeDiffComponent = () => {
8888

8989
let documentModifiedCount = result ? result.length : 0
9090

91-
let author= currentCRObject&&currentCRObject.hasOwnProperty("creator") ? currentCRObject["creator"] : "user"
91+
// email address
92+
let author= currentCRObject && currentCRObject.hasOwnProperty("creator_email") ? currentCRObject["creator_email"] : "creator"
9293

9394
return <Tabs
94-
id="change_request_tabs"
95-
activeKey={key}
96-
onSelect={(k) => setKey(k)}
97-
className="mb-3">
98-
<Tab eventKey={DIFFS} title={DIFFS}>
99-
{loading && <Loading message={`Loading Diffs ...`}/>}
100-
{errorMsg && <Alert variant={"danger"} className="mr-3">
101-
{errorMsg}
102-
</Alert>}
103-
{!documentModifiedCount && <h6 className="text-muted fw-bold mt-3 mb-3">
104-
{`No documents `}
105-
</h6>}
106-
<Card bg="transparent" className="border-secondary mt-5 mb-5">
107-
<Card.Header>
108-
<Stack direction="horizontal" gap={2} className="mt-1">
109-
<DisplayHeader author={author}
110-
tracking_branch={currentCRObject.tracking_branch}
111-
documentModifiedCount={documentModifiedCount}/>
112-
</Stack>
113-
</Card.Header>
114-
<Card.Body>
115-
116-
{currentCRObject.status !== MERGED && <ReviewComponent setKey={setKey} action={action} setAction={setAction}/> }
117-
<DiffView diffs={result} CRObject={currentCRObject}/>
118-
</Card.Body>
119-
</Card>
120-
</Tab>
121-
<Tab eventKey={MESSAGES} title={MESSAGES}>
122-
<Messages/>
123-
</Tab>
124-
</Tabs>
95+
id="change_request_tabs"
96+
activeKey={key}
97+
onSelect={(k) => setKey(k)}
98+
className="mb-3">
99+
<Tab eventKey={DIFFS} title={DIFFS}>
100+
{loading && <Loading message={`Loading Diffs ...`}/>}
101+
{errorMsg && <Alert variant={"danger"} className="mr-3">
102+
{errorMsg}
103+
</Alert>}
104+
{!documentModifiedCount && <h6 className="text-muted fw-bold mt-3 mb-3">
105+
{`No documents `}
106+
</h6>}
107+
<Card bg="transparent" className="border-secondary mt-5 mb-5">
108+
<Card.Header>
109+
<Stack direction="horizontal" gap={2} className="mt-1">
110+
<DisplayHeader author={author}
111+
tracking_branch={currentCRObject.tracking_branch}
112+
documentModifiedCount={documentModifiedCount}/>
113+
</Stack>
114+
</Card.Header>
115+
<Card.Body>
116+
117+
{currentCRObject.status !== MERGED && <ReviewComponent setKey={setKey} action={action} setAction={setAction}/> }
118+
<DiffView diffs={result} CRObject={currentCRObject}/>
119+
</Card.Body>
120+
</Card>
121+
</Tab>
122+
<Tab eventKey={MESSAGES} title={MESSAGES}>
123+
<Messages/>
124+
</Tab>
125+
</Tabs>
125126
}
126127

127128
/*<small className="fw-bold mr-2 h6">You are in change request mode</small>

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,7 @@ export const REJECTED="Rejected"
476476
export const COMMENT="Comment"
477477
export const APPROVE="Approve"
478478
export const REJECT="Reject"
479+
export const UPDATE_BRANCH="Update Change Request"
479480

480481
// review component constants
481482
export const REVIEW_OPTIONS = [

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

Lines changed: 72 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React, {useState, useEffect} from 'react'
22
import {Button} from "react-bootstrap"
33
import { Layout } from './Layout'
4+
import Card from "react-bootstrap/Card"
45
import {useParams} from 'react-router-dom'
56
import {GetDiffList} from "../hooks/DocumentHook"
67
import {WOQLClientObj} from "../init-woql-client"
@@ -13,24 +14,81 @@ import Stack from 'react-bootstrap/Stack'
1314
import {ChangeRequest} from "../hooks/ChangeRequest"
1415
import {Loading} from "../components/Loading"
1516
import Alert from 'react-bootstrap/Alert'
16-
import { ChangeDiffComponent } from '../components/ChangeDiffComponent'
17-
import {
18-
DIFFS,
19-
MERGED,
20-
MESSAGES,
21-
TRACKING_BRANCH
22-
} from "../components/constants"
17+
import { ChangeDiffComponent, BranchCRMessage } from '../components/ChangeDiffComponent'
18+
import * as CONST from "../components/constants"
19+
import {FiAlertTriangle} from "react-icons/fi"
2320
import {Messages} from "../components/Messages"
2421
import {ReviewComponent} from "../components/ReviewComponent"
22+
import Spinner from 'react-bootstrap/Spinner';
23+
import {extractID} from "../components/utils"
2524

25+
const CRAction = ({}) => {
26+
const {
27+
currentCRObject,
28+
setCurrentCRObject
29+
} = WOQLClientObj()
30+
31+
const {
32+
rebaseChangeRequestBranch,
33+
loading,
34+
error
35+
} = ChangeRequest()
36+
37+
const rebaseHandler = async ()=>{
38+
const changeRequestDoc = await rebaseChangeRequestBranch(extractID(currentCRObject["@id"]))
39+
if(changeRequestDoc && setCurrentCRObject){
40+
setCurrentCRObject(changeRequestDoc)
41+
}
42+
}
43+
44+
// loading while waiting for currentCRObject
45+
if(!currentCRObject) return <Loading message={`Loading Change Request ...`}/>
46+
47+
48+
//{currentCRObject.needRebase && currentCRObject.status !== "Merged" && <div>
49+
if (currentCRObject.needRebase === false || currentCRObject.status === CONST.MERGED)
50+
return <ChangeDiffComponent/>
51+
52+
// if needRebase
53+
return <Card className="update__change__request__card">
54+
<Card.Header className="w-100">
55+
{`You are in Change Request `}<BranchCRMessage branch={currentCRObject.tracking_branch} css={"primary"}/>
56+
</Card.Header>
57+
<Card.Body>
58+
<Stack direction="vertical" gap={3}>
59+
<div className='d-flex'>
60+
<FiAlertTriangle className="text-warning h2 mr-3"/>
61+
<h3>This Change Request is out of date</h3>
62+
</div>
63+
<div className='d-flex'>
64+
<h4 className="mr-3">Merge latest changes from </h4>
65+
<BranchCRMessage branch={"main"} css={"success"}/>
66+
<h4>into this Change Request</h4>
67+
</div>
68+
</Stack>
69+
</Card.Body>
70+
<Button onClick={rebaseHandler}
71+
className="btn btn-lg bg-light text-dark mb-5">
72+
{loading && <Spinner
73+
as="span"
74+
animation="border"
75+
size="sm"
76+
role="status"
77+
className="mr-1 mt-1"
78+
aria-hidden="true"
79+
/>}
80+
{CONST.UPDATE_BRANCH}
81+
</Button>
82+
</Card>
83+
}
2684

2785

2886
export const ChangeDiff = () => {
2987
const {id} = useParams()
3088
const {
3189
woqlClient:client,
32-
currentCRObject,
33-
setCurrentCRObject
90+
setCurrentCRObject,
91+
currentCRObject
3492
} = WOQLClientObj()
3593

3694
const {
@@ -40,12 +98,7 @@ export const ChangeDiff = () => {
4098
error
4199
} = ChangeRequest()
42100

43-
const rebaseHandler = async ()=>{
44-
const changeRequestDoc = await rebaseChangeRequestBranch(id)
45-
if(changeRequestDoc){
46-
setCurrentCRObject(changeRequestDoc)
47-
}
48-
}
101+
49102

50103
useEffect(() => {
51104
async function getCRID() {
@@ -58,13 +111,14 @@ export const ChangeDiff = () => {
58111
}, [id, client])
59112

60113
if(!client) return <div/>
114+
115+
116+
console.log("currentCRObject", currentCRObject)
61117

62118
return <Layout>
63119
<div className='d-flex ml-5 mt-4 mr-5'>
64120
<div className='w-100'>
65-
{currentCRObject.needRebase && currentCRObject.status !== "Merged" && <div>
66-
<Button onClick={rebaseHandler}>Rebase</Button></div>}
67-
{(currentCRObject.needRebase === false || currentCRObject.status === "Merged") && <ChangeDiffComponent/>}
121+
{currentCRObject && <CRAction/>}
68122
</div>
69123
</div>
70124
</Layout>

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

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,14 +94,19 @@ export const PlansPage = (props) => {
9494
return <Card className="mr-4">
9595
<Card.Body>
9696
<Stack direction="horizontal" gap={3}>
97-
<h6 className="text-light fw-lighter">Current Subscription</h6>
98-
<Badge className={`ms-auto ${payment[0].className}`}>{payment[0].title}</Badge>
99-
<div className={`${payment[0].className} border border-0`}>
97+
<h6 className="text-light fw-bold">Current Subscription</h6>
98+
<Badge bg="" className={`ms-auto`} style={{backgroundColor: payment[0].color , color: payment[0].textColor}}>
99+
{payment[0].title.toUpperCase()}
100+
</Badge>
101+
{(tier === PROFESSIONAL_PLAN || tier === SCALE_PLAN) && <div className={`${payment[0].className} border border-0 fw-bold`}>
102+
<MdEuroSymbol className="mb-1"/>
100103
{payment[0].price}
101-
</div>
104+
</div>}
105+
{tier === COMMUNITY_PLAN && <div className={`${payment[0].className} ${payment[0].textColor} border border-0`}>
106+
{payment[0].price}
107+
</div>}
102108
</Stack>
103109
</Card.Body>
104-
105110
</Card>
106111
}
107112

packages/tdb-dashboard/src/payment/labels.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ export const PLANS_DESCRIPTION = [
4545
'100,000 API calls per month'
4646
],
4747
color:"#fed893",
48+
textColor: "#664d03",
4849
buttonLabel:'Get Started',
4950
buttonTextColor: "free_button_text_color",
5051
showButton:false,
@@ -69,6 +70,7 @@ export const PLANS_DESCRIPTION = [
6970
'1 million API calls per month'
7071
],
7172
color:"#e87cd6",
73+
textColor: "text-white",
7274
buttonTextColor: "text-white",
7375
buttonLabel:"Upgrade to Professional",
7476
icon: <RiUserStarLine className="subscription_icons professional"/>,
@@ -92,6 +94,7 @@ export const PLANS_DESCRIPTION = [
9294
'10 million API calls per month'
9395
],
9496
color:"#8659fa",
97+
textColor: "text-white",
9598
buttonTextColor: "text-white",
9699
buttonLabel:"Upgrade to Scale",
97100
icon: <RiCommunityLine className="subscription_icons scale"/>,
@@ -113,6 +116,7 @@ export const PLANS_DESCRIPTION = [
113116
'placeholder_label'
114117
],
115118
color:"#3450dc",
119+
textColor: "text-white",
116120
buttonTextColor: "text-white",
117121
buttonLabel:"Contact us",
118122
icon: <ImLibrary className="subscription_icons enterprise"/>,

0 commit comments

Comments
 (0)