Skip to content

Commit

Permalink
Merge pull request #1824 from oasisprotocol/lw/ledger-disabled-paratimes
Browse files Browse the repository at this point in the history
Show a link to disabled ParaTimes page on Ledger accounts
  • Loading branch information
lukaw3d committed Jan 11, 2024
2 parents 31509c8 + 7ec365a commit c933e1d
Show file tree
Hide file tree
Showing 16 changed files with 722 additions and 63 deletions.
1 change: 1 addition & 0 deletions .changelog/1824.feature.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Show a link to disabled ParaTimes page on Ledger accounts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ const renderComponent = (store: any, { walletHasAccounts, isMobile }: MobileFoot
describe('<MobileFooterNavigation />', () => {
let store: ReturnType<typeof configureAppStore>
const mockUseParaTimesNavigationResult = {
canAccessParaTimesRoute: false,
getParaTimesRoutePath: (address: string) => address,
paraTimesRouteLabel: 'MockParaTimesLabel',
} as ParaTimesNavigationHook
Expand All @@ -47,7 +46,7 @@ describe('<MobileFooterNavigation />', () => {
renderComponent(store, { walletHasAccounts: true, isMobile: true })

expect(screen.getByTestId('mobile-footer-navigation')).toBeInTheDocument()
expect(screen.queryByText('MockParaTimesLabel')).not.toBeInTheDocument()
expect(screen.queryByText('MockParaTimesLabel')).toBeInTheDocument()
})

it('should not render component for non mobile', () => {
Expand All @@ -61,15 +60,4 @@ describe('<MobileFooterNavigation />', () => {

expect(screen.queryByTestId('mobile-footer-navigation')).not.toBeInTheDocument()
})

it('should render paraTime link', () => {
jest.mocked(useParaTimesNavigation).mockReturnValue({
...mockUseParaTimesNavigationResult,
canAccessParaTimesRoute: true,
})
renderComponent(store, { walletHasAccounts: true, isMobile: true })

expect(screen.getByText('MockParaTimesLabel')).toBeInTheDocument()
expect(screen.getByLabelText('Inherit')).toBeInTheDocument()
})
})
18 changes: 7 additions & 11 deletions src/app/components/MobileFooterNavigation/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export interface MobileFooterNavigationProps {
export const MobileFooterNavigation = ({ walletHasAccounts, isMobile }: MobileFooterNavigationProps) => {
const { t } = useTranslation()
const address = useSelector(selectAddress)
const { canAccessParaTimesRoute, getParaTimesRoutePath, paraTimesRouteLabel } = useParaTimesNavigation()
const { getParaTimesRoutePath, paraTimesRouteLabel } = useParaTimesNavigation()
const getMenuItems = useMemo(() => {
const menuItems = [
{
Expand All @@ -53,15 +53,11 @@ export const MobileFooterNavigation = ({ walletHasAccounts, isMobile }: MobileFo
Icon: LineChart,
to: `/account/${address}/stake`,
},
...(canAccessParaTimesRoute
? [
{
label: paraTimesRouteLabel,
Icon: Inherit,
to: getParaTimesRoutePath(address!),
},
]
: []),
{
label: paraTimesRouteLabel,
Icon: Inherit,
to: getParaTimesRoutePath(address!),
},
...(IS_FIAT_ONRAMP_ENABLED
? [
{
Expand All @@ -73,7 +69,7 @@ export const MobileFooterNavigation = ({ walletHasAccounts, isMobile }: MobileFo
: []),
]
return menuItems
}, [address, canAccessParaTimesRoute, getParaTimesRoutePath, paraTimesRouteLabel, t])
}, [address, getParaTimesRoutePath, paraTimesRouteLabel, t])

if (!isMobile || !walletHasAccounts) {
return null
Expand Down
Loading

0 comments on commit c933e1d

Please sign in to comment.