From 14fe1d82ebfb7ece6cae1020c6c558873833675a Mon Sep 17 00:00:00 2001 From: slowbackspace Date: Thu, 2 May 2019 14:00:24 +0200 Subject: [PATCH] change notification prop type to variant --- src/actions/DiscoveryActions.js | 4 +-- src/actions/ImportAccountActions.js | 6 ++--- src/actions/NotificationActions.js | 2 +- src/actions/ReceiveActions.js | 2 +- src/actions/SelectedAccountActions.js | 4 +++ src/actions/SignVerifyActions.js | 6 ++--- src/actions/TrezorConnectActions.js | 3 ++- src/actions/ethereum/SendFormActions.js | 6 ++--- src/actions/ripple/SendFormActions.js | 6 ++--- .../App/components/NoBackup/index.js | 2 +- .../App/components/OnlineStatus/index.js | 2 +- .../App/components/UpdateBridge/index.js | 2 +- .../App/components/UpdateFirmware/index.js | 2 +- .../Context/components/Account/index.js | 4 +-- .../components/Group/index.js | 12 ++++----- .../components/NotificationsGroups/index.js | 27 ++++++++++--------- .../Context/components/Static/index.js | 6 ++--- src/reducers/NotificationReducer.js | 4 +-- src/reducers/SelectedAccountReducer.js | 2 +- .../components/InitializationError/index.js | 2 +- src/views/Wallet/views/Acquire/index.js | 2 +- .../Wallet/views/UnreadableDevice/index.js | 2 +- 22 files changed, 58 insertions(+), 50 deletions(-) diff --git a/src/actions/DiscoveryActions.js b/src/actions/DiscoveryActions.js index d61f2085..154de83c 100644 --- a/src/actions/DiscoveryActions.js +++ b/src/actions/DiscoveryActions.js @@ -175,7 +175,7 @@ const begin = (device: TrezorDevice, networkName: string): AsyncAction => async dispatch({ type: NOTIFICATION.ADD, payload: { - type: 'error', + variant: 'error', title: 'Discovery error', message: error.message, cancelable: true, @@ -263,7 +263,7 @@ const discoverAccount = (device: TrezorDevice, discoveryProcess: Discovery): Asy dispatch({ type: NOTIFICATION.ADD, payload: { - type: 'error', + variant: 'error', title: 'Account discovery error', message: error.message, cancelable: true, diff --git a/src/actions/ImportAccountActions.js b/src/actions/ImportAccountActions.js index 5e673f60..91a16277 100644 --- a/src/actions/ImportAccountActions.js +++ b/src/actions/ImportAccountActions.js @@ -80,7 +80,7 @@ export const importAddress = ( dispatch({ type: NOTIFICATION.ADD, payload: { - type: 'success', + variant: 'success', title: 'The account has been successfully imported', cancelable: true, }, @@ -132,7 +132,7 @@ export const importAddress = ( dispatch({ type: NOTIFICATION.ADD, payload: { - type: 'success', + variant: 'success', title: 'The account has been successfully imported', cancelable: true, }, @@ -147,7 +147,7 @@ export const importAddress = ( dispatch({ type: NOTIFICATION.ADD, payload: { - type: 'error', + variant: 'error', title: 'Import account error', message: error.message, cancelable: true, diff --git a/src/actions/NotificationActions.js b/src/actions/NotificationActions.js index 48e2706e..35ea0c18 100644 --- a/src/actions/NotificationActions.js +++ b/src/actions/NotificationActions.js @@ -9,7 +9,7 @@ export type NotificationAction = | { type: typeof NOTIFICATION.ADD, payload: { - +type: string, + +variant: string, +title: React.Node | string, +message?: ?(React.Node | string), +cancelable: boolean, diff --git a/src/actions/ReceiveActions.js b/src/actions/ReceiveActions.js index 867f7e2a..bbb5d247 100644 --- a/src/actions/ReceiveActions.js +++ b/src/actions/ReceiveActions.js @@ -111,7 +111,7 @@ export const showAddress = (path: Array): AsyncAction => async ( dispatch({ type: NOTIFICATION.ADD, payload: { - type: 'error', + variant: 'error', title: 'Verifying address error', message: response.payload.error, cancelable: true, diff --git a/src/actions/SelectedAccountActions.js b/src/actions/SelectedAccountActions.js index 75ef722d..a0459b9f 100644 --- a/src/actions/SelectedAccountActions.js +++ b/src/actions/SelectedAccountActions.js @@ -139,6 +139,7 @@ const getAccountNotification = ( if (blockchain && !blockchain.connected) { return { type: 'backend', + variant: 'error', title: `${network.name} backend is not connected`, shouldRender: false, }; @@ -148,6 +149,7 @@ const getAccountNotification = ( if (account && discovery && !discovery.completed && !discovery.waitingForDevice) { return { type: 'info', + variant: 'info', title: 'Loading other accounts...', shouldRender: true, }; @@ -157,6 +159,7 @@ const getAccountNotification = ( if (!device.connected) { return { type: 'info', + variant: 'info', title: `Device ${device.instanceLabel} is disconnected`, shouldRender: true, }; @@ -167,6 +170,7 @@ const getAccountNotification = ( if (!device.available) { return { type: 'info', + variant: 'info', title: `Device ${device.instanceLabel} is unavailable`, message: 'Change passphrase settings to use this device', shouldRender: true, diff --git a/src/actions/SignVerifyActions.js b/src/actions/SignVerifyActions.js index 8fc3982f..ecfe784b 100644 --- a/src/actions/SignVerifyActions.js +++ b/src/actions/SignVerifyActions.js @@ -64,7 +64,7 @@ const sign = (path: Array, message: string, hex: boolean = false): Async dispatch({ type: NOTIFICATION.ADD, payload: { - type: 'error', + variant: 'error', title: 'Sign error', message: response.payload.error, cancelable: true, @@ -109,7 +109,7 @@ const verify = ( dispatch({ type: NOTIFICATION.ADD, payload: { - type: 'success', + variant: 'success', title: 'Verify success', message: 'signature is valid', cancelable: true, @@ -119,7 +119,7 @@ const verify = ( dispatch({ type: NOTIFICATION.ADD, payload: { - type: 'error', + variant: 'error', title: 'Verify error', message: response.payload.error, cancelable: true, diff --git a/src/actions/TrezorConnectActions.js b/src/actions/TrezorConnectActions.js index 0b5ce5f2..bfa52881 100644 --- a/src/actions/TrezorConnectActions.js +++ b/src/actions/TrezorConnectActions.js @@ -263,7 +263,7 @@ export const authorizeDevice = (): AsyncAction => async ( type: NOTIFICATION.ADD, payload: { devicePath: selected.path, - type: 'error', + variant: 'error', title: 'Authentication error', message: response.payload.error, cancelable: false, @@ -350,6 +350,7 @@ export function acquire(): AsyncAction { type: NOTIFICATION.ADD, payload: { type: 'error', + variant: 'error', title: 'Acquire device error', message: response.payload.error, cancelable: true, diff --git a/src/actions/ethereum/SendFormActions.js b/src/actions/ethereum/SendFormActions.js index c1983404..094a9158 100644 --- a/src/actions/ethereum/SendFormActions.js +++ b/src/actions/ethereum/SendFormActions.js @@ -716,7 +716,7 @@ export const onSend = (): AsyncAction => async ( dispatch({ type: NOTIFICATION.ADD, payload: { - type: 'error', + variant: 'error', title: 'Transaction error', message: signedTransaction.payload.error, cancelable: true, @@ -806,7 +806,7 @@ export const onSend = (): AsyncAction => async ( dispatch({ type: NOTIFICATION.ADD, payload: { - type: 'success', + variant: 'success', title: 'Transaction success', message: ( @@ -821,7 +821,7 @@ export const onSend = (): AsyncAction => async ( dispatch({ type: NOTIFICATION.ADD, payload: { - type: 'error', + variant: 'error', title: 'Transaction error', message: error.message || error, cancelable: true, diff --git a/src/actions/ripple/SendFormActions.js b/src/actions/ripple/SendFormActions.js index 41c34fdc..302d0051 100644 --- a/src/actions/ripple/SendFormActions.js +++ b/src/actions/ripple/SendFormActions.js @@ -454,7 +454,7 @@ export const onSend = (): AsyncAction => async ( dispatch({ type: NOTIFICATION.ADD, payload: { - type: 'error', + variant: 'error', title: 'Transaction error', message: signedTransaction.payload.error, cancelable: true, @@ -473,7 +473,7 @@ export const onSend = (): AsyncAction => async ( dispatch({ type: NOTIFICATION.ADD, payload: { - type: 'error', + variant: 'error', title: 'Transaction error', message: push.payload.error, cancelable: true, @@ -496,7 +496,7 @@ export const onSend = (): AsyncAction => async ( dispatch({ type: NOTIFICATION.ADD, payload: { - type: 'success', + variant: 'success', title: 'Transaction success', message: txid, cancelable: true, diff --git a/src/components/notifications/App/components/NoBackup/index.js b/src/components/notifications/App/components/NoBackup/index.js index bbe7ffb1..6d6846d3 100644 --- a/src/components/notifications/App/components/NoBackup/index.js +++ b/src/components/notifications/App/components/NoBackup/index.js @@ -13,7 +13,7 @@ export default (props: Props) => { return ( } message={} actions={[ diff --git a/src/components/notifications/App/components/OnlineStatus/index.js b/src/components/notifications/App/components/OnlineStatus/index.js index 529c40a1..5002ee67 100644 --- a/src/components/notifications/App/components/OnlineStatus/index.js +++ b/src/components/notifications/App/components/OnlineStatus/index.js @@ -11,7 +11,7 @@ export default (props: Props) => { return ( diff --git a/src/components/notifications/App/components/UpdateBridge/index.js b/src/components/notifications/App/components/UpdateBridge/index.js index d5bb1131..1e451bd1 100644 --- a/src/components/notifications/App/components/UpdateBridge/index.js +++ b/src/components/notifications/App/components/UpdateBridge/index.js @@ -11,7 +11,7 @@ export default (props: Props) => { return ( { return ( { // TODO: this is a different component with "auto resolve" button return ( { } return ( diff --git a/src/components/notifications/Context/components/Action/components/NotificationsGroups/components/Group/index.js b/src/components/notifications/Context/components/Action/components/NotificationsGroups/components/Group/index.js index 8f5e135c..db6dde68 100644 --- a/src/components/notifications/Context/components/Action/components/NotificationsGroups/components/Group/index.js +++ b/src/components/notifications/Context/components/Action/components/NotificationsGroups/components/Group/index.js @@ -65,17 +65,17 @@ class Group extends PureComponent { }; render() { - const { type, groupNotifications, close } = this.props; - const color = getPrimaryColor(type); + const { variant, groupNotifications, close } = this.props; + const color = getPrimaryColor(variant); return ( {groupNotifications.length > 1 && (
- + {groupNotifications.length}{' '} - {groupNotifications.length > 1 ? `${type}s` : type} + {groupNotifications.length > 1 ? `${variant}s` : variant} @@ -93,7 +93,7 @@ class Group extends PureComponent { {groupNotifications.slice(0, this.state.visibleCount).map(notification => ( notifications.reduce((acc, obj) => { - const key = obj.type; + const key = obj.variant; if (!acc[key]) { acc[key] = []; } @@ -20,6 +20,7 @@ class NotificationsGroup extends PureComponent { }, {}); sortByPriority(notifications) { + //TODO return notifications; } @@ -29,51 +30,53 @@ class NotificationsGroup extends PureComponent { // { // key: 1, // title: 'this is a title of error notification', - // type: 'error', + // variant: 'error', // message: 'this is a message of error notification', // }, // { // key: 2, // title: 'this is a title of warning notification', - // type: 'warning', + // variant: 'warning', // message: 'this is a message of warning notification', // }, // { // key: 3, // title: 'this is a title of warning notification', - // type: 'warning', + // variant: 'warning', // message: 'this is a message of warning notification', // }, // { // key: 4, // title: 'this is a title of warning notification sds d', - // type: 'warning', + // variant: 'warning', // message: 'this is a message of warning notification', // }, // { // key: 5, // title: 'this is a title of warning notification as', - // type: 'success', + // variant: 'success', // }, // { // key: 6, // title: 'this is a title of warning notification as', - // type: 'info', + // variant: 'info', // message: 'this is a message of warning notification', // }, // { // key: 7, // title: 'this is a title of info notification s ', - // type: 'info', + // variant: 'info', // message: 'this is a message of info notification', - // actions: - // [{ + // actions: [ + // { // label: 'Update', // callback: 'props.routerActions.gotoBridgeUpdate', - // }], + // }, + // ], // }, // ]; const notificationGroups = this.groupNotifications(notifications); + console.log(notificationGroups); const sortedNotifications = this.sortByPriority(notificationGroups); return ( @@ -82,7 +85,7 @@ class NotificationsGroup extends PureComponent { ))} diff --git a/src/components/notifications/Context/components/Static/index.js b/src/components/notifications/Context/components/Static/index.js index d14c5aa0..fa30ff68 100644 --- a/src/components/notifications/Context/components/Static/index.js +++ b/src/components/notifications/Context/components/Static/index.js @@ -30,7 +30,7 @@ export default withRouter((props: {| ...Props, ...ContextRouter |}) => { notifications.push( } @@ -61,7 +61,7 @@ export default withRouter((props: {| ...Props, ...ContextRouter |}) => { notifications.push( @@ -72,7 +72,7 @@ export default withRouter((props: {| ...Props, ...ContextRouter |}) => { notifications.push( diff --git a/src/reducers/NotificationReducer.js b/src/reducers/NotificationReducer.js index 5e3691cc..e9275e6f 100644 --- a/src/reducers/NotificationReducer.js +++ b/src/reducers/NotificationReducer.js @@ -16,7 +16,7 @@ export type NotificationEntry = { +key: string, // React.Key +id: ?string, +devicePath: ?string, - +type: string, + +variant: string, +title: React.Node | string, +message: ?(React.Node | string), +cancelable: boolean, @@ -42,7 +42,7 @@ const addNotification = (state: State, payload: any): State => { key: new Date().getTime().toString(), id: payload.id, devicePath: payload.devicePath, - type: payload.type, + variant: payload.variant, title: payload.title, message: payload.message, cancelable: payload.cancelable, diff --git a/src/reducers/SelectedAccountReducer.js b/src/reducers/SelectedAccountReducer.js index 4ae2fa08..ee58ab0e 100644 --- a/src/reducers/SelectedAccountReducer.js +++ b/src/reducers/SelectedAccountReducer.js @@ -10,7 +10,7 @@ export type Loader = { }; export type Notification = { - type: string, + variant: string, title: string, message?: string, }; diff --git a/src/views/Landing/components/InitializationError/index.js b/src/views/Landing/components/InitializationError/index.js index bb19573f..f39bc2e9 100644 --- a/src/views/Landing/components/InitializationError/index.js +++ b/src/views/Landing/components/InitializationError/index.js @@ -13,7 +13,7 @@ const InitializationError = (props: { error: string }) => ( diff --git a/src/views/Wallet/views/Acquire/index.js b/src/views/Wallet/views/Acquire/index.js index 8e84263f..de2dede0 100644 --- a/src/views/Wallet/views/Acquire/index.js +++ b/src/views/Wallet/views/Acquire/index.js @@ -37,7 +37,7 @@ const Acquire = (props: Props) => ( (