diff --git a/ui/components/app/snaps/snap-authorship-expanded/snap-authorship-expanded.js b/ui/components/app/snaps/snap-authorship-expanded/snap-authorship-expanded.js index ac3fefd72d27..0c3eb1f0bfac 100644 --- a/ui/components/app/snaps/snap-authorship-expanded/snap-authorship-expanded.js +++ b/ui/components/app/snaps/snap-authorship-expanded/snap-authorship-expanded.js @@ -1,38 +1,36 @@ -import React from 'react'; -import PropTypes from 'prop-types'; -import classnames from 'classnames'; import { getSnapPrefix } from '@metamask/snaps-utils'; +import classnames from 'classnames'; +import PropTypes from 'prop-types'; +import React from 'react'; import { useDispatch, useSelector } from 'react-redux'; -import Box from '../../../ui/box'; import { + AlignItems, BackgroundColor, - TextColor, - FLEX_DIRECTION, - TextVariant, + BlockSize, BorderColor, - AlignItems, - DISPLAY, - BLOCK_SIZES, - JustifyContent, + BorderRadius, BorderStyle, Color, - BorderRadius, + Display, + FlexDirection, FontWeight, + JustifyContent, + TextColor, + TextVariant, } from '../../../../helpers/constants/design-system'; import { formatDate, getSnapName, removeSnapIdPrefix, } from '../../../../helpers/utils/util'; - -import { ButtonLink, Text } from '../../../component-library'; -import { getTargetSubjectMetadata } from '../../../../selectors'; -import SnapAvatar from '../snap-avatar'; import { useI18nContext } from '../../../../hooks/useI18nContext'; -import Tooltip from '../../../ui/tooltip/tooltip'; -import ToggleButton from '../../../ui/toggle-button'; -import { disableSnap, enableSnap } from '../../../../store/actions'; import { useOriginMetadata } from '../../../../hooks/useOriginMetadata'; +import { getTargetSubjectMetadata } from '../../../../selectors'; +import { disableSnap, enableSnap } from '../../../../store/actions'; +import { Box, ButtonLink, Text } from '../../../component-library'; +import ToggleButton from '../../../ui/toggle-button'; +import Tooltip from '../../../ui/tooltip/tooltip'; +import SnapAvatar from '../snap-avatar'; import SnapVersion from '../snap-version/snap-version'; const SnapAuthorshipExpanded = ({ snapId, className, snap }) => { @@ -46,8 +44,10 @@ const SnapAuthorshipExpanded = ({ snapId, className, snap }) => { const snapPrefix = snapId && getSnapPrefix(snapId); const packageName = snapId && removeSnapIdPrefix(snapId); const isNPM = snapPrefix === 'npm:'; + + const versionPath = snap?.version ? `/v/${snap?.version}` : ''; const url = isNPM - ? `https://www.npmjs.com/package/${packageName}` + ? `https://www.npmjs.com/package/${packageName}${versionPath}` : packageName; const subjectMetadata = useSelector((state) => @@ -76,13 +76,13 @@ const SnapAuthorshipExpanded = ({ snapId, className, snap }) => { backgroundColor={BackgroundColor.backgroundDefault} borderColor={BorderColor.borderDefault} borderWidth={1} - width={BLOCK_SIZES.FULL} + width={BlockSize.Full} borderRadius={BorderRadius.LG} > { @@ -110,69 +110,67 @@ const SnapAuthorshipExpanded = ({ snapId, className, snap }) => { - - - - {t('enabled')} - - - - - - + + + {t('enabled')} + + + + + - - {installOrigin && installInfo && ( - - - {t('installOrigin')} - - - - {installOrigin.host} - - - {t('installedOn', [ - formatDate(installInfo.date, 'dd MMM yyyy'), - ])} - - - - )} + + + {installOrigin && installInfo && ( - {t('version')} + {t('installOrigin')} - + + + {installOrigin.host} + + + {t('installedOn', [ + formatDate(installInfo.date, 'dd MMM yyyy'), + ])} + + + )} + + + {t('version')} + + diff --git a/ui/components/app/snaps/snap-authorship-header/snap-authorship-header.js b/ui/components/app/snaps/snap-authorship-header/snap-authorship-header.js index fd0848677e28..139bb8360942 100644 --- a/ui/components/app/snaps/snap-authorship-header/snap-authorship-header.js +++ b/ui/components/app/snaps/snap-authorship-header/snap-authorship-header.js @@ -35,14 +35,18 @@ const SnapAuthorshipHeader = ({ const snapPrefix = snapId && getSnapPrefix(snapId); const packageName = snapId && removeSnapIdPrefix(snapId); const isNPM = snapPrefix === 'npm:'; - const url = isNPM - ? `https://www.npmjs.com/package/${packageName}` - : packageName; const subjectMetadata = useSelector((state) => getTargetSubjectMetadata(state, snapId), ); + const versionPath = subjectMetadata?.version + ? `/v/${subjectMetadata?.version}` + : ''; + const url = isNPM + ? `https://www.npmjs.com/package/${packageName}${versionPath}` + : packageName; + const friendlyName = snapId && getSnapName(snapId, subjectMetadata); return (