Skip to content

Commit

Permalink
added review perm page
Browse files Browse the repository at this point in the history
  • Loading branch information
NidhiKJha committed Aug 22, 2024
1 parent fb87f95 commit 8881106
Show file tree
Hide file tree
Showing 11 changed files with 272 additions and 0 deletions.
3 changes: 3 additions & 0 deletions app/_locales/en/messages.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions ui/components/multichain/global-menu/global-menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
NOTIFICATIONS_ROUTE,
SNAPS_ROUTE,
PERMISSIONS,
REVIEW_PERMISSIONS,
} from '../../../helpers/constants/routes';
import {
lockMetamask,
Expand Down Expand Up @@ -247,6 +248,24 @@ export const GlobalMenu = ({ closeMenu, anchorElement, isOpen }) => {
>
{t('allPermissions')}
</MenuItem>
<MenuItem
iconName={IconName.SecurityTick}
onClick={() => {
history.push(REVIEW_PERMISSIONS);
trackEvent({
event: MetaMetricsEventName.NavPermissionsOpened,
category: MetaMetricsEventCategory.Navigation,
properties: {
location: METRICS_LOCATION,
},
});
closeMenu();
}}
data-testid="global-menu-connected-sites"
disabled={hasUnapprovedTransactions}
>
"nid"
</MenuItem>

{
///: BEGIN:ONLY_INCLUDE_IF(build-mmi)
Expand Down
1 change: 1 addition & 0 deletions ui/components/multichain/pages/index.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export { Connections } from './connections';
export { PermissionsPage } from './permissions-page/permissions-page';
export { ReviewPermissions } from './review-permissions-page/review-permissions-page';
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { ReviewPermissions } from './review-permissions-page';
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import React from 'react';
import { ReviewPermissions } from '.';

export default {
title: 'Components/Multichain/ReviewPermissions',
};

export const DefaultStory = () => <ReviewPermissions />;

DefaultStory.storyName = 'Default';
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import React, { useState } from 'react';
import { useDispatch, useSelector } from 'react-redux';
import { useHistory } from 'react-router-dom';
import {
BackgroundColor,
IconColor,
} from '../../../../helpers/constants/design-system';
import { useI18nContext } from '../../../../hooks/useI18nContext';
import { getConnectedSitesListWithNetworkInfo } from '../../../../selectors/index';
import {
ButtonIcon,
ButtonIconSize,
IconName,
} from '../../../component-library';
import { Content, Footer, Header, Page } from '../page';

export const ReviewPermissions = () => {
const t = useI18nContext();
const dispatch = useDispatch();
const history = useHistory();
const sitesConnectionsList = useSelector(
getConnectedSitesListWithNetworkInfo,
);
console.log(sitesConnectionsList, 'sitesConnectionsList');
return (
<Page
data-testid="connections-page"
className="main-container connections-page"
>
<Header
backgroundColor={BackgroundColor.backgroundDefault}
startAccessory={
<ButtonIcon
ariaLabel={t('back')}
iconName={IconName.ArrowLeft}
className="connections-header__start-accessory"
size={ButtonIconSize.Sm}
/>
}
></Header>
<Content padding={0}>Nidhi</Content>
<Footer></Footer>
</Page>
);
};
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,184 @@
import React from 'react';
import PropTypes from 'prop-types';
import { SubjectType } from '@metamask/permission-controller';
import {
AlignItems,
BackgroundColor,
BlockSize,
Display,
FlexDirection,
IconColor,
JustifyContent,
TextAlign,
TextColor,
TextVariant,
} from '../../../../../helpers/constants/design-system';
import { useI18nContext } from '../../../../../hooks/useI18nContext';
import {
AvatarFavicon,
AvatarNetwork,
AvatarNetworkSize,
BadgeWrapper,
Box,
Icon,
IconName,
IconSize,
Text,
} from '../../../../component-library';
import { getURLHost } from '../../../../../helpers/utils/util';
import { ConnectionListTooltip } from '../../permissions-page/connection-list-tooltip/connection-list-tooltip';

export const ConnectionListItem = ({ connection, onClick }) => {
const t = useI18nContext();
const isSnap = connection.subjectType === SubjectType.Snap;

return (
<>
<Box
data-testid="connection-list-item"
as="button"
display={Display.Flex}
flexDirection={FlexDirection.Row}
alignItems={AlignItems.baseline}
width={BlockSize.Full}
backgroundColor={BackgroundColor.backgroundDefault}
onClick={onClick}
padding={4}
gap={4}
className="multichain-connection-list-item"
>
<Icon
display={Display.Flex}
name={IconName.ArrowRight}
color={IconColor.iconDefault}
size={IconSize.Sm}
backgroundColor={BackgroundColor.backgroundDefault}
/>
<Box
display={Display.Flex}
flexDirection={FlexDirection.Column}
width={BlockSize.FiveTwelfths}
style={{ alignSelf: 'center', flexGrow: '1' }}
>
<Text
variant={TextVariant.bodyMd}
textAlign={TextAlign.Left}
ellipsis
>
{t('accountsPermissionsTitle')}
</Text>

<Box
display={Display.Flex}
flexDirection={FlexDirection.Row}
alignItems={AlignItems.center}
gap={1}
>
<Text
as="span"
width={BlockSize.Max}
color={TextColor.textAlternative}
variant={TextVariant.bodyMd}
>
{t('connectedWith')}
</Text>
<ConnectionListTooltip connection={connection} />
</Box>
</Box>
<Box
display={Display.Flex}
justifyContent={JustifyContent.flexEnd}
alignItems={AlignItems.center}
style={{ flex: '1', alignSelf: 'center' }}
gap={2}
>
<Icon
display={Display.Flex}
name={IconName.MoreVertical}
color={IconColor.iconDefault}
size={IconSize.Sm}
backgroundColor={BackgroundColor.backgroundDefault}
/>
</Box>
</Box>
<Box
data-testid="connection-list-item"
as="button"
display={Display.Flex}
flexDirection={FlexDirection.Row}
alignItems={AlignItems.baseline}
width={BlockSize.Full}
backgroundColor={BackgroundColor.backgroundDefault}
onClick={onClick}
padding={4}
gap={4}
className="multichain-connection-list-item"
>
<Icon
display={Display.Flex}
name={IconName.ArrowRight}
color={IconColor.iconDefault}
size={IconSize.Sm}
backgroundColor={BackgroundColor.backgroundDefault}
/>
<Box
display={Display.Flex}
flexDirection={FlexDirection.Column}
width={BlockSize.FiveTwelfths}
style={{ alignSelf: 'center', flexGrow: '1' }}
>
<Text
variant={TextVariant.bodyMd}
textAlign={TextAlign.Left}
ellipsis
>
{t('accountsPermissionsTitle')}
</Text>

<Box
display={Display.Flex}
flexDirection={FlexDirection.Row}
alignItems={AlignItems.center}
gap={1}
>
<Text
as="span"
width={BlockSize.Max}
color={TextColor.textAlternative}
variant={TextVariant.bodyMd}
>
{t('connectedWith')}
</Text>
<ConnectionListTooltip connection={connection} />
</Box>
</Box>
<Box
display={Display.Flex}
justifyContent={JustifyContent.flexEnd}
alignItems={AlignItems.center}
style={{ flex: '1', alignSelf: 'center' }}
gap={2}
>
<Icon
display={Display.Flex}
name={IconName.MoreVertical}
color={IconColor.iconDefault}
size={IconSize.Sm}
backgroundColor={BackgroundColor.backgroundDefault}
/>
</Box>
</Box>
</>
);
};

ConnectionListItem.propTypes = {
/**
* The connection data to display
*/
connection: PropTypes.object.isRequired,
/**
* The function to call when the connection is clicked
*/
onClick: PropTypes.func.isRequired,
};
2 changes: 2 additions & 0 deletions ui/helpers/constants/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ const SRP_REMINDER = '/onboarding/remind-srp';
///: END:ONLY_INCLUDE_IF
const SEND_ROUTE = '/send';
const CONNECTIONS = '/connections';
const REVIEW_PERMISSIONS = './review-permissions';
const PERMISSIONS = '/permissions';
const TOKEN_DETAILS = '/token-details';
const CONNECT_ROUTE = '/connect';
Expand Down Expand Up @@ -222,6 +223,7 @@ export {
SEND_ROUTE,
CONNECTIONS,
PERMISSIONS,
REVIEW_PERMISSIONS,
TOKEN_DETAILS,
CONFIRM_TRANSACTION_ROUTE,
CONFIRM_SEND_ETHER_PATH,
Expand Down
7 changes: 7 additions & 0 deletions ui/pages/routes/routes.component.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import Home from '../home';
import {
PermissionsPage,
Connections,
ReviewPermissions,
} from '../../components/multichain/pages';
import Settings from '../settings';
import Authenticated from '../../helpers/higher-order-components/authenticated';
Expand Down Expand Up @@ -77,6 +78,7 @@ import {
TOKEN_DETAILS,
CONNECTIONS,
PERMISSIONS,
REVIEW_PERMISSIONS,
///: BEGIN:ONLY_INCLUDE_IF(build-mmi)
INSTITUTIONAL_FEATURES_DONE_ROUTE,
CUSTODY_ACCOUNT_DONE_ROUTE,
Expand Down Expand Up @@ -438,6 +440,11 @@ export default class Routes extends Component {
component={Connections}
/>
<Authenticated path={PERMISSIONS} component={PermissionsPage} exact />
<Authenticated
path={REVIEW_PERMISSIONS}
component={ReviewPermissions}
exact
/>
<Authenticated path={DEFAULT_ROUTE} component={Home} />
</Switch>
);
Expand Down

0 comments on commit 8881106

Please sign in to comment.