diff --git a/package.json b/package.json index fdcbb96fe1..7661c60d1c 100644 --- a/package.json +++ b/package.json @@ -74,6 +74,7 @@ "@polkadot/types": "12.4.2", "@polkadot/util": "13.0.2", "@polkadot/util-crypto": "13.0.2", + "@radix-ui/react-checkbox": "^1.1.2", "@radix-ui/react-dialog": "1.1.2", "@radix-ui/react-dropdown-menu": "2.1.2", "@radix-ui/react-popover": "1.1.2", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 72b29cd7ae..2640edaa95 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -35,6 +35,9 @@ importers: '@polkadot/util-crypto': specifier: 13.0.2 version: 13.0.2(@polkadot/util@13.0.2) + '@radix-ui/react-checkbox': + specifier: ^1.1.2 + version: 1.1.2(@types/react-dom@18.0.5)(@types/react@18.0.14)(react-dom@18.3.1(react@18.3.1))(react@18.3.1) '@radix-ui/react-dialog': specifier: 1.1.2 version: 1.1.2(@types/react-dom@18.0.5)(@types/react@18.0.14)(react-dom@18.3.1(react@18.3.1))(react@18.3.1) @@ -2212,6 +2215,19 @@ packages: '@types/react-dom': optional: true + '@radix-ui/react-checkbox@1.1.2': + resolution: {integrity: sha512-/i0fl686zaJbDQLNKrkCbMyDm6FQMt4jg323k7HuqitoANm9sE23Ql8yOK3Wusk34HSLKDChhMux05FnP6KUkw==} + peerDependencies: + '@types/react': '*' + '@types/react-dom': '*' + react: ^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc + react-dom: ^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc + peerDependenciesMeta: + '@types/react': + optional: true + '@types/react-dom': + optional: true + '@radix-ui/react-collection@1.1.0': resolution: {integrity: sha512-GZsZslMJEyo1VKm5L1ZJY8tGDxZNPAoUeQUIbKeJfoi7Q4kmig5AsgLMYYuyYbfjd8fBmFORAIwYAkXMnXZgZw==} peerDependencies: @@ -11411,7 +11427,7 @@ snapshots: '@types/node': 20.5.1 chalk: 4.1.2 cosmiconfig: 8.3.6(typescript@5.5.4) - cosmiconfig-typescript-loader: 4.4.0(@types/node@20.5.1)(cosmiconfig@8.3.6(typescript@5.5.4))(ts-node@10.9.2(@swc/core@1.7.35(@swc/helpers@0.5.13))(@types/node@18.19.55)(typescript@5.5.4))(typescript@5.5.4) + cosmiconfig-typescript-loader: 4.4.0(@types/node@20.5.1)(cosmiconfig@8.3.6(typescript@5.5.4))(ts-node@10.9.2(@swc/core@1.7.35(@swc/helpers@0.5.13))(@types/node@20.5.1)(typescript@5.5.4))(typescript@5.5.4) lodash.isplainobject: 4.0.6 lodash.merge: 4.6.2 lodash.uniq: 4.5.0 @@ -12704,7 +12720,7 @@ snapshots: '@polkadot/x-randomvalues@13.0.2(@polkadot/util@13.0.2)(@polkadot/wasm-util@7.3.2(@polkadot/util@13.0.2))': dependencies: '@polkadot/util': 13.0.2 - '@polkadot/wasm-util': 7.3.2(@polkadot/util@12.6.2) + '@polkadot/wasm-util': 7.3.2(@polkadot/util@13.0.2) '@polkadot/x-global': 13.0.2 tslib: 2.7.0 @@ -12759,6 +12775,22 @@ snapshots: '@types/react': 18.0.14 '@types/react-dom': 18.0.5 + '@radix-ui/react-checkbox@1.1.2(@types/react-dom@18.0.5)(@types/react@18.0.14)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)': + dependencies: + '@radix-ui/primitive': 1.1.0 + '@radix-ui/react-compose-refs': 1.1.0(@types/react@18.0.14)(react@18.3.1) + '@radix-ui/react-context': 1.1.1(@types/react@18.0.14)(react@18.3.1) + '@radix-ui/react-presence': 1.1.1(@types/react-dom@18.0.5)(@types/react@18.0.14)(react-dom@18.3.1(react@18.3.1))(react@18.3.1) + '@radix-ui/react-primitive': 2.0.0(@types/react-dom@18.0.5)(@types/react@18.0.14)(react-dom@18.3.1(react@18.3.1))(react@18.3.1) + '@radix-ui/react-use-controllable-state': 1.1.0(@types/react@18.0.14)(react@18.3.1) + '@radix-ui/react-use-previous': 1.1.0(@types/react@18.0.14)(react@18.3.1) + '@radix-ui/react-use-size': 1.1.0(@types/react@18.0.14)(react@18.3.1) + react: 18.3.1 + react-dom: 18.3.1(react@18.3.1) + optionalDependencies: + '@types/react': 18.0.14 + '@types/react-dom': 18.0.5 + '@radix-ui/react-collection@1.1.0(@types/react-dom@18.0.5)(@types/react@18.0.14)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)': dependencies: '@radix-ui/react-compose-refs': 1.1.0(@types/react@18.0.14)(react@18.3.1) @@ -15894,11 +15926,11 @@ snapshots: core-util-is@1.0.3: {} - cosmiconfig-typescript-loader@4.4.0(@types/node@20.5.1)(cosmiconfig@8.3.6(typescript@5.5.4))(ts-node@10.9.2(@swc/core@1.7.35(@swc/helpers@0.5.13))(@types/node@18.19.55)(typescript@5.5.4))(typescript@5.5.4): + cosmiconfig-typescript-loader@4.4.0(@types/node@20.5.1)(cosmiconfig@8.3.6(typescript@5.5.4))(ts-node@10.9.2(@swc/core@1.7.35(@swc/helpers@0.5.13))(@types/node@20.5.1)(typescript@5.5.4))(typescript@5.5.4): dependencies: '@types/node': 20.5.1 cosmiconfig: 8.3.6(typescript@5.5.4) - ts-node: 10.9.2(@swc/core@1.7.35(@swc/helpers@0.5.13))(@types/node@18.19.55)(typescript@5.5.4) + ts-node: 10.9.2(@swc/core@1.7.35(@swc/helpers@0.5.13))(@types/node@20.5.1)(typescript@5.5.4) typescript: 5.5.4 cosmiconfig@7.1.0: diff --git a/src/renderer/entities/governance/index.ts b/src/renderer/entities/governance/index.ts index fd90a4275c..af09c7c353 100644 --- a/src/renderer/entities/governance/index.ts +++ b/src/renderer/entities/governance/index.ts @@ -30,6 +30,7 @@ export { getGroupPallet, getTrackIds, getTreasuryTrackDescription, + getTrackTitles, } from './lib/tracksService'; export { createSubscriber } from './utils/createSubscriber'; @@ -43,6 +44,7 @@ export type { TransactionStandardVote, } from './types/voteTransaction'; export type { Track } from './types/tracks'; +export type { VotesToRemove } from './types/tracks'; export type { VoteHistoryRecord } from './model/voteHistory'; export { diff --git a/src/renderer/entities/governance/lib/tracksService.ts b/src/renderer/entities/governance/lib/tracksService.ts index e05e98ff13..73b9353a64 100644 --- a/src/renderer/entities/governance/lib/tracksService.ts +++ b/src/renderer/entities/governance/lib/tracksService.ts @@ -34,3 +34,15 @@ export const getGroupPallet = ( return tracksGroupId.length !== 0 && tracksGroupId.every((t) => tracksIds.includes(t)) ? 'primary' : 'secondary'; }; + +export const getTrackTitles = (trackIds: string[], allTracks: Track[], t: TFunction): string => { + const titles = allTracks.reduce((titles, { id, value }) => { + if (trackIds.includes(id)) { + titles.push(t(value)); + } + + return titles; + }, []); + + return titles.join(', '); +}; diff --git a/src/renderer/entities/governance/types/tracks.ts b/src/renderer/entities/governance/types/tracks.ts index 0d0d458104..1e22c542e9 100644 --- a/src/renderer/entities/governance/types/tracks.ts +++ b/src/renderer/entities/governance/types/tracks.ts @@ -1,5 +1,13 @@ +import { type Address, type ReferendumId } from '@/shared/core'; + export type Track = { id: string; value: string; description: string; }; + +export type VotesToRemove = { + referendum: ReferendumId; + track: string; + voter: Address; +}; diff --git a/src/renderer/features/governance/components/AccountsMultiSelector/AccountsMultiSelector.tsx b/src/renderer/features/governance/components/AccountsMultiSelector/AccountsMultiSelector.tsx index 392dc57cd7..5659582ff2 100644 --- a/src/renderer/features/governance/components/AccountsMultiSelector/AccountsMultiSelector.tsx +++ b/src/renderer/features/governance/components/AccountsMultiSelector/AccountsMultiSelector.tsx @@ -3,7 +3,7 @@ import { Fragment, type ReactNode, useId } from 'react'; import { useI18n } from '@/shared/i18n'; import { cnTw } from '@/shared/lib/utils'; -import { CaptionText, Checkbox, FootnoteText, Icon, LabelText } from '@/shared/ui'; +import { CaptionText, FootnoteText, Icon, LabelText } from '@/shared/ui'; import { OptionStyle, OptionStyleTheme, @@ -14,6 +14,7 @@ import { } from '@/shared/ui/Dropdowns/common/constants'; import { type DropdownResult, type Position, type Theme } from '@/shared/ui/Dropdowns/common/types'; import { CommonInputStyles, CommonInputStylesTheme } from '@/shared/ui/Inputs/common/styles'; +import { Checkbox } from '@/shared/ui-kit'; type DropdownOption = { id: string; @@ -147,7 +148,7 @@ export const AccountsMultiSelector = ({ selectedIds.includes(option.id))} semiChecked={optionsFlat.some((option) => selectedIds.includes(option.id))} - onChange={(event) => toggleAll(event.target.checked)} + onChange={(checked) => toggleAll(checked)} > {t('balances.allAccounts')} @@ -171,16 +172,15 @@ export const AccountsMultiSelector = ({ > {({ selected }) => (
- - {element} - + {element} +
+ {additionalElement} )} @@ -242,18 +242,19 @@ const Group = ({ group, selectedIds, selectedOptions, theme, onChange }: PropsGr OptionStyleTheme[theme](false, isChecked), )} > - selectedIds.includes(id))} - onChange={(event) => toggleGroup(event.target.checked)} - > -
- {list.length} -
- {groupName} - {groupValue} -
+
+ selectedIds.includes(id))} + onChange={(checked) => toggleGroup(checked)} + > +
+ {list.length} +
+ {groupName} + {groupValue} +
+