Skip to content

Commit

Permalink
Explorer tabs upgrade and add config page (#485)
Browse files Browse the repository at this point in the history
* Squashed commit of the following:

commit b4bb2cc
Author: fabiolalombardim <lombardifabiola@hotmail.com>
Date:   Wed Dec 21 12:16:17 2022 +0100

    internal link to Lite

* title block updated & buttons removed

* table filter

* clean up

* dao info tables

* updated missing field

* removed material ui styles

* clean up

* removed view code button

* responsive tables

* requested changes

* delete console.log

* execute text updated

* formulas added
  • Loading branch information
fabiolalombardim authored Feb 11, 2023
1 parent 23b4698 commit c33f88d
Show file tree
Hide file tree
Showing 22 changed files with 4,976 additions and 24,172 deletions.
19,891 changes: 0 additions & 19,891 deletions package-lock.json

This file was deleted.

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@
"source-map-explorer": "2.5.2",
"typescript": "^4.2.3"
},
"resolutions": {
"@types/react": "~17.0.3"
},
"eslintConfig": {
"extends": [
"react-app"
Expand Down
8 changes: 8 additions & 0 deletions src/assets/logos/config.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions src/models/Token.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ export const SUPPORTED_MIME_TYPES = [
] as const
export const SUPPORTED_MEDIA_TYPES = ["image", "audio", "video"] as const

export type NFTMimeType = typeof SUPPORTED_MIME_TYPES[number] | "unknown"
export type NFTMediaType = typeof SUPPORTED_MEDIA_TYPES[number] | "unknown"
export type NFTMimeType = (typeof SUPPORTED_MIME_TYPES)[number] | "unknown"
export type NFTMediaType = (typeof SUPPORTED_MEDIA_TYPES)[number] | "unknown"

interface NFTParams extends TokenParams {
description: string
Expand Down
3 changes: 1 addition & 2 deletions src/modules/common/WarningFooter.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Box, Grid, IconButton, Typography } from "@material-ui/core"
import { styled } from "@material-ui/styles"
import { Box, Grid, IconButton, Typography, styled } from "@material-ui/core"
import React, { useEffect, useState } from "react"
import { ReactComponent as WarningIcon } from "assets/logos/warning.svg"
import CloseIcon from "@material-ui/icons/Close"
Expand Down
140 changes: 140 additions & 0 deletions src/modules/explorer/components/AllProposalsList.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
import { Collapse, Grid, IconButton, 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 { Link } from "react-router-dom"
import { Proposal, ProposalStatus } from "services/indexer/dao/mappers/proposal/types"
import { ContentContainer } from "./ContentContainer"
import { Dropdown } from "./Dropdown"

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

const TableHeader = styled(Grid)({
padding: "16px 46px",
minHeight: 34
})

const ProposalsFooter = styled(Grid)({
padding: "16px 46px",
borderTop: ".6px solid rgba(125,140,139, 0.2)",
minHeight: 34
})

interface Props {
currentLevel: number
proposals: Proposal[]
title: string
showFooter?: boolean
rightItem?: (proposal: Proposal) => React.ReactElement
}

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

const filterProposals = useCallback(
(status?: any) => {
if (status === "All") {
return setFilteredProposals(proposals)
} else if (status !== "All" && status !== undefined) {
const filtered = proposals.filter(proposal => proposal["cachedStatus"]?.status === status)
setFilteredProposals(filtered)
} else {
return setFilteredProposals(proposals)
}
},
[proposals]
)

useEffect(() => {
filterProposals(filter)
}, [filter, filterProposals])

useEffect(() => {
setFilteredProposals(proposals)
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [])

const filterProposalByStatus = (status: any) => {
setFilter(status)
}

return (
<TableContainer item>
<Grid container direction="column" wrap={"nowrap"}>
<TableHeader item container justifyContent="space-between" alignItems="center">
<Grid item>
<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}
</TableHeader>
{filteredProposal.length ? (
<Grid
item
container
wrap={"nowrap"}
component={Collapse}
in={true}
timeout="auto"
unmountOnExit
direction="column"
>
{filteredProposal.map((p, i) => (
<Grid item key={`proposal-${i}`}>
<Link to={`proposal/${p.id}`}>
<ProposalItem proposal={p} status={p.getStatus(currentLevel).status}>
{rightItem ? rightItem(p) : null}
</ProposalItem>
</Link>
</Grid>
))}
</Grid>
) : (
<ProposalsFooter item container direction="column" justifyContent="center">
<Grid item>
<Typography color="textPrimary" align="center">
No items
</Typography>
</Grid>
</ProposalsFooter>
)}
{showFooter && (
<ProposalsFooter item container direction="column" justifyContent="center">
<Grid item>
<Link to="proposals">
<Typography color="secondary" variant="body2" align="center">
View All Proposals
</Typography>
</Link>
</Grid>
</ProposalsFooter>
)}
</Grid>
</TableContainer>
)
}
66 changes: 66 additions & 0 deletions src/modules/explorer/components/Dropdown.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import React, { useEffect, useState } from "react"
import { Select, SelectProps, MenuItem, makeStyles, Theme } from "@material-ui/core"
interface DropdownProps extends SelectProps {
options: { name: string; value: string | undefined }[]
value?: string | undefined
onSelected?: (item: string | undefined) => void
isFirst?: boolean
}

const useStyles = makeStyles((theme: Theme) => ({
icon: {
left: 0
},
iconOpen: {
transform: "none"
},
selectSelect: {
[theme.breakpoints.down("sm")]: {
fontSize: 16
},
paddingLeft: 10,
paddingTop: 0,
paddingBottom: 0,
minHeight: 24
},
option: {
"padding": 8,
"fontFamily": "Roboto Mono",
"cursor": "pointer",
"text-transform": "capitalize",
"&:hover": {
background: "rgba(129, 254, 183, .4)"
}
}
}))

export const Dropdown: React.FC<DropdownProps> = ({ options, value, onSelected }) => {
const classes = useStyles()
const [selected, setSelected] = useState<string | undefined>(value)

useEffect(() => {
setSelected(value)
}, [value])

const handleSelected = (event: any) => {
setSelected(event.target.value)
if (onSelected) onSelected(event.target.value)
}

return (
<Select
// native
value={selected}
onChange={handleSelected}
classes={{
select: classes.selectSelect
}}
>
{options.map(({ name, value }, index) => (
<option value={value} key={`${name}-${index}`} className={classes.option}>
{name}
</option>
))}
</Select>
)
}
16 changes: 12 additions & 4 deletions src/modules/explorer/components/NavigationMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { ReactComponent as TreasuryIcon } from "assets/logos/treasury.svg"
import { ReactComponent as RegistryIcon } from "assets/logos/list.svg"
import { ReactComponent as UserIcon } from "assets/logos/user.svg"
import { ReactComponent as NFTIcon } from "assets/logos/nft.svg"
import { ReactComponent as ConfigIcon } from "assets/logos/config.svg"
import React, { useEffect, useState } from "react"
import { useDAOID } from "../pages/DAO/router"
import { useDAO } from "services/indexer/dao/hooks/useDAO"
Expand Down Expand Up @@ -81,7 +82,8 @@ const IconContainer = styled("span")(({ theme, isSelected }: { theme: Theme; isS
"justifyContent": "center",

"& > svg > *": {
fill: isSelected ? theme.palette.secondary.main : theme.palette.text.primary
fill: isSelected ? theme.palette.secondary.main : theme.palette.text.primary,
stroke: isSelected ? theme.palette.secondary.main : theme.palette.text.primary
}
}))

Expand Down Expand Up @@ -134,10 +136,16 @@ 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`
}
]

const StyledBottomBar = styled(Grid)(({ theme, visible }: { theme: Theme; visible: boolean }) => ({
const StyledBottomBar = styled(Grid)(({ theme }: { theme: Theme }) => ({
position: "fixed",
height: 55,
width: "100%",
Expand Down Expand Up @@ -173,7 +181,7 @@ const BottomNavBar: React.FC = ({ children }) => {
}, [prevScrollPos, visible])

return (
<StyledBottomBar container direction={"row"} visible={visible}>
<StyledBottomBar container direction={"row"}>
<BottomBarItems container>{children}</BottomBarItems>
</StyledBottomBar>
)
Expand Down Expand Up @@ -225,7 +233,7 @@ export const NavigationMenu: React.FC<{ disableMobileMenu?: boolean }> = ({ disa
) : (
<BottomNavBar>
{pages.map((page, i) => (
<PageItem key={`page-${i}`} isSelected={pathId === page.pathId} item alignItems="center">
<PageItem key={`page-${i}`} isSelected={pathId === page.pathId} container item alignItems="center">
<Link to={page.href}>
<Grid container alignItems="center" justifyContent="center">
<Grid item>
Expand Down
4 changes: 2 additions & 2 deletions src/modules/explorer/components/ResponsiveDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export const ResponsiveDialog: React.FC<{
<BottomSheet open={open} onDismiss={onClose}>
<Content container direction="column" style={{ gap: 46 }}>
<Grid item container direction="row" wrap="nowrap" justifyContent="space-between">
<Grid item>{Boolean(onGoBack) ? <BackButton onGoBack={onGoBack} /> : null}</Grid>
<Grid item>{onGoBack ? <BackButton onGoBack={onGoBack} /> : null}</Grid>
<Grid item>
<TitleText>{title}</TitleText>
</Grid>
Expand All @@ -54,7 +54,7 @@ export const ResponsiveDialog: React.FC<{
<CustomDialog open={open} onClose={onClose} maxWidth={template ? "md" : "sm"}>
<Content container direction="column" style={{ gap: 30 }}>
<Grid item container direction="row" wrap="nowrap" justifyContent="space-between">
<Grid item>{Boolean(onGoBack) ? <BackButton onGoBack={onGoBack} /> : null}</Grid>
<Grid item>{onGoBack ? <BackButton onGoBack={onGoBack} /> : null}</Grid>
<Grid item>
<TitleText color="textPrimary">{title}</TitleText>
</Grid>
Expand Down
4 changes: 2 additions & 2 deletions src/modules/explorer/components/StatusBadge.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,11 @@ const statusColors = (status: ProposalStatus) => {
}

const Badge = styled(Grid)(({ status }: { status: ProposalStatus; theme: Theme }) => ({
borderRadius: 4,
borderRadius: 50,
textAlign: "center",
minHeight: 24,
minWidth: 105,
padding: "2px 5px",
padding: "2px 8px",
background: statusColors(status).background,
color: statusColors(status).color,
whiteSpace: "nowrap"
Expand Down
2 changes: 1 addition & 1 deletion src/modules/explorer/components/UsersTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ const TableText = styled(Typography)({
}
})

const titleDataMatcher = (title: typeof titles[number], rowData: RowData) => {
const titleDataMatcher = (title: (typeof titles)[number], rowData: RowData) => {
switch (title) {
case "Rank":
return rowData.address
Expand Down
Loading

0 comments on commit c33f88d

Please sign in to comment.