Skip to content

Commit

Permalink
fix: fix issue with input auto-complete and validator dropdown (#1036)
Browse files Browse the repository at this point in the history
* disable auto complete for input by default

* fix e2e test

* fix e2e test

* fix UI freeze in staking
  • Loading branch information
ost-ptk authored Aug 18, 2024
1 parent 36029e0 commit 84b6721
Show file tree
Hide file tree
Showing 15 changed files with 261 additions and 177 deletions.
8 changes: 2 additions & 6 deletions e2e-tests/popup/buy-cspr/buy-cspr.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,9 @@ popup.describe('Popup UI: buy cspr', () => {
await popupPage.getByRole('button', { name: 'Next' }).click();

await popupExpect(
popupPage.getByRole('heading', { name: 'Pick provider' })
popupPage.getByRole('heading', { name: 'Review provider option' })
).toBeVisible();

await popupExpect(
popupPage.getByRole('button', { name: 'Confirm' })
).toBeDisabled();

await popupPage.getByText('Topper by Uphold').click();

await popupExpect(
Expand All @@ -47,7 +43,7 @@ popup.describe('Popup UI: buy cspr', () => {
}
);

popup(
popup.skip(
'should redirect to Ramp provider page',
async ({ popupPage, unlockVault, context }) => {
await unlockVault();
Expand Down
4 changes: 4 additions & 0 deletions e2e-tests/popup/stakes/redelagation.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ popup.describe('Popup UI: Redelegation', () => {

await popupPage.getByPlaceholder('0.00', { exact: true }).fill('500');

await popupExpect(
popupPage.getByRole('button', { name: 'Next' })
).not.toBeDisabled();

await popupPage.getByRole('button', { name: 'Next' }).click();

await popupPage.getByText('Delegate', { exact: true }).click();
Expand Down
77 changes: 75 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@
"react-query": "^3.39.3",
"react-redux": "8.0.5",
"react-router-dom": "6.16.0",
"react-virtualized": "^9.22.5",
"redux": "4.2.1",
"redux-saga": "1.2.3",
"reselect": "4.1.7",
Expand Down Expand Up @@ -123,6 +124,7 @@
"@types/node": "^20.9.0",
"@types/react": "^18.2.55",
"@types/react-dom": "^18.2.18",
"@types/react-virtualized": "^9.21.30",
"@types/styled-components": "^5.1.26",
"babel-eslint": "^10.1.0",
"babel-loader": "9.1.0",
Expand Down
1 change: 0 additions & 1 deletion src/apps/popup/pages/create-account/content.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ export function CreateAccountPageContent({
{...register('name')}
error={!!errorMessage}
validationText={errorMessage}
autoComplete="off"
autoFocus
/>
</InputsContainer>
Expand Down
83 changes: 83 additions & 0 deletions src/apps/popup/pages/stakes/components/validator-list.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
import React from 'react';
import { Trans, useTranslation } from 'react-i18next';
import AutoSizer from 'react-virtualized/dist/commonjs/AutoSizer';
import List from 'react-virtualized/dist/commonjs/List';
import styled from 'styled-components';

import {
DropdownHeader,
SpacingSize,
VerticalSpaceContainer
} from '@libs/layout';
import { ValidatorResultWithId } from '@libs/services/validators-service';
import { Tile, Typography, ValidatorPlate } from '@libs/ui/components';

interface ValidatorListProps {
filteredValidatorsList: ValidatorResultWithId[];
handleValidatorClick: (validator: ValidatorResultWithId) => void;
totalStake: 'total_stake' | 'user_stake';
}

const Container = styled.div``;

export const ValidatorList = ({
filteredValidatorsList,
handleValidatorClick,
totalStake
}: ValidatorListProps) => {
const { t } = useTranslation();

return (
<VerticalSpaceContainer top={SpacingSize.Tiny}>
<Tile borderRadius="base">
<DropdownHeader>
<Typography type="labelMedium" color="contentSecondary">
<Trans t={t}>Validator</Trans>
</Typography>
<Typography type="labelMedium" color="contentSecondary">
<Trans t={t}>Total stake, fee, delegators</Trans>
</Typography>
</DropdownHeader>
<AutoSizer disableHeight>
{({ width }) => (
<List
overscanRowCount={5}
rowHeight={64}
height={Math.min(3 * 64, filteredValidatorsList.length * 64)}
width={width}
rowCount={filteredValidatorsList.length}
rowRenderer={({ index, key, style }) => {
const validator = filteredValidatorsList[index];
const logo =
validator?.account_info?.info?.owner?.branding?.logo?.svg ||
validator?.account_info?.info?.owner?.branding?.logo
?.png_256 ||
validator?.account_info?.info?.owner?.branding?.logo
?.png_1024;

return (
<Container style={style}>
<ValidatorPlate
key={key}
publicKey={validator?.public_key}
fee={validator.fee}
name={validator?.account_info?.info?.owner?.name}
logo={logo}
// TODO: remove user_stake after we merge recipient and amount steps for undelegation
totalStake={validator[totalStake]}
delegatorsNumber={validator?.delegators_number}
handleClick={() => {
handleValidatorClick(validator);
}}
withBorder
/>
</Container>
);
}}
/>
)}
</AutoSizer>
</Tile>
</VerticalSpaceContainer>
);
};
Loading

0 comments on commit 84b6721

Please sign in to comment.