Unverified Commit fdaf16bb authored by Jonathan Porta's avatar Jonathan Porta Committed by GitHub
Browse files

Merge branch 'sps-implementation' into sps-implementation-show-sp

parents c137dda4 59e0ac3a
......@@ -24,26 +24,36 @@ module.exports = {
'/market',
'/~witnesses',
'/submit.html',
'/steem_proposal_system',
'/proposals',
].forEach(path => testHttpGet('localhost', 8080, path, browser));
},
};
const testHttpGet = (host, port, path, browser) => {
http
.request({
host,
port,
path,
method: 'GET'
}, function(res) {
browser.assert.equal(res.statusCode, 200, `Response for ${path} is 200`);
})
.setTimeout(30000, function() {
browser.assert.equal(true, false, `request for ${path} took more than 30 seconds`);
})
.on('error', function (err) {
browser.assert.equal(true, false, err);
})
.end();
http.request(
{
host,
port,
path,
method: 'GET',
},
(res) => {
browser.assert.equal(
res.statusCode,
200,
`Response for ${path} is 200`
);
}
)
.setTimeout(30000, () => {
browser.assert.equal(
true,
false,
`request for ${path} took more than 30 seconds`
);
})
.on('error', (err) => {
browser.assert.equal(true, false, err);
})
.end();
};
......@@ -58,23 +58,17 @@ export default function resolveRoute(path) {
if (path === '/~witnesses') {
return { page: 'Witnesses' };
}
if (path === '/steem_proposal_system') {
return { page: 'SteemProposalSystem' };
}
if (path === '/proposals') {
console.log('/proposals');
return { page: 'Proposals' };
}
match =
path.match(routeRegex.UserProfile1) ||
path.match(routeRegex.UserProfile2);
if (match) {
console.log('MATCH');
if (GDPRUserList.includes(match[1].substring(1))) {
return { page: 'NotFound' };
}
return { page: 'UserProfile', params: match.slice(1) };
}
console.log('NO MATCH');
return { page: 'NotFound' };
}
......@@ -33,7 +33,6 @@ describe('resolveRoute', () => {
['/recover_account_step_2', { page: 'RecoverAccountStep2' }],
['/market', { page: 'Market' }],
['/~witnesses', { page: 'Witnesses' }],
['/steem_proposal_system', { page: 'SteemProposalSystem' }],
['/proposals', { page: 'Proposals' }],
['/@gdpr/nice345', { page: 'NotFound' }],
['/taggy/@gdpr/nice345', { page: 'NotFound' }],
......
......@@ -44,8 +44,6 @@ export default {
cb(null, [require('app/components/pages/RecoverAccountStep2')]);
} else if (route.page === 'Witnesses') {
cb(null, [require('app/components/pages/Witnesses')]);
} else if (route.page === 'SteemProposalSystem') {
cb(null, [require('app/components/pages/SteemProposalSystem')]);
} else if (route.page === 'Proposals') {
cb(null, [require('app/components/pages/Proposals')]);
} else if (route.page === 'UserProfile') {
......
......@@ -52,4 +52,3 @@
@import './pages/Witnesses';
@import './pages/About';
@import './pages/WalletIndex';
@import './pages/SteemProposalSystem';
......@@ -60,10 +60,10 @@ class Header extends React.Component {
/*Set the document.title on each header render.*/
const route = resolveRoute(pathname);
let home_account = false;
const home_account = false;
let page_title = route.page;
let topic = '';
const topic = '';
let page_name = null;
if (route.page === 'WalletIndex') {
} else if (route.page == 'Privacy') {
......@@ -81,10 +81,10 @@ class Header extends React.Component {
route.page == 'RecoverAccountStep2'
) {
page_title = tt('header_jsx.stolen_account_recovery');
} else if (route.page === 'SteemProposalSystem') {
page_title = tt('header_jsx.steem_proposal_system');
} else if (route.page === 'Proposals') {
page_title = tt('header_jsx.steem_proposals');
} else if (route.page === 'UserProfile') {
let user_name = route.params[0].slice(1);
const user_name = route.params[0].slice(1);
const name = account_meta
? normalizeProfile(account_meta.toJS()).name
: null;
......@@ -263,6 +263,9 @@ const mapDispatchToProps = dispatch => ({
},
});
const connectedHeader = connect(mapStateToProps, mapDispatchToProps)(Header);
const connectedHeader = connect(
mapStateToProps,
mapDispatchToProps
)(Header);
export default connectedHeader;
......@@ -112,7 +112,20 @@ class Powerdown extends React.Component {
);
}
if (notes.length === 0) {
let AMOUNT = vestsToSpf(this.props.state, new_withdraw) / 13;
const total_vesting_shares = this.props.state.getIn([
'props',
'total_vesting_shares',
]);
const total_vesting_fund_steem = this.props.state.getIn([
'props',
'total_vesting_fund_steem',
]);
let AMOUNT =
vestsToSpf(
total_vesting_shares,
total_vesting_fund_steem,
new_withdraw
) / 13;
AMOUNT = AMOUNT.toFixed(AMOUNT >= 10 ? 0 : 1);
notes.push(
<li key="per_week">
......
......@@ -2,7 +2,7 @@ import React from 'react';
import PropTypes from 'prop-types';
import Moment from 'moment';
import NumAbbr from 'number-abbreviate';
import { numberWithCommas } from 'app/utils/StateFunctions';
import { numberWithCommas, vestsToSpf } from 'app/utils/StateFunctions';
import Icon from 'app/components/elements/Icon';
......@@ -22,7 +22,7 @@ Proposal.propTypes = {
isUpVoted: PropTypes.bool.isRequired,
// passed through connect from global state object to calc vests to sp
total_vesting_shares: PropTypes.string.isRequired,
total_vesting_fund_steem: PropTypes.string.isRequired,
total_vesting_fund_steem: PropTypes.string.isRequired
};
export default function Proposal(props) {
......@@ -40,13 +40,19 @@ export default function Proposal(props) {
voteFailed,
voteSucceeded,
isUpVoted,
total_vesting_shares,
total_vesting_fund_steem,
} = props;
const start = new Date(props.start_date);
const end = new Date(props.end_date);
const duration = end - start;
const durationInDays = Moment(end).diff(Moment(start), 'days');
const totalPayout = durationInDays * daily_pay.split(' SBD')[0]; // ¯\_(ツ)_/¯
const total_votes_in_sp = vestsToSpf(
total_vesting_shares,
total_vesting_fund_steem,
parseFloat(total_votes)
).toFixed(3);
console.log(
'PROPOSAL-RENDER(isUpVoted, voteSucceeded, voteFailed, isVoting)',
......@@ -54,7 +60,11 @@ export default function Proposal(props) {
isUpVoted,
voteSucceeded,
voteFailed,
isVoting
isVoting,
total_votes_in_sp,
total_vesting_shares,
total_vesting_fund_steem,
total_votes
);
const classUp =
'Voting__button Voting__button-up' +
......@@ -72,7 +82,6 @@ export default function Proposal(props) {
/>
</span>
</a>
<span>{abbreviateNumber(
simpleVotesToSp(
total_votes,
......@@ -120,7 +129,7 @@ export default function Proposal(props) {
</a>
</span>
<small>
${abbreviateNumber(daily_pay.amount)} per day for{' '}
${abbreviateNumber(daily_pay.split(' SBD')[0])} per day for{' '}
{durationInDays} days
</small>
</div>
......
......@@ -61,10 +61,22 @@ class ProposalContainer extends React.Component {
};
render() {
const { proposal } = this.props;
const {
proposal,
total_vesting_shares,
total_vesting_fund_steem,
} = this.props;
// console.log('ProposalContainer.jsx::render()', this.props);
return <Proposal {...proposal} onVote={this.onVote} {...this.state} />;
return (
<Proposal
{...proposal}
onVote={this.onVote}
{...this.state}
total_vesting_shares={total_vesting_shares}
total_vesting_fund_steem={total_vesting_fund_steem}
/>
);
}
}
......@@ -72,6 +84,8 @@ ProposalContainer.propTypes = {
proposal: PropTypes.shape({ creator: PropTypes.string.isRequired })
.isRequired,
voteOnProposal: PropTypes.func.isRequired,
total_vesting_shares: PropTypes.number.isRequired,
total_vesting_fund_steem: PropTypes.number.isRequired,
};
export default connect((state, ownProps) => {
......
......@@ -7,6 +7,8 @@ ProposalList.propTypes = {
proposals: PropTypes.array.isRequired,
voteOnProposal: PropTypes.func.isRequired,
loading: PropTypes.bool.isRequired,
total_vesting_shares: PropTypes.number.isRequired,
total_vesting_fund_steem: PropTypes.number.isRequired,
// proposals: PropTypes.arrayOf(
// PropTypes.shape({
// color: PropTypes.string.isRequired,
......@@ -22,7 +24,13 @@ ProposalList.propTypes = {
export default function ProposalList(props) {
// console.log('ProposalList.jsx->()', props);
const { proposals, voteOnProposal, loading } = props;
const {
proposals,
voteOnProposal,
loading,
total_vesting_shares,
total_vesting_fund_steem,
} = props;
const proposalCount = proposals.length;
if (!loading && proposalCount == 0) {
......@@ -60,6 +68,8 @@ export default function ProposalList(props) {
key={proposal.id}
voteOnProposal={voteOnProposal}
proposal={proposal}
total_vesting_shares={total_vesting_shares}
total_vesting_fund_steem={total_vesting_fund_steem}
/>
))}
</div>
......
......@@ -7,6 +7,8 @@ ProposalList.propTypes = {
proposals: PropTypes.array.isRequired, // TODO: Specify shape.
voteOnProposal: PropTypes.func.isRequired,
loading: PropTypes.bool.isRequired,
total_vesting_shares: PropTypes.number.isRequired,
total_vesting_fund_steem: PropTypes.number.isRequired,
};
class ProposalListContainer extends React.Component {
......@@ -20,7 +22,7 @@ class ProposalListContainer extends React.Component {
}
render() {
const { proposals, voteOnProposal, loading } = this.props;
// const { proposals, voteOnProposal, loading } = this.props;
// console.log('ProposalListContainer.jsx::render()', arguments);
return <ProposalList {...this.props} />;
......
......@@ -73,9 +73,9 @@ const SidePanel = ({ alignment, visible, hideSidePanel, username }) => {
link: `/~witnesses`,
},
{
value: 'steem_proposal_system',
label: tt('navigation.steem_proposal_system'),
link: `/steem_proposal_system`,
value: 'proposals',
label: tt('navigation.steem_proposals'),
link: `/proposals`,
},
],
exchanges: [
......@@ -83,9 +83,7 @@ const SidePanel = ({ alignment, visible, hideSidePanel, username }) => {
value: 'blocktrades',
label: 'Blocktrades',
link: username
? `https://blocktrades.us/?input_coin_type=eth&output_coin_type=steem&receive_address=${
username
}`
? `https://blocktrades.us/?input_coin_type=eth&output_coin_type=steem&receive_address=${username}`
: `https://blocktrades.us/?input_coin_type=eth&output_coin_type=steem`,
},
{
......@@ -181,23 +179,23 @@ const SidePanel = ({ alignment, visible, hideSidePanel, username }) => {
<CloseButton onClick={hideSidePanel} />
<ul className={`vertical menu ${loggedIn}`}>
{makeInternalLink(
sidePanelLinks['extras'][0],
sidePanelLinks.extras[0],
0,
sidePanelLinks['extras']
sidePanelLinks.extras
)}
{makeExternalLink(
sidePanelLinks['extras'][1],
sidePanelLinks.extras[1],
1,
sidePanelLinks['extras']
sidePanelLinks.extras
)}
{makeInternalLink(
sidePanelLinks['extras'][2],
sidePanelLinks.extras[2],
2,
sidePanelLinks['extras']
sidePanelLinks.extras
)}
</ul>
<ul className="vertical menu">
{sidePanelLinks['internal'].map(makeInternalLink)}
{sidePanelLinks.internal.map(makeInternalLink)}
</ul>
<ul className="vertical menu">
<li>
......@@ -205,16 +203,16 @@ const SidePanel = ({ alignment, visible, hideSidePanel, username }) => {
{tt('navigation.third_party_exchanges')}
</a>
</li>
{sidePanelLinks['exchanges'].map(makeExternalLink)}
{sidePanelLinks.exchanges.map(makeExternalLink)}
</ul>
<ul className="vertical menu">
{sidePanelLinks['external'].map(makeExternalLink)}
{sidePanelLinks.external.map(makeExternalLink)}
</ul>
<ul className="vertical menu">
{sidePanelLinks['organizational'].map(makeExternalLink)}
{sidePanelLinks.organizational.map(makeExternalLink)}
</ul>
<ul className="vertical menu">
{sidePanelLinks['legal'].map(makeInternalLink)}
{sidePanelLinks.legal.map(makeInternalLink)}
</ul>
</div>
</div>
......
......@@ -159,6 +159,7 @@ class Proposals extends React.Component {
render() {
console.log('Proposals->render()', this.state);
const { proposals, loading } = this.state;
const { total_vesting_shares, total_vesting_fund_steem } = this.props;
let showBottomLoading = false;
if (loading && proposals && proposals.length > 0) {
showBottomLoading = true;
......@@ -169,6 +170,8 @@ class Proposals extends React.Component {
voteOnProposal={this.voteOnProposal}
proposals={proposals}
loading={loading}
total_vesting_shares={total_vesting_shares}
total_vesting_fund_steem={total_vesting_fund_steem}
/>
<center style={{ paddingTop: '1em', paddingBottom: '1em' }}>
{!loading ? (
......@@ -191,6 +194,8 @@ Proposals.propTypes = {
// updateProposalVotes: PropTypes.func.isRequired,
createProposal: PropTypes.func.isRequired,
voteOnProposal: PropTypes.func.isRequired,
total_vesting_shares: PropTypes.number.isRequired,
total_vesting_fund_steem: PropTypes.number.isRequired,
};
module.exports = {
......@@ -216,13 +221,21 @@ module.exports = {
// `transaction_proposal_vote_active_${currentUser}`,
// List()
// );
const total_vesting_shares = state.global.getIn([
'props',
'total_vesting_shares',
]);
const total_vesting_fund_steem = state.global.getIn([
'props',
'total_vesting_fund_steem',
]);
return {
currentUser,
proposals: newProposals,
// voterProposals,
total_vesting_shares,
total_vesting_fund_steem,
last_id,
// votesInProgress,
};
},
dispatch => {
......@@ -327,7 +340,7 @@ module.exports = {
type: 'remove_proposal',
operation: { proposal_owner, proposal_ids },
confirm: tt(
'steem_proposal_system_jsx.confirm_remove_proposal_description'
'steem_proposals.confirm_remove_proposal_description'
),
successCallback,
errorCallback,
......
This diff is collapsed.
.SteemProposalSystem {
table {
tr:nth-child(4n),
tr:nth-child(4n-1) {
// background-color: #f4f4f4;
@include themify($themes) {
background-color: themed('backgroundColorOpaque');
color: themed('textColorPrimary');
}
}
tr:nth-child(4n -2),
tr:nth-child(4n-3) {
@include themify($themes) {
background-color: themed('tableRowEvenBackgroundColor');
}
}
td.permlink-column {
display: flex;
justify-content: space-around;
align-items: center;
a {
display: flex;
align-items: center;
justify-content: center;
}
.Voting__button-up {
padding-right: 0 !important;
}
}
td.subject-column,
td.subject-table-header {
display: none;
}
tr.proposal-subject-row {
td {
text-align: center;
}
}
tbody {
td.id-column,
td.daily_pay-column,
td.total_votes-column {
text-align: right;
}
}
.proposals-filter-header {
.proposals-filter-wrapper {
display: flex;
justify-content: space-between;
align-items: center;
.dropdowns {
li {
span {
padding: 0.4rem;
font-weight: bold;
text-align: left;
padding-left: 16px;
&:hover {
cursor: pointer;
color: $color-teal;
}
}
}
}
.pagination {
display: flex;
align-items: center;
margin-bottom: 0;
}
}
}
.proposal-remove {
span {
color: red;
font-size: 1.25em;
}
}
@media only screen and (min-width: 768px) {
td.start_date-column,
td.end_date-column {
width: 22ch;
}
td.total_votes-column {
width: 13ch;
}
td.daily_pay-column {
width: 18ch;
}
}
@media only screen and (max-width: 768px) {
thead tr:nth-child(2) {
display: none;
}
tr {
margin-bottom: 10px;
display: block;
}
tr.proposals-filter-header {
margin-bottom: 2px;
}
tr.proposal-subject-row {
display: none;
}
tr:nth-child(4n),
tr:nth-child(4n-1) {
background-color: transparent;
}
td.subject-column {
display: block;
}
td.permlink-column {
display: flex;
justify-content: flex-end;
align-items: center;
a {
width: 30px;
height: 30px;
}
}
td {
display: block;
text-align: right;
}
td::before {