From ca05dd93cbd7fa5adc81338873fe34884154bc50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=ABck=20V=C3=A9zien?= Date: Fri, 2 Feb 2018 14:15:20 +0100 Subject: [PATCH] Add feature for rename and archive account --- src/actions/accounts.js | 6 + src/components/AccountPage.js | 10 +- src/components/DashboardPage.js | 4 +- src/components/ReceiveBox.js | 5 +- src/components/SelectAccount/index.js | 4 +- src/components/SideBar/index.js | 41 +++-- src/components/TopBar.js | 5 +- src/components/base/Button/index.js | 1 + src/components/base/Modal/index.js | 13 +- src/components/base/Modal/stories.js | 2 - src/components/modals/SettingsAccount.js | 186 +++++++++++++++++++++++ src/components/modals/index.js | 1 + src/constants.js | 1 + src/main/app.js | 3 - src/reducers/accounts.js | 20 +++ src/reducers/modals.js | 11 ++ src/styles/global.js | 10 +- src/types/common.js | 1 + 18 files changed, 266 insertions(+), 58 deletions(-) create mode 100644 src/components/modals/SettingsAccount.js diff --git a/src/actions/accounts.js b/src/actions/accounts.js index bb4b20fd..ed8da2ad 100644 --- a/src/actions/accounts.js +++ b/src/actions/accounts.js @@ -14,6 +14,12 @@ export const addAccount: AddAccount = payload => ({ payload, }) +export type EditAccount = Account => { type: string, payload: Account } +export const editAccount: AddAccount = payload => ({ + type: 'DB:EDIT_ACCOUNT', + payload, +}) + type FetchAccounts = () => { type: string } export const fetchAccounts: FetchAccounts = () => ({ type: 'FETCH_ACCOUNTS', diff --git a/src/components/AccountPage.js b/src/components/AccountPage.js index e3db5bff..649c9fbf 100644 --- a/src/components/AccountPage.js +++ b/src/components/AccountPage.js @@ -5,7 +5,7 @@ import { compose } from 'redux' import { connect } from 'react-redux' import { translate } from 'react-i18next' -import { MODAL_SEND, MODAL_RECEIVE } from 'constants' +import { MODAL_SEND, MODAL_RECEIVE, MODAL_SETTINGS_ACCOUNT } from 'constants' import type { MapStateToProps } from 'react-redux' import type { T, Account, AccountData } from 'types/common' @@ -46,7 +46,7 @@ class AccountPage extends PureComponent { - {`${account.name} account`} + {account.name} @@ -70,7 +70,11 @@ class AccountPage extends PureComponent { - + + + + + ) : ( + account.name + )} + + {!editName && + nameHovered && ( + + + + )} + + + + + + + + + + + ) + }} + /> + ) + } +} + +export default connect(null, mapDispatchToProps)(SettingsAccount) diff --git a/src/components/modals/index.js b/src/components/modals/index.js index aede545a..26754eb5 100644 --- a/src/components/modals/index.js +++ b/src/components/modals/index.js @@ -1,3 +1,4 @@ export AddAccount from './AddAccount' export Receive from './Receive' export Send from './Send' +export SettingsAccount from './SettingsAccount' diff --git a/src/constants.js b/src/constants.js index 73575ade..b776dcd7 100644 --- a/src/constants.js +++ b/src/constants.js @@ -4,3 +4,4 @@ export const SYNC_ACCOUNT_TIMEOUT = 3e3 export const MODAL_ADD_ACCOUNT = 'MODAL_ADD_ACCOUNT' export const MODAL_SEND = 'MODAL_SEND' export const MODAL_RECEIVE = 'MODAL_RECEIVE' +export const MODAL_SETTINGS_ACCOUNT = 'MODAL_SETTINGS_ACCOUNT' diff --git a/src/main/app.js b/src/main/app.js index 53dde287..438eef12 100644 --- a/src/main/app.js +++ b/src/main/app.js @@ -22,9 +22,6 @@ function createMainWindow() { width: MIN_WIDTH, minHeight: MIN_HEIGHT, minWidth: MIN_WIDTH, - webPreferences: { - blinkFeatures: 'CSSBackdropFilter', - }, } const window = new BrowserWindow(windowOptions) diff --git a/src/reducers/accounts.js b/src/reducers/accounts.js index c6cfc5d7..2ab6d4d6 100644 --- a/src/reducers/accounts.js +++ b/src/reducers/accounts.js @@ -33,6 +33,13 @@ const handlers: Object = { ...state, [account.id]: getAccount(account), }), + EDIT_ACCOUNT: (state: AccountsState, { payload: account }: { payload: Account }) => ({ + ...state, + [account.id]: { + ...state[account.id], + ...getAccount(account), + }, + }), FETCH_ACCOUNTS: (state: AccountsState, { payload: accounts }: { payload: Accounts }) => accounts, SET_ACCOUNT_DATA: ( state: AccountsState, @@ -85,6 +92,19 @@ export function getAccounts(state: { accounts: AccountsState }) { }, {}) } +export function getVisibleAccounts(state: { accounts: AccountsState }) { + const accounts = getAccounts(state) + return Object.keys(accounts).reduce((result, key) => { + const account = accounts[key] + + if (account.archived !== true) { + result[key] = account + } + + return result + }, {}) +} + export function getAccountById(state: { accounts: AccountsState }, id: string) { return getAccounts(state)[id] } diff --git a/src/reducers/modals.js b/src/reducers/modals.js index 877b32de..5d871d77 100644 --- a/src/reducers/modals.js +++ b/src/reducers/modals.js @@ -41,12 +41,23 @@ const handlers = { }, } }, + MODAL_SET_DATA: (state, { payload }: { payload: OpenPayload }) => { + const { name, data } = payload + return { + ...state, + [name]: { + ...state[name], + data, + }, + } + }, } // Actions export const openModal = createAction('MODAL_OPEN', (name, data = {}) => ({ name, data })) export const closeModal = createAction('MODAL_CLOSE', name => ({ name })) +export const setDataModal = createAction('MODAL_SET_DATA', (name, data = {}) => ({ name, data })) // Selectors diff --git a/src/styles/global.js b/src/styles/global.js index a08115d4..767e00e0 100644 --- a/src/styles/global.js +++ b/src/styles/global.js @@ -14,21 +14,17 @@ injectGlobal` font: inherit; color: inherit; user-select: none; - cursor: inherit; min-width: 0; // it will surely make problem in the future... to be inspected. flex-shrink: 0; } - html { - -ms-overflow-style: -ms-autohiding-scrollbar; - } - body { - line-height: 1.5; - font-size: 16px; + cursor: default; font-family: "Open Sans", Arial, Helvetica, sans-serif; + font-size: 16px; + line-height: 1.5; } #app { diff --git a/src/types/common.js b/src/types/common.js index 69183ecd..fe576260 100644 --- a/src/types/common.js +++ b/src/types/common.js @@ -27,6 +27,7 @@ export type AccountData = { export type Account = { id: string, + archived?: boolean, name: string, type: string, data?: AccountData,