mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-24 11:01:41 +01:00
d8179ff030
* Add UI for selecting multiple accounts on the first permissions connect screen * Make accounts list scrollable on connect screen * Change title wording on connect screen to 'select your accounts' * Add select all tooltip to info circle on top of connect screen account list * Add security info footer to the first screen of the connect flow * Apply redesigns to page 2 of connect flow * Display number of accounts on connect flow second screen if there are multiple to connect * Update e2e tests for connect screen multi-select changes * Remove unused chooseAnAcount message * Fix styling/display of redirect elements on second page of connect flow * Assorted small fixes in permissions connect * Remove unnecessary tiny delays in spec files * Remove incorrect use of bem modified in choose-account * Remove unused locale * Use Set for managing selected accounts in choose-acount and permissions-connect componets * Compone! * Move connect flow header into a reusable component, and implement new header designs * Update locales and add missing locales * Improve permission list item design (second screen of connect flow) * Check box component improvements * Fixes in variables.scss * Simplfy code in selectAll of choose-account.component * Hide checkboxes on first pages on connect flow when there is only one account * Allow autofill of default new account modal text with right arrow * Disable next button on first screen of connect flow when no accounts selected * Improve choose-account/index.scss * Remove metamask secure graphic * Fix connect flow redirect screen * Fix connectToMultiple locale * Remove locales no longer used after connect flow multiple connect updates * Fix size of dapp icon on redirect screen of connect flow * Clean up choose-account code * Stop using placeholder in new-account-modal * Remove unused styles in permission-page-container/index.scss * Pass origin instead of site name to PermissionsConnectHeader in connect flow * Make iconName a required prop in permissions-connect-header * Show checkbox in cases where there is one account in the choose-account list * Do not render select all checkbox when only 1 list item, instead of just hiding it * Small cleanup in choose-account/index.scss
103 lines
3.3 KiB
JavaScript
103 lines
3.3 KiB
JavaScript
import { connect } from 'react-redux'
|
|
import PropTypes from 'prop-types'
|
|
import PermissionApproval from './permissions-connect.component'
|
|
import {
|
|
getPermissionsRequests,
|
|
getNativeCurrency,
|
|
getAccountsWithLabels,
|
|
getLastConnectedInfo,
|
|
getPermissionsDomains,
|
|
getTargetDomainMetadata,
|
|
} from '../../selectors/selectors'
|
|
import { formatDate } from '../../helpers/utils/util'
|
|
import { approvePermissionsRequest, rejectPermissionsRequest, showModal, getCurrentWindowTab, getRequestAccountTabIds } from '../../store/actions'
|
|
import {
|
|
CONNECT_ROUTE,
|
|
CONNECT_CONFIRM_PERMISSIONS_ROUTE,
|
|
} from '../../helpers/constants/routes'
|
|
|
|
const mapStateToProps = (state, ownProps) => {
|
|
const {
|
|
match: { params: { id: permissionsRequestId } },
|
|
location: { pathname },
|
|
} = ownProps
|
|
const permissionsRequests = getPermissionsRequests(state)
|
|
|
|
const permissionsRequest = permissionsRequests
|
|
.find((permissionsRequest) => permissionsRequest.metadata.id === permissionsRequestId)
|
|
|
|
const { metadata = {} } = permissionsRequest || {}
|
|
const { origin } = metadata
|
|
const nativeCurrency = getNativeCurrency(state)
|
|
|
|
const accountsWithLabels = getAccountsWithLabels(state)
|
|
|
|
const { requestAccountTabs = {} } = state.appState
|
|
|
|
const lastConnectedInfo = getLastConnectedInfo(state) || {}
|
|
const addressLastConnectedMap = lastConnectedInfo[origin] || {}
|
|
|
|
Object.keys(addressLastConnectedMap).forEach((key) => {
|
|
addressLastConnectedMap[key] = formatDate(addressLastConnectedMap[key], 'yyyy-M-d')
|
|
})
|
|
|
|
const connectPath = `${CONNECT_ROUTE}/${permissionsRequestId}`
|
|
const confirmPermissionPath = `${CONNECT_ROUTE}/${permissionsRequestId}${CONNECT_CONFIRM_PERMISSIONS_ROUTE}`
|
|
|
|
let page = ''
|
|
if (pathname === connectPath) {
|
|
page = '1'
|
|
} else if (pathname === confirmPermissionPath) {
|
|
page = '2'
|
|
} else {
|
|
throw new Error('Incorrect path for permissions-connect component')
|
|
}
|
|
|
|
const targetDomainMetadata = getTargetDomainMetadata(state, permissionsRequest, origin)
|
|
|
|
return {
|
|
permissionsRequest,
|
|
permissionsRequestId,
|
|
accounts: accountsWithLabels,
|
|
originName: origin,
|
|
newAccountNumber: accountsWithLabels.length + 1,
|
|
nativeCurrency,
|
|
requestAccountTabs,
|
|
addressLastConnectedMap,
|
|
domains: getPermissionsDomains(state),
|
|
connectPath,
|
|
confirmPermissionPath,
|
|
page,
|
|
targetDomainMetadata,
|
|
}
|
|
}
|
|
|
|
const mapDispatchToProps = (dispatch) => {
|
|
return {
|
|
approvePermissionsRequest: (request, accounts) => dispatch(approvePermissionsRequest(request, accounts)),
|
|
rejectPermissionsRequest: (requestId) => dispatch(rejectPermissionsRequest(requestId)),
|
|
showNewAccountModal: ({ onCreateNewAccount, newAccountNumber }) => {
|
|
return dispatch(showModal({
|
|
name: 'NEW_ACCOUNT',
|
|
onCreateNewAccount,
|
|
newAccountNumber,
|
|
}))
|
|
},
|
|
getRequestAccountTabIds: () => dispatch(getRequestAccountTabIds()),
|
|
getCurrentWindowTab: () => dispatch(getCurrentWindowTab()),
|
|
}
|
|
}
|
|
|
|
const PermissionApprovalContainer = connect(mapStateToProps, mapDispatchToProps)(PermissionApproval)
|
|
|
|
PermissionApprovalContainer.propTypes = {
|
|
history: PropTypes.object.isRequired,
|
|
match: PropTypes.shape({
|
|
params: PropTypes.shape({
|
|
id: PropTypes.string,
|
|
}).isRequired,
|
|
}).isRequired,
|
|
}
|
|
|
|
export default PermissionApprovalContainer
|