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

Proposals UI update #556

Merged
merged 5 commits into from
May 23, 2023
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
3 changes: 3 additions & 0 deletions src/assets/img/chart-icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions src/assets/img/cycle-icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions src/assets/img/list-icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions src/assets/img/tezos-icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions src/models/Choice.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
export interface Choice {
_id?: string
name: string
pollID: string
walletAddresses: WalletAddress[]
selected?: boolean
}

export interface WalletAddress {
address: string
balanceAtReferenceBlock: string
}
26 changes: 26 additions & 0 deletions src/models/Community.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
export interface Community {
_id?: string
name: string
description: string
linkToTerms: string
members: string[]
tokenAddress: string
polls: string[]
tokenType?: string
symbol: string
tokenID: string
picUri: string
requiredTokenOwnership: boolean
allowPublicAccess: boolean
decimals?: string
network: string
}

export interface CommunityToken {
_id?: string
daoID: string
tokenID: number
symbol: string
tokenAddress: string
decimals: string
}
32 changes: 32 additions & 0 deletions src/models/Polls.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
export enum ProposalStatus {
ACTIVE = "active",
CLOSED = "closed"
}
export interface Poll {
_id?: string
daoID: string
description: string
name: string
referenceBlock?: string
startTime: string
endTime: string
totalSupplyAtReferenceBlock?: any
choices: string[]
externalLink: ""
author: string
isActive?: ProposalStatus
timeFormatted?: string
tokenSymbol?: string
tokenAddress?: string
tokenDecimals?: string
votes?: Vote[]
votingStrategy: number
endTimeMinutes?: number | null
endTimeHours?: number | null
endTimeDays?: number | null
}

export interface Vote {
address: string
balanceAtReferenceBlock: string
}
15 changes: 15 additions & 0 deletions src/models/Proposal.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
export interface Proposal {
id?: string
title: string
description: string
externalLink: string
choices: string[]
startTime: number
endTime: number
daoID: string
}

interface Choice {
index: number
description: string
}
48 changes: 15 additions & 33 deletions src/modules/explorer/components/AllProposalsList.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
import { Collapse, Grid, IconButton, Typography } from "@material-ui/core"
import { Collapse, Grid, Theme, Typography } from "@material-ui/core"
import { styled } from "@material-ui/styles"
import { ProposalItem } from "modules/explorer/pages/User"
import React, { useCallback, useEffect, useMemo, useState } from "react"
import React, { useCallback, useEffect, useState } from "react"
import { Link } from "react-router-dom"
import { Proposal, ProposalStatus } from "services/indexer/dao/mappers/proposal/types"
import { Proposal } from "services/indexer/dao/mappers/proposal/types"
import { ContentContainer } from "./ContentContainer"
import { Dropdown } from "./Dropdown"
import { ProposalFilter } from "./ProposalsFilter"

const TableContainer = styled(ContentContainer)({
width: "100%"
})

const TableHeader = styled(Grid)({
const TableHeader = styled(Grid)(({ theme }: { theme: Theme }) => ({
padding: "16px 46px",
minHeight: 34
})
minHeight: 34,
[theme.breakpoints.down("sm")]: {
gap: 10
}
}))

const ProposalsFooter = styled(Grid)({
padding: "16px 46px",
Expand All @@ -32,13 +35,13 @@ interface Props {

export const AllProposalsList: React.FC<Props> = ({ currentLevel, proposals, title, showFooter, rightItem }) => {
const [filteredProposal, setFilteredProposals] = useState(proposals)
const [filter, setFilter] = useState("All")
const [filter, setFilter] = useState("all")

const filterProposals = useCallback(
(status?: any) => {
if (status === "All") {
if (status === "all") {
return setFilteredProposals(proposals)
} else if (status !== "All" && status !== undefined) {
} else if (status !== "all" && status !== undefined) {
const filtered = proposals.filter(proposal => proposal["cachedStatus"]?.status === status)
setFilteredProposals(filtered)
} else {
Expand Down Expand Up @@ -66,32 +69,11 @@ export const AllProposalsList: React.FC<Props> = ({ currentLevel, proposals, tit
<Grid container direction="column" wrap={"nowrap"}>
<TableHeader item container justifyContent="space-between" alignItems="center">
<Grid item>
<Typography variant="body2" style={{ fontWeight: "500" }} color="textPrimary">
<Typography variant="body1" style={{ fontWeight: "500" }} color="textPrimary">
{title}
</Typography>
</Grid>
{proposals.length ? (
<Grid item>
<IconButton aria-label="expand row" size="small">
<Dropdown
options={[
{ name: "All", value: "All" },
{ name: ProposalStatus.ACTIVE, value: ProposalStatus.ACTIVE },
{ name: ProposalStatus.DROPPED, value: ProposalStatus.DROPPED },
{ name: ProposalStatus.EXECUTABLE, value: ProposalStatus.EXECUTABLE },
{ name: ProposalStatus.EXECUTED, value: ProposalStatus.EXECUTED },
{ name: ProposalStatus.EXPIRED, value: ProposalStatus.EXPIRED },
{ name: ProposalStatus.NO_QUORUM, value: ProposalStatus.NO_QUORUM },
{ name: ProposalStatus.PASSED, value: ProposalStatus.PASSED },
{ name: ProposalStatus.PENDING, value: ProposalStatus.PENDING },
{ name: ProposalStatus.REJECTED, value: ProposalStatus.REJECTED }
]}
value={"All"}
onSelected={filterProposalByStatus}
/>{" "}
</IconButton>
</Grid>
) : null}
{proposals.length ? <ProposalFilter filterProposalByStatus={filterProposalByStatus} /> : null}
</TableHeader>
{filteredProposal.length ? (
<Grid
Expand Down
8 changes: 4 additions & 4 deletions src/modules/explorer/components/ConfigProposalFormLambda.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ enum LambdaProposalState {
const codeEditorPlaceholder = {
addLambda: `Write Michelson Code for Lambda's Implementation

Eg:-
Eg:-

(Left (Left (Pair (Pair { DROP ;
NIL operation ;
Expand All @@ -102,7 +102,7 @@ Eg:-
`,
lambdaExecuteArgumentsCode: `Write Michelson Code for the input Paramerers of your Lambda

Eg:-
Eg:-

{
"prim": "pair",
Expand All @@ -127,7 +127,7 @@ Eg:-
`,
lambdaExecuteParams: `Enter the values for the given params in a JSON/JavaScript Object format.

Eg:-
Eg:-

{
xtz_transfer_type: {
Expand Down Expand Up @@ -352,7 +352,7 @@ export const ProposalFormLambda: React.FC<Props> = ({ open, handleClose, action
open={open}
onClose={handleClose}
title={ProposalAction[action] + " Lambda Proposal"}
template="lambda"
template="md"
>
{state === LambdaProposalState.write_action ? (
<>
Expand Down
6 changes: 0 additions & 6 deletions src/modules/explorer/components/NavigationMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -133,12 +133,6 @@ const getPages = (daoId: string): Page[] => [
name: "User",
icon: UserIcon,
href: `/explorer/dao/${daoId}/user`
},
{
pathId: "config",
name: "Config",
icon: ConfigIcon,
href: `/explorer/dao/${daoId}/config`
}
]

Expand Down
Loading