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: resolved voting power #880

Merged
merged 11 commits into from
Apr 17, 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Features

- [#880](https://github.com/alleslabs/celatone-frontend/pull/880) Add resolved voting power for proposals
- [#878](https://github.com/alleslabs/celatone-frontend/pull/878) Support searching proposal id and validator address on the main search
- [#875](https://github.com/alleslabs/celatone-frontend/pull/875) Add Amplitude tracking to validator details page
- [#865](https://github.com/alleslabs/celatone-frontend/pull/865) Apply voted proposals filter and search input to table
Expand Down
1 change: 0 additions & 1 deletion src/lib/components/ExplorerLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,6 @@ export const ExplorerLink = ({
display={{ base: "inline-flex", md: "flex" }}
align="center"
h={fixedHeight ? "24px" : "auto"}
w="full"
transition="all 0.25s ease-in-out"
_hover={{
textDecoration: "underline",
Expand Down
4 changes: 2 additions & 2 deletions src/lib/components/PageHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ interface PageHeaderProps {
export const PageHeader = ({ title, subtitle, docHref }: PageHeaderProps) => {
const isMobile = useMobile();
return (
<Flex w="full" justifyContent="space-between" alignItems="center" mb={8}>
<div>
<Flex justifyContent="space-between" alignItems="center" mb={8}>
<div style={{ width: "100%" }}>
<Flex justifyContent="space-between">
<Heading
as="h5"
Expand Down
6 changes: 5 additions & 1 deletion src/lib/components/Tooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@ export const Tooltip = ({
{...tooltipProps}
>
<span
style={{ display: "flex", alignItems: "center" }}
style={{
display: "inline-flex",
alignItems: "center",
height: "fit-content",
}}
onMouseEnter={onOpen}
onMouseLeave={onClose}
onClickCapture={onToggle}
Expand Down
2 changes: 1 addition & 1 deletion src/lib/components/button/AdminButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const AdminButton = ({ contractAddress, admin }: AdminButtonProps) => {
<Menu>
<Tooltip
label="You don't have admin access to this contract."
isDisabled={isAdmin}
hidden={isAdmin}
>
<MenuButton
variant="outline-gray"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Flex, Heading, Spinner, Text } from "@chakra-ui/react";
import type { Big } from "big.js";
import type Big from "big.js";

import { big } from "lib/types";
import type { Option, TokenWithValue, USD } from "lib/types";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Flex, Heading, Text, useDisclosure } from "@chakra-ui/react";
import type { Big } from "big.js";
import type Big from "big.js";
import plur from "plur";

import { CustomIcon } from "lib/components/icon";
Expand Down
2 changes: 1 addition & 1 deletion src/lib/components/delegations/total-card/OverviewCard.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Flex, Heading } from "@chakra-ui/react";
import type { Big } from "big.js";
import type Big from "big.js";

import { big } from "lib/types";
import type { Option, TokenWithValue, USD } from "lib/types";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
ModalOverlay,
Text,
} from "@chakra-ui/react";
import type { Big } from "big.js";
import type Big from "big.js";

import { CopyLink } from "lib/components/CopyLink";
import { CustomIcon } from "lib/components/icon";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Flex, Heading, Text, useDisclosure } from "@chakra-ui/react";
import big from "big.js";
import type { Big } from "big.js";
import type Big from "big.js";

import { TotalCardModal } from "../TotalCardModal";
import { CustomIcon } from "lib/components/icon";
Expand Down
3 changes: 2 additions & 1 deletion src/lib/components/module/FunctionCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,10 @@ export const FunctionCard = ({
<Tooltip
bg="primary.dark"
label="Only functions with “is_entry: true” are able to interacted through Celatone’s module interactions."
isDisabled={!disabled}
hidden={!disabled}
>
<Flex
w="full"
borderRadius={8}
py={2}
px={3}
Expand Down
2 changes: 1 addition & 1 deletion src/lib/components/module/FunctionDetailCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -193,9 +193,9 @@ export const FunctionDetailCard = ({
</Flex>

<Tooltip
isDisabled={!disabled}
bg="primary.dark"
label="Only execute functions with “is_entry: true” and “visibility: public” are interactable through Celatone’s module interactions."
hidden={!disabled}
>
<Button
variant={getButtonStyle().variant}
Expand Down
60 changes: 60 additions & 0 deletions src/lib/components/table/blocks/BlocksTable.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import { useMobile } from "lib/app-provider";
import { Loading } from "lib/components/Loading";
import { ErrorFetching } from "lib/components/state";
import { MobileTableContainer, TableContainer } from "lib/components/table";
import type { Block, Option } from "lib/types";

import { BlocksTableHeader } from "./BlocksTableHeader";
import { BlocksTableMobileCard } from "./BlocksTableMobileCard";
import { BlocksTableRow } from "./BlocksTableRow";

interface BlocksTableProps {
blocks: Option<Block[]>;
isLoading: boolean;
emptyState: JSX.Element;
showProposer?: boolean;
}

export const BlocksTable = ({
blocks,
isLoading,
emptyState,
showProposer = true,
}: BlocksTableProps) => {
const isMobile = useMobile();

if (isLoading) return <Loading />;
if (!blocks) return <ErrorFetching dataName="blocks" />;
if (!blocks.length) return emptyState;

const templateColumns = showProposer
? "140px 160px minmax(300px,1fr) 120px 280px"
: "150px minmax(160px, 1fr) 180px 280px";

return isMobile ? (
<MobileTableContainer>
{blocks.map((block) => (
<BlocksTableMobileCard
key={block.hash}
blockData={block}
showProposer={showProposer}
/>
))}
</MobileTableContainer>
) : (
<TableContainer>
<BlocksTableHeader
templateColumns={templateColumns}
showProposer={showProposer}
/>
{blocks.map((block) => (
<BlocksTableRow
key={block.hash}
templateColumns={templateColumns}
blockData={block}
showProposer={showProposer}
/>
))}
</TableContainer>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,20 @@ import { TableHeader } from "lib/components/table";

interface BlocksTableHeaderProps {
templateColumns: GridProps["templateColumns"];
scrollComponentId: string;
hideProposer?: boolean;
showProposer: boolean;
}

export const BlocksTableHeader = ({
templateColumns,
scrollComponentId,
hideProposer = false,
showProposer = true,
}: BlocksTableHeaderProps) => (
<Grid
templateColumns={templateColumns}
id={scrollComponentId}
sx={{ "> div": { color: "text.dark" } }}
>
<TableHeader>Block Height</TableHeader>
<TableHeader>Block Hash</TableHeader>
{!hideProposer && <TableHeader>Proposed by</TableHeader>}
{showProposer && <TableHeader>Proposed by</TableHeader>}
<TableHeader textAlign="center">Transactions</TableHeader>
<TableHeader>Timestamp</TableHeader>
</Grid>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ import { dateFromNow, formatUTC, truncate } from "lib/utils";

interface BlocksTableMobileCardProps {
blockData: Block;
hideProposer?: boolean;
showProposer: boolean;
}
export const BlocksTableMobileCard = ({
blockData,
hideProposer = false,
showProposer,
}: BlocksTableMobileCardProps) => {
const navigate = useInternalNavigate();
return (
Expand Down Expand Up @@ -47,7 +47,7 @@ export const BlocksTableMobileCard = ({
</Flex>
}
middleContent={
!hideProposer && <ValidatorBadge validator={blockData.proposer} />
showProposer && <ValidatorBadge validator={blockData.proposer} />
}
bottomContent={
<Flex align="start" gap={4} w="full">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ import { dateFromNow, formatUTC, truncate } from "lib/utils";
interface BlocksTableRowProps {
templateColumns: GridProps["templateColumns"];
blockData: Block;
hideProposer?: boolean;
showProposer: boolean;
}

export const BlocksTableRow = ({
templateColumns,
blockData,
hideProposer = false,
showProposer,
}: BlocksTableRowProps) => {
const navigate = useInternalNavigate();

Expand Down Expand Up @@ -46,9 +46,9 @@ export const BlocksTableRow = ({
</ExplorerLink>
</TableRow>
<TableRow>
{truncate(blockData.hash.toUpperCase(), hideProposer ? [9, 9] : [6, 6])}
{truncate(blockData.hash.toUpperCase(), showProposer ? [6, 6] : [9, 9])}
</TableRow>
{!hideProposer && (
{showProposer && (
<TableRow>
<ValidatorBadge
validator={blockData.proposer}
Expand Down
1 change: 1 addition & 0 deletions src/lib/components/table/blocks/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./BlocksTable";
3 changes: 1 addition & 2 deletions src/lib/components/table/proposals/ProposalTextCell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export const ProposalTextCell = ({
Number(typeRef.current?.scrollWidth) >
Number(typeRef.current?.clientWidth));

if (isMobile) {
if (isMobile)
return (
<Flex direction="column" gap={1}>
<MobileLabel label="Proposal Title" />
Expand Down Expand Up @@ -68,7 +68,6 @@ export const ProposalTextCell = ({
)}
</Flex>
);
}

return (
<Flex
Expand Down
Loading
Loading