diff --git a/src/app/components/AddressBox/__tests__/__snapshots__/index.test.tsx.snap b/src/app/components/AddressBox/__tests__/__snapshots__/index.test.tsx.snap
new file mode 100644
index 0000000000..c18100c9cd
--- /dev/null
+++ b/src/app/components/AddressBox/__tests__/__snapshots__/index.test.tsx.snap
@@ -0,0 +1,158 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[` should render address properly 1`] = `
+.c2 {
+ display: inline-block;
+ -webkit-flex: 0 0 auto;
+ -ms-flex: 0 0 auto;
+ flex: 0 0 auto;
+ width: 18px;
+ height: 18px;
+ fill: #666666;
+ stroke: #666666;
+}
+
+.c2 g {
+ fill: inherit;
+ stroke: inherit;
+}
+
+.c2 *:not([stroke])[fill="none"] {
+ stroke-width: 0;
+}
+
+.c2 *[stroke*="#"],.c2 *[STROKE*="#"] {
+ stroke: inherit;
+ fill: none;
+}
+
+.c2 *[fill-rule],
+.c2 *[FILL-RULE],
+.c2 *[fill*="#"],.c2 *[FILL*="#"] {
+ fill: inherit;
+ stroke: none;
+}
+
+.c0 {
+ display: -webkit-box;
+ display: -webkit-flex;
+ display: -ms-flexbox;
+ display: flex;
+ box-sizing: border-box;
+ max-width: 100%;
+ -webkit-align-items: center;
+ -webkit-box-align: center;
+ -ms-flex-align: center;
+ align-items: center;
+ min-width: 0;
+ min-height: 0;
+ -webkit-flex-direction: row;
+ -ms-flex-direction: row;
+ flex-direction: row;
+ width: -webkit-fit-content;
+ width: -moz-fit-content;
+ width: fit-content;
+ padding-right: 12px;
+ border-radius: 5px;
+}
+
+.c3 {
+ font-size: 18px;
+ line-height: 24px;
+ font-weight: bold;
+ word-break: break-word;
+}
+
+.c1 {
+ display: inline-block;
+ box-sizing: border-box;
+ cursor: pointer;
+ font: inherit;
+ -webkit-text-decoration: none;
+ text-decoration: none;
+ margin: 0;
+ background: transparent;
+ overflow: visible;
+ text-transform: none;
+ color: inherit;
+ outline: none;
+ border: none;
+ padding: 0;
+ text-align: inherit;
+ line-height: 0;
+ padding: 12px;
+}
+
+.c1:focus {
+ outline: none;
+ box-shadow: 0 0 2px 2px #6FFFB0;
+}
+
+.c1:focus > circle,
+.c1:focus > ellipse,
+.c1:focus > line,
+.c1:focus > path,
+.c1:focus > polygon,
+.c1:focus > polyline,
+.c1:focus > rect {
+ outline: none;
+ box-shadow: 0 0 2px 2px #6FFFB0;
+}
+
+.c1:focus::-moz-focus-inner {
+ border: 0;
+}
+
+.c1:focus:not(:focus-visible) {
+ outline: none;
+ box-shadow: none;
+}
+
+.c1:focus:not(:focus-visible) > circle,.c1:focus:not(:focus-visible) > ellipse,
+.c1:focus:not(:focus-visible) > line,.c1:focus:not(:focus-visible) > path,
+.c1:focus:not(:focus-visible) > polygon,.c1:focus:not(:focus-visible) > polyline,
+.c1:focus:not(:focus-visible) > rect {
+ outline: none;
+ box-shadow: none;
+}
+
+.c1:focus:not(:focus-visible)::-moz-focus-inner {
+ border: 0;
+}
+
+@media only screen and (max-width:768px) {
+ .c0 {
+ padding-right: 6px;
+ }
+}
+
+
+
+
+
+ oasis1 qqur xkga vtcj jytn eume clx5 9ds3 avja qg7f tqph
+
+
+
+`;
diff --git a/src/app/components/AddressBox/__tests__/index.test.tsx b/src/app/components/AddressBox/__tests__/index.test.tsx
new file mode 100644
index 0000000000..79aa6351f4
--- /dev/null
+++ b/src/app/components/AddressBox/__tests__/index.test.tsx
@@ -0,0 +1,33 @@
+import * as React from 'react'
+import copy from 'copy-to-clipboard'
+import { screen } from '@testing-library/dom'
+import { render } from '@testing-library/react'
+import userEvent from '@testing-library/user-event'
+
+import { AddressBox } from '../index'
+
+jest.mock('copy-to-clipboard')
+
+const testAddress = 'oasis1qqurxkgavtcjjytneumeclx59ds3avjaqg7ftqph'
+
+const renderComponent = () => render()
+
+describe('', () => {
+ it('should render address properly', () => {
+ const { container } = renderComponent()
+ expect(container).toMatchSnapshot()
+ })
+
+ it('should be able to copy address to clipboard', async () => {
+ renderComponent()
+ await userEvent.click(screen.getByTestId('copy-address'))
+ expect(copy).toHaveBeenCalledWith(testAddress)
+ })
+
+ it('should be able to show a notification', async () => {
+ renderComponent()
+ jest.mocked(copy).mockReturnValue(true) // Copy must return true so that the notification is actually displayed
+ await userEvent.click(screen.getByTestId('copy-address'))
+ expect(await screen.getByText('account.addressCopied')).toBeInTheDocument()
+ })
+})
diff --git a/src/app/components/AddressBox/index.tsx b/src/app/components/AddressBox/index.tsx
index 3fd5489813..c97151f9cb 100644
--- a/src/app/components/AddressBox/index.tsx
+++ b/src/app/components/AddressBox/index.tsx
@@ -4,9 +4,10 @@
*
*/
import copy from 'copy-to-clipboard'
-import { Box, Button, Text } from 'grommet'
+import { Box, Button, Text, Notification } from 'grommet'
import { Copy } from 'grommet-icons'
-import React, { memo } from 'react'
+import React, { memo, useState } from 'react'
+import { useTranslation } from 'react-i18next'
import { PrettyAddress } from '../PrettyAddress'
@@ -15,18 +16,34 @@ interface Props {
}
export const AddressBox = memo((props: Props) => {
+ const { t } = useTranslation()
+ const [notificationVisible, setNotificationVisible] = useState(false)
+
+ const hideNotification = () => setNotificationVisible(false)
+
const address = props.address
const copyAddress = () => {
- copy(address)
+ const wasCopied = copy(address)
+ if (wasCopied) {
+ setNotificationVisible(true)
+ }
}
return (
-
)
})
diff --git a/src/app/components/Transaction/InfoBox.tsx b/src/app/components/Transaction/InfoBox.tsx
index c23b2a606f..373d800e0d 100644
--- a/src/app/components/Transaction/InfoBox.tsx
+++ b/src/app/components/Transaction/InfoBox.tsx
@@ -1,8 +1,10 @@
-import { Box, Text } from 'grommet'
+import { Box, Text, Notification } from 'grommet'
import * as React from 'react'
import type { Icon } from 'grommet-icons'
import copy from 'copy-to-clipboard'
import { trimLongString } from '../ShortAddress'
+import { useState } from 'react'
+import { useTranslation } from 'react-i18next'
interface InfoBoxProps {
copyToClipboard?: boolean
@@ -13,13 +15,26 @@ interface InfoBoxProps {
}
export function InfoBox({ copyToClipboard, icon: IconComponent, label, trimValue, value }: InfoBoxProps) {
+ const { t } = useTranslation()
+ const [notificationVisible, setNotificationVisible] = useState(false)
+
+ const hideNotification = () => setNotificationVisible(false)
+
+ const copyValue = () => {
+ if (!copyToClipboard) return
+ const wasCopied = copy(value)
+ if (wasCopied) {
+ setNotificationVisible(true)
+ }
+ }
+
return (
copy(value) : undefined}
+ onClick={copyValue}
>
@@ -29,6 +44,14 @@ export function InfoBox({ copyToClipboard, icon: IconComponent, label, trimValue
{label}
{trimValue ? trimLongString(value) : value}
+ {notificationVisible && (
+
+ )}
)
}
diff --git a/src/app/components/Transaction/__tests__/__snapshots__/index.test.tsx.snap b/src/app/components/Transaction/__tests__/__snapshots__/index.test.tsx.snap
index 4686a62bf6..ffe0b2a641 100644
--- a/src/app/components/Transaction/__tests__/__snapshots__/index.test.tsx.snap
+++ b/src/app/components/Transaction/__tests__/__snapshots__/index.test.tsx.snap
@@ -228,21 +228,6 @@ exports[` should handle unknown transaction types gracefully 1`]
}
.c15 {
- display: -webkit-box;
- display: -webkit-flex;
- display: -ms-flexbox;
- display: flex;
- box-sizing: border-box;
- max-width: 100%;
- min-width: 0;
- min-height: 0;
- -webkit-flex-direction: row;
- -ms-flex-direction: row;
- flex-direction: row;
- padding: 12px;
-}
-
-.c16 {
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
@@ -263,7 +248,7 @@ exports[` should handle unknown transaction types gracefully 1`]
padding-right: 12px;
}
-.c20 {
+.c19 {
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
@@ -310,13 +295,13 @@ exports[` should handle unknown transaction types gracefully 1`]
line-height: 24px;
}
-.c17 {
+.c16 {
font-size: 26px;
line-height: 32px;
font-weight: bold;
}
-.c18 {
+.c17 {
margin-left: 3px;
font-size: 12px;
line-height: 18px;
@@ -324,19 +309,19 @@ exports[` should handle unknown transaction types gracefully 1`]
font-weight: 600;
}
-.c19 {
+.c18 {
font-size: 14px;
line-height: 20px;
color: successful-label;
font-weight: bold;
}
-.c22 {
+.c21 {
font-size: 14px;
line-height: 20px;
}
-.c21 {
+.c20 {
box-sizing: border-box;
font-size: inherit;
line-height: inherit;
@@ -347,7 +332,7 @@ exports[` should handle unknown transaction types gracefully 1`]
cursor: pointer;
}
-.c21:hover {
+.c20:hover {
-webkit-text-decoration: underline;
text-decoration: underline;
}
@@ -421,18 +406,12 @@ exports[` should handle unknown transaction types gracefully 1`]
@media only screen and (max-width:768px) {
.c15 {
- padding: 6px;
- }
-}
-
-@media only screen and (max-width:768px) {
- .c16 {
margin-top: 3px;
}
}
@media only screen and (max-width:768px) {
- .c16 {
+ .c15 {
padding-right: 6px;
}
}
@@ -579,7 +558,8 @@ exports[` should handle unknown transaction types gracefully 1`]
class="c9"
>
should handle unknown transaction types gracefully 1`]
0.001
TEST
account.transaction.successful