diff --git a/.github/workflows/build-and-deploy-beta.yml b/.github/workflows/build-and-deploy-beta.yml index 4f1647eae..b5e6da758 100644 --- a/.github/workflows/build-and-deploy-beta.yml +++ b/.github/workflows/build-and-deploy-beta.yml @@ -23,7 +23,6 @@ jobs: DBSYNC_POSTGRES_USER: "postgres" GA_CLIENT_EMAIL: ${{ secrets.GA_CLIENT_EMAIL }} GA_PRIVATE_KEY: ${{ secrets.GA_PRIVATE_KEY }} - GOOGLE_APPLICATION_CREDENTIALS: ${{ secrets.GOOGLE_APPLICATION_CREDENTIALS }} GRAFANA_ADMIN_PASSWORD: ${{ secrets.GRAFANA_ADMIN_PASSWORD }} GRAFANA_SLACK_OAUTH_TOKEN: ${{ secrets.GRAFANA_SLACK_OAUTH_TOKEN }} GRAFANA_SLACK_RECIPIENT: ${{ secrets.GRAFANA_SLACK_RECIPIENT }} @@ -32,7 +31,6 @@ jobs: IP_ADDRESS_BYPASSING_BASIC_AUTH2: ${{ secrets.IP_ADDRESS_BYPASSING_BASIC_AUTH2 }} NEXT_PUBLIC_API_URL: "https://participation.sanchogov.tools" NEXT_PUBLIC_GA4_PROPERTY_ID: ${{ secrets.NEXT_PUBLIC_GA4_PROPERTY_ID }} - NGINX_BASIC_AUTH: ${{ secrets.NGINX_BASIC_AUTH }} PIPELINE_URL: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} SENTRY_DSN: ${{ secrets.SENTRY_DSN_FRONTEND }} SENTRY_DSN_BACKEND: ${{ secrets.SENTRY_DSN_BACKEND }} diff --git a/.github/workflows/build-and-deploy-dev.yml b/.github/workflows/build-and-deploy-dev.yml index e618b165e..bf11bbb39 100644 --- a/.github/workflows/build-and-deploy-dev.yml +++ b/.github/workflows/build-and-deploy-dev.yml @@ -22,7 +22,6 @@ jobs: DBSYNC_POSTGRES_USER: "postgres" GA_CLIENT_EMAIL: ${{ secrets.GA_CLIENT_EMAIL }} GA_PRIVATE_KEY: ${{ secrets.GA_PRIVATE_KEY }} - GOOGLE_APPLICATION_CREDENTIALS: ${{ secrets.GOOGLE_APPLICATION_CREDENTIALS }} GRAFANA_ADMIN_PASSWORD: ${{ secrets.GRAFANA_ADMIN_PASSWORD }} GRAFANA_SLACK_OAUTH_TOKEN: ${{ secrets.GRAFANA_SLACK_OAUTH_TOKEN }} GRAFANA_SLACK_RECIPIENT: ${{ secrets.GRAFANA_SLACK_RECIPIENT }} @@ -31,7 +30,7 @@ jobs: IP_ADDRESS_BYPASSING_BASIC_AUTH2: ${{ secrets.IP_ADDRESS_BYPASSING_BASIC_AUTH2 }} NEXT_PUBLIC_API_URL: "https://participation.sanchogov.tools" NEXT_PUBLIC_GA4_PROPERTY_ID: ${{ secrets.NEXT_PUBLIC_GA4_PROPERTY_ID }} - NGINX_BASIC_AUTH: ${{ secrets.NGINX_BASIC_AUTH }} + DEV_NGINX_BASIC_AUTH: ${{ secrets.DEV_NGINX_BASIC_AUTH }} PIPELINE_URL: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} SENTRY_DSN: ${{ secrets.SENTRY_DSN_FRONTEND }} SENTRY_DSN_BACKEND: ${{ secrets.SENTRY_DSN_BACKEND }} diff --git a/.github/workflows/build-and-deploy-staging.yml b/.github/workflows/build-and-deploy-staging.yml index c47365565..6b00eec0c 100644 --- a/.github/workflows/build-and-deploy-staging.yml +++ b/.github/workflows/build-and-deploy-staging.yml @@ -24,7 +24,6 @@ jobs: DBSYNC_POSTGRES_USER: "postgres" GA_CLIENT_EMAIL: ${{ secrets.GA_CLIENT_EMAIL }} GA_PRIVATE_KEY: ${{ secrets.GA_PRIVATE_KEY }} - GOOGLE_APPLICATION_CREDENTIALS: ${{ secrets.GOOGLE_APPLICATION_CREDENTIALS }} GRAFANA_ADMIN_PASSWORD: ${{ secrets.GRAFANA_ADMIN_PASSWORD }} GRAFANA_SLACK_OAUTH_TOKEN: ${{ secrets.GRAFANA_SLACK_OAUTH_TOKEN }} GRAFANA_SLACK_RECIPIENT: ${{ secrets.GRAFANA_SLACK_RECIPIENT }} @@ -33,7 +32,7 @@ jobs: IP_ADDRESS_BYPASSING_BASIC_AUTH2: ${{ secrets.IP_ADDRESS_BYPASSING_BASIC_AUTH2 }} NEXT_PUBLIC_API_URL: "https://participation.sanchogov.tools" NEXT_PUBLIC_GA4_PROPERTY_ID: ${{ secrets.NEXT_PUBLIC_GA4_PROPERTY_ID }} - NGINX_BASIC_AUTH: ${{ secrets.NGINX_BASIC_AUTH }} + STAGING_NGINX_BASIC_AUTH: ${{ secrets.STAGING_NGINX_BASIC_AUTH }} PIPELINE_URL: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} SENTRY_DSN: ${{ secrets.SENTRY_DSN_FRONTEND }} SENTRY_DSN_BACKEND: ${{ secrets.SENTRY_DSN_BACKEND }} diff --git a/.github/workflows/build-and-deploy-test.yml b/.github/workflows/build-and-deploy-test.yml index 343b4a944..55ade7aea 100644 --- a/.github/workflows/build-and-deploy-test.yml +++ b/.github/workflows/build-and-deploy-test.yml @@ -15,11 +15,22 @@ jobs: name: Deploy app runs-on: ubuntu-latest env: + DBSYNC_POSTGRES_DB: "cexplorer" + DBSYNC_POSTGRES_PASSWORD: "pSa8JCpQOACMUdGb" + DBSYNC_POSTGRES_USER: "postgres" + GA_CLIENT_EMAIL: ${{ secrets.GA_CLIENT_EMAIL }} + GA_PRIVATE_KEY: ${{ secrets.GA_PRIVATE_KEY }} GRAFANA_ADMIN_PASSWORD: ${{ secrets.GRAFANA_ADMIN_PASSWORD }} GRAFANA_SLACK_RECIPIENT: ${{ secrets.GRAFANA_SLACK_RECIPIENT }} GRAFANA_SLACK_OAUTH_TOKEN: ${{ secrets.GRAFANA_SLACK_OAUTH_TOKEN }} SENTRY_DSN_BACKEND: ${{ secrets.SENTRY_DSN_BACKEND }} GTM_ID: ${{ secrets.GTM_ID }} + IP_ADDRESS_BYPASSING_BASIC_AUTH1: ${{ secrets.IP_ADDRESS_BYPASSING_BASIC_AUTH1 }} + IP_ADDRESS_BYPASSING_BASIC_AUTH2: ${{ secrets.IP_ADDRESS_BYPASSING_BASIC_AUTH2 }} + NEXT_PUBLIC_API_URL: "https://participation.sanchogov.tools" + NEXT_PUBLIC_GA4_PROPERTY_ID: ${{ secrets.NEXT_PUBLIC_GA4_PROPERTY_ID }} + TEST_NGINX_BASIC_AUTH: ${{ secrets.TEST_NGINX_BASIC_AUTH }} + PIPELINE_URL: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} SENTRY_DSN: ${{ secrets.SENTRY_DSN_FRONTEND }} PIPELINE_URL: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} USERSNAP_SPACE_API_KEY: ${{ secrets.USERSNAP_SPACE_API_KEY }} diff --git a/.github/workflows/frontend_sonar_scan.yml b/.github/workflows/frontend_sonar_scan.yml index 8a4df29ab..09b8f994f 100644 --- a/.github/workflows/frontend_sonar_scan.yml +++ b/.github/workflows/frontend_sonar_scan.yml @@ -15,15 +15,40 @@ jobs: - uses: actions/checkout@v4 with: fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis + + - name: Cache dependencies + uses: actions/cache@v2 + with: + path: govtool/frontend/node_modules + key: ${{ runner.os }}-node-${{ hashFiles('govtool/frontend/package-lock.json') }} + + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version-file: "govtool/frontend/.nvmrc" + + - name: 🧪 Test + working-directory: govtool/frontend + env: + NODE_OPTIONS: "--max_old_space_size=4096" + run: | + npm install + npm run test:coverage + +# Running with docker +# +# - name: Run SonarQube Scanner +# run: | +# docker run --rm \ +# -e SONAR_HOST_URL="https://sonarcloud.io" \ +# -e SONAR_TOKEN="ec4183646e59dd70c8077acfabe52062ccbea7a9" \ +# -v "$(pwd):/usr/src" \ +# --workdir=/usr/src/govtool/frontend \ +# sonarsource/sonar-scanner-cli:5.0.1 + - uses: sonarsource/sonarqube-scan-action@master with: projectBaseDir: govtool/frontend env: SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }} - - # Fail the build if it doesn't meet quality gate - # - uses: sonarsource/sonarqube-quality-gate-action@master - # timeout-minutes: 5 - # env: - # SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + SONAR_HOST_URL: https://sonarcloud.io \ No newline at end of file diff --git a/.gitignore b/.gitignore index ce63fca47..c242ad8d8 100644 --- a/.gitignore +++ b/.gitignore @@ -140,6 +140,5 @@ scripts/govtool/dev-postgres_password node_modules - # sonar scanner .scannerwork/ \ No newline at end of file diff --git a/govtool/frontend/public/icons/Edit.svg b/govtool/frontend/public/icons/Edit.svg new file mode 100644 index 000000000..a2c68c344 --- /dev/null +++ b/govtool/frontend/public/icons/Edit.svg @@ -0,0 +1,4 @@ + + + + diff --git a/govtool/frontend/sonar-project.properties b/govtool/frontend/sonar-project.properties index e31d782bf..b7334acaf 100644 --- a/govtool/frontend/sonar-project.properties +++ b/govtool/frontend/sonar-project.properties @@ -1 +1,7 @@ -sonar.projectKey=voltaire-era_AYra4oOPzihwqYo-BApS +sonar.projectKey=intersect-govtool +sonar.sources=./src +sonar.host.url=https://sonarcloud.io +sonar.organization=intersect +sonar.javascript.lcov.reportPaths=./coverage/lcov.info +sonar.junit.reportsPath=./junit-report.xml +sonar.exclusions=node_modules \ No newline at end of file diff --git a/govtool/frontend/src/components/molecules/Card.tsx b/govtool/frontend/src/components/molecules/Card.tsx index a6ef31177..a5af603fe 100644 --- a/govtool/frontend/src/components/molecules/Card.tsx +++ b/govtool/frontend/src/components/molecules/Card.tsx @@ -10,6 +10,7 @@ type CardProps = PropsWithChildren & { label?: string; sx?: SxProps; variant?: "default" | "error" | "primary" | "success" | "warning"; + onCardClick?: () => void; }; const COLORS = { @@ -42,6 +43,7 @@ export const Card = ({ elevation = 3, label, sx, + onCardClick, }: CardProps) => { const colors = COLORS[variant]; @@ -57,6 +59,7 @@ export const Card = ({ position: "relative", ...sx, }} + onClick={onCardClick} > {label && ( { const { t } = useTranslation(); @@ -27,8 +27,10 @@ export const DelegationAction = ({ justifyContent: "space-between", px: 1.5, py: 1, + cursor: "pointer", ...sx, }} + onCardClick={onCardClick} > @@ -45,11 +47,7 @@ export const DelegationAction = ({ {dRepId} - + ); }; diff --git a/govtool/frontend/src/components/molecules/types.ts b/govtool/frontend/src/components/molecules/types.ts index b3b5343b2..5ec91cd3a 100644 --- a/govtool/frontend/src/components/molecules/types.ts +++ b/govtool/frontend/src/components/molecules/types.ts @@ -18,7 +18,7 @@ export type StepProps = { export type DirectVoterActionProps = { dRepId: string; - onClickArrow: () => void; + onCardClick: () => void; sx?: SxProps; }; diff --git a/govtool/frontend/src/components/organisms/AutomatedVotingOptions.tsx b/govtool/frontend/src/components/organisms/AutomatedVotingOptions.tsx index 5844caf52..a6e3a60ee 100644 --- a/govtool/frontend/src/components/organisms/AutomatedVotingOptions.tsx +++ b/govtool/frontend/src/components/organisms/AutomatedVotingOptions.tsx @@ -9,9 +9,9 @@ import { import { Typography } from "@atoms"; import { ICONS } from "@consts"; import { PendingTransaction } from "@context"; -import { useTranslation } from "@hooks"; +import { useGetNetworkMetrics, useTranslation } from "@hooks"; import { AutomatedVotingCard } from "@molecules"; -import { openInNewTab } from "@/utils"; +import { correctAdaFormat, openInNewTab } from "@/utils"; import { AutomatedVotingOptionCurrentDelegation, AutomatedVotingOptionDelegationId, @@ -42,6 +42,8 @@ export const AutomatedVotingOptions = ({ const [isOpen, setIsOpen] = useState(false); + const { networkMetrics } = useGetNetworkMetrics(); + // TODO: Change to certain automated voted option if available const onClickInfo = () => openInNewTab("https://docs.sanchogov.tools/"); @@ -63,10 +65,13 @@ export const AutomatedVotingOptions = ({ isDelegationToAbstainInProgress || isDelegationToNoConfidenceInProgress; - if (shouldBeSetOpen) { - setIsOpen(true); - } - }, [currentDelegation, delegationInProgress]); + setIsOpen(shouldBeSetOpen); + }, [ + isDelegatedToAbstain, + isDelegatedToNoConfidence, + isDelegationToAbstainInProgress, + isDelegationToNoConfidenceInProgress, + ]); return ( )} diff --git a/govtool/frontend/src/consts/icons.ts b/govtool/frontend/src/consts/icons.ts index dff246b62..bd70a2b06 100644 --- a/govtool/frontend/src/consts/icons.ts +++ b/govtool/frontend/src/consts/icons.ts @@ -17,6 +17,7 @@ export const ICONS = { drawerIcon: "/icons/DrawerIcon.svg", dRepDirectoryActiveIcon: "/icons/DRepDirectoryActive.svg", dRepDirectoryIcon: "/icons/DRepDirectory.svg", + editIcon: "/icons/Edit.svg", externalLinkIcon: "/icons/ExternalLink.svg", faqsActiveIcon: "/icons/FaqsActive.svg", faqsIcon: "/icons/Faqs.svg", diff --git a/govtool/frontend/src/consts/queryKeys.ts b/govtool/frontend/src/consts/queryKeys.ts index ccfdffe3f..0a8c7fdf1 100644 --- a/govtool/frontend/src/consts/queryKeys.ts +++ b/govtool/frontend/src/consts/queryKeys.ts @@ -4,6 +4,7 @@ export const QUERY_KEYS = { useGetDRepListInfiniteKey: "useGetDRepListInfiniteKey", useGetDRepVotesKey: "useGetDRepVotesKey", useGetDRepVotingPowerKey: "useGetDRepVotingPowerKey", + useGetNetworkMetricsKey: "useGetNetworkMetricsKey", useGetProposalKey: "useGetProposalKey", useGetProposalsKey: "useGetProposalsKey", useGetProposalsInfiniteKey: "useGetProposalsInfiniteKey", diff --git a/govtool/frontend/src/hooks/queries/index.ts b/govtool/frontend/src/hooks/queries/index.ts index f088d04fb..2b888a14b 100644 --- a/govtool/frontend/src/hooks/queries/index.ts +++ b/govtool/frontend/src/hooks/queries/index.ts @@ -4,6 +4,7 @@ export * from "./useGetVoterInfoQuery"; export * from "./useGetDRepListQuery"; export * from "./useGetDRepVotesQuery"; export * from "./useGetDRepVotingPowerQuery"; +export * from "./useGetNetworkMetrics"; export * from "./useGetProposalQuery"; export * from "./useGetProposalsQuery"; export * from "./useGetProposalsInfiniteQuery"; diff --git a/govtool/frontend/src/hooks/queries/useGetNetworkMetrics.ts b/govtool/frontend/src/hooks/queries/useGetNetworkMetrics.ts new file mode 100644 index 000000000..f83b5646f --- /dev/null +++ b/govtool/frontend/src/hooks/queries/useGetNetworkMetrics.ts @@ -0,0 +1,17 @@ +import { useQuery } from "react-query"; + +import { getNetworkMetrics } from "@services"; +import { QUERY_KEYS } from "@consts"; +import { useCardano } from "@/context"; + +export const useGetNetworkMetrics = () => { + const { isEnabled } = useCardano(); + + const { data } = useQuery({ + queryKey: QUERY_KEYS.useGetNetworkMetricsKey, + queryFn: () => getNetworkMetrics(), + enabled: isEnabled, + }); + + return { networkMetrics: data }; +}; diff --git a/govtool/frontend/src/i18n/locales/en.ts b/govtool/frontend/src/i18n/locales/en.ts index f54da84d1..56d199455 100644 --- a/govtool/frontend/src/i18n/locales/en.ts +++ b/govtool/frontend/src/i18n/locales/en.ts @@ -261,11 +261,11 @@ export const en = { directVoter: "Direct Voter", filterTitle: "DRep Status", goToDRepDirectory: "Go to DRep Directory", - meAsDRep: "This DRep ID is connected to your wallet", + meAsDRep: "This DRep ID is connected to your wallet", myDelegation: "You have delegated ₳ {{ada}} to:", myDelegationToYourself: "You have delegated ₳ {{ada}} to yourself:", - myDRep: "This is your DRep", + myDRep: "This is your DRep profile", listTitle: "Find a DRep", noConfidenceDefaultDescription: "Select this to signal no confidence in the current constitutional committee by voting NO on every proposal and voting YES to no confidence proposals", diff --git a/govtool/frontend/src/pages/DRepDetails.tsx b/govtool/frontend/src/pages/DRepDetails.tsx index a184ef66d..b797f2feb 100644 --- a/govtool/frontend/src/pages/DRepDetails.tsx +++ b/govtool/frontend/src/pages/DRepDetails.tsx @@ -12,6 +12,7 @@ import { ICONS, PATHS } from "@consts"; import { useCardano, useModal } from "@context"; import { useDelegateTodRep, + useGetAdaHolderCurrentDelegationQuery, useGetDRepListInfiniteQuery, useScreenDimension, useTranslation, @@ -37,7 +38,7 @@ type DRepDetailsProps = { }; export const DRepDetails = ({ isConnected }: DRepDetailsProps) => { - const { dRepID: myDRepId, pendingTransaction } = useCardano(); + const { dRepID: myDRepId, pendingTransaction, stakeKey } = useCardano(); const { t } = useTranslation(); const navigate = useNavigate(); const location = useLocation(); @@ -45,6 +46,7 @@ export const DRepDetails = ({ isConnected }: DRepDetailsProps) => { const { screenWidth } = useScreenDimension(); const { dRepId: dRepParam } = useParams(); const { delegate, isDelegating } = useDelegateTodRep(); + const { currentDelegation } = useGetAdaHolderCurrentDelegationQuery(stakeKey); const displayBackButton = location.state?.enteredFromWithinApp || false; @@ -73,7 +75,7 @@ export const DRepDetails = ({ isConnected }: DRepDetailsProps) => { const { view, status, votingPower, type } = dRep; const isMe = isSameDRep(dRep, myDRepId); - const isMyDrep = isSameDRep(dRep, myDRepId); + const isMyDrep = isSameDRep(dRep, currentDelegation?.dRepView); const isMyDrepInProgress = isSameDRep( dRep, pendingTransaction.delegate?.resourceId, @@ -117,50 +119,94 @@ export const DRepDetails = ({ isConnected }: DRepDetailsProps) => { }} > {(isMe || isMyDrep) && ( - theme.shadows[2], - color: (theme) => theme.palette.text.primary, - mb: 1.5, - px: 2, - py: 0.5, - width: "100%", + display: "flex", + alignItems: "center", + justifyContent: "space-between", + mb: "18px", + ...(screenWidth <= 1020 && { + flexDirection: "column", + gap: 3, + }), }} - /> - )} - - - {type} - - {isMe && ( - - )} - - + theme.shadows[2], + color: (theme) => theme.palette.text.primary, + px: 2, + py: 0.5, + ...(isMe && { + width: "351px", + }), + ...(isMyDrep && + !isMe && { + width: "100%", + }), + ...(screenWidth <= 1020 && { + width: "100%", + }), + }} + /> + {isMe && ( + + + {screenWidth > 1020 && } + + )} + + )} + + + {type} + + {(screenWidth <= 1020 || !isMe) && ( + + )} + {view} @@ -175,9 +221,11 @@ export const DRepDetails = ({ isConnected }: DRepDetailsProps) => { {/* TODO: fetch metadata, add views for metadata errors */} + {/* TODO: change email */} @@ -187,8 +235,13 @@ export const DRepDetails = ({ isConnected }: DRepDetailsProps) => { flexDirection="column" gap={1.5} > + {/* TODO: update links */} {LINKS.map((link) => ( - + ))} @@ -299,10 +352,18 @@ const DRepId = ({ children }: PropsWithChildren) => ( type LinkWithIconProps = { label: string; navTo: string; + isEmail?: boolean; }; -const MoreInfoLink = ({ label, navTo }: LinkWithIconProps) => { - const openLink = () => openInNewTab(navTo); +const MoreInfoLink = ({ label, navTo, isEmail = false }: LinkWithIconProps) => { + const openLink = () => { + if (isEmail) { + window.location.assign(`mailto:${navTo}`); + + return; + } + openInNewTab(navTo); + }; return ( = ({ const dRepListToDisplay = yourselfDRep ? [yourselfDRep, ...dRepsWithoutYourself] : dRepList; + const inProgressDelegationDRepData = dRepListToDisplay.find( + (dRep) => dRep.drepId === inProgressDelegation, + ); const isAnAutomatedVotingOptionChosen = currentDelegation?.dRepView && @@ -110,7 +113,7 @@ export const DRepDirectoryContent: FC = ({ return ( {/* My delegation */} - {myDrep && ( + {myDrep && !inProgressDelegation && (
@@ -123,6 +126,14 @@ export const DRepDirectoryContent: FC = ({ />
)} + {inProgressDelegation && inProgressDelegationDRepData && ( + + )} {/* Automated voting options */} {isConnected && ( @@ -204,7 +215,10 @@ export const DRepDirectoryContent: FC = ({ )} {dRepListToDisplay?.map((dRep) => { - if (isSameDRep(dRep, myDrep?.view)) { + if ( + isSameDRep(dRep, myDrep?.view) || + isSameDRep(dRep, inProgressDelegation) + ) { return null; } return ( @@ -212,7 +226,6 @@ export const DRepDirectoryContent: FC = ({ delegate(dRep.drepId)} /> diff --git a/govtool/frontend/src/services/requests/getNetworkMetrics.ts b/govtool/frontend/src/services/requests/getNetworkMetrics.ts new file mode 100644 index 000000000..59fd0c674 --- /dev/null +++ b/govtool/frontend/src/services/requests/getNetworkMetrics.ts @@ -0,0 +1,7 @@ +import { API } from "../API"; + +export const getNetworkMetrics = async () => { + const response = await API.get("/network/metrics"); + + return response.data; +}; diff --git a/govtool/frontend/src/services/requests/index.ts b/govtool/frontend/src/services/requests/index.ts index 3121e4c5c..f6721175a 100644 --- a/govtool/frontend/src/services/requests/index.ts +++ b/govtool/frontend/src/services/requests/index.ts @@ -18,3 +18,4 @@ export * from "./postDRepRemoveVote"; export * from "./postDRepRetire"; export * from "./postDRepVote"; export * from "./metadataValidation"; +export * from "./getNetworkMetrics"; diff --git a/govtool/frontend/src/utils/dRep.ts b/govtool/frontend/src/utils/dRep.ts index 7743a017e..1521fda5d 100644 --- a/govtool/frontend/src/utils/dRep.ts +++ b/govtool/frontend/src/utils/dRep.ts @@ -2,7 +2,7 @@ import { DRepData } from "@/models"; export const isSameDRep = ( { drepId, view }: DRepData, - dRepIdOrView: string | undefined, + dRepIdOrView: string | undefined | null, ) => { if (!dRepIdOrView) { return false; diff --git a/govtool/frontend/vite.config.ts b/govtool/frontend/vite.config.ts index 4316c151e..0442b81a1 100644 --- a/govtool/frontend/vite.config.ts +++ b/govtool/frontend/vite.config.ts @@ -51,7 +51,11 @@ const vitestConfig = defineVitestConfig({ setupFiles: "./src/setupTests.ts", globals: true, environment: "jsdom", - reporters: ["verbose", "junit"], + reporters: ["default","junit"], + outputFile: { + junit: './junit-report.xml', + json: './json-report.json', + }, coverage: { include: [ "src/components/**/*", @@ -62,7 +66,8 @@ const vitestConfig = defineVitestConfig({ "src/utils/**/*", ], provider: "v8", - reporter: ["json-summary"], + reporter: ["json-summary","lcov"], + reportOnFailure: true, enabled: true, }, }, diff --git a/scripts/govtool/.envrc b/scripts/govtool/.envrc index 0e49e3cbd..fa6f7d8f1 100644 --- a/scripts/govtool/.envrc +++ b/scripts/govtool/.envrc @@ -1,4 +1,16 @@ source_up -env_vars_required ENVIRONMENT AWS_PROFILE CARDANO_NETWORK DBSYNC_POSTGRES_USER DBSYNC_POSTGRES_PASSWORD DBSYNC_POSTGRES_DB TRAEFIK_LE_EMAIL GTM_ID SENTRY_DSN_BACKEND SENTRY_DSN SENTRY_ENVIRONMENT GRAFANA_ADMIN_PASSWORD GRAFANA_SLACK_RECIPIENT NGINX_BASIC_AUTH GRAFANA_SLACK_OAUTH_TOKEN IP_ADDRESS_BYPASSING_BASIC_AUTH1 IP_ADDRESS_BYPASSING_BASIC_AUTH2 +env_vars_required ENVIRONMENT AWS_PROFILE CARDANO_NETWORK DBSYNC_POSTGRES_USER DBSYNC_POSTGRES_PASSWORD DBSYNC_POSTGRES_DB TRAEFIK_LE_EMAIL GTM_ID SENTRY_DSN_BACKEND SENTRY_DSN SENTRY_ENVIRONMENT GRAFANA_ADMIN_PASSWORD GRAFANA_SLACK_RECIPIENT GRAFANA_SLACK_OAUTH_TOKEN IP_ADDRESS_BYPASSING_BASIC_AUTH1 IP_ADDRESS_BYPASSING_BASIC_AUTH2 + +case "$ENVIRONMENT" in + "dev") + env_vars_required DEV_NGINX_BASIC_AUTH + ;; + "test") + env_vars_required TEST_NGINX_BASIC_AUTH + ;; + "staging") + env_vars_required STAGING_NGINX_BASIC_AUTH + ;; +esac use flake --extra-experimental-features nix-command --extra-experimental-features flakes ../..#scripts diff --git a/scripts/govtool/config.mk b/scripts/govtool/config.mk index 2a7c4b770..439d75495 100644 --- a/scripts/govtool/config.mk +++ b/scripts/govtool/config.mk @@ -112,9 +112,9 @@ $(target_config_dir)/nginx/auth.conf: $(target_config_dir)/nginx/ fi $(target_config_dir)/nginx/govtool.htpasswd: $(target_config_dir)/nginx/ - @:$(call check_defined, domain) - if [[ "$(domain)" == *"sanchonet.govtool.byron.network"* ]]; then \ - echo "$${NGINX_BASIC_AUTH}" > $@; \ + @:$(call check_defined, env) + if [[ "$(env)" != "beta" ]]; then \ + echo "$${$(shell echo $(env) | tr a-z A-Z)_NGINX_BASIC_AUTH}" > $@; \ else \ echo > $@; \ fi diff --git a/scripts/govtool/config/templates/backend-config.json.tpl b/scripts/govtool/config/templates/backend-config.json.tpl index c3851bbe1..9ff9f2f11 100644 --- a/scripts/govtool/config/templates/backend-config.json.tpl +++ b/scripts/govtool/config/templates/backend-config.json.tpl @@ -9,5 +9,7 @@ "port" : 9876, "host" : "0.0.0.0", "cachedurationseconds": 20, - "sentrydsn": "" + "sentrydsn": "", + "metadatavalidationhost": "http://metadata-validation", + "metadatavalidationport": "3000" } diff --git a/scripts/govtool/config/templates/docker-compose.yml.tpl b/scripts/govtool/config/templates/docker-compose.yml.tpl index 42c09f083..975895d30 100644 --- a/scripts/govtool/config/templates/docker-compose.yml.tpl +++ b/scripts/govtool/config/templates/docker-compose.yml.tpl @@ -244,7 +244,7 @@ services: labels: - "traefik.enable=true" - "traefik.http.middlewares.backend-stripprefix.stripprefix.prefixes=/api" - - "traefik.http.middlewares.backend-cors.headers.accesscontrolallowmethods=GET,HEAD,OPTIONS" + - "traefik.http.middlewares.backend-cors.headers.accesscontrolallowmethods=GET,POST,HEAD,OPTIONS" - "traefik.http.middlewares.backend-cors.headers.accesscontrolallowheaders=*" - "traefik.http.middlewares.backend-cors.headers.accesscontrolalloworiginlist=https://" - "traefik.http.middlewares.backend-cors.headers.accesscontrolmaxage=100" diff --git a/scripts/govtool/frontend.mk b/scripts/govtool/frontend.mk index 97caf9bef..fb74d798b 100644 --- a/scripts/govtool/frontend.mk +++ b/scripts/govtool/frontend.mk @@ -15,7 +15,7 @@ build-frontend: docker-login if [[ "$(cardano_network)" = "mainnet" ]]; then NETWORK_FLAG=1; else NETWORK_FLAG=0; fi; \ $(call check_image_on_ecr,frontend,$(frontend_image_tag)) || \ $(docker) build --tag "$(repo_url)/frontend:$(frontend_image_tag)" \ - --build-arg VITE_BASE_URL="https://$(domain)" \ + --build-arg VITE_BASE_URL="https://$(domain)/api" \ --build-arg VITE_GTM_ID="$${GTM_ID}" \ --build-arg VITE_NETWORK_FLAG="$$NETWORK_FLAG" \ --build-arg VITE_SENTRY_DSN="$${SENTRY_DSN}" \