Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: Application summary page access #176

Merged
merged 2 commits into from
May 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 46 additions & 31 deletions apps/web/src/components/applications/applicationRow.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import { ActionIcon, Table, Tooltip } from "@mantine/core";
import { ActionIcon, Group, Table, Tooltip } from "@mantine/core";
import Link from "next/link";
import { FC } from "react";
import { TbInbox, TbPlugConnected, TbPlugConnectedX } from "react-icons/tb";
import {
TbInbox,
TbPlugConnected,
TbPlugConnectedX,
TbStack2,
} from "react-icons/tb";
import { Address as AddressType } from "viem";
import { Application } from "../../graphql/explorer/types";
import { useConnectionConfig } from "../../providers/connectionConfig/hooks";
Expand Down Expand Up @@ -40,39 +45,49 @@ const ApplicationRow: FC<ApplicationRowProps> = (props) => {
</Table.Td>
<Table.Td>{connection?.url ?? "N/A"}</Table.Td>
<Table.Td>
<Tooltip label="Inputs">
<Link
href={`/applications/${appId}/inputs`}
data-testid="applications-link"
>
<ActionIcon variant="default">
<TbInbox />
</ActionIcon>
</Link>
</Tooltip>
{hasConnection(appId) ? (
<Tooltip label="Remove connection">
<ActionIcon
data-testid="remove-connection"
variant="default"
ml={4}
onClick={() => removeConnection(appId)}
<Group gap="xs">
<Tooltip label="Summary">
<Link
href={`/applications/${appId}`}
data-testid="applications-summary-link"
>
<TbPlugConnectedX />
</ActionIcon>
<ActionIcon variant="default">
<TbStack2 />
</ActionIcon>
</Link>
</Tooltip>
) : (
<Tooltip label="Add a connection">
<ActionIcon
data-testid="add-connection"
variant="default"
ml={4}
onClick={() => showConnectionModal(appId)}
<Tooltip label="Inputs">
<Link
href={`/applications/${appId}/inputs`}
data-testid="applications-link"
>
<TbPlugConnected />
</ActionIcon>
<ActionIcon variant="default">
<TbInbox />
</ActionIcon>
</Link>
</Tooltip>
)}
{hasConnection(appId) ? (
<Tooltip label="Remove connection">
<ActionIcon
data-testid="remove-connection"
variant="default"
onClick={() => removeConnection(appId)}
>
<TbPlugConnectedX />
</ActionIcon>
</Tooltip>
) : (
<Tooltip label="Add a connection">
<ActionIcon
data-testid="add-connection"
variant="default"
onClick={() => showConnectionModal(appId)}
>
<TbPlugConnected />
</ActionIcon>
</Tooltip>
)}
</Group>
</Table.Td>
</Table.Tr>
);
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/components/applications/applications.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ const AllApplications: FC = () => {

export const Applications = () => {
return (
<Tabs defaultValue="all-apps">
<Tabs defaultValue="all-apps" keepMounted={false}>
<Tabs.List>
<Tabs.Tab value="all-apps">All Apps</Tabs.Tab>
<Tabs.Tab value="my-apps">My Apps</Tabs.Tab>
Expand Down
79 changes: 48 additions & 31 deletions apps/web/src/components/applications/userApplicationsRow.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
import { ActionIcon, Box, Table, Text, Tooltip } from "@mantine/core";
import { ActionIcon, Box, Group, Table, Text, Tooltip } from "@mantine/core";
import Link from "next/link";
import prettyMilliseconds from "pretty-ms";
import { FC } from "react";
import { TbInbox, TbPlugConnected, TbPlugConnectedX } from "react-icons/tb";
import {
TbInbox,
TbPlugConnected,
TbPlugConnectedX,
TbStack2,
} from "react-icons/tb";
import { Address as AddressType } from "viem";
import { useConnectionConfig } from "../../providers/connectionConfig/hooks";
import Address from "../address";
Expand Down Expand Up @@ -41,39 +46,51 @@ const UserApplicationsRow: FC<ApplicationRowProps> = (props) => {
</Box>
</Table.Td>
<Table.Td>
<Tooltip label="Inputs">
<Link
href={`/applications/${appId}/inputs`}
data-testid="applications-link"
>
<ActionIcon variant="default">
<TbInbox />
</ActionIcon>
</Link>
</Tooltip>
{hasConnection(appId) ? (
<Tooltip label="Remove connection">
<ActionIcon
data-testid="remove-connection"
variant="default"
ml={4}
onClick={() => removeConnection(appId)}
<Group gap="xs">
<Tooltip label="Summary">
<Link
href={`/applications/${appId}`}
data-testid="applications-summary-link"
>
<TbPlugConnectedX />
</ActionIcon>
<ActionIcon variant="default">
<TbStack2 />
</ActionIcon>
</Link>
</Tooltip>
) : (
<Tooltip label="Add a connection">
<ActionIcon
data-testid="add-connection"
variant="default"
ml={4}
onClick={() => showConnectionModal(appId)}
<Tooltip label="Inputs">
<Link
href={`/applications/${appId}/inputs`}
data-testid="applications-link"
>
<TbPlugConnected />
</ActionIcon>
<ActionIcon variant="default">
<TbInbox />
</ActionIcon>
</Link>
</Tooltip>
)}
{hasConnection(appId) ? (
<Tooltip label="Remove connection">
<ActionIcon
data-testid="remove-connection"
variant="default"
ml={4}
onClick={() => removeConnection(appId)}
>
<TbPlugConnectedX />
</ActionIcon>
</Tooltip>
) : (
<Tooltip label="Add a connection">
<ActionIcon
data-testid="add-connection"
variant="default"
ml={4}
onClick={() => showConnectionModal(appId)}
>
<TbPlugConnected />
</ActionIcon>
</Tooltip>
)}
</Group>
</Table.Td>
</Table.Tr>
);
Expand Down
18 changes: 14 additions & 4 deletions apps/web/test/components/applications/applicationRow.test.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { afterEach, beforeEach, describe, it } from "vitest";
import type { FC } from "react";
import { Table } from "@mantine/core";
import { cleanup, fireEvent, render, screen } from "@testing-library/react";
import type { FC } from "react";
import { afterEach, beforeEach, describe, it } from "vitest";
import ApplicationRow, {
ApplicationRowProps,
} from "../../../src/components/applications/applicationRow";
import { withMantineTheme } from "../../utils/WithMantineTheme";
import { Table } from "@mantine/core";
import { useConnectionConfig } from "../../../src/providers/connectionConfig/hooks";
import { withMantineTheme } from "../../utils/WithMantineTheme";

vi.mock("../../../src/providers/connectionConfig/hooks");
const useConnectionConfigMock = vi.mocked(useConnectionConfig, true);
Expand Down Expand Up @@ -111,6 +111,16 @@ describe("ApplicationRow component", () => {
expect(screen.getByText(defaultConnection.url)).toBeInTheDocument();
});

it("should display link to the application summary page", () => {
render(<Component {...defaultProps} />);
const link = screen.getByTestId("applications-summary-link");

expect(link).toBeInTheDocument();
expect(link.getAttribute("href")).toBe(
`/applications/${defaultProps.application.id}`,
);
});

it("should display link to application inputs page", () => {
render(<Component {...defaultProps} />);
const link = screen.getByTestId("applications-link");
Expand Down
10 changes: 10 additions & 0 deletions apps/web/test/components/applications/userApplicationRow.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,16 @@ describe("ApplicationRow component", () => {
expect(screen.getByText(defaultConnection.url)).toBeInTheDocument();
});

it("should display link to application summary page", () => {
render(<Component {...defaultProps} />);
const link = screen.getByTestId("applications-summary-link");

expect(link).toBeInTheDocument();
expect(link.getAttribute("href")).toBe(
`/applications/${defaultProps.application.id}`,
);
});

it("should display link to application inputs page", () => {
render(<Component {...defaultProps} />);
const link = screen.getByTestId("applications-link");
Expand Down
Loading