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

feat(2793): permission UI requirements from figma, avatar groups and other stuff #11827

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
594dd04
feat: add the ability to make multiple edit (permissions (add/remove)…
EtherWizard33 Oct 10, 2024
2c7ae15
chore: exclude this file from stat converage from now until we circle…
EtherWizard33 Oct 10, 2024
923ba5c
feat: add the ability to hide the disconnect all button when necessar…
EtherWizard33 Oct 10, 2024
4b840db
feat: add the ability to show something relevant when no accounts dis…
EtherWizard33 Oct 10, 2024
60dd6a9
style: lint
EtherWizard33 Oct 10, 2024
e5fa0f8
feat: add the ability to navigate back to the permission summary rath…
EtherWizard33 Oct 10, 2024
b224569
style: lint
EtherWizard33 Oct 10, 2024
06d6a85
fix: the initialization of the list when its used in the connect more…
EtherWizard33 Oct 11, 2024
1a04123
Merge branch 'main' into feat
EtherWizard33 Oct 11, 2024
80046bc
feat: when connecting to dapp, the button should say Connect rather t…
EtherWizard33 Oct 15, 2024
298400c
feat: displays the correct account label for one account, next step m…
EtherWizard33 Oct 16, 2024
0130024
Merge branch 'main' into feat
EtherWizard33 Oct 16, 2024
8e4f244
Merge branch 'main' into feat
EtherWizard33 Oct 16, 2024
c8214aa
Merge branch 'account-selection-with-cal-input' into minor-ui-fixes
EtherWizard33 Oct 16, 2024
10a3c30
feat: use the account address prop added in previous commit to add th…
EtherWizard33 Oct 16, 2024
dcc9e5e
feat: and now for the flow of initial connection, connect the account…
EtherWizard33 Oct 16, 2024
39b094c
feat: add the ability for the back button to discard changes made to …
EtherWizard33 Oct 17, 2024
74516ed
test: update snapshot as expecred, since the the label in front of th…
EtherWizard33 Oct 17, 2024
fe7e9db
fix: cta buttons were truncated on android only, for some reason
EtherWizard33 Oct 17, 2024
eb516a4
feat: small phones lke iphone SE also had truncated cta buttons
EtherWizard33 Oct 18, 2024
ebd88e4
Merge branch 'temp' into feat
EtherWizard33 Oct 18, 2024
141f46b
Merge branch 'main' into feat-2793-permission-ui-requirements-from-fi…
EtherWizard33 Oct 18, 2024
c14790b
Merge branch 'main' into feat
EtherWizard33 Oct 18, 2024
6925146
Merge branch 'temp' into feat
EtherWizard33 Oct 18, 2024
a34a7c7
Merge branch 'main' into fdeat
EtherWizard33 Oct 18, 2024
f1a5290
Merge branch 'main' into feat-2793-permission-ui-requirements-from-fi…
EtherWizard33 Oct 21, 2024
321f5e8
Merge branch 'main' into feat-2793-permission-ui-requirements-from-fi…
EtherWizard33 Oct 21, 2024
49312a8
test: update snapshot to match the updated labels
EtherWizard33 Oct 21, 2024
3f84f35
Merge branch 'main' into feat-2793-permission-ui-requirements-from-fi…
EtherWizard33 Oct 22, 2024
0ba7a41
Merge branch 'main' into feat-2793-permission-ui-requirements-from-fi…
EtherWizard33 Oct 22, 2024
be9e9d5
Merge branch 'main' into feat-2793-permission-ui-requirements-from-fi…
EtherWizard33 Oct 22, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 49 additions & 17 deletions app/components/UI/PermissionsSummary/PermissionsSummary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ const PermissionsSummary = ({
isRenderedAsBottomSheet = true,
isDisconnectAllShown = true,
isNetworkSwitch = false,
accountAddresses = [],
}: PermissionsSummaryProps) => {
const { colors } = useTheme();
const { styles } = useStyles(styleSheet, { isRenderedAsBottomSheet });
Expand Down Expand Up @@ -163,6 +164,33 @@ const PermissionsSummary = ({
});
}, [navigate, currentPageInformation?.url]);

const getAccountLabel = useCallback(() => {
if (isAlreadyConnected) {
if (accountAddresses.length === 0 && selectedAccount) {
return `${strings('permissions.connected_to')} ${selectedAccount.name}`;
}
return accountAddresses.length === 1
? `1 ${strings('accounts.account_connected')}`
: `${accountAddresses.length} ${strings(
'accounts.accounts_connected',
)}`;
}

if (
accountAddresses.length === 1 ||
(accountAddresses.length === 0 && selectedAccount)
) {
return (
selectedAccount?.name &&
`${strings('permissions.requesting_for')}${selectedAccount?.name}`
);
}

return strings('permissions.requesting_for_accounts', {
numberOfAccounts: accountAddresses.length,
});
}, [accountAddresses, isAlreadyConnected, selectedAccount]);

function renderAccountPermissionsRequestInfoCard() {
return (
<TouchableOpacity onPress={handleEditAccountsButtonPress}>
Expand All @@ -177,31 +205,35 @@ const PermissionsSummary = ({
/>
<View style={styles.accountPermissionRequestDetails}>
<TextComponent variant={TextVariant.BodyMD}>
{strings('permissions.wants_to_see_your_accounts')}
{strings('permissions.see_your_accounts')}
</TextComponent>
<View style={styles.permissionRequestAccountInfo}>
<View style={styles.permissionRequestAccountName}>
<TextComponent numberOfLines={1} ellipsizeMode="tail">
<TextComponent variant={TextVariant.BodySM}>
{strings('permissions.requesting_for')}
</TextComponent>
<TextComponent variant={TextVariant.BodySMMedium}>
{`${
selectedAccount?.name ??
strings('browser.undefined_account')
}`}
{getAccountLabel()}
</TextComponent>
</TextComponent>
</View>
{selectedAccount?.address && (
<View style={styles.avatarGroup}>
<Avatar
size={AvatarSize.Xs}
variant={AvatarVariant.Account}
accountAddress={selectedAccount?.address}
<View style={styles.avatarGroup}>
{accountAddresses.length > 0 ? (
<AvatarGroup
avatarPropsList={accountAddresses.map((address) => ({
variant: AvatarVariant.Account,
accountAddress: address,
size: AvatarSize.Xs,
}))}
/>
</View>
)}
) : (
selectedAccount?.address && (
<Avatar
size={AvatarSize.Xs}
variant={AvatarVariant.Account}
accountAddress={selectedAccount.address}
/>
)
)}
</View>
</View>
</View>
{renderEndAccessory()}
Expand Down Expand Up @@ -317,7 +349,7 @@ const PermissionsSummary = ({
]}
testID={CommonSelectorsIDs.CONNECT_BUTTON}
>
{strings('confirmation_modal.confirm_cta')}
{strings('accounts.connect')}
</StyledButton>
</View>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,5 @@ export interface PermissionsSummaryProps {
chainName: string;
chainId: string;
};
accountAddresses?: string[];
}
Original file line number Diff line number Diff line change
Expand Up @@ -240,22 +240,7 @@ exports[`PermissionsSummary should render correctly 1`] = `
}
}
>
Requesting for
</Text>
<Text
accessibilityRole="text"
style={
{
"color": "#141618",
"fontFamily": "EuclidCircularB-Medium",
"fontSize": 12,
"fontWeight": "500",
"letterSpacing": 0,
"lineHeight": 20,
}
}
>
Account 2
Connected to Account 2
</Text>
</Text>
</View>
Expand Down Expand Up @@ -1018,7 +1003,7 @@ exports[`PermissionsSummary should render correctly 1`] = `
]
}
>
Confirm
Connect
</Text>
</TouchableOpacity>
</View>
Expand Down Expand Up @@ -1512,7 +1497,7 @@ exports[`PermissionsSummary should render correctly for network switch 1`] = `
]
}
>
Confirm
Connect
</Text>
</TouchableOpacity>
</View>
Expand Down
32 changes: 23 additions & 9 deletions app/components/Views/AccountConnect/AccountConnect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,11 @@ import {
getAddressAccountType,
safeToChecksumAddress,
} from '../../../util/address';
import { getHost, getUrlObj, prefixUrlWithProtocol } from '../../../util/browser';
import {
getHost,
getUrlObj,
prefixUrlWithProtocol,
} from '../../../util/browser';
import { getActiveTabUrl } from '../../../util/transactions';
import { Account, useAccounts } from '../../hooks/useAccounts';

Expand Down Expand Up @@ -97,6 +101,9 @@ const AccountConnect = (props: AccountConnectProps) => {
const [selectedAddresses, setSelectedAddresses] = useState<string[]>(
selectedWalletAddress ? [selectedWalletAddress] : [],
);
const [confirmedAddresses, setConfirmedAddresses] =
useState<string[]>(selectedAddresses);

const sheetRef = useRef<BottomSheetRef>(null);
const [screen, setScreen] = useState<AccountConnectScreens>(
AccountConnectScreens.SingleConnect,
Expand Down Expand Up @@ -140,7 +147,8 @@ const AccountConnect = (props: AccountConnectProps) => {

const isOriginMMSDKRemoteConn = sdkConnection !== undefined;

const isOriginWalletConnect = !isOriginMMSDKRemoteConn && wc2Metadata?.id && wc2Metadata?.id.length > 0;
const isOriginWalletConnect =
!isOriginMMSDKRemoteConn && wc2Metadata?.id && wc2Metadata?.id.length > 0;

const dappIconUrl = sdkConnection?.originatorInfo?.icon;
const dappUrl = sdkConnection?.originatorInfo?.url ?? '';
Expand Down Expand Up @@ -564,9 +572,10 @@ const AccountConnect = (props: AccountConnectProps) => {
setScreen(AccountConnectScreens.MultiConnectNetworkSelector),
onUserAction: setUserIntent,
isAlreadyConnected: false,
accountAddresses: confirmedAddresses,
};
return <PermissionsSummary {...permissionsSummaryProps} />;
}, [faviconSource, urlWithProtocol]);
}, [faviconSource, urlWithProtocol, confirmedAddresses]);

const renderSingleConnectSelectorScreen = useCallback(
() => (
Expand Down Expand Up @@ -603,20 +612,25 @@ const AccountConnect = (props: AccountConnectProps) => {
secureIcon={secureIcon}
urlWithProtocol={urlWithProtocol}
onUserAction={setUserIntent}
onBack={() => setScreen(AccountConnectScreens.SingleConnect)}
onBack={() => {
setSelectedAddresses(confirmedAddresses);
setScreen(AccountConnectScreens.SingleConnect);
}}
connection={sdkConnection}
hostname={hostname}
onPrimaryActionButtonPress={
isMultichainVersion1Enabled
? () => setScreen(AccountConnectScreens.SingleConnect)
: undefined
}
onPrimaryActionButtonPress={() => {
setConfirmedAddresses(selectedAddresses);
return isMultichainVersion1Enabled
? setScreen(AccountConnectScreens.SingleConnect)
: undefined;
}}
/>
),
[
accounts,
ensByAccountAddress,
selectedAddresses,
confirmedAddresses,
isLoading,
faviconSource,
secureIcon,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { StyleSheet } from 'react-native';
// External dependencies.
import { Theme } from '../../../../util/theme/models';
import { isMultichainVersion1Enabled } from '../../../../util/networks';
import Device from '../../../../util/device';

/**
* Style sheet function for AccountConnectMultiSelector screen.
Expand All @@ -18,7 +19,7 @@ const styleSheet = (params: {
const { vars } = params;
return StyleSheet.create({
container: {
height: '100%',
height: Device.isAndroid() || Device.isMediumDevice() ? '99%' : '100%',
},
body: {
paddingHorizontal: 16,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,7 @@ const AccountPermissions = (props: AccountPermissionsProps) => {
? setPermissionsScreen(AccountPermissionsScreens.Connected)
: navigation.navigate('PermissionsManager'),
isRenderedAsBottomSheet,
accountAddresses: checksummedPermittedAddresses,
};

return <PermissionsSummary {...permissionsSummaryProps} />;
Expand Down
7 changes: 7 additions & 0 deletions locales/languages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -714,6 +714,10 @@
"site_permission_to": "This site has permission to:",
"address_balance_activity_permission": "See address, account balance, and activity",
"suggest_transactions": "Suggest transactions to approve",
"accounts_connected": "accounts connected",
"account_connected": "account connected",
"accounts_disconnected": "accounts disconnected.",
"account_disconnected": "account disconnected.",
"disconnect": "Disconnect",
"disconnect_all": "Disconnect all",
"reconnect_notice": "If you disconnect from {{dappUrl}}, you’ll need to reconnect your accounts and networks to use this site again.",
Expand Down Expand Up @@ -1825,6 +1829,9 @@
"use_enabled_networks": "Use your enabled networks",
"wants_to_see_your_accounts": "See your accounts and suggest transactions",
"requesting_for": "Requesting for ",
"requesting_for_accounts": "Requesting for {{numberOfAccounts}} accounts",
"see_your_accounts": "See your accounts and suggest transactions",
"connected_to": "Connected to ",
"manage_permissions": "Manage Permissions",
"edit": "Edit",
"cancel": "Cancel"
Expand Down
Loading