-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add block status and update transaction status on transction me…
…tadata tab
- Loading branch information
Showing
5 changed files
with
146 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import classNames from "classnames"; | ||
import moment from "moment"; | ||
import React, { useEffect, useState } from "react"; | ||
import Tooltip from "../../Tooltip"; | ||
import "../../stardust/block/BlockTangleState.scss"; | ||
import { BlockState, u64 } from "@iota/sdk-wasm-nova/web"; | ||
import { BlockFailureReason } from "@iota/sdk-wasm-nova/web/lib/types/models/block-failure-reason"; | ||
|
||
export interface BlockTangleStateProps { | ||
/** | ||
* The Block status. | ||
*/ | ||
status: BlockState; | ||
|
||
/** | ||
* The tangle status. | ||
*/ | ||
issuingTime: u64; | ||
|
||
/** | ||
* The failure reason. | ||
*/ | ||
failureReason?: BlockFailureReason; | ||
} | ||
|
||
const BlockTangleState: React.FC<BlockTangleStateProps> = ({ status, issuingTime, failureReason }) => { | ||
const [ago, setAgo] = useState<string | undefined>(); | ||
|
||
useEffect(() => { | ||
setAgo(moment(Number(issuingTime) / 1000000).fromNow()); | ||
}, [issuingTime]); | ||
|
||
return ( | ||
<div className="blocks-tangle-state"> | ||
{status && ( | ||
<React.Fragment> | ||
<div | ||
className={classNames( | ||
"block-tangle-state", | ||
{ | ||
"block-tangle-state__confirmed": status === "confirmed" || "finalized", | ||
}, | ||
{ | ||
"block-tangle-state__conflicting": status === "rejected" && "failed", | ||
}, | ||
{ "block-tangle-state__pending": status === "pending" }, | ||
)} | ||
> | ||
{failureReason ? ( | ||
// todo: add BLOCK_FAILURE_REASON_STRINGS[failureReason] as tooltip content instead of failureReason?.toString()(track: https://github.com/iotaledger/iota-sdk/issues/1846) | ||
<Tooltip tooltipContent={failureReason?.toString()}> | ||
<span className="capitalize-text" style={{ color: "#ca493d" }}> | ||
{status} | ||
</span> | ||
</Tooltip> | ||
) : ( | ||
<span className="capitalize-text">{status}</span> | ||
)} | ||
</div> | ||
<div className="block-tangle-reference"> | ||
<span> {ago}</span> | ||
</div> | ||
</React.Fragment> | ||
)} | ||
</div> | ||
); | ||
}; | ||
|
||
export default BlockTangleState; |
42 changes: 42 additions & 0 deletions
42
client/src/app/components/nova/block/section/TransactionMetadataSection.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
@import "../../../../../scss/fonts"; | ||
@import "../../../../../scss/mixins"; | ||
@import "../../../../../scss/media-queries"; | ||
@import "../../../../../scss/variables"; | ||
@import "../../../../../scss/themes"; | ||
|
||
.transaction-tangle-state { | ||
@include font-size(12px); | ||
|
||
display: flex; | ||
align-items: center; | ||
height: 24px; | ||
margin-right: 8px; | ||
padding: 0 8px; | ||
border: 0; | ||
border-radius: 6px; | ||
outline: none; | ||
background-color: $gray-light; | ||
color: $gray-midnight; | ||
font-family: $inter; | ||
font-weight: 500; | ||
letter-spacing: 0.5px; | ||
white-space: nowrap; | ||
|
||
@include phone-down { | ||
height: 32px; | ||
} | ||
|
||
&.transaction-tangle-state__confirmed { | ||
background-color: var(--message-confirmed-bg); | ||
color: $mint-green-7; | ||
} | ||
|
||
&.transaction-tangle-state__conflicting { | ||
background-color: var(--message-conflicting-bg); | ||
} | ||
|
||
&.transaction-tangle-state__pending { | ||
background-color: var(--light-bg); | ||
color: #8493ad; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -245,3 +245,7 @@ button { | |
} | ||
} | ||
} | ||
|
||
.capitalize-text { | ||
text-transform: capitalize; | ||
} |