From 8be8d63363be2913fb3d6f443e5cbf046e7bd418 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Sza=C5=82owski?= Date: Fri, 13 Dec 2024 16:19:05 +0100 Subject: [PATCH 1/6] fix: misalignment of votes on connected governance actions --- CHANGELOG.md | 1 + .../src/components/organisms/GovernanceActionDetailsCard.tsx | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b9628fd1b..49f30c36c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ changes. ### Fixed - Fix mzero parsing error on fetching the /proposal/list [Issue 2446](https://github.com/IntersectMBO/govtool/issues/2446) +- Fix scaling gov action votes on lower resolutions ### Changed diff --git a/govtool/frontend/src/components/organisms/GovernanceActionDetailsCard.tsx b/govtool/frontend/src/components/organisms/GovernanceActionDetailsCard.tsx index d4ba7bfee..df326ce17 100644 --- a/govtool/frontend/src/components/organisms/GovernanceActionDetailsCard.tsx +++ b/govtool/frontend/src/components/organisms/GovernanceActionDetailsCard.tsx @@ -31,7 +31,7 @@ export const GovernanceActionDetailsCard = ({ const [isVoteSubmitted, setIsVoteSubmitted] = useState(false); const { screenWidth, isMobile } = useScreenDimension(); - const isOneColumn = (isDashboard && screenWidth < 1645) ?? isMobile; + const isOneColumn = (isDashboard && screenWidth < 1036) ?? isMobile; const { pathname, hash } = useLocation(); const govActionLinkToShare = `${window.location.protocol}//${ From b805536178806d858720aba4e6d9d4b3089c3860 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Sza=C5=82owski?= Date: Fri, 13 Dec 2024 17:00:37 +0100 Subject: [PATCH 2/6] feat: integrate matomo analytics --- CHANGELOG.md | 2 +- govtool/frontend/src/App.tsx | 2 ++ govtool/frontend/src/hooks/useMatomo.ts | 31 +++++++++++++++++++++++++ 3 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 govtool/frontend/src/hooks/useMatomo.ts diff --git a/CHANGELOG.md b/CHANGELOG.md index b9628fd1b..73a1b3168 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,7 +12,7 @@ changes. ### Added -- +- Integrate matomo analytics ### Fixed diff --git a/govtool/frontend/src/App.tsx b/govtool/frontend/src/App.tsx index 553d5295f..7745ceefb 100644 --- a/govtool/frontend/src/App.tsx +++ b/govtool/frontend/src/App.tsx @@ -39,8 +39,10 @@ import { import { PublicRoute } from "./pages/PublicRoute"; import { TopBanners } from "./components/organisms/TopBanners"; import { DashboardHome } from "./pages/DashboardHome"; +import { useMatomo } from "./hooks/useMatomo"; export default () => { + useMatomo(); const { isProposalDiscussionForumEnabled } = useFeatureFlag(); const { enable, isEnabled } = useCardano(); const navigate = useNavigate(); diff --git a/govtool/frontend/src/hooks/useMatomo.ts b/govtool/frontend/src/hooks/useMatomo.ts new file mode 100644 index 000000000..381de7105 --- /dev/null +++ b/govtool/frontend/src/hooks/useMatomo.ts @@ -0,0 +1,31 @@ +/* eslint-disable func-names */ +/* eslint-disable no-multi-assign */ +/* eslint-disable prefer-template */ +/* eslint-disable no-underscore-dangle */ +/* eslint-disable wrap-iife */ +import { useEffect } from "react"; + +export const useMatomo = () => { + useEffect(() => { + const env = import.meta.env.VITE_APP_ENV; + if (env !== "prodction" || env !== "staging") { + return; + } + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-expect-error + const _paq = (window._paq = window._pag || []); + _paq.push(["trackPageView"]); + _paq.push(["enableLinkTracking"]); + (function () { + const u = "//analytics.gov.tools/"; + _paq.push(["setTrackerUrl", u + "matomo.php"]); + _paq.push(["setSiteId", env === "production" ? "1" : "2"]); + const d = document; + const g = d.createElement("script"); + const s = d.getElementsByTagName("script")[0]; + g.async = true; + g.src = u + "matomo.js"; + s.parentNode?.insertBefore(g, s); + })(); + }, []); +}; From e40cfaefa4295af0b529527f0e0f93fa35d83496 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Sza=C5=82owski?= Date: Tue, 10 Dec 2024 11:13:58 +0100 Subject: [PATCH 3/6] fix(#2044): fix missing validation for url length --- CHANGELOG.md | 1 + .../organisms/VoteContext/VoteContextStoringInformation.tsx | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 49f30c36c..f5816f878 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ changes. - Fix mzero parsing error on fetching the /proposal/list [Issue 2446](https://github.com/IntersectMBO/govtool/issues/2446) - Fix scaling gov action votes on lower resolutions +- Fix storing url missing length validation [Issue 2044](https://github.com/IntersectMBO/govtool/issues/2044) ### Changed diff --git a/govtool/frontend/src/components/organisms/VoteContext/VoteContextStoringInformation.tsx b/govtool/frontend/src/components/organisms/VoteContext/VoteContextStoringInformation.tsx index c4ff3e53b..953528fba 100644 --- a/govtool/frontend/src/components/organisms/VoteContext/VoteContextStoringInformation.tsx +++ b/govtool/frontend/src/components/organisms/VoteContext/VoteContextStoringInformation.tsx @@ -7,7 +7,7 @@ import { ICONS } from "@consts"; import { useTranslation, useScreenDimension, useVoteContextForm } from "@hooks"; import { Step } from "@molecules"; import { ControlledField, VoteContextWrapper } from "@organisms"; -import { URL_REGEX, openInNewTab } from "@utils"; +import { URL_REGEX, isValidURLLength, openInNewTab } from "@utils"; import { LINKS } from "@/consts/links"; type VoteContextStoringInformationProps = { @@ -144,6 +144,7 @@ export const VoteContextStoringInformation = ({ value: URL_REGEX, message: t("createGovernanceAction.fields.validations.url"), }, + validate: isValidURLLength, }} /> } From 579c2e958eef4ab779f4566371d93bbd159e0d10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Sza=C5=82owski?= Date: Fri, 13 Dec 2024 17:36:21 +0100 Subject: [PATCH 4/6] fix(#2511): fix app crash on governance action details page --- CHANGELOG.md | 1 + .../molecules/GovernanceActionDetailsCardLinks.tsx | 9 +++++++-- .../molecules/GovernanceActionDetailsCardVotes.tsx | 2 +- .../src/components/molecules/GovernanceVotedOnCard.tsx | 7 ++++++- .../frontend/src/components/molecules/VoteActionForm.tsx | 2 +- .../organisms/DashboardGovernanceActionsVotedOn.tsx | 6 +++--- .../components/organisms/GovernanceActionDetailsCard.tsx | 2 +- .../organisms/GovernanceActionDetailsCardData.tsx | 2 +- .../src/components/organisms/GovernanceActionsToVote.tsx | 6 +++--- govtool/frontend/src/hooks/forms/useVoteActionForm.tsx | 2 +- govtool/frontend/src/models/api.ts | 4 ++-- 11 files changed, 27 insertions(+), 16 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 29d1902ef..ff00f2edd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ changes. - Fix mzero parsing error on fetching the /proposal/list [Issue 2446](https://github.com/IntersectMBO/govtool/issues/2446) - Fix scaling gov action votes on lower resolutions - Fix storing url missing length validation [Issue 2044](https://github.com/IntersectMBO/govtool/issues/2044) +- Fix governance action details page crash on missing data [Issue 2511](https://github.com/IntersectMBO/govtool/issues/2511) ### Changed diff --git a/govtool/frontend/src/components/molecules/GovernanceActionDetailsCardLinks.tsx b/govtool/frontend/src/components/molecules/GovernanceActionDetailsCardLinks.tsx index 4d37dad7a..a76571396 100644 --- a/govtool/frontend/src/components/molecules/GovernanceActionDetailsCardLinks.tsx +++ b/govtool/frontend/src/components/molecules/GovernanceActionDetailsCardLinks.tsx @@ -34,8 +34,13 @@ export const GovernanceActionDetailsCardLinks = ({ > {t("govActions.supportingLinks")} - {links.map(({ uri, label }) => ( - + {links?.map(({ uri, label }) => ( + {label && ( { isCopyButton isSliderCard /> - + {vote && ( + + )} >; isInProgress?: boolean; - previousVote?: ProposalVote; + previousVote?: ProposalVote | null; proposal: ProposalData; }; diff --git a/govtool/frontend/src/components/organisms/DashboardGovernanceActionsVotedOn.tsx b/govtool/frontend/src/components/organisms/DashboardGovernanceActionsVotedOn.tsx index 5e5667109..5d4dcf134 100644 --- a/govtool/frontend/src/components/organisms/DashboardGovernanceActionsVotedOn.tsx +++ b/govtool/frontend/src/components/organisms/DashboardGovernanceActionsVotedOn.tsx @@ -42,7 +42,7 @@ export const DashboardGovernanceActionsVotedOn = ({ .includes(searchPhrase.toLowerCase()), ), })) - .filter((entry) => entry.actions.length > 0); + .filter((entry) => entry.actions?.length > 0); } return data; }, [data, searchPhrase, pendingTransaction.vote]); @@ -70,12 +70,12 @@ export const DashboardGovernanceActionsVotedOn = ({ title={getProposalTypeLabel(item.title)} navigateKey={item.title} searchPhrase={searchPhrase} - dataLength={item.actions.slice(0, 6).length} + dataLength={item.actions.slice(0, 6)?.length} onDashboard data={item.actions.map((action) => (
1600 ? "longText" : "oneLine"} /> - {tabs.length === 1 ? ( + {tabs?.length === 1 ? ( tabs[0].content ) : ( <> diff --git a/govtool/frontend/src/components/organisms/GovernanceActionsToVote.tsx b/govtool/frontend/src/components/organisms/GovernanceActionsToVote.tsx index 28777ba85..3a603668b 100644 --- a/govtool/frontend/src/components/organisms/GovernanceActionsToVote.tsx +++ b/govtool/frontend/src/components/organisms/GovernanceActionsToVote.tsx @@ -32,7 +32,7 @@ export const GovernanceActionsToVote = ({ return ( <> - {!proposals.length ? ( + {!proposals?.length ? ( {t("govActions.noResultsForTheSearch")} @@ -91,10 +91,10 @@ export const GovernanceActionsToVote = ({ />
))} - dataLength={item.actions.slice(0, 6).length} + dataLength={item.actions.slice(0, 6)?.length} filters={filters} navigateKey={item.title} - notSlicedDataLength={item.actions.length} + notSlicedDataLength={item.actions?.length} onDashboard={onDashboard} searchPhrase={searchPhrase} sorting={sorting} diff --git a/govtool/frontend/src/hooks/forms/useVoteActionForm.tsx b/govtool/frontend/src/hooks/forms/useVoteActionForm.tsx index 447204fdb..4f215199a 100644 --- a/govtool/frontend/src/hooks/forms/useVoteActionForm.tsx +++ b/govtool/frontend/src/hooks/forms/useVoteActionForm.tsx @@ -31,7 +31,7 @@ export const useVoteActionFormController = () => { }; type Props = { - previousVote?: ProposalVote; + previousVote?: ProposalVote | null; voteContextHash?: string; voteContextUrl?: string; }; diff --git a/govtool/frontend/src/models/api.ts b/govtool/frontend/src/models/api.ts index 32ef7bcc5..cbd271368 100644 --- a/govtool/frontend/src/models/api.ts +++ b/govtool/frontend/src/models/api.ts @@ -224,12 +224,12 @@ export type NewConstitutionAnchor = { }; export type VotedProposalDTO = { - vote: ProposalVote; + vote: ProposalVote | null; proposal: ProposalDataDTO; }; export type VotedProposal = { - vote: ProposalVote; + vote: ProposalVote | null; proposal: ProposalData; }; From bf0262ce8f2babdee1d0dcae54c0867524535fcd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Sza=C5=82owski?= Date: Fri, 13 Dec 2024 21:20:00 +0100 Subject: [PATCH 5/6] chore: bump GovTool to v2.0.1 --- CHANGELOG.md | 18 ++++++++++++++++++ govtool/backend/Dockerfile | 2 +- govtool/backend/Dockerfile.qovery | 2 +- govtool/backend/vva-be.cabal | 2 +- govtool/frontend/package-lock.json | 4 ++-- govtool/frontend/package.json | 4 ++-- govtool/metadata-validation/src/main.ts | 2 +- 7 files changed, 26 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ff00f2edd..4534bb406 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,24 @@ changes. ### Added +- + +### Fixed + +- + +### Changed + +- + +### Removed + +- + +## [v2.0.1](https://github.com/IntersectMBO/govtool/releases/tag/v2.0.1) 2024-12-13 + +### Added + - Integrate matomo analytics ### Fixed diff --git a/govtool/backend/Dockerfile b/govtool/backend/Dockerfile index 9252841bd..65a5b97ee 100644 --- a/govtool/backend/Dockerfile +++ b/govtool/backend/Dockerfile @@ -4,4 +4,4 @@ FROM $BASE_IMAGE_REPO:$BASE_IMAGE_TAG WORKDIR /src COPY . . RUN cabal build -RUN cp dist-newstyle/build/x86_64-linux/ghc-9.2.7/vva-be-2.0.0/x/vva-be/build/vva-be/vva-be /usr/local/bin +RUN cp dist-newstyle/build/x86_64-linux/ghc-9.2.7/vva-be-2.0.1/x/vva-be/build/vva-be/vva-be /usr/local/bin diff --git a/govtool/backend/Dockerfile.qovery b/govtool/backend/Dockerfile.qovery index 18d873579..c5845a2bd 100644 --- a/govtool/backend/Dockerfile.qovery +++ b/govtool/backend/Dockerfile.qovery @@ -4,7 +4,7 @@ FROM $BASE_IMAGE_REPO:$BASE_IMAGE_TAG WORKDIR /src COPY . . RUN cabal build -RUN cp dist-newstyle/build/x86_64-linux/ghc-9.2.7/vva-be-2.0.0/x/vva-be/build/vva-be/vva-be /usr/local/bin +RUN cp dist-newstyle/build/x86_64-linux/ghc-9.2.7/vva-be-2.0.1/x/vva-be/build/vva-be/vva-be /usr/local/bin # Expose the necessary port EXPOSE 9876 diff --git a/govtool/backend/vva-be.cabal b/govtool/backend/vva-be.cabal index d7d8a4e41..ea1cb50d1 100644 --- a/govtool/backend/vva-be.cabal +++ b/govtool/backend/vva-be.cabal @@ -1,6 +1,6 @@ cabal-version: 3.6 name: vva-be -version: 2.0.0 +version: 2.0.1 -- A short (one-line) description of the package. -- synopsis: diff --git a/govtool/frontend/package-lock.json b/govtool/frontend/package-lock.json index af8b9e7db..55b16c656 100644 --- a/govtool/frontend/package-lock.json +++ b/govtool/frontend/package-lock.json @@ -1,12 +1,12 @@ { "name": "@govtool/frontend", - "version": "2.0.0", + "version": "2.0.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@govtool/frontend", - "version": "2.0.0", + "version": "2.0.1", "hasInstallScript": true, "dependencies": { "@emotion/react": "^11.11.1", diff --git a/govtool/frontend/package.json b/govtool/frontend/package.json index 41d072d2d..4bbc7adea 100644 --- a/govtool/frontend/package.json +++ b/govtool/frontend/package.json @@ -1,7 +1,7 @@ { "name": "@govtool/frontend", "private": true, - "version": "2.0.0", + "version": "2.0.1", "type": "module", "scripts": { "build": "vite build", @@ -113,5 +113,5 @@ "nth-check": "^2.0.1", "postcss": "^8.4.31" }, - "_id": "govtool@2.0.0" + "_id": "govtool@2.0.1" } diff --git a/govtool/metadata-validation/src/main.ts b/govtool/metadata-validation/src/main.ts index b5ad664f1..24c6de032 100644 --- a/govtool/metadata-validation/src/main.ts +++ b/govtool/metadata-validation/src/main.ts @@ -13,7 +13,7 @@ async function bootstrap() { const config = new DocumentBuilder() .setTitle('Metadata Validation Tool') .setDescription('The Metadata Validation Tool API description') - .setVersion('2.0.0') + .setVersion('2.0.1') .build(); const document = SwaggerModule.createDocument(app, config); From 3932b8d03325b52f7b7d1a66df1ebe1fea50d585 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Sza=C5=82owski?= Date: Mon, 16 Dec 2024 08:52:23 +0100 Subject: [PATCH 6/6] Update CHANGELOG.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Michał Szałowski --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4534bb406..76352c5e1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,7 +26,7 @@ changes. - -## [v2.0.1](https://github.com/IntersectMBO/govtool/releases/tag/v2.0.1) 2024-12-13 +## [v2.0.1](https://github.com/IntersectMBO/govtool/releases/tag/v2.0.1) 2024-12-16 ### Added