- {this.renderTopBar()}
+ {!hideTopBar && this.renderTopBar()}
{redirecting && permissionsApproved ? (
) : (
diff --git a/ui/pages/permissions-connect/permissions-connect.container.js b/ui/pages/permissions-connect/permissions-connect.container.js
index 0995e9574..b815992b7 100644
--- a/ui/pages/permissions-connect/permissions-connect.container.js
+++ b/ui/pages/permissions-connect/permissions-connect.container.js
@@ -78,8 +78,6 @@ const mapStateToProps = (state, ownProps) => {
const requestType = getRequestType(state, permissionsRequestId);
///: BEGIN:ONLY_INCLUDE_IN(snaps)
- const isSnap = targetSubjectMetadata.subjectType === SubjectType.Snap;
-
const requestState = getRequestState(state, permissionsRequestId);
///: END:ONLY_INCLUDE_IN
@@ -101,11 +99,15 @@ const mapStateToProps = (state, ownProps) => {
const snapInstallPath = `${CONNECT_ROUTE}/${permissionsRequestId}${CONNECT_SNAP_INSTALL_ROUTE}`;
const snapUpdatePath = `${CONNECT_ROUTE}/${permissionsRequestId}${CONNECT_SNAP_UPDATE_ROUTE}`;
const snapResultPath = `${CONNECT_ROUTE}/${permissionsRequestId}${CONNECT_SNAP_RESULT_ROUTE}`;
+ const isSnapInstallOrUpdateOrResult =
+ pathname === snapInstallPath ||
+ pathname === snapUpdatePath ||
+ pathname === snapResultPath;
///: END:ONLY_INCLUDE_IN
let totalPages = 1 + isRequestingAccounts;
///: BEGIN:ONLY_INCLUDE_IN(snaps)
- totalPages += isSnap;
+ totalPages += isSnapInstallOrUpdateOrResult;
///: END:ONLY_INCLUDE_IN
totalPages = totalPages.toString();
@@ -115,11 +117,7 @@ const mapStateToProps = (state, ownProps) => {
} else if (pathname === confirmPermissionPath) {
page = isRequestingAccounts ? '2' : '1';
///: BEGIN:ONLY_INCLUDE_IN(snaps)
- } else if (
- pathname === snapInstallPath ||
- pathname === snapUpdatePath ||
- pathname === snapResultPath
- ) {
+ } else if (isSnapInstallOrUpdateOrResult) {
page = isRequestingAccounts ? '3' : '2';
///: END:ONLY_INCLUDE_IN
} else {
@@ -134,7 +132,7 @@ const mapStateToProps = (state, ownProps) => {
snapUpdatePath,
snapResultPath,
requestState,
- isSnap,
+ hideTopBar: isSnapInstallOrUpdateOrResult,
snapsInstallPrivacyWarningShown: getSnapsInstallPrivacyWarningShown(state),
///: END:ONLY_INCLUDE_IN
permissionsRequest,
diff --git a/ui/pages/permissions-connect/snaps/snap-install/index.scss b/ui/pages/permissions-connect/snaps/snap-install/index.scss
index 59fff9fd0..6f8c53ead 100644
--- a/ui/pages/permissions-connect/snaps/snap-install/index.scss
+++ b/ui/pages/permissions-connect/snaps/snap-install/index.scss
@@ -2,15 +2,22 @@
box-shadow: none;
&__content {
- flex: 1;
-
&__loader-container {
height: 100%;
}
}
+ &__scroll-button {
+ position: absolute;
+ margin-left: auto;
+ margin-right: auto;
+ right: 0;
+ left: 0;
+ bottom: 90px;
+ }
+
.page-container__footer {
width: 100%;
- margin-top: 12px;
+ border-top: 0;
}
}
diff --git a/ui/pages/permissions-connect/snaps/snap-install/snap-install.js b/ui/pages/permissions-connect/snaps/snap-install/snap-install.js
index 417243fc4..5a1e1de55 100644
--- a/ui/pages/permissions-connect/snaps/snap-install/snap-install.js
+++ b/ui/pages/permissions-connect/snaps/snap-install/snap-install.js
@@ -6,6 +6,7 @@ import SnapInstallWarning from '../../../../components/app/snaps/snap-install-wa
import Box from '../../../../components/ui/box/box';
import {
AlignItems,
+ BackgroundColor,
BLOCK_SIZES,
BorderStyle,
FLEX_DIRECTION,
@@ -17,11 +18,16 @@ import {
import { getSnapInstallWarnings } from '../util';
import PulseLoader from '../../../../components/ui/pulse-loader/pulse-loader';
import InstallError from '../../../../components/app/snaps/install-error/install-error';
-import SnapAuthorship from '../../../../components/app/snaps/snap-authorship';
-import { Text, ValidTag } from '../../../../components/component-library';
-import { useOriginMetadata } from '../../../../hooks/useOriginMetadata';
+import SnapAuthorshipHeader from '../../../../components/app/snaps/snap-authorship-header';
+import {
+ AvatarIcon,
+ IconName,
+ Text,
+ ValidTag,
+} from '../../../../components/component-library';
import { getSnapName } from '../../../../helpers/utils/util';
import SnapPermissionsList from '../../../../components/app/snaps/snap-permissions-list';
+import { useScrollRequired } from '../../../../hooks/useScrollRequired';
export default function SnapInstall({
request,
@@ -33,7 +39,9 @@ export default function SnapInstall({
const t = useI18nContext();
const [isShowingWarning, setIsShowingWarning] = useState(false);
- const originMetadata = useOriginMetadata(request.metadata?.dappOrigin) || {};
+
+ const { isScrollable, isScrolledToBottom, scrollToBottom, ref, onScroll } =
+ useScrollRequired([requestState]);
const onCancel = useCallback(
() => rejectSnapInstall(request.metadata.id),
@@ -49,13 +57,6 @@ export default function SnapInstall({
const isLoading = requestState.loading;
- const hasPermissions =
- !hasError &&
- requestState?.permissions &&
- Object.keys(requestState.permissions).length > 0;
-
- const isEmpty = !isLoading && !hasError && !hasPermissions;
-
const warnings = getSnapInstallWarnings(
requestState?.permissions ?? {},
targetSubjectMetadata,
@@ -84,25 +85,16 @@ export default function SnapInstall({
borderStyle={BorderStyle.none}
flexDirection={FLEX_DIRECTION.COLUMN}
>
+
-
- {!isLoading && !hasError && (
-
- {t('snapInstall')}
-
- )}
-
-
{isLoading && (
)}
- {hasPermissions && (
+ {!hasError && !isLoading && (
<>
+
+ {t('snapInstall')}
+
- {t('snapInstallRequestsPermission', [
+ {t('snapInstallRequest', [
+ {isScrollable && !isScrolledToBottom ? (
+
+ ) : null}
>
)}
- {isEmpty && (
-
-
- {t('snapInstallRequest', [
- {originMetadata?.hostname},
- {snapName},
- ])}
-
-
- )}
{isShowingWarning && (
diff --git a/ui/pages/permissions-connect/snaps/snap-install/snap-install.stories.js b/ui/pages/permissions-connect/snaps/snap-install/snap-install.stories.js
new file mode 100644
index 000000000..ec0ca69cc
--- /dev/null
+++ b/ui/pages/permissions-connect/snaps/snap-install/snap-install.stories.js
@@ -0,0 +1,122 @@
+import React from 'react';
+import { Provider } from 'react-redux';
+
+import configureStore from '../../../../store/store';
+import mockState from '../../../../../test/data/mock-state.json';
+import SnapInstall from '.';
+
+const store = configureStore(mockState);
+
+export default {
+ title: 'Pages/Snaps/SnapInstall',
+
+ component: SnapInstall,
+ argTypes: {},
+ decorators: [(story) =>
{story()}],
+};
+
+export const DefaultStory = (args) =>
;
+
+DefaultStory.storyName = 'Default';
+
+DefaultStory.args = {
+ request: {
+ metadata: {
+ id: 'foo',
+ },
+ },
+ requestState: {
+ loading: false,
+ permissions: {
+ 'endowment:rpc': {
+ caveats: [
+ {
+ type: 'rpcOrigin',
+ value: {
+ dapps: true,
+ },
+ },
+ ],
+ },
+ snap_dialog: {},
+ snap_getBip44Entropy: {
+ caveats: [
+ {
+ type: 'permittedCoinTypes',
+ value: [
+ {
+ coinType: 1,
+ },
+ ],
+ },
+ ],
+ },
+ },
+ },
+ targetSubjectMetadata: {
+ origin: 'npm:@metamask/test-snap-bip44',
+ },
+};
+
+export const LoadingStory = (args) =>
;
+
+LoadingStory.storyName = 'Loading';
+
+LoadingStory.args = {
+ request: {
+ metadata: {
+ id: 'foo',
+ },
+ },
+ requestState: {
+ loading: true,
+ },
+ targetSubjectMetadata: {
+ origin: 'npm:@metamask/test-snap-bip44',
+ },
+};
+
+export const ScrollingStory = (args) =>
;
+
+ScrollingStory.storyName = 'Scrolling';
+
+ScrollingStory.args = {
+ request: {
+ metadata: {
+ id: 'foo',
+ },
+ },
+ requestState: {
+ loading: false,
+ permissions: {
+ 'endowment:rpc': {
+ caveats: [
+ {
+ type: 'rpcOrigin',
+ value: {
+ dapps: true,
+ },
+ },
+ ],
+ },
+ 'endowment:network-access': {},
+ snap_notify: {},
+ snap_dialog: {},
+ snap_getBip44Entropy: {
+ caveats: [
+ {
+ type: 'permittedCoinTypes',
+ value: [
+ {
+ coinType: 1,
+ },
+ ],
+ },
+ ],
+ },
+ },
+ },
+ targetSubjectMetadata: {
+ origin: 'npm:@metamask/test-snap-bip44',
+ },
+};
diff --git a/ui/pages/permissions-connect/snaps/snap-result/index.scss b/ui/pages/permissions-connect/snaps/snap-result/index.scss
index b8bede6f3..983f8f773 100644
--- a/ui/pages/permissions-connect/snaps/snap-result/index.scss
+++ b/ui/pages/permissions-connect/snaps/snap-result/index.scss
@@ -1,16 +1,8 @@
.snap-result {
box-shadow: none;
- &__header {
- flex: 1;
-
- &__loader-container {
- height: 100%;
- }
- }
-
.page-container__footer {
width: 100%;
- margin-top: 12px;
+ border-top: 0;
}
}
diff --git a/ui/pages/permissions-connect/snaps/snap-result/snap-result.js b/ui/pages/permissions-connect/snaps/snap-result/snap-result.js
index 825da1f1e..be45e2e5f 100644
--- a/ui/pages/permissions-connect/snaps/snap-result/snap-result.js
+++ b/ui/pages/permissions-connect/snaps/snap-result/snap-result.js
@@ -26,7 +26,7 @@ import {
} from '../../../../components/component-library';
import PulseLoader from '../../../../components/ui/pulse-loader/pulse-loader';
import InstallError from '../../../../components/app/snaps/install-error/install-error';
-import SnapAuthorship from '../../../../components/app/snaps/snap-authorship';
+import SnapAuthorshipHeader from '../../../../components/app/snaps/snap-authorship-header';
import { getSnapName } from '../../../../helpers/utils/util';
export default function SnapResult({
@@ -140,17 +140,20 @@ export default function SnapResult({
borderStyle={BorderStyle.none}
flexDirection={FLEX_DIRECTION.COLUMN}
>
+
-
{isLoading && (
;
+
+DefaultStory.storyName = 'Default';
+
+DefaultStory.args = {
+ request: {
+ metadata: {
+ id: 'foo',
+ },
+ },
+ requestState: {
+ loading: false,
+ },
+ targetSubjectMetadata: {
+ origin: 'npm:@metamask/test-snap-bip44',
+ },
+};
+
+export const LoadingStory = (args) => ;
+
+LoadingStory.storyName = 'Loading';
+
+LoadingStory.args = {
+ request: {
+ metadata: {
+ id: 'foo',
+ },
+ },
+ requestState: {
+ loading: true,
+ },
+ targetSubjectMetadata: {
+ origin: 'npm:@metamask/test-snap-bip44',
+ },
+};
+
+export const ErrorStory = (args) => ;
+
+ErrorStory.storyName = 'Error';
+
+ErrorStory.args = {
+ request: {
+ metadata: {
+ id: 'foo',
+ },
+ },
+ requestState: {
+ loading: false,
+ error: 'foo',
+ },
+ targetSubjectMetadata: {
+ origin: 'npm:@metamask/test-snap-bip44',
+ },
+};
diff --git a/ui/pages/permissions-connect/snaps/snap-update/index.scss b/ui/pages/permissions-connect/snaps/snap-update/index.scss
index 81923c311..564b7f9fb 100644
--- a/ui/pages/permissions-connect/snaps/snap-update/index.scss
+++ b/ui/pages/permissions-connect/snaps/snap-update/index.scss
@@ -2,20 +2,23 @@
box-shadow: none;
&__content {
- flex: 1;
-
&__loader-container {
height: 100%;
}
+ }
- &__permission-description {
- border-bottom: 1px solid var(--color-border-default);
- }
+ &__scroll-button {
+ position: absolute;
+ margin-left: auto;
+ margin-right: auto;
+ right: 0;
+ left: 0;
+ bottom: 90px;
}
.page-container__footer {
width: 100%;
- margin-top: 12px;
+ border-top: 0;
button {
padding: 0.75rem;
diff --git a/ui/pages/permissions-connect/snaps/snap-update/snap-update.js b/ui/pages/permissions-connect/snaps/snap-update/snap-update.js
index c87a34bc7..a6bbf356e 100644
--- a/ui/pages/permissions-connect/snaps/snap-update/snap-update.js
+++ b/ui/pages/permissions-connect/snaps/snap-update/snap-update.js
@@ -6,9 +6,11 @@ import SnapInstallWarning from '../../../../components/app/snaps/snap-install-wa
import Box from '../../../../components/ui/box/box';
import {
AlignItems,
+ BackgroundColor,
BLOCK_SIZES,
BorderStyle,
FLEX_DIRECTION,
+ FontWeight,
JustifyContent,
TextVariant,
TEXT_ALIGN,
@@ -18,10 +20,16 @@ import UpdateSnapPermissionList from '../../../../components/app/snaps/update-sn
import { getSnapInstallWarnings } from '../util';
import PulseLoader from '../../../../components/ui/pulse-loader/pulse-loader';
import InstallError from '../../../../components/app/snaps/install-error/install-error';
-import SnapAuthorship from '../../../../components/app/snaps/snap-authorship';
-import { Text } from '../../../../components/component-library';
+import SnapAuthorshipHeader from '../../../../components/app/snaps/snap-authorship-header';
+import {
+ AvatarIcon,
+ IconName,
+ Text,
+ ValidTag,
+} from '../../../../components/component-library';
import { useOriginMetadata } from '../../../../hooks/useOriginMetadata';
import { getSnapName } from '../../../../helpers/utils/util';
+import { useScrollRequired } from '../../../../hooks/useScrollRequired';
export default function SnapUpdate({
request,
@@ -35,6 +43,9 @@ export default function SnapUpdate({
const [isShowingWarning, setIsShowingWarning] = useState(false);
const originMetadata = useOriginMetadata(request.metadata?.dappOrigin) || {};
+ const { isScrollable, isScrolledToBottom, scrollToBottom, ref, onScroll } =
+ useScrollRequired([requestState]);
+
const onCancel = useCallback(
() => rejectSnapUpdate(request.metadata.id),
[request, rejectSnapUpdate],
@@ -81,25 +92,26 @@ export default function SnapUpdate({
borderStyle={BorderStyle.none}
flexDirection={FLEX_DIRECTION.COLUMN}
>
+
-
{!isLoading && !hasError && (
{t('snapUpdate')}
)}
-
-
{isLoading && (
{t('snapUpdateRequest', [
- {originMetadata?.hostname},
- {snapName},
- v{newVersion},
+
+ {originMetadata?.hostname}
+ ,
+
+ {snapName}
+ ,
+
+ {newVersion}
+ ,
])}
+ {isScrollable && !isScrolledToBottom ? (
+
+ ) : null}
>
)}
@@ -141,11 +185,16 @@ export default function SnapUpdate({
className="snap-update__footer"
alignItems={AlignItems.center}
flexDirection={FLEX_DIRECTION.COLUMN}
+ style={{
+ boxShadow: 'var(--shadow-size-lg) var(--color-shadow-default)',
+ }}
>
{story()}],
+};
+
+export const DefaultStory = (args) => ;
+
+DefaultStory.storyName = 'Default';
+
+DefaultStory.args = {
+ request: {
+ metadata: {
+ id: 'foo',
+ },
+ },
+ requestState: {
+ loading: false,
+ newVersion: '2.0.0',
+ approvedPermissions: {
+ 'endowment:rpc': {
+ caveats: [
+ {
+ type: 'rpcOrigin',
+ value: {
+ dapps: true,
+ },
+ },
+ ],
+ },
+ snap_dialog: {},
+ snap_getBip44Entropy: {
+ caveats: [
+ {
+ type: 'permittedCoinTypes',
+ value: [
+ {
+ coinType: 1,
+ },
+ ],
+ },
+ ],
+ },
+ },
+ },
+ targetSubjectMetadata: {
+ origin: 'npm:@metamask/test-snap-bip44',
+ },
+};
+
+export const LoadingStory = (args) => ;
+
+LoadingStory.storyName = 'Loading';
+
+LoadingStory.args = {
+ request: {
+ metadata: {
+ id: 'foo',
+ },
+ },
+ requestState: {
+ loading: true,
+ },
+ targetSubjectMetadata: {
+ origin: 'npm:@metamask/test-snap-bip44',
+ },
+};
+
+export const ScrollingStory = (args) => ;
+
+ScrollingStory.storyName = 'Scrolling';
+
+ScrollingStory.args = {
+ request: {
+ metadata: {
+ id: 'foo',
+ },
+ },
+ requestState: {
+ loading: false,
+ newVersion: '2.0.0',
+ approvedPermissions: {
+ 'endowment:rpc': {
+ caveats: [
+ {
+ type: 'rpcOrigin',
+ value: {
+ dapps: true,
+ },
+ },
+ ],
+ },
+ 'endowment:network-access': {},
+ snap_notify: {},
+ snap_dialog: {},
+ snap_getBip44Entropy: {
+ caveats: [
+ {
+ type: 'permittedCoinTypes',
+ value: [
+ {
+ coinType: 1,
+ },
+ ],
+ },
+ ],
+ },
+ },
+ },
+ targetSubjectMetadata: {
+ origin: 'npm:@metamask/test-snap-bip44',
+ },
+};
diff --git a/ui/pages/settings/snaps/view-snap/view-snap.js b/ui/pages/settings/snaps/view-snap/view-snap.js
index c95764545..0dd7dad5e 100644
--- a/ui/pages/settings/snaps/view-snap/view-snap.js
+++ b/ui/pages/settings/snaps/view-snap/view-snap.js
@@ -14,7 +14,7 @@ import {
TextColor,
TextVariant,
} from '../../../../helpers/constants/design-system';
-import SnapAuthorship from '../../../../components/app/snaps/snap-authorship';
+import SnapAuthorshipExpanded from '../../../../components/app/snaps/snap-authorship-expanded';
import Box from '../../../../components/ui/box';
import SnapRemoveWarning from '../../../../components/app/snaps/snap-remove-warning';
import ConnectedSitesList from '../../../../components/app/connected-sites-list';
@@ -124,7 +124,7 @@ function ViewSnap() {
paddingLeft={4}
paddingRight={4}
>
-
+
{
// Snap name & Snap authorship component
expect(getByText('BIP-44 Test Snap')).toBeDefined();
- expect(container.getElementsByClassName('snaps-authorship')?.length).toBe(
- 1,
- );
+ expect(
+ container.getElementsByClassName('snaps-authorship-expanded')?.length,
+ ).toBe(1);
// Snap description
expect(
getByText('An example Snap that signs messages using BLS.'),
@@ -48,7 +48,7 @@ describe('ViewSnap', () => {
// Snap version info
expect(getByText('v5.1.2')).toBeDefined();
// Enable Snap
- expect(getByText('Enable')).toBeDefined();
+ expect(getByText('Enabled')).toBeDefined();
expect(container.getElementsByClassName('toggle-button')?.length).toBe(1);
// Permissions
expect(getByText('Permissions')).toBeDefined();