Skip to content

Commit 2d6f47c

Browse files
authored
Merge pull request #3000 from IntersectMBO/test
GovTool - v2.0.11-patch5
2 parents 2f146ce + f052f13 commit 2d6f47c

File tree

10 files changed

+116
-72
lines changed

10 files changed

+116
-72
lines changed

.github/scripts/set_commit_status.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/bash
22

33
# Ensure required environment variables are set
4-
if [ -z "$GITHUB_REPOSITORY" ] || [ -z "$GITHUB_SHA" ] || [ -z "$GITHUB_TOKEN" ] || [ -z "$GITHUB_RUN_ID" ]; then
4+
if [ -z "$GITHUB_REPOSITORY" ] || [ -z "$COMMIT_SHA" ] || [ -z "$GITHUB_TOKEN" ] || [ -z "$GITHUB_RUN_ID" ]; then
55
echo "Missing required environment variables!"
66
exit 1
77
fi
@@ -69,7 +69,7 @@ fi
6969
# Send commit status update to GitHub
7070
curl -X POST -H "Authorization: Bearer ${GITHUB_TOKEN}" \
7171
-H "Accept: application/vnd.github+json" \
72-
https://api.github.com/repos/${GITHUB_REPOSITORY}/statuses/${GITHUB_SHA} \
72+
https://api.github.com/repos/${GITHUB_REPOSITORY}/statuses/${COMMIT_SHA} \
7373
-d "{\"state\": \"${TEST_STATUS}\", \"context\": \"${CONTEXT}\", \"description\": \"${DESCRIPTION}\", \"target_url\": \"${TARGET_URL}\"}"
7474

7575
echo "Commit status updated successfully!"

.github/workflows/test_backend.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,16 @@ jobs:
4646
steps:
4747
- name: Checkout code
4848
uses: actions/checkout@v4
49+
with:
50+
ref: ${{ env.COMMIT_SHA }}
4951

5052
- name: Set pending commit status
5153
id: set-pending-status
5254
run: |
5355
echo "timestamp=$(date +%s)" >> $GITHUB_OUTPUT
5456
curl -X POST -H "Authorization: Bearer ${{ github.token }}" \
5557
-H "Accept: application/vnd.github+json" \
56-
https://api.github.com/repos/${{ github.repository }}/statuses/${{ github.sha }} \
58+
https://api.github.com/repos/${{ github.repository }}/statuses/${{ env.COMMIT_SHA }} \
5759
-d "{\"state\": \"pending\", \"context\": \"Backend Tests : ${{env.BASE_URL}}\", \"target_url\": \"https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}\"}"
5860
5961
@@ -184,3 +186,4 @@ env:
184186
BASE_URL: https://${{inputs.deployment || 'govtool.cardanoapi.io/api' }}
185187
REPORT_NAME: govtool-backend
186188
GH_PAGES: ${{vars.GH_PAGES}}
189+
COMMIT_SHA: ${{ github.event.workflow_run.head_sha || github.sha }}

.github/workflows/test_integration_playwright.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,15 @@ jobs:
4848
working-directory: tests/govtool-frontend/playwright
4949
steps:
5050
- uses: actions/checkout@v4
51+
with:
52+
ref: ${{ env.COMMIT_SHA }}
5153
- name: Set pending commit status
5254
id: set-pending-status
5355
run: |
5456
echo "timestamp=$(date +%s)" >> $GITHUB_OUTPUT
5557
curl -X POST -H "Authorization: Bearer ${{ github.token }}" \
5658
-H "Accept: application/vnd.github+json" \
57-
https://api.github.com/repos/${{ github.repository }}/statuses/${{ github.sha }} \
59+
https://api.github.com/repos/${{ github.repository }}/statuses/${{ env.COMMIT_SHA }} \
5860
-d "{\"state\": \"pending\", \"context\": \"Playwright Tests : ${{env.HOST_URL}}\", \"target_url\": \"https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}\"}"
5961
6062
- uses: actions/setup-node@v4
@@ -223,3 +225,4 @@ env:
223225
HOST_URL: https://${{inputs.deployment || 'govtool.cardanoapi.io' }}
224226
REPORT_NAME: govtool-frontend
225227
GH_PAGES: ${{vars.GH_PAGES}}
228+
COMMIT_SHA: ${{ github.event.workflow_run.head_sha || github.sha }}

.github/workflows/update-intersect-package.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ jobs:
5858
token: ${{ secrets.GITHUB_TOKEN }}
5959
branch: "chore/${{ github.event.inputs.package_name }}-${{ github.event.inputs.new_version }}"
6060
title: "Update ${{ github.event.inputs.package_name }} to ${{ github.event.inputs.new_version }}"
61+
commit-message: "chore: update ${{ github.event.inputs.package_name }} to ${{ github.event.inputs.new_version }}"
6162
body: |
6263
This PR updates `${{ github.event.inputs.package_name }}` to version `${{ github.event.inputs.new_version }}`.
6364

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ changes.
1616
- Add CC votes percentages, not voted and Ratification threshold
1717
- Add support for submitting all 7 governance action types [Issue 2258](https://github.com/IntersectMBO/govtool/issues/2258)
1818
- Add workflow to automatically update any of the @intersect.mbo package [Issue 2968](https://github.com/IntersectMBO/govtool/issues/2968)
19+
- Add Propose Governance Action button in governance actions dashboard [Issue 1188](https://github.com/IntersectMBO/govtool/issues/1188)
1920

2021
### Fixed
2122

govtool/backend/sql/list-dreps.sql

Lines changed: 35 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
WITH DRepDistr AS (
2-
SELECT
3-
drep_distr.*,
4-
ROW_NUMBER() OVER (PARTITION BY drep_hash.id ORDER BY drep_distr.epoch_no DESC) AS rn
5-
FROM
6-
drep_distr
7-
JOIN drep_hash ON drep_hash.id = drep_distr.hash_id
2+
SELECT DISTINCT ON (drep_distr.hash_id) drep_distr.*
3+
FROM drep_distr
4+
ORDER BY drep_distr.hash_id, drep_distr.epoch_no DESC
85
),
96
DRepActivity AS (
107
SELECT
@@ -19,11 +16,12 @@ DRepActivity AS (
1916
LIMIT 1
2017
),
2118
LatestVotingProcedure AS (
22-
SELECT
23-
vp.*,
24-
ROW_NUMBER() OVER (PARTITION BY drep_voter ORDER BY tx_id DESC) AS rn
19+
SELECT DISTINCT ON (vp.drep_voter)
20+
vp.*
2521
FROM
2622
voting_procedure vp
23+
ORDER BY
24+
vp.drep_voter, vp.tx_id DESC
2725
),
2826
LatestVoteEpoch AS (
2927
SELECT
@@ -33,20 +31,19 @@ LatestVoteEpoch AS (
3331
LatestVotingProcedure lvp
3432
JOIN tx ON tx.id = lvp.tx_id
3533
JOIN block ON block.id = tx.block_id
36-
WHERE
37-
lvp.rn = 1
3834
),
3935
RankedDRepRegistration AS (
40-
SELECT
36+
SELECT DISTINCT ON (dr.drep_hash_id)
4137
dr.id,
4238
dr.drep_hash_id,
4339
dr.deposit,
4440
dr.voting_anchor_id,
45-
ROW_NUMBER() OVER (PARTITION BY dr.drep_hash_id ORDER BY dr.tx_id DESC) AS rn,
4641
encode(tx.hash, 'hex') AS tx_hash
47-
FROM
42+
FROM
4843
drep_registration dr
4944
JOIN tx ON tx.id = dr.tx_id
45+
ORDER BY
46+
dr.drep_hash_id, dr.tx_id DESC
5047
),
5148
FetchError AS (
5249
SELECT
@@ -132,29 +129,31 @@ DRepData AS (
132129
off_chain_vote_drep_data.image_hash
133130
FROM
134131
drep_hash dh
135-
JOIN RankedDRepRegistration ON RankedDRepRegistration.drep_hash_id = dh.id AND RankedDRepRegistration.rn = 1
132+
JOIN RankedDRepRegistration ON RankedDRepRegistration.drep_hash_id = dh.id
136133
JOIN (
137-
SELECT
134+
SELECT DISTINCT ON (dr.drep_hash_id)
138135
dr.id,
139136
dr.drep_hash_id,
140-
dr.deposit,
141-
ROW_NUMBER() OVER (PARTITION BY dr.drep_hash_id ORDER BY dr.tx_id DESC) AS rn
137+
dr.deposit
142138
FROM
143139
drep_registration dr
144140
WHERE
145141
dr.deposit IS NOT NULL
146-
) AS dr_deposit ON dr_deposit.drep_hash_id = dh.id AND dr_deposit.rn = 1
142+
ORDER BY
143+
dr.drep_hash_id, dr.tx_id DESC
144+
) AS dr_deposit ON dr_deposit.drep_hash_id = dh.id
147145
LEFT JOIN (
148-
SELECT
146+
SELECT DISTINCT ON (dr.drep_hash_id)
149147
dr.id,
150148
dr.drep_hash_id,
151-
dr.deposit,
152-
ROW_NUMBER() OVER (PARTITION BY dr.drep_hash_id ORDER BY dr.tx_id DESC) AS rn
149+
dr.deposit
153150
FROM
154151
drep_registration dr
155-
) AS latestDeposit ON latestDeposit.drep_hash_id = dh.id AND latestDeposit.rn = 1
152+
ORDER BY
153+
dr.drep_hash_id, dr.tx_id DESC
154+
) AS latestDeposit ON latestDeposit.drep_hash_id = dh.id
156155
LEFT JOIN LatestExistingVotingAnchor leva ON leva.drep_hash_id = dh.id
157-
LEFT JOIN DRepDistr ON DRepDistr.hash_id = dh.id AND DRepDistr.rn = 1
156+
LEFT JOIN DRepDistr ON DRepDistr.hash_id = dh.id
158157
LEFT JOIN FetchError fetch_error ON fetch_error.voting_anchor_id = leva.voting_anchor_id
159158
LEFT JOIN HasNonDeregisterVotingAnchor hndva ON hndva.drep_hash_id = dh.id
160159
LEFT JOIN off_chain_vote_data ocvd ON ocvd.voting_anchor_id = leva.voting_anchor_id
@@ -163,26 +162,28 @@ DRepData AS (
163162
LEFT JOIN tx voting_procedure_transaction ON voting_procedure_transaction.id = voting_procedure.tx_id
164163
LEFT JOIN block voting_procedure_block ON voting_procedure_block.id = voting_procedure_transaction.block_id
165164
LEFT JOIN (
166-
SELECT
165+
SELECT DISTINCT ON (dr.drep_hash_id)
167166
block.epoch_no,
168167
block.time,
169-
dr.drep_hash_id,
170-
ROW_NUMBER() OVER (PARTITION BY dr.drep_hash_id ORDER BY dr.tx_id DESC) AS rn
168+
dr.drep_hash_id
171169
FROM
172-
drep_registration dr
170+
drep_registration dr
173171
JOIN tx ON tx.id = dr.tx_id
174172
JOIN block ON block.id = tx.block_id
175173
WHERE
176174
COALESCE(dr.deposit, 0) >= 0
177-
) AS newestRegister ON newestRegister.drep_hash_id = dh.id AND newestRegister.rn = 1
178-
LEFT JOIN (
179-
SELECT
175+
ORDER BY
176+
dr.drep_hash_id, dr.tx_id DESC
177+
) AS newestRegister ON newestRegister.drep_hash_id = dh.id
178+
LEFT JOIN (
179+
SELECT DISTINCT ON (dr.drep_hash_id)
180180
dr.tx_id,
181-
dr.drep_hash_id,
182-
ROW_NUMBER() OVER (PARTITION BY dr.drep_hash_id ORDER BY dr.tx_id ASC) AS rn
181+
dr.drep_hash_id
183182
FROM
184183
drep_registration dr
185-
) AS dr_first_register ON dr_first_register.drep_hash_id = dh.id AND dr_first_register.rn = 1
184+
ORDER BY
185+
dr.drep_hash_id, dr.tx_id ASC
186+
) AS dr_first_register ON dr_first_register.drep_hash_id = dh.id
186187
LEFT JOIN tx AS tx_first_register ON tx_first_register.id = dr_first_register.tx_id
187188
LEFT JOIN block AS block_first_register ON block_first_register.id = tx_first_register.block_id
188189
LEFT JOIN LatestVoteEpoch lve ON lve.drep_id = dh.id

govtool/backend/sql/list-proposals.sql

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,13 @@ EnrichedCurrentMembers AS (
8585
) AS enriched_members
8686
FROM
8787
ProcessedCurrentMembers pcm
88-
LEFT JOIN
89-
json_array_elements(pcm.current_members) AS member ON true
90-
LEFT JOIN
91-
CommitteeData cm ON cm.hash = encode(decode(member->>'hash', 'hex'), 'hex')
88+
LEFT JOIN json_array_elements(pcm.current_members) AS member ON true
89+
LEFT JOIN CommitteeData cm
90+
ON (CASE
91+
WHEN (member->>'hash') ~ '^[0-9a-fA-F]+$'
92+
THEN encode(decode(member->>'hash', 'hex'), 'hex')
93+
ELSE NULL
94+
END) = cm.hash
9295
GROUP BY
9396
pcm.id
9497
),
@@ -199,7 +202,13 @@ SELECT
199202
'tag', pd.tag,
200203
'members', em.enriched_members,
201204
'membersToBeRemoved', mtr.members_to_be_removed,
202-
'threshold', pd.threshold::float
205+
'threshold',
206+
CASE
207+
WHEN (pd.threshold->>'numerator') IS NOT NULL
208+
AND (pd.threshold->>'denominator') IS NOT NULL
209+
THEN (pd.threshold->>'numerator')::float / (pd.threshold->>'denominator')::float
210+
ELSE NULL
211+
END
203212
)
204213
FROM
205214
ParsedDescription pd

govtool/frontend/src/components/organisms/DashboardGovernanceActions.tsx

Lines changed: 54 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1-
import { useState, useEffect } from "react";
1+
import { useState, useEffect, useCallback } from "react";
22
import { Box, CircularProgress, Tab, Tabs, styled } from "@mui/material";
3-
import { useLocation } from "react-router-dom";
3+
import { useLocation, useNavigate } from "react-router-dom";
44

55
import {
66
GOVERNANCE_ACTIONS_FILTERS,
77
GOVERNANCE_ACTIONS_SORTING,
8+
PATHS,
9+
PDF_PATHS,
810
} from "@consts";
9-
import { useCardano, useDataActionsBar } from "@context";
11+
import { useCardano, useDataActionsBar, useFeatureFlag } from "@context";
1012
import {
1113
useGetProposalsQuery,
1214
useGetVoterInfo,
@@ -18,6 +20,7 @@ import {
1820
GovernanceActionsToVote,
1921
DashboardGovernanceActionsVotedOn,
2022
} from "@organisms";
23+
import { Button } from "@atoms";
2124

2225
type TabPanelProps = {
2326
children?: React.ReactNode;
@@ -74,6 +77,8 @@ export const DashboardGovernanceActions = () => {
7477
const { isMobile } = useScreenDimension();
7578
const { t } = useTranslation();
7679
const { isEnableLoading } = useCardano();
80+
const { isProposalDiscussionForumEnabled } = useFeatureFlag();
81+
const navigate = useNavigate();
7782

7883
const queryFilters =
7984
chosenFilters.length > 0 ? chosenFilters : defaultCategories;
@@ -94,6 +99,14 @@ export const DashboardGovernanceActions = () => {
9499
setContent(newValue);
95100
};
96101

102+
const onClickPropose = useCallback(() => {
103+
navigate(
104+
isProposalDiscussionForumEnabled
105+
? PDF_PATHS.proposalDiscussionPropose
106+
: PATHS.createGovernanceAction,
107+
);
108+
}, [isProposalDiscussionForumEnabled]);
109+
97110
useEffect(() => {
98111
window.history.replaceState({}, document.title);
99112
}, []);
@@ -126,36 +139,49 @@ export const DashboardGovernanceActions = () => {
126139
) : (
127140
<>
128141
{(voter?.isRegisteredAsDRep || voter?.isRegisteredAsSoleVoter) && (
129-
<Tabs
130-
sx={{
131-
marginTop: 3,
132-
display: "flex",
133-
fontSize: 16,
134-
fontWeight: 500,
135-
}}
136-
value={content}
137-
indicatorColor="secondary"
138-
onChange={handleChange}
139-
aria-label="Governance Actions tabs"
140-
>
141-
<StyledTab
142-
data-testid="to-vote-tab"
143-
label={t("govActions.toVote")}
142+
<Box display="flex" flexDirection="row" alignItems="center">
143+
<Tabs
144144
sx={{
145-
textTransform: "none",
146-
width: !isMobile ? "auto" : "50%",
145+
marginTop: 3,
146+
display: "flex",
147+
fontSize: 16,
148+
fontWeight: 500,
147149
}}
148-
/>
149-
<StyledTab
150-
data-testid="voted-tab"
151-
label={t("govActions.votedOnByMe")}
150+
value={content}
151+
indicatorColor="secondary"
152+
onChange={handleChange}
153+
aria-label="Governance Actions tabs"
154+
>
155+
<StyledTab
156+
data-testid="to-vote-tab"
157+
label={t("govActions.toVote")}
158+
sx={{
159+
textTransform: "none",
160+
width: !isMobile ? "auto" : "50%",
161+
}}
162+
/>
163+
<StyledTab
164+
data-testid="voted-tab"
165+
label={t("govActions.votedOnByMe")}
166+
sx={{
167+
textTransform: "none",
168+
width: !isMobile ? "auto" : "50%",
169+
}}
170+
/>
171+
</Tabs>
172+
<Button
173+
data-testid="proposal-discussion-link"
174+
onClick={onClickPropose}
152175
sx={{
153-
textTransform: "none",
154-
width: !isMobile ? "auto" : "50%",
176+
display: isMobile ? "none" : "block",
177+
ml: "auto",
155178
}}
156-
/>
157-
</Tabs>
179+
>
180+
{t("govActions.propose")}
181+
</Button>
182+
</Box>
158183
)}
184+
159185
<Box height={isMobile ? 24 : 60} />
160186
<CustomTabPanel value={content} index={0}>
161187
<GovernanceActionsToVote

govtool/frontend/src/i18n/locales/en.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,7 @@
444444
"noResultsForTheSearch": "No results for the search.",
445445
"onChainTransactionDetails": "On-chain Transaction Details",
446446
"optional": "(optional)",
447+
"propose": "Propose Governance Action",
447448
"provideContext": "Provide context",
448449
"provideContextAboutYourVote": "Provide context about your vote",
449450
"additionalInformationAboutYourVote": "Additional information about your vote",

govtool/frontend/src/pages/GovernanceActions.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@ export const GovernanceActions = () => {
9696
filtersTitle={t("govActions.filterTitle")}
9797
sortOptions={GOVERNANCE_ACTIONS_SORTING}
9898
/>
99-
10099
{!proposals || isProposalsLoading ? (
101100
<Box
102101
sx={{

0 commit comments

Comments
 (0)