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

Visual fixes, AWS Registry Setup & DRep Pagination Fix: Maintenance and Testing Expansion #864

Merged
merged 35 commits into from
Apr 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
0ab55d5
add tests
Sworzen1 Apr 19, 2024
37e3c32
chore: update the copy text on the maintence page
Ryun1 Apr 17, 2024
4e899e4
docs: update the copy on maintence page
Ryun1 Apr 17, 2024
7d21596
fix: typo on maintence page
Ryun1 Apr 18, 2024
0ab65e8
add test - part 2
JanJaroszczak Apr 21, 2024
56868e9
add tests - part 3
JanJaroszczak Apr 22, 2024
ecd4cc9
[#756] add pagination to drep/list
jankun4 Apr 21, 2024
d6cee86
add tests - part 4
JanJaroszczak Apr 22, 2024
e203a74
[#742] Create a status-service AWS registry
placek Apr 22, 2024
9aa6ab9
[#742] Create a metadata-validation AWS registry
placek Apr 22, 2024
fd3df1b
[#742] Add status service docker image utilization to the deploy stack
placek Apr 22, 2024
553fa0e
[#742] Add metadata-validation docker image utilization to the deploy…
placek Apr 22, 2024
7a00b94
[#826] fix drep/list sql
jankun4 Apr 22, 2024
c6d5469
Merge pull request #819 from IntersectMBO/fix/742-missing-context-for…
placek Apr 22, 2024
cebfb6c
fix: fix footer alignment across pages
MSzalowski Apr 22, 2024
84cab12
Merge pull request #828 from IntersectMBO/826-no-dreps-found-in-dreplist
MSzalowski Apr 22, 2024
c3be91c
Merge pull request #827 from IntersectMBO/fix/footer-sticks-to-the-en…
MSzalowski Apr 22, 2024
897c316
[#740] feat: add drep list pagination
MSzalowski Apr 22, 2024
65e3173
[#740] fix: fix type check error on useDelegateTodRepForm hook
MSzalowski Apr 22, 2024
752cb11
fix: hasNextPage and fetchNextPage fix
JanJaroszczak Apr 23, 2024
c665d41
fix: Status modal error message overflow
JanJaroszczak Apr 23, 2024
cb45099
fix: DelegateDashboardCard transactionId fix
JanJaroszczak Apr 23, 2024
32259c6
Merge pull request #853 from IntersectMBO/status-modal-fix
JanJaroszczak Apr 23, 2024
95fd308
fix loaders
Sworzen1 Apr 24, 2024
f1987ed
Merge pull request #777 from IntersectMBO/chore/utils-tests
Sworzen1 Apr 24, 2024
d5f7f23
add incorect format error type
Sworzen1 Apr 24, 2024
0fcd24a
[#849] Configure sanchogov.tools sub-domain for the analytics service
adgud Apr 24, 2024
da2d6c2
add test ids for drep directory
Sworzen1 Apr 24, 2024
68a688a
Merge pull request #862 from IntersectMBO/chore/add-data-test-id-in-d…
Sworzen1 Apr 24, 2024
b35529f
Merge pull request #860 from IntersectMBO/849-subdomains
placek Apr 24, 2024
687a8dd
fix missing ga data
MSzalowski Apr 24, 2024
7f86404
Merge pull request #859 from IntersectMBO/fix/metadata-validation
Sworzen1 Apr 24, 2024
d8a1584
Merge pull request #858 from IntersectMBO/fix/loaders
Sworzen1 Apr 24, 2024
1661217
change mocked data
Sworzen1 Apr 24, 2024
b8c2d0c
Merge pull request #863 from IntersectMBO/chore/add-supported-links
Sworzen1 Apr 24, 2024
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
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
Loading