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

Release/0809 #165

Merged
merged 24 commits into from
Aug 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
f424a7c
feat(dcellar-web-ui): add select object
aiden-cao Jul 26, 2023
3d8c012
feat(dcellar-web-ui): add select object
aiden-cao Jul 26, 2023
55d394b
feat(dcellar-web-ui): add temp account
devinxl Jul 25, 2023
511c5d2
fix(dcellar-web-ui): add batch delete
Miyaww Jul 28, 2023
b59889a
fix(dcellar-web-ui): merge upload
Miyaww Jul 28, 2023
0aca0e3
fix(dcellar-web-ui): batch delete commit
Miyaww Jul 28, 2023
fe00195
fix: batch delete
Miyaww Aug 1, 2023
8e43e6d
fix: batch delete
Miyaww Aug 1, 2023
bb0d041
Merge branch 'main' into feat/batch-operations
aiden-cao Aug 4, 2023
f4c1831
feat(dcellar-web-ui): add multi download
aiden-cao Aug 4, 2023
08fd237
feat(dcellar-web-ui): update multi download ui
aiden-cao Aug 8, 2023
c7f9ee1
feat(dcellar-web-ui): add share permission grant
aiden-cao Aug 8, 2023
170d88f
feat(dcellar-web-ui): add share permission grant
aiden-cao Aug 8, 2023
c191b54
fix(dcellar-web-ui): merge main branch
Miyaww Aug 9, 2023
0686097
feat(dcellar-web-ui): add fault sps & fix download pop tip ui issue
aiden-cao Aug 9, 2023
d7d4030
Merge branch 'feat/batch-delete' into feat/batch-operations
aiden-cao Aug 9, 2023
5e592d9
feat(dcellar-web-ui): fix batch delete issues
aiden-cao Aug 9, 2023
b824531
feat(dcellar-web-ui): fix createTmpAccount params
aiden-cao Aug 9, 2023
02da9b1
fix(dcellar-web-ui): fix refresh page will logout issue (#166)
wenty22 Aug 9, 2023
46131b3
fix(dcellar-web-ui): upload error and add tmp account fee (#163)
devinxl Aug 9, 2023
a56378c
feat(dcellar-web-ui): fix objectname regexp compile error
aiden-cao Aug 9, 2023
c5295d9
feat(dcellar-web-ui): bucket level statement
aiden-cao Aug 10, 2023
00d2dc5
feat(dcellar-web-ui): fix signTypedDataCallback params lost
aiden-cao Aug 10, 2023
06f79f4
feat(dcellar-web-ui): fix checkbox ui
aiden-cao Aug 10, 2023
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
3 changes: 2 additions & 1 deletion apps/dcellar-web-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@
"@reduxjs/toolkit": "^1.9.5",
"react-redux": "^8.1.1",
"next-redux-wrapper": "^8.1.0",
"redux-persist": "^6.0.0"
"redux-persist": "^6.0.0",
"@wagmi/core": "^0.10.13"
},
"devDependencies": {
"@babel/plugin-syntax-flow": "^7.14.5",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,15 +158,16 @@ export function Select(props: DCSelectProps) {
return (
<GAClick key={item.value} name={gaClickName}>
<MenuItem
as="div"
px={24}
py={8}
transitionDuration="normal"
transitionProperty="colors"
bg={isSelected ? rgba('#00BA34', 0.1) : undefined}
_hover={{
bg: isSelected ? undefined : 'bg.bottom',
bg: isSelected || !item.access ? undefined : 'bg.bottom',
}}
onClick={() => onSelectItem(item)}
onClick={() => item.access && onSelectItem(item)}
_last={{
mb: 8,
}}
Expand Down
51 changes: 44 additions & 7 deletions apps/dcellar-web-ui/src/components/common/DCTable/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export type FixedType = 'left' | 'right' | boolean;

const theme: ThemeConfig = {
token: {
colorPrimary: '#00BA34',
colorBorderSecondary: '#e6e8ea',
colorLink: '#00BA34',
colorLinkActive: '#00BA34',
Expand Down Expand Up @@ -69,17 +70,32 @@ export const SealLoading = () => {
}
`;
return (
<Flex
w={`30%`}
bg={'#1184EE'}
borderRadius={'28px'}
animation={`${loading} 1.5s linear infinite`}
/>
<Flex alignItems="center">
<Flex w={'84px'} h={'8px'} bg={'#E7F3FD'} borderRadius={'28px'} overflow={'hidden'}>
<Flex
w={`30%`}
bg={'#1184EE'}
borderRadius={'28px'}
animation={`${loading} 1.5s linear infinite`}
/>
</Flex>
<Box
color={'readable.normal'}
ml={'4px'}
fontSize={'12px'}
lineHeight={'15px'}
fontWeight={400}
borderRadius={4}
padding={4}
>
Sealing...
</Box>
</Flex>
);
};

export const UploadProgress = (props: { progress: number }) => {
let { progress = 0} = props;
let { progress = 0 } = props;
if (progress < 0) {
progress = 0;
}
Expand Down Expand Up @@ -184,6 +200,7 @@ const Container = styled.div`
padding-top: 13px;
padding-bottom: 13px;
}
.ant-table-tbody > tr.ant-table-row-selected > td,
.ant-table-tbody > tr.ant-table-row:hover > td {
background: rgba(0, 186, 52, 0.1);
}
Expand All @@ -204,4 +221,24 @@ const Container = styled.div`
.ant-table-ping-right:not(.ant-table-has-fix-right) .ant-table-container::after {
display: none;
}

.ant-checkbox-checked:after {
display: none;
}
.ant-checkbox-checked:not(.ant-checkbox-disabled):hover .ant-checkbox-inner {
background-color: #2ec659;
border-color: transparent;
}
.ant-checkbox-indeterminate .ant-checkbox-inner {
background-color: #00ba34;
border-color: #00ba34;
&:after {
background-color: #fff;
height: 2px;
}
}
.ant-checkbox-indeterminate:hover .ant-checkbox-inner {
background-color: #2ec659;
border-color: #2ec659;
}
`;
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import { genCreateObjectTx } from '@/modules/file/utils/genCreateObjectTx';
import { resolve } from '@/facade/common';
import { broadcastFault, commonFault, createTxFault, simulateFault } from '@/facade/error';
import { isEmpty } from 'lodash-es';
import { parseErrorXml } from '@/utils/common';

interface GlobalTasksProps {}

Expand Down Expand Up @@ -159,12 +160,12 @@ export const GlobalTasks = memo<GlobalTasksProps>(function GlobalTasks() {
'X-Gnfd-User-Address': headers.get('X-Gnfd-User-Address'),
'X-Gnfd-App-Domain': headers.get('X-Gnfd-App-Domain'),
},
}).catch(e => {
console.log('upload error', e);
}).catch(async (e: Response) => {
const {code, message} = await parseErrorXml(e)
dispatch(updateUploadTaskMsg({
account: loginAccount,
id: task.id,
msg: e?.message || 'Upload error',
msg: message || 'Upload error',
}));
})
};
Expand Down
26 changes: 21 additions & 5 deletions apps/dcellar-web-ui/src/context/LoginContext/provider.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { PropsWithChildren, useCallback, useMemo } from 'react';
import { PropsWithChildren, useCallback, useEffect, useMemo } from 'react';

import { LoginContext } from '@/context/LoginContext/index';

Expand All @@ -19,11 +19,12 @@ export function LoginContextProvider(props: PropsWithChildren<LoginContextProvid
const dispatch = useAppDispatch();
const { children, inline = false } = props;
const { loginAccount } = useAppSelector((root) => root.persist);


const { disconnect } = useDisconnect();

const logout = useCallback(
(removeSpAuth = false) => {
(removeSpAuth = true) => {
dispatch(resetUploadQueue({loginAccount}))
dispatch(setLogout(removeSpAuth));
disconnect();
Expand All @@ -42,21 +43,36 @@ export function LoginContextProvider(props: PropsWithChildren<LoginContextProvid
});

const { pathname } = useRouter();
const { address: walletAddress } = useAccount();
const { address: walletAddress, connector } = useAccount();

useAsyncEffect(async () => {
useEffect(() => {
if (pathname === '/' || inline) return;

if (!walletAddress || loginAccount !== walletAddress) {
logout();
}

// Once the wallet is connected, we can get the address
// but if wallet is locked, we can't get the connector from wagmi
// to avoid errors when using the connector, we treat this situation as logout.
const timer = setTimeout(() => {
if (!connector) {
logout()
}
}, 1000)

return () => {
clearTimeout(timer)
}
}, [connector, inline, loginAccount, logout, pathname, walletAddress])

useAsyncEffect(async () => {
if (loginAccount === walletAddress) {
// expire date less than 24h,remove sp auth & logout
const spMayExpired = await dispatch(checkSpOffChainMayExpired(walletAddress));
if (spMayExpired) logout(true);
}
}, [walletAddress, pathname]);
}, [walletAddress]);

const { pass } = useLoginGuard(inline);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { WagmiConfig, createClient } from 'wagmi';
import { provider, webSocketProvider } from '@/context/WalletConnectContext/config/chains';
import { connectors } from '@/context/WalletConnectContext/config/connectors';
import { provider, webSocketProvider } from '@/context/WalletConnectContext/chains';
import { connectors } from '@/context/WalletConnectContext/connectors';

const client = createClient({
autoConnect: true,
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { MetaMaskConnector as WagmiMetaMaskConnector } from 'wagmi/connectors/metaMask';

export class MetaMaskConnector extends WagmiMetaMaskConnector {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import { Chain } from 'wagmi'
import { MetaMaskConnector as WagmiMetaMaskConnector } from 'wagmi/connectors/metaMask';
import {
getClient,
} from '@wagmi/core'

export type TrustWalletConnectorOptions = {
shimDisconnect?: boolean
}

export class TrustWalletConnector extends WagmiMetaMaskConnector {
readonly id: any = 'trustWallet';

constructor({
chains,
options: _options,
}: {
chains?: Chain[]
options?: TrustWalletConnectorOptions
} = {}) {

const options = {
name: 'Trust Wallet',
shimDisconnect: true,
UNSTABLE_shimOnConnectSelectAccount: true,
getProvider: getTrustWalletProvider,
..._options,
}

super({
chains,
options,
})
}

async disconnect() {
super.disconnect()

const provider: any = await this.getProvider()
if (!provider?.off) return

provider.off('accountsChanged', this.onAccountsChanged)
provider.off('chainChanged', this.onChainChanged)
provider.off('disconnect', this.onDisconnect)

if (this.options.shimDisconnect) {
getClient().storage?.removeItem(this.shimDisconnectKey)
}
}
}

export function getTrustWalletProvider() {
const isTrustWallet = (ethereum: any) => {
return !!ethereum.isTrust
}

const injectedProviderExist = typeof window !== 'undefined' && typeof window.ethereum !== 'undefined'

if (!injectedProviderExist) {
return
}

if (isTrustWallet(window.ethereum)) {
return window.ethereum
}

if (window.ethereum?.providers) {
return window.ethereum.providers.find(isTrustWallet)
}

return window.trustWallet
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { chains } from '@/context/WalletConnectContext/chains';
import { MetaMaskConnector } from '@/context/WalletConnectContext/connectors/MetaMaskConnector';
import { TrustWalletConnector } from '@/context/WalletConnectContext/connectors/TrustWalletConnector';

const trustWalletConnector = new TrustWalletConnector({ chains })
const metaMaskConnector = new MetaMaskConnector({ chains })

export const connectors = [trustWalletConnector, metaMaskConnector];
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,20 @@ import { ConnectorData, useAccount } from 'wagmi';
export type WalletSwitchAccountHandler = (data: ConnectorData) => void;

export function useWalletSwitchAccount(handler: WalletSwitchAccountHandler) {
const { connector } = useAccount();
const {address, connector } = useAccount();

const handlerRef = useSaveFuncRef(handler);

useEffect(() => {
const handler = (data: ConnectorData) => {
if (data.account) {
const onChange = (data: ConnectorData) => {
if (data.account && data.account !== address) {
handlerRef.current?.(data);
}
};

connector?.on('change', handler);
connector?.on('change', onChange);
return () => {
connector?.off('change', handler);
connector?.off('change', onChange);
};
}, [connector, handlerRef]);
}, [address, connector, handlerRef]);
}
Loading