Skip to content
This repository was archived by the owner on Jul 1, 2022. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
607 changes: 607 additions & 0 deletions src/components/__snapshots__/storyshots.test.js.snap

Large diffs are not rendered by default.

38 changes: 38 additions & 0 deletions src/components/truncated-text-box/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import React, { PureComponent } from 'react'
import PropTypes from 'prop-types'

import './truncated-text-box.css'

export default class TruncatedTextBox extends PureComponent {
static propTypes = {
// State
text: PropTypes.string.isRequired,
maxWords: PropTypes.number.isRequired
}

state = { truncated: true }

toggleMore = () =>
this.setState(prevState => ({ truncated: !prevState.truncated }))

render() {
const { text, maxWords } = this.props
const { truncated } = this.state

const words = text.split(' ')
return (
<div className="TruncatedTextBox">
<p>
{truncated && words.length > maxWords
? words.slice(0, maxWords).join(' ')
: text}
</p>
{words.length > maxWords && (
<div className="TruncatedTextBox-actionDiv" onClick={this.toggleMore}>
Show {truncated ? 'More ∧' : 'Less ∨'}
</div>
)}
</div>
)
}
}
10 changes: 10 additions & 0 deletions src/components/truncated-text-box/truncated-text-box.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
@import '../../styles/_colors.scss';

/* @define TruncatedTextBox */
.TruncatedTextBox {
&-actionDiv {
color: $info;
font-size: 14px;
user-select: none;
}
}
10 changes: 8 additions & 2 deletions src/containers/dispute/components/details/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { ChainData } from '../../../../chainstrap'
import { ARBITRATOR_ADDRESS } from '../../../../bootstrap/dapp-api'
import { dateToString } from '../../../../utils/date'
import LabelValueGroup from '../../../../components/label-value-group'
import TruncatedTextBox from '../../../../components/truncated-text-box'
import * as chainViewConstants from '../../../../constants/chain-view'

import './details.css'
Expand All @@ -16,7 +17,8 @@ const Details = ({
arbitrationFee,
arbitrableContractAddress,
disputeID,
appealNumber
appealNumber,
description
}) => (
<div className="Details">
<small>
Expand Down Expand Up @@ -73,6 +75,9 @@ const Details = ({
]}
/>
<hr />
<h4>Contract Description</h4>
<TruncatedTextBox text={description} maxWords={200} />
<hr />
</div>
)

Expand All @@ -84,7 +89,8 @@ Details.propTypes = {
arbitrationFee: PropTypes.number.isRequired,
arbitrableContractAddress: PropTypes.string.isRequired,
disputeID: PropTypes.number.isRequired,
appealNumber: PropTypes.number.isRequired
appealNumber: PropTypes.number.isRequired,
description: PropTypes.string.isRequired
}

export default Details
108 changes: 56 additions & 52 deletions src/containers/dispute/components/ruling/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,59 +52,63 @@ const Ruling = ({
</div>
)}
<LabelValueGroup
items={[
{
label: 'Votes for Party A',
value: (
<ChainData
contractName={chainViewConstants.KLEROS_POC_NAME}
contractAddress={ARBITRATOR_ADDRESS}
functionSignature={
chainViewConstants.KLEROS_POC_GET_VOTE_COUNT_SIG
items={
inProgress
? []
: [
{
label: 'Votes for Party A',
value: (
<ChainData
contractName={chainViewConstants.KLEROS_POC_NAME}
contractAddress={ARBITRATOR_ADDRESS}
functionSignature={
chainViewConstants.KLEROS_POC_GET_VOTE_COUNT_SIG
}
parameters={chainViewConstants.KLEROS_POC_GET_VOTE_COUNT_PARAMS(
disputeID,
appeals,
1
)}
>
{votesForPartyA}
</ChainData>
)
},
{
label: 'Votes for Party B',
value: (
<ChainData
contractName={chainViewConstants.KLEROS_POC_NAME}
contractAddress={ARBITRATOR_ADDRESS}
functionSignature={
chainViewConstants.KLEROS_POC_GET_VOTE_COUNT_SIG
}
parameters={chainViewConstants.KLEROS_POC_GET_VOTE_COUNT_PARAMS(
disputeID,
appeals,
2
)}
>
{votesForPartyB}
</ChainData>
)
},
{
label: 'PNK Redistribution',
value: (
<span
className={`Ruling-netPNK Ruling-netPNK--${
won ? 'positive' : 'negative'
}`}
>
{won ? '+' : '-'}
{netPNK}
</span>
)
}
parameters={chainViewConstants.KLEROS_POC_GET_VOTE_COUNT_PARAMS(
disputeID,
appeals,
1
)}
>
{votesForPartyA}
</ChainData>
)
},
{
label: 'Votes for Party B',
value: (
<ChainData
contractName={chainViewConstants.KLEROS_POC_NAME}
contractAddress={ARBITRATOR_ADDRESS}
functionSignature={
chainViewConstants.KLEROS_POC_GET_VOTE_COUNT_SIG
}
parameters={chainViewConstants.KLEROS_POC_GET_VOTE_COUNT_PARAMS(
disputeID,
appeals,
2
)}
>
{votesForPartyB}
</ChainData>
)
},
{
label: 'PNK Redistribution',
value: (
<span
className={`Ruling-netPNK Ruling-netPNK--${
won ? 'positive' : 'negative'
}`}
>
{won ? '+' : '-'}
{netPNK}
</span>
)
}
]}
]
}
/>
<hr />
</div>
Expand Down
5 changes: 2 additions & 3 deletions src/containers/dispute/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,7 @@ class Dispute extends PureComponent {
size={12}
className="Dispute-header-title-identicon"
/>
<h3>
Decision Summary for "{dispute.data.description}"
</h3>
<h3>Decision Summary for "{dispute.data.title}"</h3>
</div>
<hr />
</div>
Expand All @@ -115,6 +113,7 @@ class Dispute extends PureComponent {
dispute.data.arbitrableContractAddress
}
disputeID={dispute.data.disputeId}
description={dispute.data.description}
/>
)
},
Expand Down
6 changes: 3 additions & 3 deletions src/containers/disputes/components/case-name-cell/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ import * as chainViewConstants from '../../../../constants/chain-view'
import './case-name-cell.css'

const CaseNameCell = ({
original: { disputeId, arbitrableContractAddress, description }
original: { disputeId, arbitrableContractAddress, title }
}) => (
<div className="CaseNameCell">
<Identicon seed={arbitrableContractAddress} size={12} />
<Link to={`/disputes/${disputeId}`}>
<div className="CaseNameCell-title">
<h5>{description}</h5>
<h5>{title}</h5>
<small>
<ChainData
contractName={chainViewConstants.KLEROS_POC_NAME}
Expand All @@ -39,7 +39,7 @@ CaseNameCell.propTypes = {
original: PropTypes.shape({
disputeId: PropTypes.string.isRequired,
arbitrableContractAddress: PropTypes.string.isRequired,
description: PropTypes.string.isRequired
title: PropTypes.string.isRequired
}).isRequired
}

Expand Down
9 changes: 4 additions & 5 deletions src/containers/home/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import * as notificationActions from '../../actions/notification'
import * as arbitratorSelectors from '../../reducers/arbitrator'
import * as arbitratorActions from '../../actions/arbitrator'
import Icosahedron from '../../components/icosahedron'
import LoadingBar from '../../components/loading-bar'
import Identicon from '../../components/identicon'
import BalancePieChart from '../../components/balance-pie-chart'
import Button from '../../components/button'
Expand Down Expand Up @@ -127,7 +126,7 @@ class Home extends PureComponent {
</h5>
<RenderIf
resource={PNKBalance}
loading={<LoadingBar />}
loading={'...'}
done={
PNKBalance.data && (
<h6>
Expand All @@ -150,7 +149,7 @@ class Home extends PureComponent {
/>
<RenderIf
resource={balance}
loading={<LoadingBar />}
loading={<Icosahedron />}
done={
<h6>
<ChainData
Expand All @@ -169,7 +168,7 @@ class Home extends PureComponent {
<div className="Home-stats-block">
<RenderIf
resource={PNKBalance}
loading={<LoadingBar />}
loading={<Icosahedron />}
done={
PNKBalance.data && (
<div className="Home-stats-block-content">
Expand Down Expand Up @@ -238,7 +237,7 @@ class Home extends PureComponent {
<div className="Home-stats-block">
<RenderIf
resource={PNKBalance}
loading={<LoadingBar />}
loading={<Icosahedron />}
done={
PNKBalance.data && (
<div className="Home-stats-block-content">
Expand Down
1 change: 1 addition & 0 deletions src/reducers/dispute.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ const {
).isRequired,

// Store Data
title: PropTypes.string.isRequired,
description: PropTypes.string.isRequired,
email: PropTypes.string.isRequired,
evidence: PropTypes.arrayOf(
Expand Down
1 change: 1 addition & 0 deletions src/sagas/dispute.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ function* fetchDisputes() {

disputes.push({
...d,
title: arbitrableData ? arbitrableData.title : null,
description: arbitrableData ? arbitrableData.description : null,
deadline: disputeDeadline ? new Date(disputeDeadline) : null
})
Expand Down
1 change: 1 addition & 0 deletions stories/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ import './status-hint'
import './table'
import './text-input'
import './toast'
import './truncated-text-box'
import './typography'
22 changes: 22 additions & 0 deletions stories/truncated-text-box.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import React from 'react'
import { storiesOf } from '@storybook/react'

import TruncatedTextBox from '../src/components/truncated-text-box'

storiesOf('Truncated Text Box', module)
.add('default', () => (
<TruncatedTextBox
text="Duis et mauris vestibulum, auctor lacus porttitor, pellentesque arcu.
Sed scelerisque dolor in orci luctus semper. Mauris turpis magna, congue
vitae sollicitudin vel, pretium nec arcu."
maxWords={10}
/>
))
.add('not exceeding max words', () => (
<TruncatedTextBox
text="Duis et mauris vestibulum, auctor lacus porttitor, pellentesque arcu.
Sed scelerisque dolor in orci luctus semper. Mauris turpis magna, congue
vitae sollicitudin vel, pretium nec arcu."
maxWords={100}
/>
))