Skip to content

Commit

Permalink
[#212] minor fix
Browse files Browse the repository at this point in the history
Signed-off-by: jankun4 <michaljankun@gmail.com>
  • Loading branch information
jankun4 committed Feb 27, 2024
2 parents 91591eb + a9de520 commit 1592ec1
Show file tree
Hide file tree
Showing 70 changed files with 1,627 additions and 718 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ As a minor extension, we also keep a semantic version for the `UNRELEASED`
changes.

## [Unreleased]
- Add possibility to vote on behalf of myself - Sole Voter [Issue 119](https://github.com/IntersectMBO/govtool/issues/119)
- Create DRep registration page about roles [Issue 205](https://github.com/IntersectMBO/govtool/issues/205)
- Create Checkbox component. Improve Field and ControlledField [Issue 177](https://github.com/IntersectMBO/govtool/pull/177)
- Vitest unit tests added for utils functions [Issue 81](https://github.com/IntersectMBO/govtool/issues/81)
- i18next library added to FE [Issue 80](https://github.com/IntersectMBO/govtool/issues/80)
Expand All @@ -17,13 +19,16 @@ changes.
- Added `isRegisteredAsSoleVoter` and `wasRegisteredAsSoleVoter` fields to the drep/info response [Issue 212](https://github.com/IntersectMBO/govtool/issues/212)

### Fixed
- Fix make button disble when wallet tries connect [Issue 265](https://github.com/IntersectMBO/govtool/issues/265)
- Fix drep voting power calculation [Issue 231](https://github.com/IntersectMBO/govtool/issues/231)
- Fix proposal/list and network/metrics bug that appeared when noone has delegated their funds either to drep_always_abstain or drep_always_no_confidence [Issue 231](https://github.com/IntersectMBO/govtool/issues/231)
- Fix GA details [Issue 272](https://github.com/IntersectMBO/govtool/issues/272)
- Fix copy for maintenance page [Issue 180](https://github.com/IntersectMBO/govtool/issues/180)
- Fix misleading metadata hash text [Issue 90](https://github.com/IntersectMBO/govtool/issues/90)
- Fixed vote calculation problems related to NoConfidence DRep [Issue 59](https://github.com/IntersectMBO/govtool/issues/59)
- Fixed ada-holder/get-current-delegation error when delegated to NoConfidence or AlwaysAbstain dreps. [Issue 82](https://github.com/IntersectMBO/govtool/issues/82)
- Fixed deployment scripts to address [Issue 171](https://github.com/IntersectMBO/govtool/issues/171).
- Fixed get drep voting power incorrectly executed endpoint [Issue 280](https://github.com/IntersectMBO/govtool/issues/280)

### Changed
- `isRegistered` and `wasRegistered` fields in the drep/info endpoint changed to `isRegisteredAsDRep` and `wasRegisteredAsDRep` respectively [Issue 212](https://github.com/IntersectMBO/govtool/issues/212)
Expand Down
5 changes: 3 additions & 2 deletions govtool/backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
FROM haskell:9.2-buster
ARG BASE_IMAGE_TAG
FROM 733019650473.dkr.ecr.eu-west-1.amazonaws.com/backend-base:$BASE_IMAGE_TAG
WORKDIR /src
COPY . .
RUN cabal update && cabal configure && cabal build
RUN cabal build
RUN cp dist-newstyle/build/x86_64-linux/ghc-9.2.8/vva-be-0.1.0.0/x/vva-be/build/vva-be/vva-be /usr/local/bin
10 changes: 10 additions & 0 deletions govtool/backend/Dockerfile.base
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# NOTE: This Dockerfile sets up an environment with precompiled dependencies for
# the GovTool Haskell backend project, streamlining the project's compilation
# process by ensuring it only needs to compile against these dependencies. This
# is a common practice in Haskell projects, as it can significantly reduce the
# time it takes to build the project.

FROM haskell:9.2-buster
WORKDIR /src
COPY . .
RUN cabal update && cabal configure && cabal install --only-dependencies && rm -rf /src/*
1 change: 1 addition & 0 deletions govtool/backend/sql/get-drep-info.sql
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ WITH DRepId AS (
CROSS JOIN DRepId
WHERE drep_hash.raw = DRepId.raw
and deposit is not null
and drep_registration.voting_anchor_id is not null
ORDER BY drep_registration.tx_id DESC
LIMIT 1
), WasRegisteredAsDRep AS (
Expand Down
5 changes: 5 additions & 0 deletions govtool/frontend/public/icons/ArrowLeftThin.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 10 additions & 3 deletions govtool/frontend/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
UpdatedRepMetadata,
GovernanceActionsCategory,
DashboardGovernanceActionsCategory,
RetireAsSoleVoter,
} from "@pages";
import {
callAll,
Expand All @@ -30,9 +31,10 @@ import {
} from "@utils";
import { SetupInterceptors } from "./services";
import { useGetDRepInfo, useWalletConnectionListener } from "./hooks";
import { RegisterAsSoleVoter } from "./pages/RegisterAsSoleVoter";

export default function App() {
const { enable, setDRep, setIsDrepLoading } = useCardano();
const { enable, setVoter, setIsDrepLoading } = useCardano();
const navigate = useNavigate();
const { data } = useGetDRepInfo();
const { modal, openModal, modals } = useModal();
Expand All @@ -45,11 +47,11 @@ export default function App() {

useEffect(() => {
setIsDrepLoading(true);
setDRep(data);
setVoter(data);
const timer = setTimeout(() => setIsDrepLoading(false), 1000);

return () => clearTimeout(timer);
}, [data?.isRegistered]);
}, [data?.isRegisteredAsDRep, data?.isRegisteredAsSoleVoter]);

const checkTheWalletIsActive = useCallback(() => {
const hrefCondition =
Expand Down Expand Up @@ -115,6 +117,11 @@ export default function App() {
</Route>
<Route path={PATHS.delegateTodRep} element={<DelegateTodRep />} />
<Route path={PATHS.registerAsdRep} element={<RegisterAsdRep />} />
<Route
path={PATHS.registerAsSoleVoter}
element={<RegisterAsSoleVoter />}
/>
<Route path={PATHS.retireAsSoleVoter} element={<RetireAsSoleVoter />} />
<Route path={PATHS.stakeKeys} element={<ChooseStakeKey />} />
<Route path={PATHS.updateMetadata} element={<UpdatedRepMetadata />} />
<Route path="*" element={<ErrorPage />} />
Expand Down
10 changes: 5 additions & 5 deletions govtool/frontend/src/components/atoms/VotingPowerChips.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { correctAdaFormat } from "@utils";
import { Tooltip } from "@atoms";

export const VotingPowerChips = () => {
const { dRep, stakeKey, isDrepLoading } = useCardano();
const { voter, stakeKey, isDrepLoading } = useCardano();
const { dRepVotingPower, isDRepVotingPowerLoading } =
useGetDRepVotingPowerQuery();
const { votingPower, powerIsLoading } =
Expand All @@ -33,7 +33,7 @@ export const VotingPowerChips = () => {
alignItems="center"
maxHeight={isMobile ? undefined : 48}
>
{dRep?.isRegistered && (
{voter?.isRegisteredAsDRep && (
<Tooltip
heading={t("tooltips.votingPower.heading")}
paragraphOne={t("tooltips.votingPower.paragraphOne")}
Expand All @@ -55,8 +55,8 @@ export const VotingPowerChips = () => {
{t("votingPower")}
</Typography>
)}
{(dRep?.isRegistered && isDRepVotingPowerLoading) ||
(!dRep?.isRegistered && powerIsLoading) ||
{(voter?.isRegisteredAsDRep && isDRepVotingPowerLoading) ||
(!voter?.isRegisteredAsDRep && powerIsLoading) ||
isDrepLoading ? (
<CircularProgress size={20} color="primary" />
) : (
Expand All @@ -67,7 +67,7 @@ export const VotingPowerChips = () => {
sx={{ whiteSpace: "nowrap" }}
>
{" "}
{dRep?.isRegistered
{voter?.isRegisteredAsDRep
? correctAdaFormat(dRepVotingPower) ?? 0
: correctAdaFormat(votingPower) ?? 0}
</Typography>
Expand Down
1 change: 0 additions & 1 deletion govtool/frontend/src/components/molecules/ActionCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ export const ActionCard: FC<ActionCardProps> = ({ ...props }) => {
<Button
data-testid={dataTestIdFirstButton}
onClick={firstButtonAction}
size="large"
sx={{
width: MOBILE_AND_WIDE_CONDITION ? "100%" : "auto",
}}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import { useMemo } from "react";
import { Box } from "@mui/material";

import { Button, LoadingButton } from "@atoms";
import { useScreenDimension, useTranslation } from "@hooks";

interface Props {
onBackButton: () => void;
onActionButton: () => void;
isLoading?: boolean;
backButtonText?: string;
actionButtonText?: string;
}

export const CenteredBoxBottomButtons = ({
onBackButton,
onActionButton,
isLoading,
backButtonText,
actionButtonText,
}: Props) => {
const { isMobile } = useScreenDimension();
const { t } = useTranslation();

const renderBackButton = useMemo(() => {
return (
<Button
data-testid={"back-button"}
onClick={onBackButton}
size="extraLarge"
sx={{
px: 6,
}}
variant="outlined"
>
{backButtonText ?? t("cancel")}
</Button>
);
}, [isMobile]);

const renderActionButton = useMemo(() => {
return (
<LoadingButton
data-testid={"register-button"}
isLoading={isLoading}
onClick={onActionButton}
sx={{
px: 6,
height: 48,
fontSize: 16,
}}
variant="contained"
>
{actionButtonText ?? t("continue")}
</LoadingButton>
);
}, [isLoading, isMobile]);

return (
<Box
display="flex"
flexDirection={isMobile ? "column-reverse" : "row"}
justifyContent="space-around"
mt={6}
>
{renderBackButton}
<Box px={2} py={isMobile ? 1.5 : 0} />
{renderActionButton}
</Box>
);
};
108 changes: 108 additions & 0 deletions govtool/frontend/src/components/molecules/CenteredBoxPageWrapper.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
import { FC, PropsWithChildren } from "react";
import { Box, Link } from "@mui/material";

import { Background, Typography } from "@atoms";
import { ICONS } from "@consts";
import { DashboardTopNav } from "@organisms";
import { useScreenDimension } from "@hooks";
import { useNavigate } from "react-router-dom";
import { theme } from "@/theme";

interface Props {
pageTitle: string;
backButtonText: string;
backButtonPath: string;
isVotingPowerHidden?: boolean;
}
export const CenteredBoxPageWrapper: FC<PropsWithChildren<Props>> = ({
pageTitle,
backButtonText,
backButtonPath,
isVotingPowerHidden,
children,
}) => {
const { isMobile, screenWidth, pagePadding } = useScreenDimension();
const navigate = useNavigate();
const {
palette: { boxShadow2 },
} = theme;

return (
<Background isReverted>
<Box display={"flex"} minHeight={"100vh"} flexDirection="column">
<DashboardTopNav
imageSRC={ICONS.appLogoIcon}
imageWidth={isMobile ? undefined : 42}
imageHeight={isMobile ? 24 : 35}
title={pageTitle}
isVotingPowerHidden={isVotingPowerHidden}
/>
<Box
display={"flex"}
justifyContent={"center"}
flexDirection={"column"}
mt={isMobile ? 0 : 7}
height={isMobile ? "100%" : "auto"}
sx={{ marginTop: "97px" }}
>
{isMobile && (
<Box borderBottom={1} borderColor={"#fff"}>
<Typography
variant="body2"
sx={{
ml: 2,
my: "26px",
fontSize: "24px",
fontWeight: 400,
}}
>
{pageTitle}
</Typography>
</Box>
)}
<Link
data-testid={"back-button"}
sx={{
cursor: "pointer",
display: "flex",
textDecoration: "none",
my: 3,
marginLeft: isMobile ? 2 : "40px",
}}
onClick={() => navigate(backButtonPath)}
>
<img
src={ICONS.arrowLeftThinIcon}
alt="arrow"
style={{ marginRight: "4px" }}
/>
<Typography
variant="body2"
color="primary"
sx={{
fontWeight: 400,
paddingTop: "1px",
}}
>
{backButtonText}
</Typography>
</Link>
<Box display={"flex"} justifyContent={"center"}>
<Box
width={screenWidth < 768 ? "auto" : "52vw"}
boxShadow={isMobile ? "" : `2px 2px 20px 0px ${boxShadow2}`}
px={pagePadding}
py={isMobile ? 3 : 8}
borderRadius={"20px"}
height="auto"
>
<Box display="flex" flexDirection="column">
{children}
</Box>
</Box>
</Box>
</Box>
</Box>
</Background>
);
};
Loading

0 comments on commit 1592ec1

Please sign in to comment.