Skip to content

Commit

Permalink
Address PR review
Browse files Browse the repository at this point in the history
  • Loading branch information
pedronfigueiredo committed Dec 19, 2024
1 parent 9db772d commit 22f0e33
Show file tree
Hide file tree
Showing 5 changed files with 100 additions and 116 deletions.
130 changes: 65 additions & 65 deletions ui/components/app/metamask-template-renderer/safe-component-list.js
Original file line number Diff line number Diff line change
@@ -1,84 +1,111 @@
import Button from '../../ui/button';
import Chip from '../../ui/chip';
import DefinitionList from '../../ui/definition-list';
import TruncatedDefinitionList from '../../ui/truncated-definition-list';
import Popover from '../../ui/popover';
import Typography from '../../ui/typography';
import Box from '../../ui/box';
import MetaMaskTranslation from '../metamask-translation';
import NetworkDisplay from '../network-display';
import TextArea from '../../ui/textarea/textarea';
import TextField from '../../ui/text-field';
import ConfirmationNetworkSwitch from '../../../pages/confirmations/confirmation/components/confirmation-network-switch';
import UrlIcon from '../../ui/url-icon';
import Tooltip from '../../ui/tooltip/tooltip';
import { SmartTransactionStatusPage } from '../../../pages/smart-transactions/smart-transaction-status-page';
import {
AvatarIcon,
BannerAlert,
FormTextField,
Text,
BannerAlert,
} from '../../component-library';
import { AccountListItem } from '../../multichain';
import ActionableMessage from '../../ui/actionable-message/actionable-message';
import Box from '../../ui/box';
import Button from '../../ui/button';
import Chip from '../../ui/chip';
import DefinitionList from '../../ui/definition-list';
import Preloader from '../../ui/icon/preloader';
import OriginPill from '../../ui/origin-pill/origin-pill';
import { AccountListItem } from '../../multichain';
import Popover from '../../ui/popover';
import Spinner from '../../ui/spinner';
import TextField from '../../ui/text-field';
import TextArea from '../../ui/textarea/textarea';
import Tooltip from '../../ui/tooltip/tooltip';
import TruncatedDefinitionList from '../../ui/truncated-definition-list';
import Typography from '../../ui/typography';
import UrlIcon from '../../ui/url-icon';
import {
ConfirmInfoRow,
ConfirmInfoRowAddress,
ConfirmInfoRowValueDouble,
} from '../confirm/info/row';
import { SnapDelineator } from '../snaps/snap-delineator';
import MetaMaskTranslation from '../metamask-translation';
import NetworkDisplay from '../network-display';
import { Copyable } from '../snaps/copyable';
import Spinner from '../../ui/spinner';
import Preloader from '../../ui/icon/preloader';
import { SnapUIMarkdown } from '../snaps/snap-ui-markdown';
import { SnapUILink } from '../snaps/snap-ui-link';
import { SmartTransactionStatusPage } from '../../../pages/smart-transactions/smart-transaction-status-page';
import { SnapDelineator } from '../snaps/snap-delineator';
import { SnapUIAddress } from '../snaps/snap-ui-address';
import { SnapUIAvatar } from '../snaps/snap-ui-avatar';
import { SnapUIButton } from '../snaps/snap-ui-button';
import { SnapUICard } from '../snaps/snap-ui-card';
import { SnapUICheckbox } from '../snaps/snap-ui-checkbox';
import { SnapUIDropdown } from '../snaps/snap-ui-dropdown';
import { SnapUIFileInput } from '../snaps/snap-ui-file-input';
import { SnapUIFooterButton } from '../snaps/snap-ui-footer-button';
import { SnapUIForm } from '../snaps/snap-ui-form';
import { SnapUIIcon } from '../snaps/snap-ui-icon';
import { SnapUIImage } from '../snaps/snap-ui-image';
import { SnapUIFileInput } from '../snaps/snap-ui-file-input';
import { SnapUIInput } from '../snaps/snap-ui-input';
import { SnapUIForm } from '../snaps/snap-ui-form';
import { SnapUIButton } from '../snaps/snap-ui-button';
import { SnapUIDropdown } from '../snaps/snap-ui-dropdown';
import { SnapUILink } from '../snaps/snap-ui-link';
import { SnapUIMarkdown } from '../snaps/snap-ui-markdown';
import { SnapUIRadioGroup } from '../snaps/snap-ui-radio-group';
import { SnapUICheckbox } from '../snaps/snap-ui-checkbox';
import { SnapUITooltip } from '../snaps/snap-ui-tooltip';
import { SnapUICard } from '../snaps/snap-ui-card';
import { SnapUIAddress } from '../snaps/snap-ui-address';
import { SnapUIAvatar } from '../snaps/snap-ui-avatar';
import { SnapUISelector } from '../snaps/snap-ui-selector';
import { SnapUIFooterButton } from '../snaps/snap-ui-footer-button';
import { SnapUITooltip } from '../snaps/snap-ui-tooltip';
///: BEGIN:ONLY_INCLUDE_IF(keyring-snaps)
import { SnapAccountSuccessMessage } from '../../../pages/confirmations/components/snap-account-success-message';
import { SnapAccountErrorMessage } from '../../../pages/confirmations/components/snap-account-error-message';
import { SnapAccountSuccessMessage } from '../../../pages/confirmations/components/snap-account-success-message';
import { CreateSnapAccount } from '../../../pages/create-snap-account';
import { CreateNamedSnapAccount } from '../../multichain/create-named-snap-account';
import {
RemoveSnapAccount,
SnapAccountCard,
} from '../../../pages/remove-snap-account';
import { SnapAccountRedirect } from '../../../pages/snap-account-redirect';
import { CreateNamedSnapAccount } from '../../multichain/create-named-snap-account';
import SnapAuthorshipHeader from '../snaps/snap-authorship-header';
///: END:ONLY_INCLUDE_IF

export const safeComponentList = {
a: 'a',
ActionableMessage,
AccountListItem,
ActionableMessage,
AvatarIcon,
b: 'b',
BannerAlert,
Box,
Button,
Chip,
ConfirmationNetworkSwitch,
ConfirmInfoRow,
ConfirmInfoRowAddress,
ConfirmInfoRowValueDouble,
Copyable,
DefinitionList,
div: 'div',
FormTextField,
i: 'i',
MetaMaskTranslation,
NetworkDisplay,
OriginPill,
p: 'p',
Popover,
Preloader,
SnapDelineator,
SnapUIAddress,
SnapUIAvatar,
SnapUIButton,
SnapUICard,
SnapUICheckbox,
SnapUIDropdown,
SnapUIFileInput,
SnapUIForm,
SnapUIFooterButton,
SnapUIIcon,
SnapUIImage,
SnapUIInput,
SnapUILink,
SnapUIMarkdown,
SnapUIRadioGroup,
SnapUISelector,
SnapUITooltip,
span: 'span',
Spinner,
Text,
TextArea,
TextField,
Expand All @@ -87,41 +114,14 @@ export const safeComponentList = {
Typography,
SmartTransactionStatusPage,
UrlIcon,
OriginPill,
Copyable,
SnapDelineator,
SnapUIMarkdown,
SnapUILink,
SnapUIIcon,
SnapUIImage,
BannerAlert,
Spinner,
Preloader,
ConfirmInfoRow,
ConfirmInfoRowAddress,
ConfirmInfoRowValueDouble,
SnapUIFileInput,
SnapUIInput,
SnapUIButton,
SnapUIForm,
SnapUIDropdown,
SnapUIRadioGroup,
SnapUICheckbox,
SnapUITooltip,
SnapUICard,
SnapUISelector,
SnapUIAddress,
SnapUIAvatar,
SnapUIFooterButton,
FormTextField,
///: BEGIN:ONLY_INCLUDE_IF(keyring-snaps)
CreateNamedSnapAccount,
CreateSnapAccount,
RemoveSnapAccount,
CreateNamedSnapAccount,
SnapAccountSuccessMessage,
SnapAccountCard,
SnapAccountErrorMessage,
SnapAuthorshipHeader,
SnapAccountRedirect,
SnapAccountCard,
SnapAccountSuccessMessage,
SnapAuthorshipHeader,
///: END:ONLY_INCLUDE_IF
};

This file was deleted.

22 changes: 0 additions & 22 deletions ui/components/ui/origin-pill/origin-pill.test.js

This file was deleted.

27 changes: 27 additions & 0 deletions ui/components/ui/origin-pill/origin-pill.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { screen } from '@testing-library/dom';
import React from 'react';
import configureMockStore from 'redux-mock-store';
import mockState from '../../../../test/data/mock-state.json';
import { renderWithProvider } from '../../../../test/lib/render-helpers';
import OriginPill from './origin-pill';

describe('<OriginPill />', () => {
it('renders correct elements', () => {
const defaultProps = {
origin: 'Test Origin',
dataTestId: 'test-data-test-id',
};
const store = configureMockStore()(mockState);

renderWithProvider(<OriginPill {...defaultProps} />, store);

expect(screen.getByTestId(defaultProps.dataTestId)).toBeDefined();
expect(
screen.getByTestId(`${defaultProps.dataTestId}-avatar-favicon`),
).toBeDefined();
expect(screen.getByTestId(`${defaultProps.dataTestId}-text`)).toBeDefined();
expect(
screen.getByTestId(`${defaultProps.dataTestId}-text`),
).toHaveTextContent(defaultProps.origin);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import React from 'react';
import { useSelector } from 'react-redux';
import {
AlignItems,
BorderColor,
BorderRadius,
BorderStyle,
Color,
Display,
JustifyContent,
TextColor,
Expand All @@ -14,7 +14,12 @@ import {
import { getSubjectMetadata } from '../../../selectors';
import { AvatarFavicon, Box, Text } from '../../component-library';

export default function OriginPill({ origin, dataTestId }) {
type OriginPillProps = {
origin: string;
dataTestId: string;
};

export default function OriginPill({ origin, dataTestId }: OriginPillProps) {
const subjectMetadata = useSelector(getSubjectMetadata);

const { iconUrl: siteImage = '' } = subjectMetadata[origin] || {};
Expand All @@ -28,7 +33,7 @@ export default function OriginPill({ origin, dataTestId }) {
marginRight={4}
marginLeft={4}
padding={2}
borderColor={Color.borderMuted}
borderColor={BorderColor.borderMuted}
borderStyle={BorderStyle.solid}
borderRadius={BorderRadius.pill}
borderWidth={1}
Expand Down

0 comments on commit 22f0e33

Please sign in to comment.