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

feat: Simple pool join & call to action UI #2050

Merged
merged 99 commits into from
Apr 2, 2024
Merged
Show file tree
Hide file tree
Changes from 92 commits
Commits
Show all changes
99 commits
Select commit Hold shift + click to select a range
94473d5
some tidy up
Mar 28, 2024
bf5aada
use vLast
Mar 28, 2024
ea9e579
export types
Mar 28, 2024
a101b7c
initialization syncing by default
Mar 28, 2024
0590f9e
add `bonded-pools` syncId, check duplicates, all on by default
Mar 28, 2024
3b554d0
hide manage buttons if read only account
Mar 28, 2024
8d6ebf5
add dispatchAllDefault to SyncController
Mar 28, 2024
a1abe84
sync dispatch logic fixes
Mar 28, 2024
dca005d
active pools synced if no pool accounts
Mar 28, 2024
f423781
useSyncing wildcard by default
Mar 28, 2024
b2e4535
add new pool member ui
Mar 28, 2024
6819901
replace span with button
Mar 28, 2024
c09b2a4
fix
Mar 28, 2024
a9af1e5
update locales
Mar 29, 2024
8dafa16
init join pool canvas
Mar 29, 2024
cc92fb0
tsx -> ts
Mar 29, 2024
05c881d
some structural elements
Mar 29, 2024
55d5f4c
prepare start nominating button
Mar 29, 2024
e4d8d71
secondary section to next line
Mar 30, 2024
f5bfa7e
buttons to next line on small screens
Mar 30, 2024
7d238c6
amend note
Mar 30, 2024
05ac346
amend brightness on hover
Mar 30, 2024
3696070
transition filter
Mar 30, 2024
d882d97
add preload to CallToAction
Mar 30, 2024
6b429fa
dim rewards on inactive
Mar 30, 2024
f44d6f4
prompt border if inactive
Mar 30, 2024
161ef15
add border styling
Mar 30, 2024
c0f7e40
add input card
Mar 30, 2024
67bcdee
choose another pool
Mar 30, 2024
dcad91d
amend spacing
Mar 30, 2024
ea8b398
amend spacing
Mar 30, 2024
1bde7b0
spacing
Mar 30, 2024
060ed77
JoinForm, add pool title
Mar 30, 2024
9c060b3
tab and title boilerplate
Mar 30, 2024
87e0b6d
spacing
Mar 30, 2024
6618232
finalise header design
Mar 31, 2024
135f93d
spacing
Mar 31, 2024
31c32b7
abstract join pool Header
Mar 31, 2024
c1da47c
implement pool nominations tab
Mar 31, 2024
a629f32
pool state in header
Mar 31, 2024
6b9bc8c
overview badge styling
Mar 31, 2024
7408ac7
basic rewards
Mar 31, 2024
d9d3024
fix pending rewards race
Apr 1, 2024
09569c7
expose activePoolsRef
Apr 1, 2024
5564b2e
newline
Apr 1, 2024
0da281a
more boilerplate
Apr 1, 2024
9979e51
add pool roles, AddressSection
Apr 1, 2024
70ef03a
replace help key
Apr 1, 2024
b84199f
title fixes
Apr 1, 2024
f1d1297
plug in era points
Apr 1, 2024
ba7974b
check keys exist
Apr 1, 2024
b473e03
fetch daily active open pools
Apr 1, 2024
1119648
bring back shadow
Apr 1, 2024
bee3144
add pool bonded amount
Apr 1, 2024
c160e1e
filter currently inactive pools
Apr 1, 2024
89d8dd7
theming
Apr 1, 2024
0bc6e92
fix unwanted re-renders
Apr 1, 2024
af944fa
PerformanceGraph
Apr 1, 2024
4060cab
make graph responsive
Apr 1, 2024
5b00914
make design responsive
Apr 1, 2024
f49e8e9
adjust theme
Apr 1, 2024
8045263
styling, remove help button
Apr 1, 2024
6db8c5d
styling
Apr 1, 2024
5e44258
remove help
Apr 1, 2024
3ee1b0c
remove unused hook
Apr 1, 2024
aabd16f
amend text
Apr 1, 2024
fa72c18
graph spacing
Apr 1, 2024
b647ff0
add autoSelect badge
Apr 1, 2024
21526f5
fix margin
Apr 1, 2024
12e26e5
optimise mobile ordering
Apr 1, 2024
faf4141
use secondary
Apr 1, 2024
cbb0c8a
misc fixes
Apr 2, 2024
c620c2a
displayFirstWarningOnly to bond inputs
Apr 2, 2024
a1c5af5
support `card` DisplayFor
Apr 2, 2024
e6fde89
put extrinsic & SubmitTx in JoinForm
Apr 2, 2024
1c5d16b
separate signer from tx styling
Apr 2, 2024
7434bb1
add disabled styling
Apr 2, 2024
dbdf8d2
add card SubmitTx form factor
Apr 2, 2024
cfdc778
deprecate JoinPool modal
Apr 2, 2024
3e9713b
Merge branch 'main' into rb-simple-pool-join
Apr 2, 2024
e53c93e
fix Header & random selection
Apr 2, 2024
bca14bb
amend nominations types
Apr 2, 2024
272f915
address section props
Apr 2, 2024
179f191
various tidy ups
Apr 2, 2024
ab8b535
minify props
Apr 2, 2024
511eb00
wrapper adjustments
Apr 2, 2024
b74b579
move targets to Nominations tab
Apr 2, 2024
d651355
ensure all membership properties exist
Apr 2, 2024
1c9ddcc
lint
Apr 2, 2024
e7059a5
remove space
Apr 2, 2024
718c0ee
claim permission input tidy up
Apr 2, 2024
efaa7e1
misc tidy up
Apr 2, 2024
f42fe73
some translations
Apr 2, 2024
acc8f48
add translations
Apr 2, 2024
77a9283
local order + translation
Apr 2, 2024
a452955
add translations
Apr 2, 2024
1d4ae77
fix key
Apr 2, 2024
7184ef9
translation
TingALin Apr 2, 2024
f8bedf9
yarn locale:order
TingALin Apr 2, 2024
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
118 changes: 118 additions & 0 deletions src/canvas/JoinPool/Header.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
// Copyright 2024 @paritytech/polkadot-staking-dashboard authors & contributors
// SPDX-License-Identifier: GPL-3.0-only

import {
faArrowsRotate,
faHashtag,
faTimes,
} from '@fortawesome/free-solid-svg-icons';
import { ButtonPrimary } from 'kits/Buttons/ButtonPrimary';
import { ButtonPrimaryInvert } from 'kits/Buttons/ButtonPrimaryInvert';
import { TitleWrapper } from './Wrappers';
import { Polkicon } from '@w3ux/react-polkicon';
import { determinePoolDisplay, remToUnit } from '@w3ux/utils';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { PageTitleTabs } from 'kits/Structure/PageTitleTabs';
import { useTranslation } from 'react-i18next';
import { useOverlay } from 'kits/Overlay/Provider';
import type { JoinPoolHeaderProps } from './types';

export const Header = ({
activeTab,
bondedPool,
filteredBondedPools,
metadata,
autoSelected,
setActiveTab,
setSelectedPoolId,
setSelectedPoolCount,
}: JoinPoolHeaderProps) => {
const { t } = useTranslation();
const { closeCanvas } = useOverlay().canvas;

// Randomly select a new pool to display.
const handleChooseNewPool = () => {
// Trigger refresh of memoied selected bonded pool.
setSelectedPoolCount((prev: number) => prev + 1);

// Randomly select a filtered bonded pool and set it as the selected pool.
const index = Math.ceil(Math.random() * filteredBondedPools.length - 1);
setSelectedPoolId(filteredBondedPools[index].id);
};

return (
<>
<div className="head">
<ButtonPrimaryInvert
text={'Choose Another Pool'}
iconLeft={faArrowsRotate}
onClick={() => handleChooseNewPool()}
lg
/>
<ButtonPrimary
text={t('cancel', { ns: 'library' })}
lg
onClick={() => closeCanvas()}
iconLeft={faTimes}
style={{ marginLeft: '1.1rem' }}
/>
</div>
<TitleWrapper>
<div className="inner">
<div>
<Polkicon
address={bondedPool?.addresses.stash || ''}
size={remToUnit('4rem')}
outerColor="transparent"
/>
</div>
<div>
<div className="title">
<h1>
{determinePoolDisplay(
bondedPool?.addresses.stash || '',
metadata
)}
</h1>
</div>
<div className="labels">
<h3>
Pool <FontAwesomeIcon icon={faHashtag} transform="shrink-2" />
{bondedPool.id}
{['Blocked', 'Destroying'].includes(bondedPool.state) && (
<span className={bondedPool.state.toLowerCase()}>
{bondedPool.state}
</span>
)}
</h3>

{autoSelected && (
<h3>
<span>Auto Selected</span>
</h3>
)}
</div>
</div>
</div>

<PageTitleTabs
sticky={false}
tabs={[
{
title: t('pools.overview', { ns: 'pages' }),
active: activeTab === 0,
onClick: () => setActiveTab(0),
},
{
title: 'Nominations',
active: activeTab === 1,
onClick: () => setActiveTab(1),
},
]}
tabClassName="canvas"
inline={true}
/>
</TitleWrapper>
</>
);
};
50 changes: 50 additions & 0 deletions src/canvas/JoinPool/Nominations/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// Copyright 2024 @paritytech/polkadot-staking-dashboard authors & contributors
// SPDX-License-Identifier: GPL-3.0-only

import { ValidatorList } from 'library/ValidatorList';
import { ListWrapper } from 'modals/PoolNominations/Wrappers';
import { useTranslation } from 'react-i18next';
import { HeadingWrapper, NominationsWrapper } from '../Wrappers';
import type { NominationsProps } from '../types';
import { useValidators } from 'contexts/Validators/ValidatorEntries';
import { useBondedPools } from 'contexts/Pools/BondedPools';

export const Nominations = ({ stash, poolId }: NominationsProps) => {
const { t } = useTranslation('modals');
const { poolsNominations } = useBondedPools();

const { validators } = useValidators();

// Extract validator entries from pool targets.
const targets = poolsNominations[poolId]?.targets || [];
const filteredTargets = validators.filter(({ address }) =>
targets.includes(address)
);

return (
<NominationsWrapper>
<HeadingWrapper>
<h3>
{targets.length} Nomination{targets.length === 1 ? '' : 's'}
</h3>
</HeadingWrapper>
<ListWrapper>
{targets.length > 0 ? (
<ValidatorList
format="nomination"
bondFor="pool"
validators={filteredTargets}
nominator={stash}
showMenu={false}
displayFor="canvas"
allowListFormat={false}
allowMoreCols={true}
refetchOnListUpdate
/>
) : (
<h3>{t('poolIsNotNominating')}</h3>
)}
</ListWrapper>
</NominationsWrapper>
);
};
45 changes: 45 additions & 0 deletions src/canvas/JoinPool/Overview/AddressSection.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// Copyright 2024 @paritytech/polkadot-staking-dashboard authors & contributors
// SPDX-License-Identifier: GPL-3.0-only

import { useHelp } from 'contexts/Help';
import { ButtonHelp } from 'kits/Buttons/ButtonHelp';
import { HeadingWrapper } from '../Wrappers';
import { Polkicon } from '@w3ux/react-polkicon';
import { CopyAddress } from 'library/ListItem/Labels/CopyAddress';
import { ellipsisFn, remToUnit } from '@w3ux/utils';
import type { AddressSectionProps } from '../types';

export const AddressSection = ({
address,
label,
helpKey,
}: AddressSectionProps) => {
const { openHelp } = useHelp();

return (
<section>
<HeadingWrapper>
<h4 className="heading">
{label}
{!!helpKey && (
<ButtonHelp marginLeft onClick={() => openHelp(helpKey)} />
)}
</h4>
</HeadingWrapper>

<div>
<span>
<Polkicon
address={address}
size={remToUnit('2.25rem')}
outerColor="transparent"
/>
</span>
<h4>
{ellipsisFn(address, 6)}
<CopyAddress address={address} />
</h4>
</div>
</section>
);
};
22 changes: 22 additions & 0 deletions src/canvas/JoinPool/Overview/Addresses.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Copyright 2024 @paritytech/polkadot-staking-dashboard authors & contributors
// SPDX-License-Identifier: GPL-3.0-only

import { CardWrapper } from 'library/Card/Wrappers';
import { AddressesWrapper, HeadingWrapper } from '../Wrappers';
import { AddressSection } from './AddressSection';
import type { OverviewSectionProps } from '../types';

export const Addresses = ({
bondedPool: { addresses },
}: OverviewSectionProps) => (
<CardWrapper className="canvas secondary">
<HeadingWrapper>
<h3>Pool Addresses</h3>
</HeadingWrapper>

<AddressesWrapper>
<AddressSection address={addresses.stash} label="Stash" />
<AddressSection address={addresses.reward} label="Reward" />
</AddressesWrapper>
</CardWrapper>
);
Loading
Loading