Skip to content

Commit 6660a98

Browse files
authored
Merge pull request #115 from Patrik-Stas/feature/ui-value-copy
Add copy value button to UI
2 parents 90b2bf5 + 4a6d0cf commit 6660a98

File tree

13 files changed

+106
-46
lines changed

13 files changed

+106
-46
lines changed

indypool-client/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "indyscan-daemon",
3-
"version": "4.3.1",
3+
"version": "4.4.0",
44
"author": "Patrik Staš",
55
"license": "ISC",
66
"description": "Application scanning Hyperledger Indy blockchain for fetching and processing transactions.",

indyscan-api-client/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "indyscan-api-client",
3-
"version": "4.3.1",
3+
"version": "4.4.0",
44
"author": "Patrik Staš",
55
"license": "ISC",
66
"description": "IndyScan HTTP API client.",

indyscan-api/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "indyscan-api",
3-
"version": "4.3.1",
3+
"version": "4.4.0",
44
"description": "Web application to browse Hyperledger Indy blockchain transactions.",
55
"main": "index.js",
66
"scripts": {

indyscan-daemon-api-client/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "indyscan-daemon-api-client",
3-
"version": "4.3.1",
3+
"version": "4.4.0",
44
"author": "Patrik Staš",
55
"license": "ISC",
66
"description": "IndyScan Daemon HTTP API client.",

indyscan-daemon-ui/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "indyscan-daemon-ui",
3-
"version": "4.3.1",
3+
"version": "4.4.0",
44
"author": "Patrik Staš",
55
"license": "ISC",
66
"description": "UI to view and manage the state of indyscan-daemon.",

indyscan-daemon/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "indyscan-daemon",
3-
"version": "4.3.1",
3+
"version": "4.4.0",
44
"author": "Patrik Staš",
55
"license": "ISC",
66
"description": "Application scanning Hyperledger Indy blockchain for fetching and processing transactions.",

indyscan-storage/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "indyscan-storage",
3-
"version": "4.3.1",
3+
"version": "4.4.0",
44
"author": "Patrik Staš",
55
"license": "ISC",
66
"description": "",

indyscan-txtype/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "indyscan-txtype",
3-
"version": "4.3.1",
3+
"version": "4.4.0",
44
"description": "",
55
"main": "index.js",
66
"scripts": {
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
import React, { useState } from 'react'
2+
import './BadgedValueDisplay.scss'
3+
import { Icon, Label, List } from 'semantic-ui-react'
4+
import ReactTooltip from 'react-tooltip'
5+
import { renderValuesAsBadges } from '../Common'
6+
7+
export function BadgedValueDisplay (props) {
8+
9+
const [copied, setCopied] = useState(false)
10+
11+
function renderKeyValuePair (key, value, keyValueId, color = 'red') {
12+
return (
13+
<List.Item key={keyValueId} style={{ marginTop: 5 }}>
14+
<Label color={color} horizontal>
15+
<div className="tooltip">
16+
{ copied === key &&
17+
< span className="tooltiptext">Copied</span>
18+
}
19+
<Icon data-tip data-for="registerTip"
20+
name='copy outline icon'
21+
style={{ cursor: 'pointer', marginRight: '1em' }}
22+
onClick={() => {
23+
navigator.clipboard.writeText(value)
24+
setCopied(key)
25+
setTimeout(() => setCopied(null), 400)
26+
}}
27+
>
28+
</Icon>
29+
</div>
30+
{key}
31+
</Label>
32+
33+
{Array.isArray(value) ? renderValuesAsBadges(key, value) : <Label>{value.toString().trim()}</Label>}
34+
</List.Item>
35+
)
36+
}
37+
38+
function renderKeyValues (obj, groupId, color) {
39+
let items = []
40+
let i = 0
41+
for (let [key, value] of Object.entries(obj)) {
42+
if (value) {
43+
if (Array.isArray(value) && value.length > 0) {
44+
items.push(renderKeyValuePair(key, value, `${groupId}-${i}`, color))
45+
} else {
46+
let stringified = value.toString().trim()
47+
if (stringified) {
48+
items.push(renderKeyValuePair(key, value, `${groupId}-${i}`, color))
49+
} else {
50+
continue
51+
}
52+
}
53+
i++
54+
}
55+
}
56+
return items
57+
}
58+
59+
return <div>
60+
{renderKeyValues(props.obj, props.groupId, props.color)}
61+
</div>
62+
}
63+
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/* Tooltip container */
2+
.tooltip {
3+
position: relative;
4+
display: inline-block;
5+
}
6+
7+
/* Tooltip text */
8+
.tooltip .tooltiptext {
9+
visibility: visible;
10+
width: 60px;
11+
background-color: black;
12+
color: #fff;
13+
text-align: center;
14+
padding: 5px 0;
15+
border-radius: 6px;
16+
17+
/* Position the tooltip text - see examples below! */
18+
position: absolute;
19+
left: -50px;
20+
bottom: 0.3em;
21+
z-index: 1;
22+
}
23+
24+
///* Show the tooltip text when you mouse over the tooltip container */
25+
//.tooltip:hover .tooltiptext {
26+
// visibility: visible;
27+
//}

0 commit comments

Comments
 (0)