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

test: #466, #481, #378, #377, #365, #462, #463, #380, #393, #445 #492

Merged
merged 30 commits into from
Mar 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
3cfb87a
[#453] Storybook update
JanJaroszczak Mar 11, 2024
2cc923c
[#453] Fixes after CR
JanJaroszczak Mar 13, 2024
575bba2
Introduce frontend image build environment tag
placek Mar 13, 2024
eb74647
Merge pull request #468 from IntersectMBO/hotfix/466-enhancing-docker…
placek Mar 13, 2024
45538ca
Merge pull request #454 from IntersectMBO/453-storybook-update-part-1
JanJaroszczak Mar 13, 2024
ffed96f
[#378] feat: add hash and validation of the metadata
MSzalowski Mar 12, 2024
854d915
[#378] feat: create gov action transaction builder & submit
MSzalowski Mar 13, 2024
e50ee51
add pending transaction for governance action creation
Sworzen1 Mar 13, 2024
401b348
[#378] remove console.log of hash
MSzalowski Mar 13, 2024
919d72d
[#453] Storybook update
JanJaroszczak Mar 11, 2024
b17a9c2
[#453] Fixes after CR
JanJaroszczak Mar 13, 2024
bb1bc51
Introduce frontend image build environment tag
placek Mar 13, 2024
854034f
[#378] fix text wrapping on review governance action submission
MSzalowski Mar 13, 2024
318d29d
Merge pull request #458 from IntersectMBO/feat/378-hash-and-validatio…
MSzalowski Mar 14, 2024
451feba
Merge pull request #474 from IntersectMBO/develop
pmbinapps Mar 14, 2024
7f12a1c
[#364] fix: i18n labels of storage information screen
MSzalowski Mar 14, 2024
21f7681
Merge pull request #475 from IntersectMBO/fix/364-fix-i18n-labels-of-…
MSzalowski Mar 14, 2024
b65aa9f
[#364] fix: i18n labels of storage information screen
MSzalowski Mar 14, 2024
5d15dc9
[#462] [#463] fix cards width and fonts for RWDs
Sworzen1 Mar 14, 2024
1b6b163
[#451] fix: whitelist any jsonld file in CSP
MSzalowski Mar 14, 2024
4e348fa
[#481] ]wrap too long link
Sworzen1 Mar 14, 2024
2a5683e
Merge pull request #480 from IntersectMBO/fix/allow-jsonld-files-in-csp
MSzalowski Mar 15, 2024
33b040f
Merge pull request #483 from IntersectMBO/fix/481-ga-details-long-ext…
Sworzen1 Mar 15, 2024
d6ecbb4
Merge pull request #478 from IntersectMBO/fix/462/463
Sworzen1 Mar 15, 2024
e662a3f
[#462] [#463] fix cards width and fonts for RWDs
Sworzen1 Mar 14, 2024
fa32861
[#451] fix: whitelist any jsonld file in CSP
MSzalowski Mar 14, 2024
5b409c4
[#481] ]wrap too long link
Sworzen1 Mar 14, 2024
88e2a2b
[#377] fix: validation of ada amount
MSzalowski Mar 15, 2024
59d7704
Merge pull request #490 from IntersectMBO/fix/377/fix-validation-of-a…
MSzalowski Mar 15, 2024
209264e
Merge pull request #491 from IntersectMBO/develop
MSzalowski Mar 15, 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
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@ As a minor extension, we also keep a semantic version for the `UNRELEASED`
changes.

## [Unreleased]

- Add generate jsonld function [Issue 451](https://github.com/IntersectMBO/govtool/issues/451)
- Create GA review subbmision page [Issue 362](https://github.com/IntersectMBO/govtool/issues/362)
- Create GA creation form [Issue 360](https://github.com/IntersectMBO/govtool/issues/360)
- Create TextArea [Issue 110](https://github.com/IntersectMBO/govtool/issues/110)
- Choose GA type - GA Submiter [Issue 358](https://github.com/IntersectMBO/govtool/issues/358)

- Add on-chain inputs validation [Issue 377](https://github.com/IntersectMBO/govtool/issues/377)
- Add hash and validation of the metadata [Issue 378](https://github.com/IntersectMBO/govtool/issues/378)
- Add githubusercontent.com and ipfs.io to content security policy header [Issue 451](https://github.com/IntersectMBO/govtool/issues/451)

### Added

Expand Down Expand Up @@ -44,6 +46,7 @@ changes.
- Fixed CSP settings to allow error reports with Sentry [Issue 291](https://github.com/IntersectMBO/govtool/issues/291).

### Changed

- `drep/list` now return also `status` and `type` fields. Also it now returns the retired dreps, and you can search for given drep by name using optional query parameter. If the drep name is passed exactly, then you can even find a drep that's sole voter. [Issue 446](https://github.com/IntersectMBO/govtool/issues/446)
- `drep/list` and `drep/info` endpoints now return additional data such as metadata url and hash, and voting power [Issue 223](https://github.com/IntersectMBO/govtool/issues/223)
- `drep/info` now does not return sole voters (dreps without metadata) [Issue 317](https://github.com/IntersectMBO/govtool/issues/317)
Expand Down
48 changes: 28 additions & 20 deletions govtool/frontend/.storybook/preview.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import React from "react";
import type { Preview } from "@storybook/react";
import { ThemeProvider } from "@emotion/react";
import { theme } from "../src/theme";
import { MemoryRouter, Routes, Route } from "react-router-dom";
import { QueryClient, QueryClientProvider } from "react-query";
import { I18nextProvider } from "react-i18next";
import i18n from "../src/i18n";
import { ModalProvider } from "../src/context/modal";

const queryClient = new QueryClient();

Expand All @@ -19,26 +23,30 @@ const preview: Preview = {
decorators: [
(Story) => (
<QueryClientProvider client={queryClient}>
<ThemeProvider theme={theme}>
<MemoryRouter>
<Routes>
<Route
path="/*"
element={
<div
style={{
margin: "0px",
padding: "0px",
position: "relative",
}}
>
<Story />
</div>
}
/>
</Routes>
</MemoryRouter>
</ThemeProvider>
<ModalProvider>
<I18nextProvider i18n={i18n}>
<ThemeProvider theme={theme}>
<MemoryRouter>
<Routes>
<Route
path="/*"
element={
<div
style={{
margin: "0px",
padding: "0px",
position: "relative",
}}
>
<Story />
</div>
}
/>
</Routes>
</MemoryRouter>
</ThemeProvider>
</I18nextProvider>
</ModalProvider>
</QueryClientProvider>
),
],
Expand Down
2 changes: 1 addition & 1 deletion govtool/frontend/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ endif
.DEFAULT_GOAL := push-frontend

# image tags
frontend_image_tag := $(shell git log -n 1 --format="%H" -- $(root_dir)/govtool/frontend)
frontend_image_tag := $(shell git log -n 1 --format="%H" -- $(root_dir)/govtool/frontend)-$(env)

.PHONY: build-frontend
build-frontend: docker-login
Expand Down
1 change: 1 addition & 0 deletions govtool/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"@mui/icons-material": "^5.14.3",
"@mui/material": "^5.14.4",
"@sentry/react": "^7.77.0",
"@types/jsonld": "^1.5.13",
"@types/react": "^18.2.12",
"@types/react-gtm-module": "^2.0.2",
"axios": "^1.4.0",
Expand Down
4 changes: 2 additions & 2 deletions govtool/frontend/src/components/atoms/Typography.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export const Typography = ({
}: TypographyProps) => {
const fontSize = {
headline1: 100,
headline2: 50,
headline2: 57,
headline3: 36,
headline4: 32,
headline5: 28,
Expand All @@ -21,7 +21,7 @@ export const Typography = ({

const fontWeight = {
headline1: 600,
headline2: 600,
headline2: 700,
headline3: 400,
headline4: 600,
headline5: 500,
Expand Down
24 changes: 7 additions & 17 deletions govtool/frontend/src/components/molecules/ActionCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export const ActionCard: FC<ActionCardProps> = ({ ...props }) => {
secondButtonLabel,
title,
} = props;
const { isMobile, screenWidth } = useScreenDimension();
const { screenWidth } = useScreenDimension();

const {
palette: { boxShadow2 },
Expand All @@ -52,23 +52,14 @@ export const ActionCard: FC<ActionCardProps> = ({ ...props }) => {
>
<Box display="flex" flexDirection="column" flex={1}>
{imageURL ? (
<img
src={imageURL}
width={imageWidth}
height={imageHeight}
style={{
alignSelf: screenWidth < 640 ? "center" : "start",
}}
/>
<img height={imageHeight} src={imageURL} width={imageWidth} />
) : null}
{title ? (
<Typography
fontWeight={isMobile ? 600 : 500}
sx={{
mt: screenWidth < 640 ? 4 : 2.5,
textAlign: screenWidth < 640 ? "center" : "left",
mt: 2.5,
}}
variant={isMobile ? "title2" : "headline5"}
variant={"headline5"}
>
{title}
</Typography>
Expand All @@ -79,9 +70,8 @@ export const ActionCard: FC<ActionCardProps> = ({ ...props }) => {
sx={{
mb: 4.25,
mt: 1.75,
textAlign: screenWidth < 640 ? "center" : "left",
}}
variant={isMobile ? "body2" : "body1"}
variant={"body1"}
>
{description}
</Typography>
Expand All @@ -103,11 +93,11 @@ export const ActionCard: FC<ActionCardProps> = ({ ...props }) => {
data-testid={dataTestIdSecondButton}
onClick={secondButtonAction}
sx={{
visibility: secondButtonLabel ? "visible" : "hidden",
display: !secondButtonLabel && screenWidth < 768 ? "none" : "block",
ml: screenWidth < 640 ? 0 : 2,
mt: screenWidth < 640 ? 2 : 0,
visibility: secondButtonLabel ? "visible" : "hidden",
width: screenWidth < 640 ? "100%" : "auto",
display: !secondButtonLabel && screenWidth < 768 ? "none" : "block",
}}
variant="outlined"
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import { Button, InfoText, Spacer, Typography } from "@atoms";
import { GOVERNANCE_ACTION_FIELDS } from "@consts";
import { useCreateGovernanceActionForm, useTranslation } from "@hooks";
import { Field } from "@molecules";
import { URL_REGEX } from "@/utils";
import { GovernanceActionField } from "@/types/governanceAction";

import { BgCard } from "../BgCard";
import { ControlledField } from "../ControlledField";
import { GovernanceActionField } from "@/types/governanceAction";
import { URL_REGEX } from "@/utils";

const LINK_PLACEHOLDER = "https://website.com/";
const MAX_NUMBER_OF_LINKS = 8;
Expand Down Expand Up @@ -117,10 +117,6 @@ export const CreateGovernanceActionForm = ({
placeholder={LINK_PLACEHOLDER}
name={`links.${index}.link`}
rules={{
required: {
value: true,
message: t("createGovernanceAction.fields.validations.required"),
},
pattern: {
value: URL_REGEX,
message: t("createGovernanceAction.fields.validations.url"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,14 @@ export const ReviewCreatedGovernanceAction = ({
key.charAt(0).toUpperCase() + key.slice(1).replace(/_/g, " ");

return (
<Box sx={{ mb: 5 }}>
<Box sx={{ mb: 5, width: "100%" }}>
<Typography color="neutralGray" fontWeight={400} variant="body2">
{label}
</Typography>
<Typography sx={{ mt: 0.5 }} variant="body2">
<Typography
sx={{ mt: 0.5, wordBreak: "break-word" }}
variant="body2"
>
{value as string}
</Typography>
</Box>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Dispatch, SetStateAction, useCallback, useState } from "react";
import { Dispatch, SetStateAction, useCallback } from "react";
import { Box } from "@mui/material";
import OpenInNewIcon from "@mui/icons-material/OpenInNew";

Expand All @@ -7,7 +7,7 @@ import { ICONS } from "@consts";
import { useCreateGovernanceActionForm, useTranslation } from "@hooks";
import { Step } from "@molecules";
import { BgCard, ControlledField } from "@organisms";
import { URL_REGEX, downloadJson, openInNewTab } from "@utils";
import { URL_REGEX, openInNewTab } from "@utils";

type StorageInformationProps = {
setStep: Dispatch<SetStateAction<number>>;
Expand All @@ -19,11 +19,11 @@ export const StorageInformation = ({ setStep }: StorageInformationProps) => {
control,
errors,
createGovernanceAction,
generateJsonBody,
getValues,
watch,
} = useCreateGovernanceActionForm();
const [isJsonDownloaded, setIsJsonDownloaded] = useState<boolean>(false);
onClickDownloadJson,
isLoading,
} = useCreateGovernanceActionForm(setStep);

// TODO: change on correct file name
const fileName = getValues("governance_action_type");
Expand All @@ -34,24 +34,18 @@ export const StorageInformation = ({ setStep }: StorageInformationProps) => {
[]
);

const isActionButtonDisabled = !watch("storingURL") || !isJsonDownloaded;
const isActionButtonDisabled = !watch("storingURL");

const onClickBack = useCallback(() => setStep(5), []);

const onClickDownloadJson = async () => {
const data = getValues();
const jsonBody = await generateJsonBody(data);
downloadJson(jsonBody, fileName);
setIsJsonDownloaded(true);
};

return (
<BgCard
actionButtonLabel={t("continue")}
backButtonLabel={t("back")}
isActionButtonDisabled={isActionButtonDisabled}
onClickActionButton={createGovernanceAction}
onClickBackButton={onClickBack}
isLoadingActionButton={isLoading}
>
<Typography sx={{ textAlign: "center" }} variant="headline4">
{t("createGovernanceAction.storingInformationTitle")}
Expand Down
33 changes: 20 additions & 13 deletions govtool/frontend/src/components/organisms/DashboardCards.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,20 @@ export const DashboardCards = () => {
buildSignSubmitConwayCertTx,
delegateTo,
delegateTransaction,
voter,
dRepID,
dRepIDBech32,
govActionTransaction,
isDrepLoading,
isPendingTransaction,
registerTransaction,
soleVoterTransaction,
stakeKey,
voter,
} = useCardano();
const navigate = useNavigate();
const { currentDelegation, isCurrentDelegationLoading } =
useGetAdaHolderCurrentDelegationQuery(stakeKey);
const { isMobile, screenWidth } = useScreenDimension();
const { screenWidth } = useScreenDimension();
const { openModal } = useModal();
const [isRetirementLoading, setIsRetirementLoading] =
useState<boolean>(false);
Expand Down Expand Up @@ -185,6 +186,14 @@ export const DashboardCards = () => {
[isPendingTransaction, navigate]
);

const onClickGovernanceActionCardActionButton = useCallback(() => {
if (govActionTransaction.transactionHash) {
navigate(PATHS.dashboardGovernanceActions);
return;
}
navigate(PATHS.createGovernanceAction);
}, [govActionTransaction.transactionHash, navigate]);

const displayedDelegationId = useMemo(() => {
const restrictedNames = [
dRepID,
Expand Down Expand Up @@ -323,11 +332,12 @@ export const DashboardCards = () => {
display: "grid",
gridTemplateColumns:
screenWidth < 1280
? "1fr"
: screenWidth > 1728
? "repeat(3, minmax(300px, 572px))"
: "repeat(2, minmax(300px, 572px))",
px: isMobile ? 2 : 5,
? "repeat(1, minmax(300px, 530px))"
: screenWidth >= 1728
? "repeat(3, minmax(300px, 570px))"
: "repeat(2, minmax(300px, 530px))",
justifyContent: screenWidth < 1024 ? "center" : "flex-start",
px: screenWidth < 640 ? 2 : 5,
py: 3,
rowGap: 3,
}}
Expand Down Expand Up @@ -525,16 +535,13 @@ export const DashboardCards = () => {
<DashboardActionCard
dataTestidFirstButton="propose-governance-actions-button"
description={t("dashboard.proposeGovernanceAction.description")}
// TODO: add isPendingGovernanceAction to the context
// inProgress={isPendingGovernanceAction}
firstButtonAction={() => navigate(PATHS.createGovernanceAction)}
firstButtonAction={onClickGovernanceActionCardActionButton}
firstButtonLabel={t(
`dashboard.proposeGovernanceAction.${
// TODO: add isPendingGovernanceAction to the context
// isPendingGovernanceAction ? "propose" : "viewGovernanceActions"
`propose`
govActionTransaction.transactionHash ? "view" : "propose"
}`
)}
inProgress={!!govActionTransaction.transactionHash}
secondButtonLabel={t("learnMore")}
secondButtonAction={() =>
openInNewTab(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export function ExternalLinkModal() {
marginBottom: "38px",
color: primaryBlue,
textDecoration: "underline",
wordBreak: "break-word",
}}
>
{state?.externalLink}
Expand Down
2 changes: 1 addition & 1 deletion govtool/frontend/src/components/organisms/Hero.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export const Hero = () => {
<Typography
variant={screenWidth < 860 ? "headline2" : "headline1"}
sx={{ whiteSpace: "pre-line" }}
{...(screenWidth < 375 && { fontSize: 45 })}
{...(screenWidth < 430 && { fontSize: 50 })}
>
{t("hero.headline")}
</Typography>
Expand Down
Loading
Loading