Skip to content

Commit

Permalink
Merge pull request #864 from IntersectMBO/develop
Browse files Browse the repository at this point in the history
Visual fixes, AWS Registry Setup & DRep Pagination Fix: Maintenance and Testing Expansion
  • Loading branch information
pmbinapps authored Apr 24, 2024
2 parents a210181 + b8c2d0c commit 57c56d9
Show file tree
Hide file tree
Showing 83 changed files with 1,659 additions and 431 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ changes.

### Added

- added pagination to `drep/list` [Issue 756](https://github.com/IntersectMBO/govtool/issues/756)
- added search query param to the `drep/getVotes` [Issue 640](https://github.com/IntersectMBO/govtool/issues/640)
- added filtering and sorting capabilities to the `drep/list` [Issue 722](https://github.com/IntersectMBO/govtool/issues/722)
- added drepView and txHash to the `ada-holder/get-current-delegation` [Issue 689](https://github.com/IntersectMBO/govtool/issues/689)
Expand Down Expand Up @@ -55,9 +56,11 @@ changes.
- Add frontend test workflow on github actions [Issue 500](https://github.com/IntersectMBO/govtool/issues/500)
- Add type check & lint to github actions [Issue 512](https://github.com/IntersectMBO/govtool/issues/512)
- Add eslint & prettier to frontend package [Issue 166](https://github.com/IntersectMBO/govtool/issues/166)
- Add DRep list pagination [Issue 740](https://github.com/IntersectMBO/govtool/issues/740)

### Fixed

- drep/list sql fix (now the latest tx date is correct) [Issue 826](https://github.com/IntersectMBO/govtool/issues/826)
- drep/info no longer returns null values [Issue 720](https://github.com/IntersectMBO/govtool/issues/720)
- drep/getVotes no longer returns 500 [Issue 685](https://github.com/IntersectMBO/govtool/issues/685)
- drep/info no longer returns 500 [Issue 676](https://github.com/IntersectMBO/govtool/issues/676)
Expand Down Expand Up @@ -109,6 +112,7 @@ changes.
- Update frontend package readme to reflect recent changes [Issue 543](https://github.com/IntersectMBO/govtool/issues/543)
- Change input selection strategy to 3 (random) [Issue 575](https://github.com/IntersectMBO/govtool/issues/575)
- Changed documents to prepare for open source [Issue 737](https://github.com/IntersectMBO/govtool/issues/737)
- Changed copy on maintenance page [Issue 753](https://github.com/IntersectMBO/govtool/issues/753)

### Removed

Expand Down
10 changes: 5 additions & 5 deletions govtool/backend/sql/list-dreps.sql
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ FROM
LEFT JOIN voting_procedure AS voting_procedure ON voting_procedure.drep_voter = dh.id
LEFT JOIN tx AS tx ON tx.id = voting_procedure.tx_id
LEFT JOIN block AS block ON block.id = tx.block_id
JOIN (
LEFT JOIN (
SELECT
block.time,
dr.drep_hash_id,
Expand All @@ -79,18 +79,18 @@ FROM
JOIN tx ON tx.id = dr.tx_id
JOIN block ON block.id = tx.block_id
WHERE
NOT (dr.deposit > 0)) AS newestRegister ON newestRegister.drep_hash_id = dh.id
NOT (dr.deposit < 0)) AS newestRegister ON newestRegister.drep_hash_id = dh.id
AND newestRegister.rn = 1
JOIN (
LEFT JOIN (
SELECT
dr.tx_id,
dr.drep_hash_id,
ROW_NUMBER() OVER (PARTITION BY dr.drep_hash_id ORDER BY dr.tx_id ASC) AS rn
FROM
drep_registration dr) AS dr_first_register ON dr_first_register.drep_hash_id = dh.id
AND dr_first_register.rn = 1
JOIN tx AS tx_first_register ON tx_first_register.id = dr_first_register.tx_id
JOIN block AS block_first_register ON block_first_register.id = tx_first_register.block_id
LEFT JOIN tx AS tx_first_register ON tx_first_register.id = dr_first_register.tx_id
LEFT JOIN block AS block_first_register ON block_first_register.id = tx_first_register.block_id
GROUP BY
dh.raw,
second_to_newest_drep_registration.voting_anchor_id,
Expand Down
26 changes: 22 additions & 4 deletions govtool/backend/src/VVA/API.hs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ type VVAApi =
:> QueryParam "search" Text
:> QueryParams "status" DRepStatus
:> QueryParam "sort" DRepSortMode
:> Get '[JSON] [DRep]
:> QueryParam "page" Natural
:> QueryParam "pageSize" Natural
:> Get '[JSON] ListDRepsResponse
:<|> "drep" :> "get-voting-power" :> Capture "drepId" HexText :> Get '[JSON] Integer
:<|> "drep" :> "getVotes"
:> Capture "drepId" HexText
Expand Down Expand Up @@ -120,8 +122,8 @@ delegationToResponse Types.Delegation {..} =
}


drepList :: App m => Maybe Text -> [DRepStatus] -> Maybe DRepSortMode -> m [DRep]
drepList mSearchQuery statuses mSortMode = do
drepList :: App m => Maybe Text -> [DRepStatus] -> Maybe DRepSortMode -> Maybe Natural -> Maybe Natural -> m ListDRepsResponse
drepList mSearchQuery statuses mSortMode mPage mPageSize = do
CacheEnv {dRepListCache} <- asks vvaCache
dreps <- cacheRequest dRepListCache () DRep.listDReps

Expand All @@ -148,7 +150,23 @@ drepList mSearchQuery statuses mSortMode = do
dRepRegistrationStatus


return $ map drepRegistrationToDrep $ sortDReps $ filterDRepsByQuery $ filterDRepsByStatus dreps
let allValidDReps = map drepRegistrationToDrep $ sortDReps $ filterDRepsByQuery $ filterDRepsByStatus dreps


let page = (fromIntegral $ fromMaybe 0 mPage) :: Int
pageSize = (fromIntegral $ fromMaybe 10 mPageSize) :: Int

total = length allValidDReps :: Int

let elements = take pageSize $ drop (page * pageSize) allValidDReps

return $ ListDRepsResponse
{ listDRepsResponsePage = fromIntegral page
, listDRepsResponsePageSize = fromIntegral pageSize
, listDRepsResponseTotal = fromIntegral total
, listDRepsResponseElements = elements
}


getVotingPower :: App m => HexText -> m Integer
getVotingPower (unHexText -> dRepId) = do
Expand Down
36 changes: 36 additions & 0 deletions govtool/backend/src/VVA/API/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -750,6 +750,42 @@ instance ToSchema DRep where
& example
?~ toJSON exampleDrep


exampleListDRepsResponse :: Text
exampleListDRepsResponse =
"{ \"page\": 0,"
<> "\"pageSize\": 1,"
<> "\"total\": 1000,"
<> "\"elements\": ["
<> exampleDrep <> "]}"

data ListDRepsResponse
= ListDRepsResponse
{ listDRepsResponsePage :: Integer
, listDRepsResponsePageSize :: Integer
, listDRepsResponseTotal :: Integer
, listDRepsResponseElements :: [DRep]
}
deriving (Generic, Show)

deriveJSON (jsonOptions "listDRepsResponse") ''ListDRepsResponse

instance ToSchema ListDRepsResponse where
declareNamedSchema proxy = do
NamedSchema name_ schema_ <-
genericDeclareNamedSchema
( fromAesonOptions $
jsonOptions "listDRepsResponse"
)
proxy
return $
NamedSchema name_ $
schema_
& description ?~ "ListProposalsResponse"
& example
?~ toJSON exampleListDRepsResponse


data DelegationResponse
= DelegationResponse
{ delegationResponseDRepHash :: Maybe HexText
Expand Down
8 changes: 6 additions & 2 deletions govtool/frontend/maintenance-page/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,12 @@
<div>
<h1 class="heading">GovTool is down</h1>
<h2 class="text">
The SanchoNet GovTool is currently down for maintenance. Please try
again later.
The SanchoNet GovTool Beta is currently down for maintenance.
SanchoNet Govtool is connected to SanchoNet testnet, which
means that if the network gets upgraded with new features
Govtool needs to be updated too.

Please try again later.
</h2>
<!-- <a href="" class="status">Status tracker</a> -->
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Button, LoadingButton, Typography } from "@atoms";
import { primaryBlue } from "@consts";
import { useModal } from "@context";
import { useScreenDimension, useTranslation } from "@hooks";
import { openInNewTab } from "@utils";
import { openInNewTab, testIdFromLabel } from "@utils";

import { Card } from "./Card";
import { AutomatedVotingCardProps } from "./types";
Expand All @@ -24,6 +24,7 @@ export const AutomatedVotingCard = ({
const { isMobile, screenWidth } = useScreenDimension();
const { openModal } = useModal();
const { t } = useTranslation();
const testIdLabel = testIdFromLabel(title);

const onClickShowTransaction = () =>
openInNewTab(`https://sancho.cexplorer.io/tx/${transactionId}`);
Expand Down Expand Up @@ -121,7 +122,7 @@ export const AutomatedVotingCard = ({
}}
>
<Button
// TODO handle button click
data-testid={`${testIdLabel}-info-button`}
onClick={onClickInfo}
size={isMobile ? "medium" : "large"}
sx={{ flex: screenWidth < 768 ? 1 : undefined }}
Expand All @@ -131,6 +132,7 @@ export const AutomatedVotingCard = ({
</Button>
{!isConnected ? (
<Button
data-testid={`${testIdLabel}-connect-to-delegate-button`}
onClick={() => openModal({ type: "chooseWallet" })}
size={isMobile ? "medium" : "large"}
sx={{ flex: screenWidth < 768 ? 1 : undefined }}
Expand All @@ -140,6 +142,7 @@ export const AutomatedVotingCard = ({
) : (
!isSelected && (
<LoadingButton
data-testid={`${testIdLabel}-delegate-button`}
isLoading={isDelegateLoading}
onClick={onClickDelegate}
size={isMobile ? "medium" : "large"}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ export const CenteredBoxPageWrapper: FC<PropsWithChildren<Props>> = ({
</Box>
</Box>
</Box>
{/* FIXME: Footer should be on top of the layout.
Should not be rerendered across the pages */}
<Footer />
</Box>
</Background>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { Box, Link } from "@mui/material";

import { Typography } from "@atoms";
import { useTranslation } from "@hooks";
import { MetadataValidationStatus } from "@models";
import { openInNewTab } from "@utils";
import { MetadataValidationStatus } from "@/models";

export const DataMissingInfoBox = ({
isDataMissing,
Expand All @@ -26,6 +26,9 @@ export const DataMissingInfoBox = ({
[MetadataValidationStatus.INVALID_HASH]: t(
"errors.gAMetadata.message.notVerifiable",
),
[MetadataValidationStatus.INCORRECT_FORMAT]: t(
"errors.gAMetadata.message.incorrectFormat",
),
}[isDataMissing as MetadataValidationStatus];

const gaMetadataErrorDescription = {
Expand All @@ -38,6 +41,9 @@ export const DataMissingInfoBox = ({
[MetadataValidationStatus.INVALID_HASH]: t(
"errors.gAMetadata.description.notVerifiable",
),
[MetadataValidationStatus.INCORRECT_FORMAT]: t(
"errors.gAMetadata.description.incorrectFormat",
),
}[isDataMissing as MetadataValidationStatus];

return isDataMissing && !isSubmitted && !isInProgress ? (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,66 +1,64 @@
import { Box } from "@mui/material";

import { Typography } from "@atoms";
import { ICONS } from "@consts";
import { useModal } from "@context";
import { useScreenDimension, useTranslation } from "@hooks";
import { LinkWithIcon } from "@molecules";
import { ICONS } from "@/consts";
import { useModal } from "@/context";

// TODO: When BE is ready, pass links as props
const LINKS = [
"https://docs.sanchogov.tools/support/get-help-in-discord",
"https://docs.sanchogov.tools/how-to-use-the-govtool/prerequsites",
"https://docs.sanchogov.tools/faqs",
"https://docs.sanchogov.tools/",
];

export const GovernanceActionDetailsCardLinks = () => {
export const GovernanceActionDetailsCardLinks = ({
links,
}: {
links?: string[];
}) => {
const { isMobile } = useScreenDimension();
const { t } = useTranslation();
const { openModal } = useModal();

return (
<>
<Typography
sx={{
fontSize: 14,
fontWeight: 600,
lineHeight: "20px",
color: "neutralGray",
overflow: "hidden",
textOverflow: "ellipsis",
whiteSpace: "nowrap",
mb: 2,
}}
data-testid="supporting-links"
>
{t("govActions.supportingLinks")}
</Typography>
<Box
sx={{
display: "grid",
gridTemplateColumns: isMobile ? undefined : "1fr 1fr",
columnGap: 2,
rowGap: 2,
}}
>
{LINKS.map((link) => (
<LinkWithIcon
key={link}
label={link}
onClick={() => {
openModal({
type: "externalLink",
state: {
externalLink: link,
},
});
}}
icon={<img alt="link" src={ICONS.link} />}
cutWithEllipsis
/>
))}
</Box>
</>
links && (
<>
<Typography
sx={{
fontSize: 14,
fontWeight: 600,
lineHeight: "20px",
color: "neutralGray",
overflow: "hidden",
textOverflow: "ellipsis",
whiteSpace: "nowrap",
mb: 2,
}}
data-testid="supporting-links"
>
{t("govActions.supportingLinks")}
</Typography>
<Box
sx={{
display: "grid",
gridTemplateColumns: isMobile ? undefined : "1fr 1fr",
columnGap: 2,
rowGap: 2,
}}
>
{links.map((link) => (
<LinkWithIcon
key={link}
label={link}
onClick={() => {
openModal({
type: "externalLink",
state: {
externalLink: link,
},
});
}}
icon={<img alt="link" src={ICONS.link} />}
cutWithEllipsis
/>
))}
</Box>
</>
)
);
};
Loading

0 comments on commit 57c56d9

Please sign in to comment.