Skip to content

Commit ebb2670

Browse files
[DDW-741] Implement Wallet sorting (#2775)
Co-authored-by: Daniel Main <daniel.main.cernhoff@icloud.com>
1 parent b13a30e commit ebb2670

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+1463
-89
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,13 @@
44

55
### Features
66

7+
- Implemented wallet sorting on sidebar menu ([PR 2775](https://github.com/input-output-hk/daedalus/pull/2775))
78
- Implemented new token picker ([PR 2787](https://github.com/input-output-hk/daedalus/pull/2787))
89

910
## 4.8.0-FC1
1011

12+
### Features
13+
1114
- Added dynamic RTS flags setting ([PR 2758](https://github.com/input-output-hk/daedalus/pull/2758/files))
1215
- Updated messages about Cardano node sync on the initial screen ([PR 2827](https://github.com/input-output-hk/daedalus/pull/2827)) ([PR 2831](https://github.com/input-output-hk/daedalus/pull/2831))
1316

jest.config.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -182,10 +182,10 @@ module.exports = {
182182
},
183183

184184
// An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation
185-
// transformIgnorePatterns: [
186-
// "/node_modules/",
187-
// "\\.pnp\\.[^\\/]+$"
188-
// ],
185+
transformIgnorePatterns: [
186+
'node_modules/(?!react-polymorph)',
187+
// "\\.pnp\\.[^\\/]+$"
188+
],
189189

190190
// An array of regexp pattern strings that are matched against all modules before the module loader will automatically return a mock for them
191191
// unmockedModulePathPatterns: undefined,

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,9 +205,11 @@
205205
"fireworks-js": "1.0.4",
206206
"form-data": "3.0.0",
207207
"fs-extra": "9.0.1",
208+
"fuse.js": "6.5.3",
208209
"glob": "7.1.6",
209210
"graceful-fs": "4.2.4",
210211
"gulp": "4.0.2",
212+
"highlight-words": "1.2.0",
211213
"history": "4.10.1",
212214
"humanize-duration": "3.23.1",
213215
"inquirer": "7.3.3",

source/renderer/app/actions/sidebar-actions.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// @flow
2+
23
import Action from './lib/Action';
34

45
// ======= SIDEBAR ACTIONS =======
Lines changed: 15 additions & 0 deletions
Loading

source/renderer/app/components/sidebar/Sidebar.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,16 @@ const Sidebar = ({
7979
<SidebarWalletsMenu
8080
wallets={menus?.wallets?.items || []}
8181
onAddWallet={onAddWallet}
82-
onWalletItemClick={menus?.wallets?.actions?.onWalletItemClick}
82+
onWalletItemClick={menus?.wallets?.actions.onWalletItemClick}
8383
isActiveWallet={(id) => id === menus?.wallets?.activeWalletId}
8484
isAddWalletButtonActive={pathname === ROUTES.WALLETS.ADD}
8585
isShelleyActivated={isShelleyActivated}
8686
visible={isShowingSubMenus}
87+
onWalletSortBy={menus?.wallets?.actions.onWalletSortBy}
88+
sortBy={menus?.wallets?.walletSortConfig?.sortBy}
89+
sortOrder={menus?.wallets?.walletSortConfig?.sortOrder}
90+
searchValue={menus?.wallets?.searchValue}
91+
onSearch={menus?.wallets?.actions.onSearch}
8792
/>
8893
)}
8994
</div>

source/renderer/app/components/sidebar/SidebarMenu.scss

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,6 @@
1010
}
1111

1212
.visible {
13-
display: block;
13+
display: flex;
14+
flex-direction: column;
1415
}

source/renderer/app/components/sidebar/types.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,25 @@
11
// @flow
2-
import type { SidebarWalletType } from '../../types/sidebarTypes';
2+
import type {
3+
SidebarWalletType,
4+
WalletSortByOptions,
5+
WalletSortOrderOptions,
6+
WalletSortConfig,
7+
} from '../../types/sidebarTypes';
38

49
export type SidebarMenus = {
510
wallets: ?{
611
items: Array<SidebarWalletType>,
712
activeWalletId: ?string,
813
actions: {
914
onWalletItemClick: Function,
15+
onWalletSortBy: ({
16+
sortBy: WalletSortByOptions,
17+
sortOrder: WalletSortOrderOptions,
18+
}) => void,
19+
onSearch: (term: string) => void,
1020
},
21+
walletSortConfig: WalletSortConfig,
22+
searchValue: string,
1123
},
1224
};
1325

source/renderer/app/components/sidebar/wallets/SidebarWalletMenuItem.js

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import React, { Component } from 'react';
33
import { observer } from 'mobx-react';
44
import classNames from 'classnames';
5+
import highlightWords from 'highlight-words';
56
import SVGInline from 'react-svg-inline';
67
import LegacyBadge, {
78
LEGACY_BADGE_MODES,
@@ -26,6 +27,7 @@ type Props = {
2627
hasNotification: boolean,
2728
isHardwareWalletDisconnected?: boolean,
2829
isHardwareWallet: boolean,
30+
searchValue: string,
2931
};
3032

3133
@observer
@@ -45,6 +47,7 @@ export default class SidebarWalletMenuItem extends Component<Props> {
4547
hasNotification,
4648
isHardwareWalletDisconnected,
4749
isHardwareWallet,
50+
searchValue,
4851
} = this.props;
4952

5053
const showLegacyBadge = isLegacy && isShelleyActivated;
@@ -67,11 +70,29 @@ export default class SidebarWalletMenuItem extends Component<Props> {
6770
: styles.connected,
6871
]);
6972

73+
const chunks = highlightWords({
74+
text: title,
75+
query: `/(${searchValue.split('').join('|')})/i`,
76+
});
77+
7078
return (
71-
<button className={componentStyles} onClick={onClick}>
79+
<button
80+
className={componentStyles}
81+
onClick={onClick}
82+
data-testid="walletMenu"
83+
>
7284
<div className={styles.meta}>
7385
<div className={styles.topContainer}>
74-
<div className={styles.title}>{title}</div>
86+
<div className={styles.title} data-testid={title}>
87+
{chunks.map(({ text, match, key }) => (
88+
<span
89+
key={key}
90+
className={match ? styles.searchMatch : styles.searchUnmatch}
91+
>
92+
{text}
93+
</span>
94+
))}
95+
</div>
7596
{isHardwareWallet && (
7697
<div className={styles.hardwareWalletsIconWrapper}>
7798
<SVGInline svg={hardwareWalletsIcon} className={hwIconStyles} />

source/renderer/app/components/sidebar/wallets/SidebarWalletMenuItem.scss

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,14 +86,22 @@
8686
justify-content: space-between;
8787

8888
.title {
89-
color: var(--theme-sidebar-menu-item-wallet-name-color);
9089
font-family: var(--font-regular);
9190
font-size: 18px;
9291
line-height: 1.5em;
9392
margin-top: -5.5px;
9493
overflow: hidden;
9594
text-overflow: ellipsis;
9695
white-space: nowrap;
96+
97+
.searchMatch {
98+
color: var(--theme-sidebar-menu-item-wallet-name-color);
99+
}
100+
101+
.searchUnmatch {
102+
color: var(--theme-sidebar-menu-item-wallet-name-color);
103+
opacity: 0.7;
104+
}
97105
}
98106

99107
.hardwareWalletsIconWrapper {

0 commit comments

Comments
 (0)