Skip to content

Commit

Permalink
feat: header for connected dApps
Browse files Browse the repository at this point in the history
  • Loading branch information
dianasavvatina committed Dec 10, 2024
1 parent 0478c0e commit bab0de0
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 32 deletions.
15 changes: 14 additions & 1 deletion apps/web/src/components/Menu/AppsMenu/AppsMenu.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
import { Button, Text } from "@chakra-ui/react";
import { useAddPeer } from "@umami/state";

import { useColor } from "../../../styles/useColor";
import { BeaconPeers } from "../../beacon";
import { WcPeers, useOnWalletConnect } from "../../WalletConnect";
import { DrawerContentWrapper } from "../DrawerContentWrapper";

export const AppsMenu = () => {
const onBeaconConnect = useAddPeer();
const onWalletConnect = useOnWalletConnect();
const color = useColor();

return (
<DrawerContentWrapper
actions={
<>
<Text marginTop="12px" size="lg">
Connect with Pairing Request for Beacon or WalletConnect
Connect with DApps using a Pairing Request via Beacon or WalletConnect.
</Text>
<Button
width="fit-content"
Expand All @@ -31,6 +33,17 @@ export const AppsMenu = () => {
>
Connect
</Button>
<Text
marginTop="40px"
color={color("900")}
fontWeight="600"
size={{ base: "xl", md: "2xl" }}
>
Connected apps
</Text>
<Text marginTop="12px" size="lg">
DApps you've granted permission to connect with.
</Text>
</>
}
title="Apps"
Expand Down
11 changes: 1 addition & 10 deletions apps/web/src/components/WalletConnect/WalletConnectPeers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { useEffect, useState } from "react";
import { CodeSandboxIcon, StubIcon as TrashIcon } from "../../assets/icons";
import { useColor } from "../../styles/useColor";
import { AddressPill } from "../AddressPill";
import { EmptyMessage } from "../EmptyMessage";

/**
* Component displaying a list of connected dApps.
Expand All @@ -26,15 +25,7 @@ export const WcPeers = () => {
}, [isUpdated]);

if (!Object.keys(sessions).length) {
return (
<EmptyMessage
alignItems="flex-start"
marginTop="40px"
data-testid="wc-peers-empty"
subtitle="No WalletConnect Apps to show"
title="Your WalletConnect Apps will appear here..."
/>
);
return <></>;
}

return (
Expand Down
13 changes: 2 additions & 11 deletions apps/web/src/components/beacon/BeaconPeers.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
import { formatPkh } from "@umami/tezos";

import { BeaconPeers } from "./BeaconPeers";
import { act, render, screen, userEvent, waitFor, within } from "../../testUtils";
import { act, render, screen, userEvent, within } from "../../testUtils";

const peersData: ExtendedPeerInfo[] = [
{
Expand Down Expand Up @@ -58,22 +58,13 @@ describe("<BeaconPeers />", () => {
};

describe("list of paired dApps", () => {
it("shows empty state message when no paired dApps", async () => {
it("shows empty list when no paired dApps", () => {
jest.spyOn(WalletClient, "getPeers").mockResolvedValue([]);
render(<BeaconPeers />, { store });

await waitFor(() => {
expect(screen.getByText("Your Apps will appear here...")).toBeInTheDocument();
});
expect(screen.queryByTestId("peer-row")).not.toBeInTheDocument();
});

it("hides empty state message when paired dApps are present", async () => {
await getPeerRows();

expect(screen.queryByText("Your dApps will appear here")).not.toBeInTheDocument();
});

it("contains dApp names", async () => {
const peerRows = await getPeerRows();

Expand Down
11 changes: 1 addition & 10 deletions apps/web/src/components/beacon/BeaconPeers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import capitalize from "lodash/capitalize";
import { CodeSandboxIcon, StubIcon as TrashIcon } from "../../assets/icons";
import { AddressPill } from "../../components/AddressPill/AddressPill";
import { useColor } from "../../styles/useColor";
import { EmptyMessage } from "../EmptyMessage";

/**
* Component displaying a list of connected dApps.
Expand All @@ -18,15 +17,7 @@ export const BeaconPeers = () => {
const { peers } = useBeaconPeers();

if (peers.length === 0) {
return (
<EmptyMessage
alignItems="flex-start"
marginTop="40px"
data-testid="beacon-peers-empty"
subtitle="No Apps to show"
title="Your Apps will appear here..."
/>
);
return <></>;
}

return (
Expand Down

0 comments on commit bab0de0

Please sign in to comment.