From 54b2f70ab46d487c3e517f36a209ecb9083edc8c Mon Sep 17 00:00:00 2001 From: Monte Lai Date: Wed, 4 Oct 2023 20:40:23 +0800 Subject: [PATCH] fix: add missing update available and arrow icon (#21101) Adds a missing `Update Available` and arrow icon in the Add Snap Account Page. --- ui/pages/keyring-snaps/index.scss | 1 + .../new-snap-account-page.tsx | 6 +++++ .../snap-account-detail-page/header.tsx | 2 +- .../__snapshots__/snap-card.test.tsx.snap | 4 +-- .../keyring-snaps/snap-card/snap-card.scss | 7 +++++ .../snap-card/snap-card.test.tsx | 9 +++++++ .../keyring-snaps/snap-card/snap-card.tsx | 27 +++++++++++++++++-- 7 files changed, 51 insertions(+), 5 deletions(-) create mode 100644 ui/pages/keyring-snaps/snap-card/snap-card.scss diff --git a/ui/pages/keyring-snaps/index.scss b/ui/pages/keyring-snaps/index.scss index 8762f63fd28c..0094ced75fc7 100644 --- a/ui/pages/keyring-snaps/index.scss +++ b/ui/pages/keyring-snaps/index.scss @@ -1,2 +1,3 @@ @import "./snap-account-detail-page/snap-account-detail-page"; @import "./new-snap-account-page/new-snap-account-page"; +@import "./snap-card/snap-card"; diff --git a/ui/pages/keyring-snaps/new-snap-account-page/new-snap-account-page.tsx b/ui/pages/keyring-snaps/new-snap-account-page/new-snap-account-page.tsx index 2ec9aea8c6e9..03aa44b3bcde 100644 --- a/ui/pages/keyring-snaps/new-snap-account-page/new-snap-account-page.tsx +++ b/ui/pages/keyring-snaps/new-snap-account-page/new-snap-account-page.tsx @@ -2,6 +2,7 @@ import { Snap } from '@metamask/snaps-utils'; import React, { useState, useEffect } from 'react'; import { shallowEqual, useSelector } from 'react-redux'; import { useHistory } from 'react-router-dom'; +import semver from 'semver'; import { Box, Text } from '../../../components/component-library'; import { AlignItems, @@ -116,11 +117,16 @@ export default function NewSnapAccountPage() { const isInstalled = Boolean(foundSnap); + const updateAvailable = Boolean( + foundSnap?.version && semver.gt(snap.version, foundSnap.version), + ); + return ( { history.push(`/add-snap-account/${snap.id}`); }} diff --git a/ui/pages/keyring-snaps/snap-account-detail-page/header.tsx b/ui/pages/keyring-snaps/snap-account-detail-page/header.tsx index 9a53cbd67762..8786b9c1260f 100644 --- a/ui/pages/keyring-snaps/snap-account-detail-page/header.tsx +++ b/ui/pages/keyring-snaps/snap-account-detail-page/header.tsx @@ -91,7 +91,7 @@ export const SnapDetailHeader = ({ {isInstalled && updateAvailable && ( ) : (