Skip to content
This repository was archived by the owner on Nov 7, 2023. It is now read-only.

Commit 343bb30

Browse files
committed
Use beta3 version of the ipfs pinner
- Implement size operation - Show sizes on hover as bytes - Progress bar will show at least 1% if the value is more than 0 but less than 1%. This is visual for the user to at least see a value
1 parent 0550dcb commit 343bb30

File tree

8 files changed

+25
-17
lines changed

8 files changed

+25
-17
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"typescript": "~4.0.5"
2929
},
3030
"devDependencies": {
31-
"@rsksmart/ipfs-cpinner-client": "^0.1.1-beta.2",
31+
"@rsksmart/ipfs-cpinner-client": "^0.1.1-beta.3",
3232
"@rsksmart/rlogin": "0.0.1-beta.3",
3333
"@testing-library/jest-dom": "^5.11.4",
3434
"@testing-library/react": "^11.1.0",

src/app/Dashboard/panels/DataVaultSummary.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ describe('Component: DataVaultSummary.test', () => {
1919
})
2020

2121
it('displays numbers in tooltip', () => {
22-
const props = { storage: { used: 150, available: 890 }, handleButton: jest.fn() }
22+
const props = { storage: { used: 1000, available: 9000 }, handleButton: jest.fn() }
2323
const wrapper = mount(<DataVaultSummary {...props} />)
24-
expect(wrapper.find('.hover-content').first().text()).toBe('150 of 890')
24+
expect(wrapper.find('.hover-content').first().text()).toBe('1000 of 10,000 bytes')
2525
})
2626
})

src/app/Dashboard/panels/DataVaultSummary.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,10 @@ const DataVaultSummary: React.FC<DataVaultSummaryInterface> = ({ storage, handle
1515
storage ? (
1616
<Panel title={<><img src={datavaultIcon} alt="DataVault" /> DataVault Summary</>} className="dataVault">
1717
<h2>Storage Usage</h2>
18-
1918
<div className="container">
2019
<div className="columnDouble">
21-
<ToolTip className="tooltip-progress" hoverContent={<p>{storage.used} of {storage.available}</p>}>
22-
<ProgressBar total={storage.available} value={storage.used} />
20+
<ToolTip className="tooltip-progress" hoverContent={<p>{storage.used} of {(storage.available + storage.used).toLocaleString()} bytes</p>}>
21+
<ProgressBar total={(storage.available + storage.used)} value={storage.used} />
2322
</ToolTip>
2423
</div>
2524
<div className="column">

src/app/state/operations/datavault.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Dispatch } from 'react'
22
import DataVaultWebClient from '@rsksmart/ipfs-cpinner-client'
33
import { createDidFormat } from '../../../formatters'
4-
import { addContentToKey, DataVaultContent, receiveKeyData, removeContentfromKey, swapContentById, receiveStorageInformation } from '../reducers/datavault'
4+
import { addContentToKey, DataVaultContent, receiveKeyData, removeContentfromKey, swapContentById, receiveStorageInformation, DataVaultStorageState } from '../reducers/datavault'
55
import { getDataVault } from '../../../config/getConfig'
66
import { CreateContentResponse } from '@rsksmart/ipfs-cpinner-client/lib/types'
77

@@ -77,6 +77,5 @@ export const swapDataVaultContent = (client: DataVaultWebClient, key: string, co
7777
* @param client DataVault client
7878
*/
7979
export const getStorageInformation = (client: DataVaultWebClient) => (dispatch: Dispatch<any>) =>
80-
dispatch((receiveStorageInformation({ storage: { used: 10, available: 150 } })))
81-
// client.getStorageInformation()
82-
// .then((storage: DataVaultStorageState) => dispatch(receiveStorageInformation({ storage })))
80+
client.getStorageInformation()
81+
.then((storage: DataVaultStorageState) => dispatch(receiveStorageInformation({ storage })))

src/components/ProgressBar/ProgressBar.test.tsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,22 @@ describe('Component: ProgressBar.test', () => {
1717

1818
it('26 of 150', () => {
1919
const wrapper = mount(<ProgressBar value={26} total={150} />)
20-
expect(wrapper.find('.progress').first().props().style).toMatchObject({ width: '17%' })
20+
expect(wrapper.find('.progress').first().props().style).toMatchObject({ width: '18%' })
2121
})
2222
})
2323

2424
it('returns 100% if thge total is higher than the value', () => {
2525
const wrapper = mount(<ProgressBar value={82} total={40} />)
2626
expect(wrapper.find('.progress').first().props().style).toMatchObject({ width: '100%' })
2727
})
28+
29+
it('returns 0% if the value is 0', () => {
30+
const wrapper = mount(<ProgressBar value={0} total={40} />)
31+
expect(wrapper.find('.progress').first().props().style).toMatchObject({ width: '0%' })
32+
})
33+
34+
it('shows a visual bar of 1% if the value is less than 1% but not 0', () => {
35+
const wrapper = mount(<ProgressBar value={1} total={1000} />)
36+
expect(wrapper.find('.progress').first().props().style).toMatchObject({ width: '1%' })
37+
})
2838
})

src/components/ProgressBar/ProgressBar.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ const BarProgress = styled.div`
3434
`
3535

3636
const ProgressBar: React.FC<ProgressBarInterface> = ({ total, value }) => {
37-
const width = value < total ? Math.round((value * 100) / total) : 100
37+
const width = value < total ? Math.ceil((value * 100) / total) : 100
3838
return (
3939
<BarWrapper className="progress-wrapper">
4040
<BarProgress className="progress" style={{ width: `${width}%` }}></BarProgress>

src/config/config.testnet.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44
"tokens": [ "0x19f64674d8a5b4e652319f5e239efd3bc969a1fe" ],
55
"dataVault": {
66
"serviceDid": "did:ethr:rsk:testnet:0x285B30492a3F444d78f75261A35cB292Fc8F41A6",
7-
"serviceUrl": "http://ec2-3-131-142-122.us-east-2.compute.amazonaws.com:5107"
7+
"serviceUrl": "https://identity.staging.rifcomputing.net"
88
}
99
}

yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1589,10 +1589,10 @@
15891589
ethjs-query "^0.3.8"
15901590
ethr-did-resolver "^1.0.2"
15911591

1592-
"@rsksmart/ipfs-cpinner-client@^0.1.1-beta.2":
1593-
version "0.1.1-beta.2"
1594-
resolved "https://registry.yarnpkg.com/@rsksmart/ipfs-cpinner-client/-/ipfs-cpinner-client-0.1.1-beta.2.tgz#666d2e93e9d8f8585d116a380462120534348e36"
1595-
integrity sha512-H9Yp+xJsRnxGd/6JSh6bLXW3ijixtOTwmZjngYGNxABOZ0AEYkRfo7rMrgFQuVM1oNQeuWetrhO2daWiVVYMpA==
1592+
"@rsksmart/ipfs-cpinner-client@^0.1.1-beta.3":
1593+
version "0.1.1-beta.3"
1594+
resolved "https://registry.yarnpkg.com/@rsksmart/ipfs-cpinner-client/-/ipfs-cpinner-client-0.1.1-beta.3.tgz#6cb862a60ffdceb185bd24bab1f3425d9dd1cf83"
1595+
integrity sha512-Uh59NfVxje2uwATYjRdw9dvRjqXdhGh3GicJt4VRwbAYLVGJcN4ddFwEyxixjqF9IV++Edpy0PYxdCdAgdRWyA==
15961596
dependencies:
15971597
axios "^0.21.0"
15981598
did-jwt "^4.6.2"

0 commit comments

Comments
 (0)