Skip to content

Commit

Permalink
Merge pull request PolkaGate#1083 from AMIRKHANEF/Address#1076
Browse files Browse the repository at this point in the history
Address#1076
  • Loading branch information
Nick-1979 authored Apr 4, 2024
2 parents 5580c27 + 5c31975 commit 7ae6f6d
Showing 1 changed file with 28 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { faHistory, faPaperPlane, faVoteYea } from '@fortawesome/free-solid-svg-
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { ArrowForwardIos as ArrowForwardIosIcon, Boy as BoyIcon } from '@mui/icons-material';
import { Box, ClickAwayListener, Divider, Grid, IconButton, Slide, Typography, useTheme } from '@mui/material';
import React, { useCallback, useState } from 'react';
import React, { useCallback, useMemo, useState } from 'react';
import { useHistory } from 'react-router-dom';

import { AccountId } from '@polkadot/types/interfaces/runtime';
Expand Down Expand Up @@ -48,6 +48,8 @@ export default function QuickActionFullScreen ({ address, assetId, containerRef,

const [showHistory, setShowHistory] = useState<boolean>();

const supportGov = useMemo(() => GOVERNANCE_CHAINS.includes(account?.genesisHash ?? ''), [account?.genesisHash]);

const handleOpen = useCallback(() => setQuickActionOpen(String(address)), [address, setQuickActionOpen]);
const handleClose = useCallback(() => quickActionOpen === address && setQuickActionOpen(undefined), [address, quickActionOpen, setQuickActionOpen]);

Expand Down Expand Up @@ -76,12 +78,14 @@ export default function QuickActionFullScreen ({ address, assetId, containerRef,
});
}, [account?.genesisHash, address, history]);

const goToGovernanceOrHistory = useCallback(() => {
GOVERNANCE_CHAINS.includes(account?.genesisHash ?? '')
? windowOpen(`/governance/${address}/referenda`).catch(console.error)
: setShowHistory(true);
const goToGovernance = useCallback(() => {
supportGov && windowOpen(`/governance/${address}/referenda`).catch(console.error);
}, [account?.genesisHash, address]);

const goToHistory = useCallback(() => {
setShowHistory(true);
}, []);

const nullF = useCallback(() => null, []);

const isSlideOpen = quickActionOpen === address;
Expand Down Expand Up @@ -165,6 +169,22 @@ export default function QuickActionFullScreen ({ address, assetId, containerRef,
onClick={goToCrowdLoans}
title={t('Crowdloans')}
/>
<QuickActionButton
disabled={!account?.genesisHash || !supportGov}
divider
icon={
<FontAwesomeIcon
color={
supportGov
? theme.palette.text.primary
: theme.palette.action.disabledBackground
}
icon={faVoteYea}
style={{ height: ACTION_ICON_SIZE }}
/>}
onClick={goToGovernance}
title={t('Governance')}
/>
<QuickActionButton
disabled={!account?.genesisHash}
icon={
Expand All @@ -174,11 +194,11 @@ export default function QuickActionFullScreen ({ address, assetId, containerRef,
? theme.palette.text.primary
: theme.palette.action.disabledBackground
}
icon={GOVERNANCE_CHAINS.includes(account?.genesisHash ?? '') ? faVoteYea : faHistory}
icon={faHistory}
style={{ height: ACTION_ICON_SIZE }}
/>}
onClick={goToGovernanceOrHistory}
title={t<string>(GOVERNANCE_CHAINS.includes(account?.genesisHash ?? '') ? 'Governance' : 'History')}
onClick={goToHistory}
title={t('History')}
/>
</Grid>
);
Expand Down

0 comments on commit 7ae6f6d

Please sign in to comment.