From 64a952da7cb845598e17a7c5ba2edddadbe546a5 Mon Sep 17 00:00:00 2001 From: Jason Syrotuck Date: Wed, 8 Nov 2023 14:06:17 -0800 Subject: [PATCH 1/6] dont' direct import. --- .../src/components/mine/Permit/MinePermitTable.tsx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/services/core-web/src/components/mine/Permit/MinePermitTable.tsx b/services/core-web/src/components/mine/Permit/MinePermitTable.tsx index f4d7f53cc0..11a9c9024f 100644 --- a/services/core-web/src/components/mine/Permit/MinePermitTable.tsx +++ b/services/core-web/src/components/mine/Permit/MinePermitTable.tsx @@ -4,7 +4,8 @@ import { withRouter, Link, RouteComponentProps } from "react-router-dom"; import { Menu, Dropdown, Button, Popconfirm } from "antd"; import { PlusOutlined, SafetyCertificateOutlined, ReadOutlined } from "@ant-design/icons"; import { connect } from "react-redux"; -import { Feature, VC_CRED_ISSUE_STATES, isFeatureEnabled } from "@mds/common/index"; +import { Feature, VC_CRED_ISSUE_STATES } from "@mds/common/index"; +import { useFeatureFlag } from "@mds/common/providers/featureFlags/useFeatureFlag"; import { formatDate } from "@common/utils/helpers"; import { getPartyRelationships } from "@common/selectors/partiesSelectors"; import { @@ -29,6 +30,7 @@ import { ColumnsType } from "antd/lib/table"; */ const draftAmendment = "DFT"; +const { isFeatureEnabled } = useFeatureFlag(); interface MinePermitTableProps { permits?: IPermit[]; @@ -113,7 +115,7 @@ const renderDeleteButtonForPermitAmendments = (record) => { okText={isLinkedToNowApplication ? "Ok" : "Delete"} cancelText="Cancel" onConfirm={ - isLinkedToNowApplication ? () => { } : () => record.handleDeletePermitAmendment(record) + isLinkedToNowApplication ? () => {} : () => record.handleDeletePermitAmendment(record) } >
@@ -358,7 +360,7 @@ const columns: ColumnsType = [ onConfirm={ isDeletionAllowed ? () => record.handleDeletePermit((record.permit as IPermit).permit_guid) - : () => { } + : () => {} } okText={isDeletionAllowed ? "Delete" : "Ok"} cancelText="Cancel" From 42c666aad60c78ac104ccf9a56c9fa40bfdd5236 Mon Sep 17 00:00:00 2001 From: Jason Syrotuck Date: Wed, 8 Nov 2023 15:03:49 -0800 Subject: [PATCH 2/6] must be in class context --- .../mine/Permit/MinePermitTable.tsx | 45 ++++++++++--------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/services/core-web/src/components/mine/Permit/MinePermitTable.tsx b/services/core-web/src/components/mine/Permit/MinePermitTable.tsx index 11a9c9024f..383a4801b6 100644 --- a/services/core-web/src/components/mine/Permit/MinePermitTable.tsx +++ b/services/core-web/src/components/mine/Permit/MinePermitTable.tsx @@ -30,7 +30,6 @@ import { ColumnsType } from "antd/lib/table"; */ const draftAmendment = "DFT"; -const { isFeatureEnabled } = useFeatureFlag(); interface MinePermitTableProps { permits?: IPermit[]; @@ -400,27 +399,6 @@ const columns: ColumnsType = [ }, ]; -if (isFeatureEnabled(Feature.VERIFIABLE_CREDENTIALS)) { - const colourMap = { - "Not Active": "#D8292F", - Pending: "#F1C21B", - Active: "#45A776", - }; - - const issuanceColumn = { - title: "VC Issuance State", - dataIndex: "lastAmendedVC", - key: "lastAmendedVC", - render: (text) => { - const badgeText = text ? VC_CRED_ISSUE_STATES[text] : "N/A"; - const colour = colourMap[badgeText] ?? "transparent"; - return ; - }, - }; - - columns.splice(5, 0, issuanceColumn); -} - const childColumns: ColumnsType = [ { title: "#", @@ -663,6 +641,29 @@ const transformChildRowData = ( }); export const MinePermitTable: React.FC = (props) => { + const { isFeatureEnabled } = useFeatureFlag(); + + if (isFeatureEnabled(Feature.VERIFIABLE_CREDENTIALS)) { + const colourMap = { + "Not Active": "#D8292F", + Pending: "#F1C21B", + Active: "#45A776", + }; + + const issuanceColumn = { + title: "VC Issuance State", + dataIndex: "lastAmendedVC", + key: "lastAmendedVC", + render: (text) => { + const badgeText = text ? VC_CRED_ISSUE_STATES[text] : "N/A"; + const colour = colourMap[badgeText] ?? "transparent"; + return ; + }, + }; + + columns.splice(5, 0, issuanceColumn); + } + const amendmentHistory = (permit) => { return permit?.permit_amendments?.map((amendment, index) => transformChildRowData( From 1e98fc508978145a0e3895e91459f8c5ea02c927 Mon Sep 17 00:00:00 2001 From: Jason Syrotuck Date: Wed, 8 Nov 2023 15:53:48 -0800 Subject: [PATCH 3/6] mock for test --- .../tests/components/mine/Permit/MinePermitTable.spec.tsx | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/services/core-web/src/tests/components/mine/Permit/MinePermitTable.spec.tsx b/services/core-web/src/tests/components/mine/Permit/MinePermitTable.spec.tsx index fd960a9540..b50fa7ba9e 100644 --- a/services/core-web/src/tests/components/mine/Permit/MinePermitTable.spec.tsx +++ b/services/core-web/src/tests/components/mine/Permit/MinePermitTable.spec.tsx @@ -6,6 +6,14 @@ import * as MOCK from "@/tests/mocks/dataMocks"; const dispatchProps: any = {}; const props: any = {}; +jest.mock("@mds/common/providers/featureFlags/useFeatureFlag", () => ({ + useFeatureFlag: () => ({ + isFeatureEnabled: { + verifiable_credentials: true, + }, + }), +})); + const setupDispatchProps = () => { dispatchProps.openEditPermitModal = jest.fn(); dispatchProps.openAddPermitAmendmentModal = jest.fn(); From e2947f3d3390ffbaf1e04888720b63c17eb7b505 Mon Sep 17 00:00:00 2001 From: Jason Syrotuck Date: Wed, 8 Nov 2023 16:04:23 -0800 Subject: [PATCH 4/6] return true regardless of input --- .../tests/components/mine/Permit/MinePermitTable.spec.tsx | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/services/core-web/src/tests/components/mine/Permit/MinePermitTable.spec.tsx b/services/core-web/src/tests/components/mine/Permit/MinePermitTable.spec.tsx index b50fa7ba9e..baf1810a6b 100644 --- a/services/core-web/src/tests/components/mine/Permit/MinePermitTable.spec.tsx +++ b/services/core-web/src/tests/components/mine/Permit/MinePermitTable.spec.tsx @@ -7,11 +7,7 @@ const dispatchProps: any = {}; const props: any = {}; jest.mock("@mds/common/providers/featureFlags/useFeatureFlag", () => ({ - useFeatureFlag: () => ({ - isFeatureEnabled: { - verifiable_credentials: true, - }, - }), + isFeatureEnabled: () => true, })); const setupDispatchProps = () => { From 01f544ddc7eef2ad4291a3257883255bf4d31872 Mon Sep 17 00:00:00 2001 From: Jason Syrotuck Date: Wed, 8 Nov 2023 16:19:09 -0800 Subject: [PATCH 5/6] wrapped it wrong --- .../src/tests/components/mine/Permit/MinePermitTable.spec.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/services/core-web/src/tests/components/mine/Permit/MinePermitTable.spec.tsx b/services/core-web/src/tests/components/mine/Permit/MinePermitTable.spec.tsx index baf1810a6b..299ff62db9 100644 --- a/services/core-web/src/tests/components/mine/Permit/MinePermitTable.spec.tsx +++ b/services/core-web/src/tests/components/mine/Permit/MinePermitTable.spec.tsx @@ -7,7 +7,9 @@ const dispatchProps: any = {}; const props: any = {}; jest.mock("@mds/common/providers/featureFlags/useFeatureFlag", () => ({ - isFeatureEnabled: () => true, + useFeatureFlag: () => ({ + isFeatureEnabled: () => true, + }), })); const setupDispatchProps = () => { From 1cd832500f04d08bba9e38f302c56ce382106a19 Mon Sep 17 00:00:00 2001 From: Jason Syrotuck Date: Wed, 8 Nov 2023 16:44:59 -0800 Subject: [PATCH 6/6] manually update snapshot --- .../mine/Permit/__snapshots__/MinePermitTable.spec.tsx.snap | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/services/core-web/src/tests/components/mine/Permit/__snapshots__/MinePermitTable.spec.tsx.snap b/services/core-web/src/tests/components/mine/Permit/__snapshots__/MinePermitTable.spec.tsx.snap index db9fe90df3..764e4a6d45 100644 --- a/services/core-web/src/tests/components/mine/Permit/__snapshots__/MinePermitTable.spec.tsx.snap +++ b/services/core-web/src/tests/components/mine/Permit/__snapshots__/MinePermitTable.spec.tsx.snap @@ -35,6 +35,12 @@ exports[`MinePermitTable renders properly 1`] = ` "render": [Function], "title": "Last Amended", }, + Object { + "dataIndex": "lastAmendedVC", + "key": "lastAmendedVC", + "render": [Function], + "title": "VC Issuance State", + }, Object { "align": "right", "dataIndex": "addEditButton",