diff --git a/ui/components/app/flask/snaps-authorship-pill/snaps-authorship-pill.js b/ui/components/app/flask/snaps-authorship-pill/snaps-authorship-pill.js index 6625694b7..86f040025 100644 --- a/ui/components/app/flask/snaps-authorship-pill/snaps-authorship-pill.js +++ b/ui/components/app/flask/snaps-authorship-pill/snaps-authorship-pill.js @@ -9,7 +9,17 @@ import { TYPOGRAPHY, } from '../../../../helpers/constants/design-system'; -const SnapsAuthorshipPill = ({ packageName, className, url }) => { +const snapIdPrefixes = ['npm:', 'local:']; + +const SnapsAuthorshipPill = ({ snapId, className }) => { + // @todo Use getSnapPrefix from snaps-skunkworks when possible + const snapPrefix = snapIdPrefixes.find((prefix) => snapId.startsWith(prefix)); + const packageName = snapId.replace(snapPrefix, ''); + const isNPM = snapPrefix === 'npm:'; + const url = isNPM + ? `https://www.npmjs.com/package/${packageName}` + : packageName; + const icon = isNPM ? 'fab fa-npm fa-lg' : 'fas fa-code'; return ( { - + } backgroundColor={COLORS.BACKGROUND_DEFAULT} @@ -40,17 +50,13 @@ const SnapsAuthorshipPill = ({ packageName, className, url }) => { SnapsAuthorshipPill.propTypes = { /** - * NPM package name of the snap + * The id of the snap */ - packageName: PropTypes.string, + snapId: PropTypes.string, /** * The className of the SnapsAuthorshipPill */ className: PropTypes.string, - /** - * The url of the snap's package - */ - url: PropTypes.string, }; export default SnapsAuthorshipPill; diff --git a/ui/components/app/flask/snaps-authorship-pill/snaps-authorship-pill.stories.js b/ui/components/app/flask/snaps-authorship-pill/snaps-authorship-pill.stories.js index 2bd50d0df..3808ea5ba 100644 --- a/ui/components/app/flask/snaps-authorship-pill/snaps-authorship-pill.stories.js +++ b/ui/components/app/flask/snaps-authorship-pill/snaps-authorship-pill.stories.js @@ -6,10 +6,7 @@ export default { id: __filename, component: SnapsAuthorshipPill, argTypes: { - packageName: { - control: 'text', - }, - url: { + snapId: { control: 'text', }, }, @@ -20,6 +17,5 @@ export const DefaultStory = (args) => ; DefaultStory.storyName = 'Default'; DefaultStory.args = { - packageName: 'npm-package-name', - url: 'https://www.npmjs.com/package/@airswap/protocols', + snapId: 'npm:@metamask/test-snap-bip44', }; diff --git a/ui/components/app/permissions-connect-header/index.scss b/ui/components/app/permissions-connect-header/index.scss index faecd4ab1..3f77ad9f5 100644 --- a/ui/components/app/permissions-connect-header/index.scss +++ b/ui/components/app/permissions-connect-header/index.scss @@ -7,6 +7,7 @@ display: flex; flex-direction: column; align-items: center; + margin-bottom: 16px; } &__title { @@ -14,7 +15,6 @@ text-align: center; color: var(--color-text-default); - margin-top: 16px; font-weight: bold; } diff --git a/ui/components/app/permissions-connect-header/permissions-connect-header.component.js b/ui/components/app/permissions-connect-header/permissions-connect-header.component.js index 00400d44b..482535ab9 100644 --- a/ui/components/app/permissions-connect-header/permissions-connect-header.component.js +++ b/ui/components/app/permissions-connect-header/permissions-connect-header.component.js @@ -31,8 +31,8 @@ export default class PermissionsConnectHeader extends Component { boxProps: PropTypes.shape({ ...Box.propTypes }), headerText: PropTypes.string, ///: BEGIN:ONLY_INCLUDE_IN(flask) - npmPackageName: PropTypes.string, snapVersion: PropTypes.string, + isSnapInstall: PropTypes.bool, ///: END:ONLY_INCLUDE_IN }; @@ -44,7 +44,20 @@ export default class PermissionsConnectHeader extends Component { }; renderHeaderIcon() { - const { iconUrl, iconName, siteOrigin } = this.props; + const { + iconUrl, + iconName, + siteOrigin, + ///: BEGIN:ONLY_INCLUDE_IN(flask) + isSnapInstall, + ///: END:ONLY_INCLUDE_IN + } = this.props; + + ///: BEGIN:ONLY_INCLUDE_IN(flask) + if (isSnapInstall) { + return null; + } + ///: END:ONLY_INCLUDE_IN return (
@@ -64,12 +77,12 @@ export default class PermissionsConnectHeader extends Component { headerTitle, headerText, ///: BEGIN:ONLY_INCLUDE_IN(flask) - npmPackageName, + siteOrigin, snapVersion, + isSnapInstall, ///: END:ONLY_INCLUDE_IN } = this.props; ///: BEGIN:ONLY_INCLUDE_IN(flask) - const npmPackageUrl = `https://www.npmjs.com/package/${npmPackageName}`; const { t } = this.context; ///: END:ONLY_INCLUDE_IN return ( @@ -83,12 +96,7 @@ export default class PermissionsConnectHeader extends Component {
{headerTitle}
{ ///: BEGIN:ONLY_INCLUDE_IN(flask) - npmPackageName ? ( - - ) : null + isSnapInstall && ///: END:ONLY_INCLUDE_IN } { diff --git a/ui/pages/permissions-connect/flask/snap-install/snap-install.js b/ui/pages/permissions-connect/flask/snap-install/snap-install.js index 497ca45af..466a874fa 100644 --- a/ui/pages/permissions-connect/flask/snap-install/snap-install.js +++ b/ui/pages/permissions-connect/flask/snap-install/snap-install.js @@ -37,13 +37,6 @@ export default function SnapInstall({ approveSnapInstall, ]); - const npmId = useMemo(() => { - if (!targetSubjectMetadata.origin.startsWith('npm:')) { - return undefined; - } - return targetSubjectMetadata.origin.substring(4); - }, [targetSubjectMetadata]); - const shouldShowWarning = useMemo( () => Boolean( @@ -74,7 +67,7 @@ export default function SnapInstall({ headerTitle={t('snapInstall')} headerText={null} // TODO(ritave): Add header text when snaps support description siteOrigin={targetSubjectMetadata.origin} - npmPackageName={npmId} + isSnapInstall snapVersion={targetSubjectMetadata.version} boxProps={{ alignItems: ALIGN_ITEMS.CENTER }} /> diff --git a/ui/pages/settings/flask/view-snap/view-snap.js b/ui/pages/settings/flask/view-snap/view-snap.js index eab873053..0fa9964c1 100644 --- a/ui/pages/settings/flask/view-snap/view-snap.js +++ b/ui/pages/settings/flask/view-snap/view-snap.js @@ -47,7 +47,6 @@ function ViewSnap() { } }, [history, snap]); - const authorshipPillUrl = `https://npmjs.com/package/${snap?.manifest.source.location.npm.packageName}`; const connectedSubjects = useSelector((state) => getSubjectsWithPermission(state, snap?.permissionName), ); @@ -87,10 +86,7 @@ function ViewSnap() { - +