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(2796): permission settings replace some of the mock data by real data #11590

Merged
Show file tree
Hide file tree
Changes from 56 commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
281aea6
feat: (wip) replace some the in-app browser mocked permissions with r…
EtherWizard33 Oct 1, 2024
fc8f462
feat: add the in sdk permissions
EtherWizard33 Oct 3, 2024
393f97d
feat: get the permission from subject and use regex to attemtp to fil…
EtherWizard33 Oct 3, 2024
820cab0
Merge branch 'main' into feat
EtherWizard33 Oct 8, 2024
8f2c5cf
next steps for integration
adonesky1 Oct 15, 2024
5766943
Merge branch 'main' into ad/poc
EtherWizard33 Oct 22, 2024
22259bd
feat: the network name was not showing, this is now fixed
EtherWizard33 Oct 21, 2024
2142554
feat: display the network image in the list of network permissions th…
EtherWizard33 Oct 22, 2024
9ed8230
fix: display the dapp origin only when it's specific to a dapp, since…
EtherWizard33 Oct 22, 2024
697492a
style: lint
EtherWizard33 Oct 22, 2024
d6d4453
fix: just check the dapp origin, previous commit of the PR was changi…
EtherWizard33 Oct 22, 2024
9087c64
feat: wire up the network avatar group to show permitted networks dur…
EtherWizard33 Oct 23, 2024
850e31d
test: update snapshot after having wired up the network permission's …
EtherWizard33 Oct 23, 2024
8c6d4be
feat: initial connection flow can now edit networks
EtherWizard33 Oct 23, 2024
97d3f43
chore: update the exclusions, until next week, we are starting unit t…
EtherWizard33 Oct 23, 2024
ce956c6
Merge branch 'main' into feat-2808-edit-network-happy-path
EtherWizard33 Oct 24, 2024
a461e88
Merge branch 'main' into feat-2796-permission-settings-replace-some-o…
EtherWizard33 Oct 24, 2024
b67cbcb
Merge branch 'feat-2808-edit-network-happy-path' into feat-2796-permi…
EtherWizard33 Oct 24, 2024
8035544
feat: add the number of networks
EtherWizard33 Oct 24, 2024
0ebe00e
feat: add to the display manager the count of network permission, and…
EtherWizard33 Oct 24, 2024
1fa80c6
style: lint
EtherWizard33 Oct 24, 2024
8b60810
Merge branch 'main' into
EtherWizard33 Oct 24, 2024
5ab02bd
Merge branch 'main' into feat-2808-edit-network-happy-path
EtherWizard33 Oct 28, 2024
7e7e1f0
Merge branch 'main' into feat
EtherWizard33 Oct 29, 2024
8a12949
feat: the label preceding the network avatar now displays different w…
EtherWizard33 Oct 29, 2024
d91140d
feat: the label preceding the account avatars also now displays diffe…
EtherWizard33 Oct 29, 2024
dec07ad
style: lint
EtherWizard33 Oct 29, 2024
3f6efee
Merge branch 'main' into feat-2808-edit-network-happy-path
EtherWizard33 Oct 30, 2024
f1ecfc3
feat: add the ability for the user to see a toast confirming the upda…
EtherWizard33 Oct 30, 2024
0fb4ca3
feat: change the toast message shown after the user updated his accou…
EtherWizard33 Oct 30, 2024
cafffbe
style: lint
EtherWizard33 Oct 30, 2024
dc95008
feat: add the ability to disable the udate button when checked checbo…
EtherWizard33 Oct 30, 2024
7e048c9
style: lint
EtherWizard33 Oct 30, 2024
1b398cb
Merge branch 'main' into feat-2808-edit-network-happy-path
EtherWizard33 Oct 30, 2024
ffed0c2
style: refactor for sonar, ternary operators should not be nested
EtherWizard33 Oct 31, 2024
161a924
style: refactor for sonar, should use a compare function with localeC…
EtherWizard33 Oct 31, 2024
7d50ebd
fix: the revoking from this onPress had been added from another PR la…
EtherWizard33 Oct 31, 2024
1e86077
Merge branch feat-2808-edit-network-happy-path into feat-2796-permiss…
EtherWizard33 Oct 31, 2024
856f8a0
feat: add the ability for the network checkbox list's disconnect all …
EtherWizard33 Oct 31, 2024
6bfbb10
feat: add the ability for the account checkbox list's disconnect all …
EtherWizard33 Oct 31, 2024
e830f6f
style: lint
EtherWizard33 Oct 31, 2024
431988c
feat: add the ability for the permission summary's disconnect all han…
EtherWizard33 Oct 31, 2024
d07b1a8
feat: the toast on connect should show a generic permission udpated m…
EtherWizard33 Oct 31, 2024
2b2a136
fix: the disconnect all bottom sheet was not showing as expected when…
EtherWizard33 Nov 1, 2024
5d63279
Merge branch 'main' into feat-2796-permission-settings-replace-some-o…
EtherWizard33 Nov 1, 2024
50172f5
feat: display the fav icon of the dapp
EtherWizard33 Nov 1, 2024
728cd9e
style: lint
EtherWizard33 Nov 1, 2024
e0f07c7
Merge branch 'main' into feat-2796-permission-settings-replace-some-o…
EtherWizard33 Nov 4, 2024
1c0c67a
feat: add the connection detail bottom sheet and remove the tag
EtherWizard33 Nov 4, 2024
454d011
test: update the snapshot of the permissions item
EtherWizard33 Nov 5, 2024
4f8bcd3
chore: add a feature flag specific to the settings, it shows and hide…
EtherWizard33 Nov 5, 2024
a9b78f9
chore: disable the display of wallet connect and sdk permissions unti…
EtherWizard33 Nov 5, 2024
f1ae3b9
Revert "chore: add a feature flag specific to the settings, it shows …
EtherWizard33 Nov 5, 2024
447281b
cleanup, sdk and wallet connect permissions are not supported yet, a …
EtherWizard33 Nov 5, 2024
6118ac6
Merge branch 'main' into feat-2796-permission-settings-replace-some-o…
EtherWizard33 Nov 5, 2024
4ea21ee
chore: exclude this small new component from sonar coverage for now, …
EtherWizard33 Nov 5, 2024
f95d0d9
feat: update the button label to use i18n
EtherWizard33 Nov 6, 2024
5d542dc
test: add the test id to the i icon which allows opening the connecti…
EtherWizard33 Nov 6, 2024
4d7fc4e
style: lint tsc
EtherWizard33 Nov 6, 2024
3ad2485
Merge branch 'main' into feat-2796-permission-settings-replace-some-o…
EtherWizard33 Nov 7, 2024
2c6c77e
Merge branch 'main' into feat-2796-permission-settings-replace-some-o…
EtherWizard33 Nov 7, 2024
6293f83
Merge branch 'main' into feat-2796-permission-settings-replace-some-o…
EtherWizard33 Nov 8, 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
5 changes: 5 additions & 0 deletions app/components/Nav/App/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ import AccountConnect from '../../../components/Views/AccountConnect';
import AccountPermissions from '../../../components/Views/AccountPermissions';
import { AccountPermissionsScreens } from '../../../components/Views/AccountPermissions/AccountPermissions.types';
import AccountPermissionsConfirmRevokeAll from '../../../components/Views/AccountPermissions/AccountPermissionsConfirmRevokeAll';
import ConnectionDetails from '../../../components/Views/AccountPermissions/ConnectionDetails';
import { SRPQuiz } from '../../Views/Quiz';
import { TurnOffRememberMeModal } from '../../../components/UI/TurnOffRememberMeModal';
import AssetHideConfirmation from '../../Views/AssetHideConfirmation';
Expand Down Expand Up @@ -424,6 +425,10 @@ const RootModalFlow = () => (
name={Routes.SHEET.REVOKE_ALL_ACCOUNT_PERMISSIONS}
component={AccountPermissionsConfirmRevokeAll}
/>
<Stack.Screen
name={Routes.SHEET.CONNECTION_DETAILS}
component={ConnectionDetails}
/>
<Stack.Screen
name={Routes.SHEET.NETWORK_SELECTOR}
component={NetworkSelector}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,11 @@ const createStyles = (params: {
justifyContent: 'space-between',
},
startAccessory: { flex: 1, paddingLeft: 16 },
endAccessory: { flex: 1, paddingRight: 16 },
endAccessory: {
flex: 1,
paddingRight: 16,
alignItems: 'flex-end',
},
editArrow: {
marginHorizontal: 16,
},
Expand Down
45 changes: 38 additions & 7 deletions app/components/UI/PermissionsSummary/PermissionsSummary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import ButtonIcon, {
ButtonIconSizes,
} from '../../../component-library/components/Buttons/ButtonIcon';
import { getNetworkImageSource } from '../../../util/networks';
import Engine from '../../../core/Engine';

const PermissionsSummary = ({
currentPageInformation,
Expand All @@ -64,6 +65,8 @@ const PermissionsSummary = ({
const { navigate } = useNavigation();
const selectedAccount = useSelectedAccount();

const hostname = new URL(currentPageInformation.url).hostname;

// if network switch, we get the chain name from the customNetworkInformation
let chainName = '';
let chainImage: ImageSourcePropType;
Expand Down Expand Up @@ -124,7 +127,31 @@ const PermissionsSummary = ({
</View>

<View style={styles.logoContainer}>{renderTopIcon()}</View>
<View style={styles.endAccessory}></View>
<View style={styles.endAccessory}>
{!isRenderedAsBottomSheet && (
<ButtonIcon
size={ButtonIconSizes.Sm}
iconName={IconName.Info}
iconColor={IconColor.Default}
onPress={() => {
navigate(Routes.MODAL.ROOT_MODAL_FLOW, {
screen: Routes.SHEET.CONNECTION_DETAILS,
params: {
hostInfo: {
metadata: {
origin:
currentPageInformation?.url &&
new URL(currentPageInformation?.url).hostname,
},
},
connectionDateTime: new Date().getTime(),
},
});
}}
// testID={CommonSelectorsIDs.PERMISSIONS_INFO_BUTTON}
EtherWizard33 marked this conversation as resolved.
Show resolved Hide resolved
/>
)}
</View>
</View>
);
}
Expand All @@ -150,20 +177,24 @@ const PermissionsSummary = ({
</View>
);

const onRevokeAllHandler = useCallback(async () => {
await Engine.context.PermissionController.revokeAllPermissions(hostname);
navigate('PermissionsManager');
}, [hostname, navigate]);

const toggleRevokeAllPermissionsModal = useCallback(() => {
navigate(Routes.MODAL.ROOT_MODAL_FLOW, {
screen: Routes.SHEET.REVOKE_ALL_ACCOUNT_PERMISSIONS,
params: {
hostInfo: {
metadata: {
origin:
currentPageInformation?.url &&
new URL(currentPageInformation?.url).hostname,
origin: hostname,
},
},
onRevokeAll: !isRenderedAsBottomSheet && onRevokeAllHandler,
},
});
}, [navigate, currentPageInformation?.url]);
}, [navigate, isRenderedAsBottomSheet, onRevokeAllHandler, hostname]);

const getAccountLabel = useCallback(() => {
if (isAlreadyConnected) {
Expand Down Expand Up @@ -346,10 +377,10 @@ const PermissionsSummary = ({
<TextComponent variant={TextVariant.HeadingSM}>
{!isAlreadyConnected || isNetworkSwitch
? strings('permissions.title_dapp_url_wants_to', {
dappUrl: new URL(currentPageInformation.url).hostname,
dappUrl: hostname,
})
: strings('permissions.title_dapp_url_has_approval_to', {
dappUrl: new URL(currentPageInformation.url).hostname,
dappUrl: hostname,
})}
</TextComponent>
</View>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ exports[`PermissionsSummary should render correctly 1`] = `
<View
style={
{
"alignItems": "flex-end",
"flex": 1,
"paddingRight": 16,
}
Expand Down Expand Up @@ -860,6 +861,7 @@ exports[`PermissionsSummary should render correctly for network switch 1`] = `
<View
style={
{
"alignItems": "flex-end",
"flex": 1,
"paddingRight": 16,
}
Expand Down
39 changes: 7 additions & 32 deletions app/components/Views/AccountConnect/AccountConnect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import Modal from 'react-native-modal';
import { useSelector } from 'react-redux';
// External dependencies.
import { strings } from '../../../../locales/i18n';
import { AvatarAccountType } from '../../../component-library/components/Avatars/Avatar/variants/AvatarAccount';
import BottomSheet, {
BottomSheetRef,
} from '../../../component-library/components/BottomSheets/BottomSheet';
Expand All @@ -33,7 +32,6 @@ import {
} from '../../../selectors/accountsController';
import { isDefaultAccountName } from '../../../util/ENSUtils';
import Logger from '../../../util/Logger';
import getAccountNameWithENS from '../../../util/accounts';
import {
getAddressAccountType,
safeToChecksumAddress,
Expand Down Expand Up @@ -133,11 +131,6 @@ const AccountConnect = (props: AccountConnectProps) => {
>([]);

const { toastRef } = useContext(ToastContext);
const accountAvatarType = useSelector((state: RootState) =>
state.settings.useBlockieIcon
? AvatarAccountType.Blockies
: AvatarAccountType.JazzIcon,
);

// origin is set to the last active tab url in the browser which can conflict with sdk
const inappBrowserOrigin: string = useSelector(getActiveTabUrl, isEqual);
Expand Down Expand Up @@ -439,11 +432,6 @@ const AccountConnect = (props: AccountConnectProps) => {
};
const connectedAccountLength = selectedAddresses.length;
const activeAddress = selectedAddresses[0];
const activeAccountName = getAccountNameWithENS({
accountAddress: activeAddress,
accounts,
ensByAccountAddress,
});

try {
setIsLoading(true);
Expand All @@ -463,26 +451,15 @@ const AccountConnect = (props: AccountConnectProps) => {
source: eventSource,
});
let labelOptions: ToastOptions['labelOptions'] = [];
if (connectedAccountLength > 1) {
labelOptions = [
{ label: `${connectedAccountLength} `, isBold: true },
{
label: `${strings('toast.accounts_connected')}`,
},
{ label: `\n${activeAccountName} `, isBold: true },
{ label: strings('toast.now_active') },
];
} else {
labelOptions = [
{ label: `${activeAccountName} `, isBold: true },
{ label: strings('toast.connected_and_active') },
];

if (connectedAccountLength >= 1) {
labelOptions = [{ label: `${strings('toast.permissions_updated')}` }];
}

toastRef?.current?.showToast({
variant: ToastVariants.Account,
variant: ToastVariants.Network,
labelOptions,
accountAddress: activeAddress,
accountAvatarType,
networkImageSource: faviconSource,
hasNoTimeout: false,
});
} catch (e) {
Expand All @@ -496,14 +473,12 @@ const AccountConnect = (props: AccountConnectProps) => {
eventSource,
selectedAddresses,
hostInfo,
accounts,
ensByAccountAddress,
accountAvatarType,
toastRef,
accountsLength,
channelIdOrHostname,
triggerDappViewedEvent,
trackEvent,
faviconSource,
]);

const handleCreateAccount = useCallback(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import AccountSelectorList from '../../../UI/AccountSelectorList';
import HelpText, {
HelpTextSeverity,
} from '../../../../component-library/components/Form/HelpText';
import Engine from '../../../../core/Engine';

// Internal dependencies.
import { ConnectAccountBottomSheetSelectorsIDs } from '../../../../../e2e/selectors/Browser/ConnectAccountBottomSheet.selectors';
Expand Down Expand Up @@ -84,6 +85,11 @@ const AccountConnectMultiSelector = ({
[accounts, selectedAddresses, onSelectAddress],
);

const onRevokeAllHandler = useCallback(async () => {
await Engine.context.PermissionController.revokeAllPermissions(hostname);
navigate('PermissionsManager');
}, [hostname, navigate]);

const toggleRevokeAllAccountPermissionsModal = useCallback(() => {
navigate(Routes.MODAL.ROOT_MODAL_FLOW, {
screen: Routes.SHEET.REVOKE_ALL_ACCOUNT_PERMISSIONS,
Expand All @@ -93,9 +99,10 @@ const AccountConnectMultiSelector = ({
origin: urlWithProtocol && new URL(urlWithProtocol).hostname,
},
},
onRevokeAll: !isRenderedAsBottomSheet && onRevokeAllHandler,
},
});
}, [navigate, urlWithProtocol]);
}, [navigate, urlWithProtocol, isRenderedAsBottomSheet, onRevokeAllHandler]);

const renderSelectAllButton = useCallback(
() =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,7 @@ const AccountPermissions = (props: AccountPermissionsProps) => {
useEffect(() => {
if (
previousPermittedAccounts.current === undefined &&
permittedAccountsByHostname.length === 0 &&
isRenderedAsBottomSheet
permittedAccountsByHostname.length === 0
) {
// TODO - Figure out better UX instead of auto dismissing. However, we cannot be in this state as long as accounts are not connected.
hideSheet();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ interface AccountPermissionsConfirmRevokeAllProps {
hostInfo: {
metadata: { origin: string };
};
onRevokeAll?: () => void;
};
};
}
Expand All @@ -37,6 +38,7 @@ const AccountPermissionsConfirmRevokeAll = (
hostInfo: {
metadata: { origin: hostname },
},
onRevokeAll,
} = props.route.params;

const { styles } = useStyles(styleSheet, {});
Expand All @@ -48,12 +50,18 @@ const AccountPermissionsConfirmRevokeAll = (

const revokeAllAccounts = useCallback(async () => {
try {
await Engine.context.PermissionController.revokeAllPermissions(hostname);
sheetRef.current?.onCloseBottomSheet();
if (onRevokeAll) {
onRevokeAll();
} else {
await Engine.context.PermissionController.revokeAllPermissions(
hostname,
);
sheetRef.current?.onCloseBottomSheet();
}
} catch (e) {
Logger.log(`Failed to revoke all accounts for ${hostname}`, e);
}
}, [hostname, Engine.context.PermissionController]);
}, [hostname, Engine.context.PermissionController, onRevokeAll]);

const onCancel = () => {
sheetRef.current?.onCloseBottomSheet();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Third party dependencies.
import { StyleSheet } from 'react-native';

/**
* Style sheet function for AccountConnectMultiSelector screen.
* @returns StyleSheet object.
*/
const styleSheet = () =>
StyleSheet.create({
container: {
paddingHorizontal: 16,
alignItems: 'center',
},
descriptionContainer: {
marginBottom: 16,
},
buttonsContainer: {
flexDirection: 'row',
gap: 16,
},
button: {
flex: 1,
},
});

export default styleSheet;
Loading
Loading