Skip to content

Commit 22632aa

Browse files
committed
fix(#3733): blank page when dRep have @value in uri or label references
1 parent 12ace05 commit 22632aa

File tree

6 files changed

+54
-27
lines changed

6 files changed

+54
-27
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ changes.
1616

1717
### Fixed
1818

19+
- Fix blank page on dRep details when link or identity references contain objects: { @value: ... } not strings [Issue 3733](https://github.com/IntersectMBO/govtool/issues/3733)
1920
- Fix missing off chain references in DRep details [Issue 3490](https://github.com/IntersectMBO/govtool/issues/3490)
2021
- Fix blank screen and type error on linkReferences when navigating to edit dRep page that has no links [Issue 3714](https://github.com/IntersectMBO/govtool/issues/3714)
2122
- Fix adding two link input fields when editing the dRep form when no links are present initially [Issue 3709](https://github.com/IntersectMBO/govtool/issues/3709)

govtool/backend/sql/list-dreps.sql

Lines changed: 47 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ HasNonDeregisterVotingAnchor AS (
9595
EXISTS (
9696
SELECT 1
9797
FROM drep_registration dr_sub
98-
WHERE
98+
WHERE
9999
dr_sub.drep_hash_id = dr.drep_hash_id
100100
AND dr_sub.voting_anchor_id IS NULL
101101
AND COALESCE(dr_sub.deposit, 0) >= 0
@@ -129,12 +129,25 @@ DRepData AS (
129129
off_chain_vote_drep_data.image_hash,
130130
COALESCE(
131131
(
132-
SELECT jsonb_agg(ref)
132+
SELECT jsonb_agg(
133+
jsonb_build_object(
134+
'uri', COALESCE(
135+
CASE WHEN jsonb_typeof(ref->'uri') = 'string' THEN ref->>'uri' END,
136+
ref->'uri'->>'@value',
137+
ref->>'@value'
138+
),
139+
'@type', ref->>'@type',
140+
'label', COALESCE(
141+
CASE WHEN jsonb_typeof(ref->'label') = 'string' THEN ref->>'label' END,
142+
ref->'label'->>'@value'
143+
)
144+
)
145+
)
133146
FROM jsonb_array_elements(
134-
CASE
135-
WHEN (ocvd.json::jsonb)->'body'->'references' IS NOT NULL
136-
THEN (ocvd.json::jsonb)->'body'->'references'
137-
ELSE '[]'::jsonb
147+
CASE
148+
WHEN (ocvd.json::jsonb)->'body'->'references' IS NOT NULL
149+
THEN (ocvd.json::jsonb)->'body'->'references'
150+
ELSE '[]'::jsonb
138151
END
139152
) AS ref
140153
WHERE ref->>'@type' = 'Identity'
@@ -143,12 +156,25 @@ DRepData AS (
143156
) AS identity_references,
144157
COALESCE(
145158
(
146-
SELECT jsonb_agg(ref)
159+
SELECT jsonb_agg(
160+
jsonb_build_object(
161+
'uri', COALESCE(
162+
CASE WHEN jsonb_typeof(ref->'uri') = 'string' THEN ref->>'uri' END,
163+
ref->'uri'->>'@value',
164+
ref->>'@value'
165+
),
166+
'@type', ref->>'@type',
167+
'label', COALESCE(
168+
CASE WHEN jsonb_typeof(ref->'label') = 'string' THEN ref->>'label' END,
169+
ref->'label'->>'@value'
170+
)
171+
)
172+
)
147173
FROM jsonb_array_elements(
148-
CASE
149-
WHEN (ocvd.json::jsonb)->'body'->'references' IS NOT NULL
150-
THEN (ocvd.json::jsonb)->'body'->'references'
151-
ELSE '[]'::jsonb
174+
CASE
175+
WHEN (ocvd.json::jsonb)->'body'->'references' IS NOT NULL
176+
THEN (ocvd.json::jsonb)->'body'->'references'
177+
ELSE '[]'::jsonb
152178
END
153179
) AS ref
154180
WHERE ref->>'@type' = 'Link'
@@ -185,7 +211,7 @@ DRepData AS (
185211
LEFT JOIN FetchError fetch_error ON fetch_error.voting_anchor_id = leva.voting_anchor_id
186212
LEFT JOIN HasNonDeregisterVotingAnchor hndva ON hndva.drep_hash_id = dh.id
187213
LEFT JOIN off_chain_vote_data ocvd ON ocvd.voting_anchor_id = leva.voting_anchor_id
188-
LEFT JOIN off_chain_vote_drep_data ON off_chain_vote_drep_data.off_chain_vote_data_id = ocvd.id
214+
LEFT JOIN off_chain_vote_drep_data ON off_chain_vote_drep_data.off_chain_vote_data_id = ocvd.id
189215
LEFT JOIN voting_procedure ON voting_procedure.drep_voter = dh.id
190216
LEFT JOIN tx voting_procedure_transaction ON voting_procedure_transaction.id = voting_procedure.tx_id
191217
LEFT JOIN block voting_procedure_block ON voting_procedure_block.id = voting_procedure_transaction.block_id
@@ -244,21 +270,21 @@ DRepData AS (
244270
(
245271
SELECT jsonb_agg(ref)
246272
FROM jsonb_array_elements(
247-
CASE
248-
WHEN (ocvd.json::jsonb)->'body'->'references' IS NOT NULL
249-
THEN (ocvd.json::jsonb)->'body'->'references'
250-
ELSE '[]'::jsonb
273+
CASE
274+
WHEN (ocvd.json::jsonb)->'body'->'references' IS NOT NULL
275+
THEN (ocvd.json::jsonb)->'body'->'references'
276+
ELSE '[]'::jsonb
251277
END
252278
) AS ref
253279
WHERE ref->>'@type' = 'Identity'
254280
),
255281
(
256282
SELECT jsonb_agg(ref)
257283
FROM jsonb_array_elements(
258-
CASE
259-
WHEN (ocvd.json::jsonb)->'body'->'references' IS NOT NULL
260-
THEN (ocvd.json::jsonb)->'body'->'references'
261-
ELSE '[]'::jsonb
284+
CASE
285+
WHEN (ocvd.json::jsonb)->'body'->'references' IS NOT NULL
286+
THEN (ocvd.json::jsonb)->'body'->'references'
287+
ELSE '[]'::jsonb
262288
END
263289
) AS ref
264290
WHERE ref->>'@type' = 'Link'
@@ -275,4 +301,4 @@ WHERE
275301
objectives ILIKE ? OR
276302
motivations ILIKE ? OR
277303
qualifications ILIKE ?
278-
)
304+
)

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -385,8 +385,8 @@
385385
"doNotListHelpfulText": "Check this box if you do not want to be listed in DRep directories/compilations. If you tick this, you will not have a listing in the DRep listing on GovTool.",
386386
"referenceTypes": {
387387
"link": {
388-
"title": "Links",
389-
"description": "Links to social media or any other web URL that gives a fuller picture of who you are, what you stand for, and why."
388+
"title": "Link",
389+
"description": "Link to social media or any other web URL that gives a fuller picture of who you are, what you stand for, and why."
390390
},
391391
"identity": {
392392
"title": "Identity",

govtool/frontend/src/models/api.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ export enum DRepListSort {
151151
}
152152

153153
type Reference = {
154-
"@type": "Identity" | "Links";
154+
"@type": "Identity" | "Link";
155155
label: string;
156156
uri: string;
157157
};

govtool/frontend/src/stories/DRepDetailsCard.stories.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@ const meta = {
3030
"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc porta iaculis sodales. Praesent non nisi fermentum, porta sem in, porta arcu. In dignissim pulvinar est eu dignissim. Duis vitae vehicula dui. Praesent posuere egestas lacus, at pulvinar elit tempus ut. Etiam vulputate, lorem in accumsan.",
3131
linkReferences: [
3232
{
33-
"@type": "Links",
33+
"@type": "Link",
3434
label: "Link Reference",
3535
uri: "https://example.com/",
3636
},
3737
{
38-
"@type": "Links",
38+
"@type": "Link",
3939
label: "Another Link Reference",
4040
uri: "https://example.com/",
4141
},

govtool/frontend/src/stories/GovernanceActionDetailsCard.stories.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ const commonArgs = {
5959
metadataHash: "exampleMetadataHash",
6060
references: [
6161
{
62-
"@type": "Links",
62+
"@type": "Link",
6363
uri: "https://exampleurl.com",
6464
label: "Example label",
6565
},

0 commit comments

Comments
 (0)