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

Implement the new search - Closes #1774 #1813 #1864

Merged
merged 43 commits into from Apr 15, 2019
Merged
Show file tree
Hide file tree
Changes from 38 commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
b0a1ad0
:recycle: Implement new searchBar component
Mar 21, 2019
4ed9c89
:recycle: Update topBar component for replacement of new search button
Mar 22, 2019
21ce90e
:recycle: Add new design for search bar component
Mar 26, 2019
7c390ba
:recycle: Update search bar component to use the new design, unit tes…
Mar 26, 2019
6bd684c
:recycle: Fix topBar unit test
Mar 28, 2019
66e7db2
:recycle: Update e2e test for search bar
Mar 29, 2019
a3bae22
:recycle: Update e2e test for search component
Apr 1, 2019
941a877
Merge branch '1.15.0' into 1774-implement-the-new-search
Apr 1, 2019
0e84485
:recycle: Update files after rebase
Apr 1, 2019
37697e1
:recycle: Update filters unit test
Apr 1, 2019
2420964
:recycle: Update search code after code review
Apr 1, 2019
2babf83
:recycle: Update e2e test after rebase
Apr 1, 2019
daacd1b
:white_check_mark: Update e2e search test
Apr 2, 2019
db57b90
:recycle: Update search e2e test
Apr 3, 2019
019ca96
:recycle: Recycle search e2e
Apr 3, 2019
856c601
Merge branch '1.15.0' into 1774-implement-the-new-search
Apr 4, 2019
848ecaa
Merge branch '1.15.0' into 1774-implement-the-new-search
Apr 4, 2019
1305ce2
:white_check_mark: Update search and activity e2e test, remove unused…
Apr 5, 2019
55816bc
:nail_care: Update css for searchBar
Apr 5, 2019
3fc9bbc
:recycle: Update search component amount display
Apr 8, 2019
9bc6a94
:recycle: Resolve merge conflicts
Apr 8, 2019
8b78461
:recycle: Resolve merge conflicts
Apr 9, 2019
b0025b2
Merge branch '1.16.0' into 1774-implement-the-new-search
Apr 9, 2019
4b8e9a1
:white_check_mark: Update txDetails.spec.js file to wait for the tran…
Apr 9, 2019
ccc51c8
Merge branch '1774-implement-the-new-search' of github.com:LiskHQ/lis…
Apr 9, 2019
8cb53ff
:recycle: Apply fix txDetails.spec.js file
Apr 9, 2019
65229cf
:recycle: Update txDetails E2E file
Apr 9, 2019
38232c9
:recycle: Update search bar to use key up and key down arrows on list…
Apr 9, 2019
185c65b
:recycle: Update searchBar to use mouse hover too
Apr 10, 2019
5b25599
:recycle: Fix merge conflicts
Apr 10, 2019
4c95446
:white_check_mark: Adjust e2e txDetail test to use correct transctions
massao Apr 10, 2019
f80922d
:recycle: Update topBar component after code review
Apr 10, 2019
e5d6f3d
Merge branch '1.16.0' into 1774-implement-the-new-search
Apr 11, 2019
466e7b7
:recycle: Fix merge conflicts
Apr 11, 2019
3bdd8e8
:recycle: Update account and transaction components on SearchV2 after…
Apr 11, 2019
7ec28e8
:recycle: Fix missing , on test file
Apr 11, 2019
c0887cb
:recycle: Update search E2E test
Apr 11, 2019
ee2f040
:recycle: Update search component after QA review
Apr 12, 2019
cc14f59
:recycle: Update extra.spec.js file enable 'Navigation buttons' test
Apr 12, 2019
1d36a65
:recycle: Enable onboarding E2E tests on help.spec.js file
Apr 12, 2019
0b34965
:recycle: Update search.spec.js file to make assertions properly
Apr 12, 2019
32c115e
:recycle: Remove duplicated assert
Apr 12, 2019
b434712
:recycle: Remove unnecessary comments from search.spec.js file
Apr 12, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions i18n/locales/en/common.json
Expand Up @@ -18,6 +18,7 @@
"Account Name": "Account Name",
"Account bookmarked": "Account bookmarked",
"Account initialization": "Account initialization",
"Accounts": "Accounts",
"Accounts on Ledger": "Accounts on Ledger",
"Action Denied by User": "Action Denied by User",
"Active": "Active",
Expand Down Expand Up @@ -301,6 +302,7 @@
"No newsfeed available": "No newsfeed available",
"No results": "No results",
"No results found": "No results found",
"No results found.": "No results found.",
"No transactions yet": "No transactions yet",
"No, thanks": "No, thanks",
"Not Yet Implemented. Sorry.": "Not Yet Implemented. Sorry.",
Expand Down Expand Up @@ -380,6 +382,7 @@
"Save your passphrase on an encrypted hard drive.": "Save your passphrase on an encrypted hard drive.",
"Scan this QR code using the Lisk Mobile app to access your Lisk account.": "Scan this QR code using the Lisk Mobile app to access your Lisk account.",
"Search": "Search",
"Search for Address, Transaction ID or Delegate name": "Search for Address, Transaction ID or Delegate name",
"Search for Lisk ID, Delegate or Transaction ID": "Search for Lisk ID, Delegate or Transaction ID",
"Search for a delegate": "Search for a delegate",
"Search for answers in our extensive ": "Search for answers in our extensive ",
Expand Down Expand Up @@ -482,11 +485,13 @@
"Transaction not found": "Transaction not found",
"Transaction submitted": "Transaction submitted",
"Transaction summary": "Transaction summary",
"Transactions": "Transactions",
"Transactions can’t be reversed": "Transactions can’t be reversed",
"Transfer Transaction": "Transfer Transaction",
"Try Again": "Try Again",
"Try again": "Try again",
"Try using menu for navigation.": "Try using menu for navigation.",
"Type": "Type",
"Type at least 3 characters": "Type at least 3 characters",
"Unable to connect to the node": "Unable to connect to the node",
"Unable to connect to the node, no response from the server.": "Unable to connect to the node, no response from the server.",
Expand All @@ -510,6 +515,7 @@
"Visit Help Center": "Visit Help Center",
"Visit Lisk.Chat": "Visit Lisk.Chat",
"Vote Transaction": "Vote Transaction",
"Vote Weights": "Vote Weights",
"Vote weight": "Vote weight",
"Vote_verb": "Vote",
"Voted": "Voted",
Expand Down
9 changes: 5 additions & 4 deletions src/actions/search.js
Expand Up @@ -206,13 +206,14 @@ export const searchMoreTransactions = ({
});
};

export const clearSearchSuggestions = () => ({
data: {},
type: actionTypes.searchClearSuggestions,
});

export const searchSuggestions = ({ searchTerm }) =>
(dispatch, getState) => {
const liskAPIClient = getState().peers.liskAPIClient;
dispatch({
data: {},
type: actionTypes.searchClearSuggestions,
});
searchAll({ liskAPIClient, searchTerm }).then(response => dispatch({
data: response,
type: actionTypes.searchSuggestions,
Expand Down
4 changes: 0 additions & 4 deletions src/actions/search.test.js
Expand Up @@ -42,10 +42,6 @@ describe('actions: search', () => {
const action = searchSuggestions(data);
await action(dispatch, getState);
expect(dispatch).toHaveBeenNthCalledWith(1, {
data: {},
type: actionTypes.searchClearSuggestions,
});
expect(dispatch).toHaveBeenNthCalledWith(2, {
data: {},
type: actionTypes.searchSuggestions,
});
Expand Down
11 changes: 11 additions & 0 deletions src/assets/images/icons-v2/icon_delegate_vote.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions src/assets/images/icons-v2/icon_transaction.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions src/assets/images/icons-v2/search-icon-active.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions src/assets/images/icons-v2/search-icon-inactive.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/components/app/variablesV2.css
Expand Up @@ -60,6 +60,7 @@ or "warn/action" ineastd of "red/green"
--button-font-size: var(--paragraph-font-size-s);
--button-font-size-s: 12px;
--footnote-font-size: 12px;
--font-size-extra-small: 11px;
--font-size-title: 18px;
--font-size-small-secondary: 13px;

Expand Down
61 changes: 61 additions & 0 deletions src/components/searchBarV2/accounts.js
@@ -0,0 +1,61 @@
import React, { Fragment } from 'react';
import AccountVisual from '../accountVisual';
import LiskAmount from '../liskAmount';
import styles from './accountsAndDeletegates.css';

const Accounts = ({
accounts, onSelectedRow, t, rowItemIndex, updateRowItemIndex,
}) => {
const isDelegate = accounts.some(account => account.delegate);

return (
<div className={`${styles.wrapper} accounts`}>
<header className={`${styles.header} accounts-header`}>
<label>{t('Accounts')}</label>
<div className={`${styles.subTitles} accounts-subtitle`}>
<label>{t('Address')}</label>
<label>{t('Balance')}</label>
</div>
</header>
<div className={`${styles.content} account-content`}>
{
accounts.map((account, index) => (
<div
key={index}
className={`${styles.accountRow} ${rowItemIndex === index ? styles.active : ''} account-row`}
onClick={() => onSelectedRow(account.address, 'account')}
onMouseEnter={/* istanbul ignore next */ () => updateRowItemIndex(index)}
>
<AccountVisual address={account.address} size={30} />
<div className={styles.accountInformation}>
{
isDelegate
? <Fragment>
<div>
<span className={`${styles.accountTitle} account-title`}>
{account.delegate.username}
</span>
<span className={`${styles.tag} tag`}>
{`#${account.delegate.rank} ${t('Delegate')}`}
</span>
</div>
<span className={styles.accountSubtitle}>{account.address}</span>
</Fragment>
: <span className={`${styles.accountTitle} account-title`}>
{account.address}
</span>
}
</div>
<span className={styles.accountBalance}>
<LiskAmount val={account.balance} />
<span>{t(' LSK')}</span>
</span>
</div>
))
}
</div>
</div>
);
};

export default Accounts;
84 changes: 84 additions & 0 deletions src/components/searchBarV2/accounts.test.js
@@ -0,0 +1,84 @@
import React from 'react';
import { mount } from 'enzyme';
import Accounts from './accounts';

describe('Accounts', () => {
let wrapper;

const props = {
t: v => v,
accounts: [],
onSelectedRow: jest.fn(),
rowItemIndex: 0,
updateRowItemIndex: jest.fn(),
};

beforeEach(() => {
wrapper = mount(<Accounts {...props} />);
});

it('should render properly empty accounts', () => {
expect(wrapper).toContainMatchingElement('.accounts');
expect(wrapper).toContainMatchingElement('.accounts-header');
expect(wrapper).toContainMatchingElement('.accounts-subtitle');
expect(wrapper).toContainMatchingElement('.account-content');
expect(wrapper).not.toContainMatchingElement('.account-row');
});

it('should render properly delegate accounts', () => {
const newProps = { ...props };
newProps.accounts = [
{
address: '12345234236L',
balance: '120',
delegate: {
rank: 34,
username: 'genesis_51',
},
},
];
wrapper = mount(<Accounts {...newProps} />);
expect(wrapper).toContainMatchingElement('.accounts');
expect(wrapper).toContainMatchingElement('.accounts-header');
expect(wrapper).toContainMatchingElement('.accounts-subtitle');
expect(wrapper).toContainMatchingElement('.account-content');
expect(wrapper).toContainMatchingElement('.tag');
});

it('should render properly with accounts data', () => {
const newProps = { ...props };
newProps.accounts = [
{
address: '123456L',
title: 'John',
balance: '120',
},
{
address: '12345234L',
title: 'Anna',
balance: '110',
},
];
wrapper = mount(<Accounts {...newProps} />);

expect(wrapper).toContainMatchingElement('.accounts');
expect(wrapper).toContainMatchingElement('.accounts-header');
expect(wrapper).toContainMatchingElement('.accounts-subtitle');
expect(wrapper).toContainMatchingElement('.account-content');
expect(wrapper).toContainMatchingElement('.account-row');
});

it('should call onClick function on selected row', () => {
const newProps = { ...props };
newProps.accounts = [
{
address: '123456L',
balance: '120',
},
];
wrapper = mount(<Accounts {...newProps} />);

wrapper.find('.account-row').at(0).simulate('click');
expect(props.onSelectedRow).toBeCalled();
});
});
122 changes: 122 additions & 0 deletions src/components/searchBarV2/accountsAndDeletegates.css
@@ -0,0 +1,122 @@
@import '../app/variablesV2.css';

.wrapper {
width: 100%;
height: auto;
box-sizing: border-box;
display: flex;
flex-direction: column;
justify-content: center;
align-items: flex-start;
margin-top: 20px;
}

.header {
width: 100%;
height: 100%;
box-sizing: border-box;
display: flex;
flex-direction: column;
justify-content: center;
align-items: flex-start;

& > label {
@mixin contentNormal bold;
}
}

.subTitles {
width: 100%;
height: auto;
box-sizing: border-box;
display: flex;
justify-content: space-between;
align-items: center;
padding: 10px 0;

& > label {
@mixin contentNormal bold;

color: var(--color-blue-gray);
}
}

.content {
width: calc(100% + 40px);
height: auto;
max-height: 220px;
box-sizing: border-box;
display: flex;
flex-direction: column;
justify-content: flex-start;
align-items: flex-start;
margin: 0 -20px;

& .accountRow {
width: 100%;
height: auto;
min-height: 53px;
padding: 5px 20px;
box-sizing: border-box;
display: flex;
justify-content: flex-start;
align-items: center;
cursor: pointer;

&:hover {
background-color: var(--primary-background-color);
}
}

& .accountInformation {
height: auto;
display: flex;
flex-direction: column;
justify-content: center;
align-items: flex-start;
margin-left: 20px;
box-sizing: border-box;

& > div {
display: flex;
justify-content: center;
align-items: flex-start;
}
}

& .tag {
@mixin contentSmall bold;

background: var(--color-slate-gray);
color: var(--color-white);
padding: 3px;
box-sizing: border-box;
margin-left: 7px;
border-radius: 3px;
line-height: unset;
}

& .accountTitle {
@mixin headingSmall;

color: var(--color-maastricht-blue);
}

& .accountSubtitle {
@mixin contentSmallest;

color: var(--color-slate-gray);
padding-top: 5px;
}

& .accountBalance {
@mixin contentSmallest;

color: var(--color-maastricht-blue);
margin-left: auto;
}
}

.active {
background-color: var(--primary-background-color);
}