Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ changes.

### Fixed

-
- Fix displaying DRep with doNotList property as string

### Changed

Expand Down
10 changes: 8 additions & 2 deletions govtool/frontend/src/pages/DRepDirectoryContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
} from "@hooks";
import { DataActionsBar, EmptyStateDrepDirectory } from "@molecules";
import { AutomatedVotingOptions, DRepCard } from "@organisms";
import { correctAdaFormat, isSameDRep, uniqBy } from "@utils";
import { correctAdaFormat, isSameDRep, uniqBy, parseBoolean } from "@utils";
import { DRepData, DRepListSort, DRepStatus } from "@models";
import {
AutomatedVotingOptionCurrentDelegation,
Expand Down Expand Up @@ -107,9 +107,15 @@ export const DRepDirectoryContent: FC<DRepDirectoryContentProps> = ({
const ada = correctAdaFormat(votingPower);

const listedDRepsWithoutYourself = uniqBy(
dRepList?.filter((dRep) => !dRep.doNotList && !isSameDRep(dRep, myDRepId)),
dRepList?.filter(
(dRep) =>
(typeof dRep.doNotList === "string"
? !parseBoolean(dRep.doNotList)
: !dRep.doNotList) && !isSameDRep(dRep, myDRepId),
),
"view",
);

const dRepListToDisplay =
yourselfDRep && showYourselfDRep
? [yourselfDRep, ...listedDRepsWithoutYourself]
Expand Down
1 change: 1 addition & 0 deletions govtool/frontend/src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,4 @@ export * from "./testIdFromLabel";
export * from "./uniqBy";
export * from "./wait";
export * from "./getBase64ImageDetails";
export * from "./parseBoolean";
13 changes: 13 additions & 0 deletions govtool/frontend/src/utils/parseBoolean.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/**
* Parses a string value and returns its boolean equivalent.
*
* @param value - The string value to be parsed.
* @returns `true` if the value is "true" (case insensitive),
* `false` if the value is "false" (case insensitive),
* or `null` if the value is neither.
*/
export const parseBoolean = (value: string): boolean | null =>
({
true: true,
false: false,
}[String(value).toLowerCase()] ?? null);
31 changes: 31 additions & 0 deletions govtool/frontend/src/utils/tests/parseBoolean.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import { parseBoolean } from "../parseBoolean";

describe("parseBoolean", () => {
it("should return true for 'true' (case insensitive)", () => {
expect(parseBoolean("true")).toBe(true);
expect(parseBoolean("TRUE")).toBe(true);
expect(parseBoolean("TrUe")).toBe(true);
});

it("should return false for 'false' (case insensitive)", () => {
expect(parseBoolean("false")).toBe(false);
expect(parseBoolean("FALSE")).toBe(false);
expect(parseBoolean("FaLsE")).toBe(false);
});

it("should return null for any other string", () => {
expect(parseBoolean("yes")).toBeNull();
expect(parseBoolean("no")).toBeNull();
expect(parseBoolean("1")).toBeNull();
expect(parseBoolean("0")).toBeNull();
expect(parseBoolean("")).toBeNull();
});

it("should return null for non-string values", () => {
expect(parseBoolean(null as any)).toBeNull();
expect(parseBoolean(undefined as any)).toBeNull();
expect(parseBoolean(123 as any)).toBeNull();
expect(parseBoolean({} as any)).toBeNull();
});
});
55 changes: 25 additions & 30 deletions govtool/frontend/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1367,15 +1367,15 @@
resolved "https://registry.npmjs.org/@emurgo/cardano-serialization-lib-asmjs/-/cardano-serialization-lib-asmjs-12.1.1.tgz"
integrity sha512-K3f28QUfLDJ7seO6MtKfMYtRm5ccf36TQ5yxyTmZqX1TA85MkriEdxqpgV9KLiLEA95emwnlvU2/WmlHMRPg1A==

"@esbuild/linux-x64@0.21.5":
"@esbuild/darwin-arm64@0.21.5":
version "0.21.5"
resolved "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.21.5.tgz"
integrity sha512-1rYdTpyv03iycF1+BhzrzQJCdOuAOtaqHTWJZCWvijKD2N5Xu0TtVC8/+1faWqcP9iBCWOmjmhoH94dH82BxPQ==
resolved "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.21.5.tgz"
integrity sha512-DwqXqZyuk5AiWWf3UfLiRDJ5EDd49zg6O9wclZ7kUMv2WRFr4HKjXp/5t8JZ11QbQfUS6/cRCKGwYhtNAY88kQ==

"@esbuild/linux-x64@0.24.2":
"@esbuild/darwin-arm64@0.24.2":
version "0.24.2"
resolved "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.24.2.tgz"
integrity sha512-8Qi4nQcCTbLnK9WoMjdC9NiTG6/E38RNICU6sUNqK0QFxCYgoARqVqxdFmWkdonVsvGqWhmm7MO0jyTqLqwj0Q==
resolved "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.24.2.tgz"
integrity sha512-kj3AnYWc+CekmZnS5IPu9D+HWtUI49hbnyqk0FLEJDbzCIQt7hg7ucF1SQAilhtYpIujfaHr6O0UHlzzSPdOeA==

"@eslint-community/eslint-utils@^4.2.0", "@eslint-community/eslint-utils@^4.4.0":
version "4.4.1"
Expand Down Expand Up @@ -2162,15 +2162,10 @@
resolved "https://registry.npmjs.org/@open-draft/until/-/until-2.1.0.tgz"
integrity sha512-U69T3ItWHvLwGg5eJ0n3I62nWuE6ilHlmz7zM0npLBRvPRd7e6NYmg54vvRtP5mZG7kZqZCFVdsTWo7BPtBujg==

"@parcel/watcher-linux-x64-glibc@2.5.0":
"@parcel/watcher-darwin-arm64@2.5.0":
version "2.5.0"
resolved "https://registry.npmjs.org/@parcel/watcher-linux-x64-glibc/-/watcher-linux-x64-glibc-2.5.0.tgz"
integrity sha512-d9AOkusyXARkFD66S6zlGXyzx5RvY+chTP9Jp0ypSTC9d4lzyRs9ovGf/80VCxjKddcUvnsGwCHWuF2EoPgWjw==

"@parcel/watcher-linux-x64-musl@2.5.0":
version "2.5.0"
resolved "https://registry.npmjs.org/@parcel/watcher-linux-x64-musl/-/watcher-linux-x64-musl-2.5.0.tgz"
integrity sha512-iqOC+GoTDoFyk/VYSFHwjHhYrk8bljW6zOhPuhi5t9ulqiYq1togGJB5e3PwYVFFfeVgc6pbz3JdQyDoBszVaA==
resolved "https://registry.npmjs.org/@parcel/watcher-darwin-arm64/-/watcher-darwin-arm64-2.5.0.tgz"
integrity sha512-hyZ3TANnzGfLpRA2s/4U1kbw2ZI4qGxaRJbBH2DCSREFfubMswheh8TeiC1sGZ3z2jUf3s37P0BBlrD3sjVTUw==

"@parcel/watcher@^2.4.1":
version "2.5.0"
Expand Down Expand Up @@ -2283,15 +2278,10 @@
estree-walker "^2.0.2"
picomatch "^4.0.2"

"@rollup/rollup-linux-x64-gnu@4.27.4":
"@rollup/rollup-darwin-arm64@4.27.4":
version "4.27.4"
resolved "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.27.4.tgz"
integrity sha512-Ni8mMtfo+o/G7DVtweXXV/Ol2TFf63KYjTtoZ5f078AUgJTmaIJnj4JFU7TK/9SVWTaSJGxPi5zMDgK4w+Ez7Q==

"@rollup/rollup-linux-x64-musl@4.27.4":
version "4.27.4"
resolved "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.27.4.tgz"
integrity sha512-5AeeAF1PB9TUzD+3cROzFTnAJAcVUGLuR8ng0E0WXGkYhp6RD6L+6szYVX+64Rs0r72019KHZS1ka1q+zU/wUw==
resolved "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.27.4.tgz"
integrity sha512-PlNiRQapift4LNS8DPUHuDX/IdXiLjf8mc5vdEmUR0fF/pyy2qWwzdLjB+iZquGr8LuN4LnUoSEvKRwjSVYz3Q==

"@rtsao/scc@^1.1.0":
version "1.1.0"
Expand Down Expand Up @@ -2870,15 +2860,10 @@
"@svgr/plugin-svgo" "^5.5.0"
loader-utils "^2.0.0"

"@swc/core-linux-x64-gnu@1.9.3":
"@swc/core-darwin-arm64@1.9.3":
version "1.9.3"
resolved "https://registry.npmjs.org/@swc/core-linux-x64-gnu/-/core-linux-x64-gnu-1.9.3.tgz"
integrity sha512-ivXXBRDXDc9k4cdv10R21ccBmGebVOwKXT/UdH1PhxUn9m/h8erAWjz5pcELwjiMf27WokqPgaWVfaclDbgE+w==

"@swc/core-linux-x64-musl@1.9.3":
version "1.9.3"
resolved "https://registry.npmjs.org/@swc/core-linux-x64-musl/-/core-linux-x64-musl-1.9.3.tgz"
integrity sha512-ILsGMgfnOz1HwdDz+ZgEuomIwkP1PHT6maigZxaCIuC6OPEhKE8uYna22uU63XvYcLQvZYDzpR3ms47WQPuNEg==
resolved "https://registry.npmjs.org/@swc/core-darwin-arm64/-/core-darwin-arm64-1.9.3.tgz"
integrity sha512-hGfl/KTic/QY4tB9DkTbNuxy5cV4IeejpPD4zo+Lzt4iLlDWIeANL4Fkg67FiVceNJboqg48CUX+APhDHO5G1w==

"@swc/core@*", "@swc/core@^1.5.22", "@swc/core@^1.7.26":
version "1.9.3"
Expand Down Expand Up @@ -7184,6 +7169,16 @@ fs@^0.0.1-security:
resolved "https://registry.npmjs.org/fs/-/fs-0.0.1-security.tgz"
integrity sha512-3XY9e1pP0CVEUCdj5BmfIZxRBTSDycnbqhIOGec9QYtmVH2fbLpj86CFWkrNOkt/Fvty4KZG5lTglL9j/gJ87w==

fsevents@^2.3.2, fsevents@~2.3.2, fsevents@~2.3.3:
version "2.3.3"
resolved "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz"
integrity sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==

fsevents@2.3.2:
version "2.3.2"
resolved "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz"
integrity sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==

function-bind@^1.1.2:
version "1.1.2"
resolved "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz"
Expand Down