1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00

[FLASK] Update snap delineator (#18385)

This commit is contained in:
Guillaume Roux 2023-04-03 18:04:30 +02:00 committed by GitHub
parent 1304ec7af5
commit f51055802f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
32 changed files with 275 additions and 165 deletions

View File

@ -3355,10 +3355,6 @@
"snaps": { "snaps": {
"message": "Snaps" "message": "Snaps"
}, },
"snapsInsightError": {
"message": "Ein Fehler ist mit $1: $2 aufgetreten",
"description": "This is shown when the insight snap throws an error. $1 is the snap name, $2 is the error message."
},
"snapsInsightLoading": { "snapsInsightLoading": {
"message": "Transaktions-Einsicht wird geladen ..." "message": "Transaktions-Einsicht wird geladen ..."
}, },
@ -3375,7 +3371,8 @@
"message": "Ein Snap wird nur ausgeführt, wenn er aktiviert ist" "message": "Ein Snap wird nur ausgeführt, wenn er aktiviert ist"
}, },
"snapsUIError": { "snapsUIError": {
"message": "Die vom Snap spezifizierte UI ist ungültig." "message": "Die vom Snap spezifizierte UI ist ungültig.",
"description": "This is shown when the insight snap throws an error. $1 is the snap name"
}, },
"someNetworksMayPoseSecurity": { "someNetworksMayPoseSecurity": {
"message": "Einige Netzwerke können Sicherheits- und/oder Datenschutzrisiken bergen. Informieren Sie sich über die Risiken, bevor Sie ein Netzwerk hinzufügen und nutzen." "message": "Einige Netzwerke können Sicherheits- und/oder Datenschutzrisiken bergen. Informieren Sie sich über die Risiken, bevor Sie ein Netzwerk hinzufügen und nutzen."

View File

@ -3355,10 +3355,6 @@
"snaps": { "snaps": {
"message": "Snaps" "message": "Snaps"
}, },
"snapsInsightError": {
"message": "Παρουσιάστηκε ένα σφάλμα με $1: $2",
"description": "This is shown when the insight snap throws an error. $1 is the snap name, $2 is the error message."
},
"snapsInsightLoading": { "snapsInsightLoading": {
"message": "Φόρτωση πληροφοριών συναλλαγών..." "message": "Φόρτωση πληροφοριών συναλλαγών..."
}, },
@ -3375,7 +3371,8 @@
"message": "Ένα snap θα εκτελεστεί μόνο εάν είναι ενεργοποιημένο" "message": "Ένα snap θα εκτελεστεί μόνο εάν είναι ενεργοποιημένο"
}, },
"snapsUIError": { "snapsUIError": {
"message": "Η Διεπαφή Χρήστη (UI) που καθορίζεται από το στιγμιότυπο δεν είναι έγκυρη." "message": "Η Διεπαφή Χρήστη (UI) που καθορίζεται από το στιγμιότυπο δεν είναι έγκυρη.",
"description": "This is shown when the insight snap throws an error. $1 is the snap name"
}, },
"someNetworksMayPoseSecurity": { "someNetworksMayPoseSecurity": {
"message": "Ορισμένα δίκτυα ενδέχεται να ενέχουν κινδύνους για την ασφάλεια ή/και το απόρρητο. Ενημερωθείτε για τους κινδύνους πριν προσθέσετε και χρησιμοποιήσετε ένα δίκτυο." "message": "Ορισμένα δίκτυα ενδέχεται να ενέχουν κινδύνους για την ασφάλεια ή/και το απόρρητο. Ενημερωθείτε για τους κινδύνους πριν προσθέσετε και χρησιμοποιήσετε ένα δίκτυο."

View File

@ -1374,6 +1374,10 @@
"errorWhileConnectingToRPC": { "errorWhileConnectingToRPC": {
"message": "Error while connecting to the custom network." "message": "Error while connecting to the custom network."
}, },
"errorWithSnap": {
"message": "Error with $1",
"description": "$1 represents the name of the snap"
},
"ethGasPriceFetchWarning": { "ethGasPriceFetchWarning": {
"message": "Backup gas price is provided as the main gas estimation service is unavailable right now." "message": "Backup gas price is provided as the main gas estimation service is unavailable right now."
}, },
@ -1801,6 +1805,10 @@
"inputLogicHigherNumber": { "inputLogicHigherNumber": {
"message": "This allows the contract to spend all your token balance until it reaches the cap or you revoke the spending cap. If this is not intended, consider setting a lower spending cap." "message": "This allows the contract to spend all your token balance until it reaches the cap or you revoke the spending cap. If this is not intended, consider setting a lower spending cap."
}, },
"insightsFromSnap": {
"message": "Insights from $1",
"description": "$1 represents the name of the snap"
},
"install": { "install": {
"message": "Install" "message": "Install"
}, },
@ -3627,13 +3635,12 @@
"snaps": { "snaps": {
"message": "Snaps" "message": "Snaps"
}, },
"snapsInsightError": {
"message": "An error occured with $1: $2",
"description": "This is shown when the insight snap throws an error. $1 is the snap name, $2 is the error message."
},
"snapsInsightLoading": { "snapsInsightLoading": {
"message": "Loading transaction insight..." "message": "Loading transaction insight..."
}, },
"snapsInvalidUIError": {
"message": "The UI specified by the snap is invalid."
},
"snapsNoInsight": { "snapsNoInsight": {
"message": "The snap didn't return any insight" "message": "The snap didn't return any insight"
}, },
@ -3647,7 +3654,8 @@
"message": "A snap will only run if it is enabled" "message": "A snap will only run if it is enabled"
}, },
"snapsUIError": { "snapsUIError": {
"message": "The UI specified by the snap is invalid." "message": "Contact the creators of $1 for further support.",
"description": "This is shown when the insight snap throws an error. $1 is the snap name"
}, },
"someNetworksMayPoseSecurity": { "someNetworksMayPoseSecurity": {
"message": "Some networks may pose security and/or privacy risks. Understand the risks before adding & using a network." "message": "Some networks may pose security and/or privacy risks. Understand the risks before adding & using a network."

View File

@ -3355,10 +3355,6 @@
"snaps": { "snaps": {
"message": "Complementos" "message": "Complementos"
}, },
"snapsInsightError": {
"message": "Ocurrió un error con $1: $2",
"description": "This is shown when the insight snap throws an error. $1 is the snap name, $2 is the error message."
},
"snapsInsightLoading": { "snapsInsightLoading": {
"message": "Cargando información de transacción..." "message": "Cargando información de transacción..."
}, },
@ -3375,7 +3371,8 @@
"message": "Un complemento solo se ejecutará si está habilitado" "message": "Un complemento solo se ejecutará si está habilitado"
}, },
"snapsUIError": { "snapsUIError": {
"message": "La IU especificada por el complemento no es válida." "message": "La IU especificada por el complemento no es válida.",
"description": "This is shown when the insight snap throws an error. $1 is the snap name"
}, },
"someNetworksMayPoseSecurity": { "someNetworksMayPoseSecurity": {
"message": "Algunas redes pueden presentar riesgos de seguridad y/o privacidad. Comprenda los riesgos antes de agregar y utilizar una red." "message": "Algunas redes pueden presentar riesgos de seguridad y/o privacidad. Comprenda los riesgos antes de agregar y utilizar una red."

View File

@ -3355,10 +3355,6 @@
"snaps": { "snaps": {
"message": "Snaps" "message": "Snaps"
}, },
"snapsInsightError": {
"message": "Une erreur sest produite avec $1: $2",
"description": "This is shown when the insight snap throws an error. $1 is the snap name, $2 is the error message."
},
"snapsInsightLoading": { "snapsInsightLoading": {
"message": "Chargement de laperçu de transaction…" "message": "Chargement de laperçu de transaction…"
}, },
@ -3375,7 +3371,8 @@
"message": "Un snap ne sexécute que sil est activé" "message": "Un snap ne sexécute que sil est activé"
}, },
"snapsUIError": { "snapsUIError": {
"message": "Linterface utilisateur (IU) spécifiée par le snap nest pas valide." "message": "Linterface utilisateur (IU) spécifiée par le snap nest pas valide.",
"description": "This is shown when the insight snap throws an error. $1 is the snap name"
}, },
"someNetworksMayPoseSecurity": { "someNetworksMayPoseSecurity": {
"message": "Certains réseaux peuvent présenter des risques pour la sécurité et/ou la vie privée. Informez-vous sur les risques avant dajouter et dutiliser un réseau." "message": "Certains réseaux peuvent présenter des risques pour la sécurité et/ou la vie privée. Informez-vous sur les risques avant dajouter et dutiliser un réseau."

View File

@ -3355,10 +3355,6 @@
"snaps": { "snaps": {
"message": "स्नैप्स" "message": "स्नैप्स"
}, },
"snapsInsightError": {
"message": "$1: $2 के साथ त्रुटि हुई",
"description": "This is shown when the insight snap throws an error. $1 is the snap name, $2 is the error message."
},
"snapsInsightLoading": { "snapsInsightLoading": {
"message": "ट्रांजैक्शन इनसाइट लोड हो रही है..." "message": "ट्रांजैक्शन इनसाइट लोड हो रही है..."
}, },
@ -3375,7 +3371,8 @@
"message": "कोई स्नैप तभी चलेगा जब उसे सक्षम किया गया हो" "message": "कोई स्नैप तभी चलेगा जब उसे सक्षम किया गया हो"
}, },
"snapsUIError": { "snapsUIError": {
"message": "स्नैप द्वारा विनिर्दिष्टत UI अमान्य है।" "message": "स्नैप द्वारा विनिर्दिष्टत UI अमान्य है।",
"description": "This is shown when the insight snap throws an error. $1 is the snap name"
}, },
"someNetworksMayPoseSecurity": { "someNetworksMayPoseSecurity": {
"message": "कुछ नेटवर्क सुरक्षा और/या गोपनीयता संबंधी जोखिम पैदा कर सकते हैं। नेटवर्क जोड़ने और उपयोग करने से पहले जोखिमों को समझें।" "message": "कुछ नेटवर्क सुरक्षा और/या गोपनीयता संबंधी जोखिम पैदा कर सकते हैं। नेटवर्क जोड़ने और उपयोग करने से पहले जोखिमों को समझें।"

View File

@ -3355,10 +3355,6 @@
"snaps": { "snaps": {
"message": "Snap" "message": "Snap"
}, },
"snapsInsightError": {
"message": "Terjadi kesalahan dengan $1: $2",
"description": "This is shown when the insight snap throws an error. $1 is the snap name, $2 is the error message."
},
"snapsInsightLoading": { "snapsInsightLoading": {
"message": "Memuat wawasan transaksi..." "message": "Memuat wawasan transaksi..."
}, },
@ -3375,7 +3371,8 @@
"message": "Snap hanya akan beroperasi jika diaktifkan" "message": "Snap hanya akan beroperasi jika diaktifkan"
}, },
"snapsUIError": { "snapsUIError": {
"message": "UI yang ditentukan oleh snap tidak valid." "message": "UI yang ditentukan oleh snap tidak valid.",
"description": "This is shown when the insight snap throws an error. $1 is the snap name"
}, },
"someNetworksMayPoseSecurity": { "someNetworksMayPoseSecurity": {
"message": "Beberapa jaringan dapat menimbulkan risiko keamanan dan/atau privasi. Pahami risikonya sebelum menambahkan & menggunakan jaringan." "message": "Beberapa jaringan dapat menimbulkan risiko keamanan dan/atau privasi. Pahami risikonya sebelum menambahkan & menggunakan jaringan."

View File

@ -3355,10 +3355,6 @@
"snaps": { "snaps": {
"message": "スナップ" "message": "スナップ"
}, },
"snapsInsightError": {
"message": "$1 でエラーが発生しました: $2",
"description": "This is shown when the insight snap throws an error. $1 is the snap name, $2 is the error message."
},
"snapsInsightLoading": { "snapsInsightLoading": {
"message": "トランザクションインサイトを読み込み中..." "message": "トランザクションインサイトを読み込み中..."
}, },
@ -3375,7 +3371,8 @@
"message": "スナップは有効になっている場合にのみ実行されます" "message": "スナップは有効になっている場合にのみ実行されます"
}, },
"snapsUIError": { "snapsUIError": {
"message": "スナップにより指定された UI が無効です。" "message": "スナップにより指定された UI が無効です。",
"description": "This is shown when the insight snap throws an error. $1 is the snap name"
}, },
"someNetworksMayPoseSecurity": { "someNetworksMayPoseSecurity": {
"message": "ネットワークによっては、セキュリティやプライバシーの面でリスクが伴う可能性があります。ネットワークを追加・使用する前にリスクを理解するようにしてください。" "message": "ネットワークによっては、セキュリティやプライバシーの面でリスクが伴う可能性があります。ネットワークを追加・使用する前にリスクを理解するようにしてください。"

View File

@ -3355,10 +3355,6 @@
"snaps": { "snaps": {
"message": "스냅" "message": "스냅"
}, },
"snapsInsightError": {
"message": "$1 관련 오류 발생: $2",
"description": "This is shown when the insight snap throws an error. $1 is the snap name, $2 is the error message."
},
"snapsInsightLoading": { "snapsInsightLoading": {
"message": "거래 인사이트를 가져오는 중..." "message": "거래 인사이트를 가져오는 중..."
}, },
@ -3375,7 +3371,8 @@
"message": "스냅은 활성화된 상태에서만 작동합니다." "message": "스냅은 활성화된 상태에서만 작동합니다."
}, },
"snapsUIError": { "snapsUIError": {
"message": "스냅에서 지정한 UI가 올바르지 않습니다." "message": "스냅에서 지정한 UI가 올바르지 않습니다.",
"description": "This is shown when the insight snap throws an error. $1 is the snap name"
}, },
"someNetworksMayPoseSecurity": { "someNetworksMayPoseSecurity": {
"message": "네트워크에 따라 보안이나 개인 정보 유출의 위험이 있을 수 있습니다. 네트워크 추가 및 사용 이전에 위험 요소를 파악하세요." "message": "네트워크에 따라 보안이나 개인 정보 유출의 위험이 있을 수 있습니다. 네트워크 추가 및 사용 이전에 위험 요소를 파악하세요."

View File

@ -3355,10 +3355,6 @@
"snaps": { "snaps": {
"message": "Snaps" "message": "Snaps"
}, },
"snapsInsightError": {
"message": "Ocorreu um erro com $1: $2",
"description": "This is shown when the insight snap throws an error. $1 is the snap name, $2 is the error message."
},
"snapsInsightLoading": { "snapsInsightLoading": {
"message": "Carregando insight da transação..." "message": "Carregando insight da transação..."
}, },
@ -3375,7 +3371,8 @@
"message": "O snap só será executado se estiver ativado" "message": "O snap só será executado se estiver ativado"
}, },
"snapsUIError": { "snapsUIError": {
"message": "A IU especificada pelo snap é inválida." "message": "A IU especificada pelo snap é inválida.",
"description": "This is shown when the insight snap throws an error. $1 is the snap name"
}, },
"someNetworksMayPoseSecurity": { "someNetworksMayPoseSecurity": {
"message": "Algumas redes podem representar riscos de segurança e/ou privacidade. Tenha os riscos em mente antes de adicionar e usar uma rede." "message": "Algumas redes podem representar riscos de segurança e/ou privacidade. Tenha os riscos em mente antes de adicionar e usar uma rede."

View File

@ -3355,10 +3355,6 @@
"snaps": { "snaps": {
"message": "Снапы" "message": "Снапы"
}, },
"snapsInsightError": {
"message": "Произошла ошибка с $1: $2",
"description": "This is shown when the insight snap throws an error. $1 is the snap name, $2 is the error message."
},
"snapsInsightLoading": { "snapsInsightLoading": {
"message": "Загрузка аналитики по транзакции..." "message": "Загрузка аналитики по транзакции..."
}, },
@ -3375,7 +3371,8 @@
"message": "Снап будет работать только в том случае, если он включен" "message": "Снап будет работать только в том случае, если он включен"
}, },
"snapsUIError": { "snapsUIError": {
"message": "Пользовательский интерфейс, указанный привязкой, недействителен." "message": "Пользовательский интерфейс, указанный привязкой, недействителен.",
"description": "This is shown when the insight snap throws an error. $1 is the snap name"
}, },
"someNetworksMayPoseSecurity": { "someNetworksMayPoseSecurity": {
"message": "Некоторые сети могут представлять угрозу безопасности и/или конфиденциальности. Прежде чем добавлять и использовать сеть, ознакомьтесь с рисками." "message": "Некоторые сети могут представлять угрозу безопасности и/или конфиденциальности. Прежде чем добавлять и использовать сеть, ознакомьтесь с рисками."

View File

@ -3355,10 +3355,6 @@
"snaps": { "snaps": {
"message": "Mga Snap" "message": "Mga Snap"
}, },
"snapsInsightError": {
"message": "Nagkaroon ng error sa $1: $2",
"description": "This is shown when the insight snap throws an error. $1 is the snap name, $2 is the error message."
},
"snapsInsightLoading": { "snapsInsightLoading": {
"message": "Naglo-load ng insight sa transaksyon..." "message": "Naglo-load ng insight sa transaksyon..."
}, },
@ -3375,7 +3371,8 @@
"message": "Tatakbo lamang ang snap kapag pinagana ito" "message": "Tatakbo lamang ang snap kapag pinagana ito"
}, },
"snapsUIError": { "snapsUIError": {
"message": "Ang UI na tinukoy sa pamamagitan ng snap ay hindi wasto." "message": "Ang UI na tinukoy sa pamamagitan ng snap ay hindi wasto.",
"description": "This is shown when the insight snap throws an error. $1 is the snap name"
}, },
"someNetworksMayPoseSecurity": { "someNetworksMayPoseSecurity": {
"message": "Maaaring magdulot ang ilang network ng mga panganib sa seguridad at/o pagkapribado. Unawain ang mga panganib bago idagdag o gamitin ang isang network." "message": "Maaaring magdulot ang ilang network ng mga panganib sa seguridad at/o pagkapribado. Unawain ang mga panganib bago idagdag o gamitin ang isang network."

View File

@ -3355,10 +3355,6 @@
"snaps": { "snaps": {
"message": "Snap'ler" "message": "Snap'ler"
}, },
"snapsInsightError": {
"message": "$1: $2 ile ilgili bir hata oldu",
"description": "This is shown when the insight snap throws an error. $1 is the snap name, $2 is the error message."
},
"snapsInsightLoading": { "snapsInsightLoading": {
"message": "İşlem ayrıntıları yükleniyor..." "message": "İşlem ayrıntıları yükleniyor..."
}, },
@ -3375,7 +3371,8 @@
"message": "Bir snap yalnızca etkinleştirilmişse çalışır" "message": "Bir snap yalnızca etkinleştirilmişse çalışır"
}, },
"snapsUIError": { "snapsUIError": {
"message": "Snap tarafından belirtilen Kullanıcı Arayüzü geçersiz." "message": "Snap tarafından belirtilen Kullanıcı Arayüzü geçersiz.",
"description": "This is shown when the insight snap throws an error. $1 is the snap name"
}, },
"someNetworksMayPoseSecurity": { "someNetworksMayPoseSecurity": {
"message": "Bazı ağlar güvenlik ve/veya gizlilik riskleri teşkil edebilir. Bir ağ eklemeden ve kullanmadan önce riskleri anlayın." "message": "Bazı ağlar güvenlik ve/veya gizlilik riskleri teşkil edebilir. Bir ağ eklemeden ve kullanmadan önce riskleri anlayın."

View File

@ -3355,10 +3355,6 @@
"snaps": { "snaps": {
"message": "Snap" "message": "Snap"
}, },
"snapsInsightError": {
"message": "Đã xảy ra lỗi với $1: $2",
"description": "This is shown when the insight snap throws an error. $1 is the snap name, $2 is the error message."
},
"snapsInsightLoading": { "snapsInsightLoading": {
"message": "Đang tải thông tin chi tiết về giao dịch..." "message": "Đang tải thông tin chi tiết về giao dịch..."
}, },
@ -3375,7 +3371,8 @@
"message": "Snap chỉ hoạt động khi đã bật" "message": "Snap chỉ hoạt động khi đã bật"
}, },
"snapsUIError": { "snapsUIError": {
"message": "Giao diện người dùng được chỉ định bởi snap không hợp lệ." "message": "Giao diện người dùng được chỉ định bởi snap không hợp lệ.",
"description": "This is shown when the insight snap throws an error. $1 is the snap name"
}, },
"someNetworksMayPoseSecurity": { "someNetworksMayPoseSecurity": {
"message": "Một số mạng có thể gây ra rủi ro về bảo mật và/hoặc quyền riêng tư. Bạn cần hiểu rõ các rủi ro này trước khi thêm và sử dụng mạng." "message": "Một số mạng có thể gây ra rủi ro về bảo mật và/hoặc quyền riêng tư. Bạn cần hiểu rõ các rủi ro này trước khi thêm và sử dụng mạng."

View File

@ -3355,10 +3355,6 @@
"snaps": { "snaps": {
"message": "Snap" "message": "Snap"
}, },
"snapsInsightError": {
"message": "$1 发生错误:$2",
"description": "This is shown when the insight snap throws an error. $1 is the snap name, $2 is the error message."
},
"snapsInsightLoading": { "snapsInsightLoading": {
"message": "正在加载交易洞察……" "message": "正在加载交易洞察……"
}, },
@ -3375,7 +3371,8 @@
"message": "Snap仅在启用后才会运行" "message": "Snap仅在启用后才会运行"
}, },
"snapsUIError": { "snapsUIError": {
"message": "Snap指定的用户界面无效。" "message": "Snap指定的用户界面无效。",
"description": "This is shown when the insight snap throws an error. $1 is the snap name"
}, },
"someNetworksMayPoseSecurity": { "someNetworksMayPoseSecurity": {
"message": "某些网络可能会带来安全和/或隐私风险。在添加和使用网络之前,请先了解风险。" "message": "某些网络可能会带来安全和/或隐私风险。在添加和使用网络之前,请先了解风险。"

View File

@ -1,6 +1,7 @@
import React from 'react'; import React from 'react';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import { useSelector } from 'react-redux';
import Preloader from '../../../ui/icon/preloader/preloader-icon.component'; import Preloader from '../../../ui/icon/preloader/preloader-icon.component';
import { Text } from '../../../component-library'; import { Text } from '../../../component-library';
import { import {
@ -14,8 +15,12 @@ import {
import { useI18nContext } from '../../../../hooks/useI18nContext'; import { useI18nContext } from '../../../../hooks/useI18nContext';
import { useTransactionInsightSnap } from '../../../../hooks/flask/useTransactionInsightSnap'; import { useTransactionInsightSnap } from '../../../../hooks/flask/useTransactionInsightSnap';
import Box from '../../../ui/box/box'; import Box from '../../../ui/box/box';
import ActionableMessage from '../../../ui/actionable-message/actionable-message';
import { SnapUIRenderer } from '../../flask/snap-ui-renderer'; import { SnapUIRenderer } from '../../flask/snap-ui-renderer';
import { SnapDelineator } from '../../flask/snap-delineator';
import { DelineatorType } from '../../../../helpers/constants/flask';
import { getSnapName } from '../../../../helpers/utils/util';
import { Copyable } from '../../flask/copyable';
import { getTargetSubjectMetadata } from '../../../../selectors';
export const SnapInsight = ({ transaction, origin, chainId, selectedSnap }) => { export const SnapInsight = ({ transaction, origin, chainId, selectedSnap }) => {
const t = useI18nContext(); const t = useI18nContext();
@ -30,6 +35,12 @@ export const SnapInsight = ({ transaction, origin, chainId, selectedSnap }) => {
snapId: selectedSnap.id, snapId: selectedSnap.id,
}); });
const targetSubjectMetadata = useSelector((state) =>
getTargetSubjectMetadata(state, selectedSnap.id),
);
const snapName = getSnapName(selectedSnap.id, targetSubjectMetadata);
const data = response?.content; const data = response?.content;
const hasNoData = const hasNoData =
@ -52,7 +63,11 @@ export const SnapInsight = ({ transaction, origin, chainId, selectedSnap }) => {
className="snap-insight__container" className="snap-insight__container"
> >
{data && Object.keys(data).length > 0 ? ( {data && Object.keys(data).length > 0 ? (
<SnapUIRenderer snapId={selectedSnap.id} data={data} /> <SnapUIRenderer
snapId={selectedSnap.id}
data={data}
delineatorType={DelineatorType.Insights}
/>
) : ( ) : (
<Text <Text
color={TextColor.textAlternative} color={TextColor.textAlternative}
@ -66,22 +81,13 @@ export const SnapInsight = ({ transaction, origin, chainId, selectedSnap }) => {
)} )}
{!loading && error && ( {!loading && error && (
<Box <Box padding={4} className="snap-insight__container__error">
paddingTop={0} <SnapDelineator snapName={snapName} type={DelineatorType.Error}>
paddingRight={6} <Text variant={TextVariant.bodySm} marginBottom={4}>
paddingBottom={3} {t('snapsUIError', [<b key="0">{snapName}</b>])}
paddingLeft={6} </Text>
className="snap-insight__container__error" <Copyable text={error.message} />
> </SnapDelineator>
<ActionableMessage
message={t('snapsInsightError', [
selectedSnap.manifest.proposedName,
error.message,
])}
type="danger"
useIcon
iconFillColor="var(--color-error-default)"
/>
</Box> </Box>
)} )}

View File

@ -14,6 +14,7 @@ import {
AlignItems, AlignItems,
DISPLAY, DISPLAY,
BorderRadius, BorderRadius,
BLOCK_SIZES,
} from '../../../../helpers/constants/design-system'; } from '../../../../helpers/constants/design-system';
import { import {
getSnapName, getSnapName,
@ -59,7 +60,7 @@ const SnapAuthorship = ({ snapId, className }) => {
paddingRight={4} paddingRight={4}
borderRadius={BorderRadius.pill} borderRadius={BorderRadius.pill}
display={DISPLAY.FLEX} display={DISPLAY.FLEX}
style={{ maxWidth: 'fit-content', width: '100%' }} width={BLOCK_SIZES.FULL}
> >
<Box> <Box>
<SnapAvatar snapId={snapId} /> <SnapAvatar snapId={snapId} />
@ -87,6 +88,7 @@ const SnapAuthorship = ({ snapId, className }) => {
iconName={ICON_NAMES.EXPORT} iconName={ICON_NAMES.EXPORT}
color={IconColor.infoDefault} color={IconColor.infoDefault}
size={ICON_SIZES.MD} size={ICON_SIZES.MD}
style={{ marginLeft: 'auto' }}
/> />
</Box> </Box>
); );

View File

@ -1,7 +1,7 @@
.snap-delineator { .snap-delineator {
&__header { &__header {
border-bottom-width: 1px; border-bottom-width: 1px;
border-color: var(--color-border-muted); border-color: var(--color-border-default);
border-style: solid; border-style: solid;
border-radius: 8px 8px 0 0; border-radius: 8px 8px 0 0;

View File

@ -3,7 +3,6 @@ import PropTypes from 'prop-types';
import { useI18nContext } from '../../../../hooks/useI18nContext'; import { useI18nContext } from '../../../../hooks/useI18nContext';
import { import {
BorderStyle, BorderStyle,
Size,
BorderColor, BorderColor,
BorderRadius, BorderRadius,
AlignItems, AlignItems,
@ -13,37 +12,60 @@ import {
TextColor, TextColor,
} from '../../../../helpers/constants/design-system'; } from '../../../../helpers/constants/design-system';
import Box from '../../../ui/box'; import Box from '../../../ui/box';
import { Icon, Text } from '../../../component-library'; import {
AvatarIcon,
ICON_NAMES,
ICON_SIZES,
Text,
} from '../../../component-library';
import {
DelineatorType,
getDelineatorTitle,
} from '../../../../helpers/constants/flask';
export const SnapDelineator = ({ snapName, children }) => { export const SnapDelineator = ({
snapName,
type = DelineatorType.default,
children,
}) => {
const t = useI18nContext(); const t = useI18nContext();
const isError = type === DelineatorType.Error;
return ( return (
<Box <Box
className="snap-delineator__wrapper" className="snap-delineator__wrapper"
borderStyle={BorderStyle.solid} borderStyle={BorderStyle.solid}
borderColor={BorderColor.borderMuted} borderColor={BorderColor.borderDefault}
borderRadius={BorderRadius.LG} borderRadius={BorderRadius.LG}
backgroundColor={
isError ? BackgroundColor.errorMuted : BackgroundColor.backgroundDefault
}
> >
<Box <Box
className="snap-delineator__header" className="snap-delineator__header"
alignItems={AlignItems.center} alignItems={AlignItems.center}
backgroundColor={BackgroundColor.infoMuted} padding={1}
paddingLeft={2}
paddingRight={2}
paddingTop={1}
paddingBottom={1}
> >
<Icon name="snaps" color={IconColor.infoDefault} size={Size.SM} /> <AvatarIcon
iconName={ICON_NAMES.SNAPS}
size={ICON_SIZES.XS}
backgroundColor={
isError ? IconColor.errorDefault : IconColor.infoDefault
}
margin={1}
iconProps={{
size: ICON_SIZES.XS,
color: IconColor.infoInverse,
}}
/>
<Text <Text
variant={TextVariant.bodySm} variant={TextVariant.bodySm}
color={TextColor.infoDefault} color={isError ? TextColor.errorDefault : TextColor.default}
className="snap-delineator__header__text" className="snap-delineator__header__text"
marginLeft={1} marginLeft={1}
marginTop={0} marginTop={0}
marginBottom={0} marginBottom={0}
> >
{t('contentFromSnap', [snapName])} {t(getDelineatorTitle(type), [snapName])}
</Text> </Text>
</Box> </Box>
<Box className="snap-delineator__content" padding={4}> <Box className="snap-delineator__content" padding={4}>
@ -55,5 +77,6 @@ export const SnapDelineator = ({ snapName, children }) => {
SnapDelineator.propTypes = { SnapDelineator.propTypes = {
snapName: PropTypes.string, snapName: PropTypes.string,
type: PropTypes.string,
children: PropTypes.ReactNode, children: PropTypes.ReactNode,
}; };

View File

@ -6,5 +6,5 @@ export default {
}; };
export const DefaultStory = () => ( export const DefaultStory = () => (
<SnapDelineator snapId="foo">Children</SnapDelineator> <SnapDelineator snapName="foo">Children</SnapDelineator>
); );

View File

@ -0,0 +1,35 @@
import React from 'react';
import { DelineatorType } from '../../../../helpers/constants/flask';
import { renderWithLocalization } from '../../../../../test/lib/render-helpers';
import { SnapDelineator } from './snap-delineator';
describe('SnapDelineator', () => {
const args = {
snapName: 'Test Snap',
type: DelineatorType.Content,
children: 'This is some test content',
};
it('should render the SnapDelineator with content inside', () => {
const { getByText } = renderWithLocalization(<SnapDelineator {...args} />);
expect(getByText(/Content from Test Snap/u)).toBeDefined();
expect(getByText(args.children)).toBeDefined();
});
it('should render an insight title', () => {
args.type = DelineatorType.Insights;
const { getByText } = renderWithLocalization(<SnapDelineator {...args} />);
expect(getByText(/Insights from Test Snap/u)).toBeDefined();
});
it('should render an error title', () => {
args.type = DelineatorType.Error;
const { getByText } = renderWithLocalization(<SnapDelineator {...args} />);
expect(getByText(/Error with Test Snap/u)).toBeDefined();
});
});

View File

@ -1,8 +1,8 @@
import React from 'react'; import React from 'react';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import { useSelector } from 'react-redux';
import nanoid from 'nanoid'; import nanoid from 'nanoid';
import { isComponent } from '@metamask/snaps-ui'; import { isComponent } from '@metamask/snaps-ui';
import { useSelector } from 'react-redux';
import MetaMaskTemplateRenderer from '../../metamask-template-renderer/metamask-template-renderer'; import MetaMaskTemplateRenderer from '../../metamask-template-renderer/metamask-template-renderer';
import { import {
TypographyVariant, TypographyVariant,
@ -10,12 +10,16 @@ import {
DISPLAY, DISPLAY,
FLEX_DIRECTION, FLEX_DIRECTION,
OVERFLOW_WRAP, OVERFLOW_WRAP,
TextVariant,
} from '../../../../helpers/constants/design-system'; } from '../../../../helpers/constants/design-system';
import { SnapDelineator } from '../snap-delineator'; import { SnapDelineator } from '../snap-delineator';
import { useI18nContext } from '../../../../hooks/useI18nContext'; import { useI18nContext } from '../../../../hooks/useI18nContext';
import ActionableMessage from '../../../ui/actionable-message/actionable-message';
import Box from '../../../ui/box'; import Box from '../../../ui/box';
import { getSnap } from '../../../../selectors'; import { getSnapName } from '../../../../helpers/utils/util';
import { getTargetSubjectMetadata } from '../../../../selectors';
import { Text } from '../../../component-library';
import { Copyable } from '../copyable';
import { DelineatorType } from '../../../../helpers/constants/flask';
export const UI_MAPPING = { export const UI_MAPPING = {
panel: (props) => ({ panel: (props) => ({
@ -70,22 +74,25 @@ export const mapToTemplate = (data) => {
}; };
// Component that maps Snaps UI JSON format to MetaMask Template Renderer format // Component that maps Snaps UI JSON format to MetaMask Template Renderer format
export const SnapUIRenderer = ({ snapId, data }) => { export const SnapUIRenderer = ({
snapId,
delineatorType = DelineatorType.Content,
data,
}) => {
const t = useI18nContext(); const t = useI18nContext();
const snap = useSelector((state) => getSnap(state, snapId)); const targetSubjectMetadata = useSelector((state) =>
getTargetSubjectMetadata(state, snapId),
);
const snapName = snap.manifest.proposedName; const snapName = getSnapName(snapId, targetSubjectMetadata);
if (!isComponent(data)) { if (!isComponent(data)) {
return ( return (
<SnapDelineator snapName={snapName}> <SnapDelineator snapName={snapName} type={DelineatorType.Error}>
<ActionableMessage <Text variant={TextVariant.bodySm} marginBottom={4}>
className="snap-ui-renderer__error" {t('snapsUIError', [<b key="0">{snapName}</b>])}
message={t('snapsUIError')} </Text>
type="danger" <Copyable text={t('snapsInvalidUIError')} />
useIcon
iconFillColor="var(--color-error-default)"
/>
</SnapDelineator> </SnapDelineator>
); );
} }
@ -93,7 +100,7 @@ export const SnapUIRenderer = ({ snapId, data }) => {
const sections = mapToTemplate(data); const sections = mapToTemplate(data);
return ( return (
<SnapDelineator snapName={snapName}> <SnapDelineator snapName={snapName} type={delineatorType}>
<Box className="snap-ui-renderer__content"> <Box className="snap-ui-renderer__content">
<MetaMaskTemplateRenderer sections={sections} /> <MetaMaskTemplateRenderer sections={sections} />
</Box> </Box>
@ -103,5 +110,6 @@ export const SnapUIRenderer = ({ snapId, data }) => {
SnapUIRenderer.propTypes = { SnapUIRenderer.propTypes = {
snapId: PropTypes.string, snapId: PropTypes.string,
delineatorType: PropTypes.string,
data: PropTypes.object, data: PropTypes.object,
}; };

View File

@ -0,0 +1,23 @@
import { DelineatorType, getDelineatorTitle } from './delineator';
describe('delineator utils', () => {
describe('getDelineatorTitle', () => {
it('should return the good key for an error delineator type', () => {
const result = getDelineatorTitle(DelineatorType.Error);
expect(result).toStrictEqual('errorWithSnap');
});
it('should return the good key for an insights delineator type', () => {
const result = getDelineatorTitle(DelineatorType.Insights);
expect(result).toStrictEqual('insightsFromSnap');
});
it('should return the content key for any other types', () => {
const result = getDelineatorTitle(DelineatorType.Content);
expect(result).toStrictEqual('contentFromSnap');
});
});
});

View File

@ -0,0 +1,17 @@
export enum DelineatorType {
Content = 'content',
// eslint-disable-next-line @typescript-eslint/no-shadow
Error = 'error',
Insights = 'insights',
}
export const getDelineatorTitle = (type: DelineatorType) => {
switch (type) {
case DelineatorType.Error:
return 'errorWithSnap';
case DelineatorType.Insights:
return 'insightsFromSnap';
default:
return 'contentFromSnap';
}
};

View File

@ -0,0 +1 @@
export * from './delineator';

View File

@ -17,6 +17,7 @@ import MetaMaskTemplateRenderer from '../../components/app/metamask-template-ren
import ConfirmationWarningModal from '../../components/app/confirmation-warning-modal'; import ConfirmationWarningModal from '../../components/app/confirmation-warning-modal';
import { DEFAULT_ROUTE } from '../../helpers/constants/routes'; import { DEFAULT_ROUTE } from '../../helpers/constants/routes';
import { import {
AlignItems,
FLEX_DIRECTION, FLEX_DIRECTION,
Size, Size,
TextColor, TextColor,
@ -25,7 +26,7 @@ import { useI18nContext } from '../../hooks/useI18nContext';
import { useOriginMetadata } from '../../hooks/useOriginMetadata'; import { useOriginMetadata } from '../../hooks/useOriginMetadata';
import { import {
///: BEGIN:ONLY_INCLUDE_IN(flask) ///: BEGIN:ONLY_INCLUDE_IN(flask)
getSnap, getTargetSubjectMetadata,
///: END:ONLY_INCLUDE_IN ///: END:ONLY_INCLUDE_IN
getUnapprovedTemplatedConfirmations, getUnapprovedTemplatedConfirmations,
getUnapprovedTxCount, getUnapprovedTxCount,
@ -34,6 +35,10 @@ import NetworkDisplay from '../../components/app/network-display/network-display
import Callout from '../../components/ui/callout'; import Callout from '../../components/ui/callout';
import SiteOrigin from '../../components/ui/site-origin'; import SiteOrigin from '../../components/ui/site-origin';
import { Icon, ICON_NAMES } from '../../components/component-library'; import { Icon, ICON_NAMES } from '../../components/component-library';
///: BEGIN:ONLY_INCLUDE_IN(flask)
import SnapAuthorship from '../../components/app/flask/snap-authorship/snap-authorship';
import { getSnapName } from '../../helpers/utils/util';
///: END:ONLY_INCLUDE_IN
import ConfirmationFooter from './components/confirmation-footer'; import ConfirmationFooter from './components/confirmation-footer';
import { import {
getTemplateValues, getTemplateValues,
@ -183,12 +188,14 @@ export default function ConfirmationPage({
const [submitAlerts, setSubmitAlerts] = useState([]); const [submitAlerts, setSubmitAlerts] = useState([]);
///: BEGIN:ONLY_INCLUDE_IN(flask) ///: BEGIN:ONLY_INCLUDE_IN(flask)
const snap = useSelector((state) => const targetSubjectMetadata = useSelector((state) =>
getSnap(state, pendingConfirmation?.origin), getTargetSubjectMetadata(state, pendingConfirmation?.origin),
); );
// When pendingConfirmation is undefined, this will also be undefined // When pendingConfirmation is undefined, this will also be undefined
const proposedName = snap?.manifest.proposedName; const snapName =
targetSubjectMetadata &&
getSnapName(pendingConfirmation?.origin, targetSubjectMetadata);
const SNAP_DIALOG_TYPE = [ const SNAP_DIALOG_TYPE = [
MESSAGE_TYPE.SNAP_DIALOG_ALERT, MESSAGE_TYPE.SNAP_DIALOG_ALERT,
@ -213,7 +220,7 @@ export default function ConfirmationPage({
? getTemplateValues( ? getTemplateValues(
{ {
///: BEGIN:ONLY_INCLUDE_IN(flask) ///: BEGIN:ONLY_INCLUDE_IN(flask)
snapName: isSnapDialog && proposedName, snapName: isSnapDialog && snapName,
///: END:ONLY_INCLUDE_IN ///: END:ONLY_INCLUDE_IN
...pendingConfirmation, ...pendingConfirmation,
}, },
@ -230,7 +237,7 @@ export default function ConfirmationPage({
history, history,
///: BEGIN:ONLY_INCLUDE_IN(flask) ///: BEGIN:ONLY_INCLUDE_IN(flask)
isSnapDialog, isSnapDialog,
proposedName, snapName,
///: END:ONLY_INCLUDE_IN ///: END:ONLY_INCLUDE_IN
]); ]);
@ -327,25 +334,42 @@ export default function ConfirmationPage({
/> />
</Box> </Box>
) : null} ) : null}
{pendingConfirmation.origin === 'metamask' ? null : ( {
<Box ///: BEGIN:ONLY_INCLUDE_IN(flask)
alignItems="center" !isSnapDialog &&
marginTop={1} ///: END:ONLY_INCLUDE_IN
paddingTop={1} pendingConfirmation.origin === 'metamask' && (
paddingRight={4} <Box
paddingLeft={4} alignItems={AlignItems.center}
paddingBottom={4} paddingTop={2}
flexDirection={FLEX_DIRECTION.COLUMN} paddingRight={4}
> paddingLeft={4}
<SiteOrigin paddingBottom={4}
chip flexDirection={FLEX_DIRECTION.COLUMN}
siteOrigin={originMetadata.origin} >
title={originMetadata.origin} <SiteOrigin
iconSrc={originMetadata.iconUrl} chip
iconName={originMetadata.hostname} siteOrigin={originMetadata.origin}
/> title={originMetadata.origin}
</Box> iconSrc={originMetadata.iconUrl}
)} iconName={originMetadata.hostname}
/>
</Box>
)
}
{
///: BEGIN:ONLY_INCLUDE_IN(flask)
isSnapDialog && (
<Box
alignItems="center"
margin={4}
flexDirection={FLEX_DIRECTION.COLUMN}
>
<SnapAuthorship snapId={pendingConfirmation?.origin} />
</Box>
)
///: END:ONLY_INCLUDE_IN
}
<MetaMaskTemplateRenderer sections={templatedValues.content} /> <MetaMaskTemplateRenderer sections={templatedValues.content} />
{showWarningModal && ( {showWarningModal && (
<ConfirmationWarningModal <ConfirmationWarningModal

View File

@ -1,4 +1,5 @@
import { mapToTemplate } from '../../../../../components/app/flask/snap-ui-renderer'; import { mapToTemplate } from '../../../../../components/app/flask/snap-ui-renderer';
import { DelineatorType } from '../../../../../helpers/constants/flask';
function getValues(pendingApproval, t, actions) { function getValues(pendingApproval, t, actions) {
const { const {
@ -19,6 +20,7 @@ function getValues(pendingApproval, t, actions) {
element: 'SnapDelineator', element: 'SnapDelineator',
key: 'snap-delineator', key: 'snap-delineator',
props: { props: {
type: DelineatorType.Content,
snapName, snapName,
}, },
// TODO: Replace with SnapUIRenderer when we don't need to inject the input manually. // TODO: Replace with SnapUIRenderer when we don't need to inject the input manually.

View File

@ -1,5 +1,6 @@
import { TypographyVariant } from '../../../../../helpers/constants/design-system'; import { TypographyVariant } from '../../../../../helpers/constants/design-system';
import { mapToTemplate } from '../../../../../components/app/flask/snap-ui-renderer'; import { mapToTemplate } from '../../../../../components/app/flask/snap-ui-renderer';
import { DelineatorType } from '../../../../../helpers/constants/flask';
function getValues(pendingApproval, t, actions) { function getValues(pendingApproval, t, actions) {
const { const {
@ -20,6 +21,7 @@ function getValues(pendingApproval, t, actions) {
element: 'SnapDelineator', element: 'SnapDelineator',
key: 'snap-delineator', key: 'snap-delineator',
props: { props: {
type: DelineatorType.Content,
snapName, snapName,
}, },
// TODO: Replace with SnapUIRenderer when we don't need to inject the input manually. // TODO: Replace with SnapUIRenderer when we don't need to inject the input manually.

View File

@ -1,5 +1,6 @@
import { mapToTemplate } from '../../../../../components/app/flask/snap-ui-renderer'; import { mapToTemplate } from '../../../../../components/app/flask/snap-ui-renderer';
import { MESSAGE_TYPE } from '../../../../../../shared/constants/app'; import { MESSAGE_TYPE } from '../../../../../../shared/constants/app';
import { DelineatorType } from '../../../../../helpers/constants/flask';
function getValues(pendingApproval, t, actions, _history, setInputState) { function getValues(pendingApproval, t, actions, _history, setInputState) {
const { const {
@ -20,6 +21,7 @@ function getValues(pendingApproval, t, actions, _history, setInputState) {
element: 'SnapDelineator', element: 'SnapDelineator',
key: 'snap-delineator', key: 'snap-delineator',
props: { props: {
type: DelineatorType.Content,
snapName, snapName,
}, },
children: [ children: [

View File

@ -87,6 +87,8 @@ export default function SnapInstall({
className="headers" className="headers"
alignItems={AlignItems.center} alignItems={AlignItems.center}
flexDirection={FLEX_DIRECTION.COLUMN} flexDirection={FLEX_DIRECTION.COLUMN}
paddingLeft={4}
paddingRight={4}
> >
<SnapAuthorship snapId={targetSubjectMetadata.origin} /> <SnapAuthorship snapId={targetSubjectMetadata.origin} />
{!hasError && ( {!hasError && (
@ -111,8 +113,6 @@ export default function SnapInstall({
<> <>
<Text <Text
className="headers__permission-description" className="headers__permission-description"
paddingLeft={4}
paddingRight={4}
paddingBottom={4} paddingBottom={4}
textAlign={TEXT_ALIGN.CENTER} textAlign={TEXT_ALIGN.CENTER}
> >
@ -133,11 +133,7 @@ export default function SnapInstall({
alignItems={AlignItems.center} alignItems={AlignItems.center}
justifyContent={JustifyContent.center} justifyContent={JustifyContent.center}
> >
<Text <Text textAlign={TEXT_ALIGN.CENTER}>
paddingLeft={4}
paddingRight={4}
textAlign={TEXT_ALIGN.CENTER}
>
{t('snapInstallRequest', [ {t('snapInstallRequest', [
<b key="1">{originMetadata?.hostname}</b>, <b key="1">{originMetadata?.hostname}</b>,
<b key="2">{snapName}</b>, <b key="2">{snapName}</b>,

View File

@ -49,6 +49,8 @@ export default function SnapResult({
> >
<Box <Box
className="headers" className="headers"
paddingLeft={4}
paddingRight={4}
alignItems={AlignItems.center} alignItems={AlignItems.center}
flexDirection={FLEX_DIRECTION.COLUMN} flexDirection={FLEX_DIRECTION.COLUMN}
> >
@ -69,7 +71,8 @@ export default function SnapResult({
alignItems={AlignItems.center} alignItems={AlignItems.center}
justifyContent={JustifyContent.center} justifyContent={JustifyContent.center}
height={BLOCK_SIZES.FULL} height={BLOCK_SIZES.FULL}
padding={2} paddingTop={2}
paddingBottom={2}
> >
<Text <Text
fontWeight={FONT_WEIGHT.BOLD} fontWeight={FONT_WEIGHT.BOLD}

View File

@ -91,12 +91,18 @@ export default function SnapUpdate({
> >
<Box <Box
className="headers" className="headers"
paddingLeft={4}
paddingRight={4}
alignItems={AlignItems.center} alignItems={AlignItems.center}
flexDirection={FLEX_DIRECTION.COLUMN} flexDirection={FLEX_DIRECTION.COLUMN}
> >
<SnapAuthorship snapId={targetSubjectMetadata.origin} /> <SnapAuthorship snapId={targetSubjectMetadata.origin} />
{!hasError && ( {!hasError && (
<Text padding={[4, 4, 0, 4]} variant={TextVariant.headingLg}> <Text
paddingBottom={4}
paddingTop={4}
variant={TextVariant.headingLg}
>
{t('snapUpdate')} {t('snapUpdate')}
</Text> </Text>
)} )}
@ -117,8 +123,6 @@ export default function SnapUpdate({
<> <>
<Text <Text
className="headers__permission-description" className="headers__permission-description"
paddingLeft={4}
paddingRight={4}
paddingBottom={4} paddingBottom={4}
textAlign={TEXT_ALIGN.CENTER} textAlign={TEXT_ALIGN.CENTER}
> >
@ -141,11 +145,7 @@ export default function SnapUpdate({
alignItems={AlignItems.center} alignItems={AlignItems.center}
justifyContent={JustifyContent.center} justifyContent={JustifyContent.center}
> >
<Text <Text textAlign={TEXT_ALIGN.CENTER}>
paddingLeft={4}
paddingRight={4}
textAlign={TEXT_ALIGN.CENTER}
>
{t('snapUpdateRequest', [ {t('snapUpdateRequest', [
<b key="1">{originMetadata?.hostname}</b>, <b key="1">{originMetadata?.hostname}</b>,
<b key="2">{snapName}</b>, <b key="2">{snapName}</b>,