Skip to content
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

Various UI fixes #117

Merged
merged 4 commits into from
Nov 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 16 additions & 13 deletions src/@utils/linkAsset.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
export function getLink(provider: string, item: string) {
let link;
switch (provider) {
case 'filecoin':
link = `https://gateway.ipfs.io/ipfs/${item}`
break;
case 'arweave':
link = `https://arweave.net/${item}`
break;
default:
break;
}
window.open(link, "_blank");
}
let link
switch (provider) {
case 'filecoin':
link = `https://gateway.ipfs.io/ipfs/${item}`
break
case 'ipfs':
link = `https://gateway.pinata.cloud/ipfs/${item}`
break
case 'arweave':
link = `https://arweave.net/${item}`
break
default:
break
}
window.open(link, '_blank')
}
46 changes: 0 additions & 46 deletions src/components/TabsFile/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,13 @@ import Tooltip from '../Tooltip'
import styles from './index.module.css'
import FileUploadSingle from '../FileUploadSingle'
import { useAccount, useNetwork, useContractRead } from 'wagmi'
import { switchNetwork } from '@wagmi/core'
import Button from '../Button'
import {
GetLinkResult,
GetQuoteArgs,
GetQuoteResult,
GetStatusResult
} from '@oceanprotocol/uploader'
import Networks from '../Networks'
import { formatEther } from '@ethersproject/units'
import HistoryList from '../HistoryList'
import { addEllipsesToText } from '../../@utils/textFormat'
Expand Down Expand Up @@ -44,7 +42,6 @@ export default function TabsFile({
const { address, isConnected } = useAccount()

const [isNetworkSupported, setIsNetworkSupported] = useState(false)
const [availableNetworks, setAvailableNetworks] = useState([])

const [paymentSelected, setPaymentSelected] = useState('')
const [selectedNetwork, setSelectedNetwork] = useState(chain?.id || 0)
Expand Down Expand Up @@ -143,7 +140,6 @@ export default function TabsFile({
(item: any) => parseInt(item.chainId)
)
// TODO: fix any type
setAvailableNetworks(availableNetworksByService as any)
const isNetworkSupported =
availableNetworksByService?.includes(chain?.id || 0) || false
setIsNetworkSupported(isNetworkSupported)
Expand All @@ -167,32 +163,6 @@ export default function TabsFile({
}, 3000)
}, [errorUpload])

const switchNetworks = async (chainId: number) => {
try {
const network = await switchNetwork({ chainId })
return network
} catch (error) {
console.log(error)
throw new Error('Error switching network')
}
}

const handleChangeNetwork = async (event: any) => {
event.preventDefault()
await switchNetworks(parseInt(event.target.value))
.then(() => {
setSelectedNetwork(parseInt(event.target.value))
})
.catch((error) => {
setSelectedNetwork(selectedNetwork)
console.log(error)
})
}

const handleChangePayment = (event: { target: { value: any } }) => {
setPaymentSelected(event.target.value)
}

const getQuote = async ({
type,
duration,
Expand Down Expand Up @@ -468,22 +438,6 @@ export default function TabsFile({

return (
<ReactTabs className={`${className || ''}`} defaultIndex={tabIndex}>
<div className={styles.headerContainer}>
{availableNetworks && availableNetworks?.length > 0 && (
<Networks
chainIds={availableNetworks}
paymentSelected={paymentSelected}
payments={
items[tabIndex].payment.find(
(item: any) => item.chainId === chain?.id.toString()
)?.acceptedTokens
}
handleChangeNetwork={handleChangeNetwork}
handleChangePayment={handleChangePayment}
/>
)}
</div>

<div className={styles.tabListContainer}>
<TabList className={styles.tabList}>
{items?.length > 0 &&
Expand Down
7 changes: 6 additions & 1 deletion src/components/UploaderConnection/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,12 @@ const UploaderConnection = ({
// Fetch storage info from Uploader endpoint
const getStorageInfo = async () => {
try {
const storageInfo = await client.getStorageInfo()
let storageInfo = await client.getStorageInfo()
storageInfo = storageInfo.sort((a, b) => {
if (a.type < b.type) {
return -1
} else return 1
})
return storageInfo
} catch (error) {
console.log(error)
Expand Down
Loading