-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add nano contracts list #387
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -24,7 +24,12 @@ function Sidebar({ close, open }) { | |||||
const isTokensBaseEnabled = useFlag(`${UNLEASH_TOKENS_BASE_FEATURE_FLAG}.rollout`); | ||||||
const isTokensBalanceEnabled = useFlag(`${UNLEASH_TOKEN_BALANCES_FEATURE_FLAG}.rollout`); | ||||||
const showTokensTab = isTokensBalanceEnabled || isTokensBaseEnabled; | ||||||
const theme = useSelector(state => state.theme); | ||||||
const { serverInfo, theme } = useSelector(state => { | ||||||
return { | ||||||
serverInfo: state.serverInfo, | ||||||
theme: state.theme, | ||||||
}; | ||||||
}); | ||||||
const sidebarRef = useRef(null); | ||||||
const [tokensOpen, setTokensOpen] = useState(false); | ||||||
const [nanoOpen, setNanoOpen] = useState(false); | ||||||
|
@@ -96,26 +101,31 @@ function Sidebar({ close, open }) { | |||||
)} | ||||||
</span> | ||||||
)} | ||||||
<li className="nav-item item-sidebar"> | ||||||
<span onClick={() => setNanoOpen(!nanoOpen)}> | ||||||
Nano{' '} | ||||||
<ArrorDownNavItem | ||||||
style={{ marginLeft: '5px', rotate: toolsOpen ? '180deg' : '0deg' }} | ||||||
className="dropdown-icon" | ||||||
/> | ||||||
</span> | ||||||
{nanoOpen && ( | ||||||
<div> | ||||||
<ul style={{ listStyleType: 'none', padding: 0, margin: 0 }}> | ||||||
<li> | ||||||
<NavLink to="/blueprints/?type=built-in" exact className="nav-link"> | ||||||
Blueprints List | ||||||
</NavLink> | ||||||
</li> | ||||||
</ul> | ||||||
</div> | ||||||
)} | ||||||
</li> | ||||||
{serverInfo.nano_contracts_enabled && ( | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion: If the protection is needed on the Navigation bar, add it here as well.
Suggested change
|
||||||
<li className="nav-item item-sidebar"> | ||||||
<span onClick={() => setNanoOpen(!nanoOpen)}> | ||||||
Nano{' '} | ||||||
<ArrorDownNavItem | ||||||
style={{ marginLeft: '5px', rotate: toolsOpen ? '180deg' : '0deg' }} | ||||||
className="dropdown-icon" | ||||||
/> | ||||||
</span> | ||||||
{nanoOpen && ( | ||||||
<div> | ||||||
<ul style={{ listStyleType: 'none', padding: 0, margin: 0 }}> | ||||||
<li> | ||||||
<NavLink to="/nano_contracts/" exact className="nav-link"> | ||||||
Nano Conctracts List | ||||||
</NavLink> | ||||||
<NavLink to="/blueprints/?type=built-in" exact className="nav-link"> | ||||||
Blueprints List | ||||||
</NavLink> | ||||||
</li> | ||||||
</ul> | ||||||
</div> | ||||||
)} | ||||||
</li> | ||||||
)} | ||||||
<li className="nav-item item-sidebar"> | ||||||
<NavLink | ||||||
to="/network" | ||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import React from 'react'; | ||
import SortableTable from '../SortableTable'; | ||
import EllipsiCell from '../EllipsiCell'; | ||
import dateFormatter from '../../utils/date'; | ||
|
||
// XXX We should use function component with SortableTable as a component | ||
// but renderTableHead and renderTableBody are implemented and not | ||
// expected as a props, so it demands a bigger refactor | ||
class NanoContractsTable extends SortableTable { | ||
renderTableHead() { | ||
return ( | ||
<tr> | ||
<th className="d-lg-table-cell">NANO CONTRACT ID</th> | ||
<th className="d-lg-table-cell">BLUEPRINT</th> | ||
<th className="d-lg-table-cell">LAST TRANSACTION</th> | ||
<th className="d-lg-table-cell">TOTAL TRANSACTIONS</th> | ||
Comment on lines
+15
to
+16
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. question(non-blocking): Why don't we allow ordering by those columns too? |
||
<th | ||
className="d-lg-table-cell sortable" | ||
onClick={e => this.props.tableHeaderClicked(e, 'created_at')} | ||
> | ||
CREATED AT {this.getArrow('created_at')} | ||
</th> | ||
</tr> | ||
); | ||
} | ||
|
||
renderTableBody() { | ||
return this.props.data.map(nano => { | ||
return ( | ||
<tr | ||
key={nano.nano_contract_id} | ||
onClick={_e => this.props.handleClickRow(nano.nano_contract_id)} | ||
> | ||
<td className="d-lg-table-cell pe-3"> | ||
{this.props.isMobile ? ( | ||
<EllipsiCell id={nano.nano_contract_id} countBefore={10} countAfter={10} /> | ||
) : ( | ||
nano.nano_contract_id | ||
)} | ||
</td> | ||
<td className="d-lg-table-cell pe-3">{nano.blueprint_name}</td> | ||
<td className="d-lg-table-cell pe-3"> | ||
{dateFormatter.parseTimestampNewUi(nano.last_tx_timestamp)} | ||
</td> | ||
<td className="d-lg-table-cell pe-3">{nano.total_txs}</td> | ||
<td className="d-lg-table-cell pe-3"> | ||
{dateFormatter.parseTimestampNewUi(nano.created_at)} | ||
</td> | ||
</tr> | ||
); | ||
}); | ||
} | ||
} | ||
|
||
NanoContractsTable.propTypes = SortableTable.propTypes; | ||
|
||
export default NanoContractsTable; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question: Is it possible that this component is rendered before the server info arrives? If so, it's important to protect this validation with a conditional.