Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] - Minespace VC Feature Flag #2793

Merged
merged 7 commits into from
Nov 9, 2023
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
51 changes: 27 additions & 24 deletions services/core-web/src/components/mine/Permit/MinePermitTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -113,7 +114,7 @@ const renderDeleteButtonForPermitAmendments = (record) => {
okText={isLinkedToNowApplication ? "Ok" : "Delete"}
cancelText="Cancel"
onConfirm={
isLinkedToNowApplication ? () => { } : () => record.handleDeletePermitAmendment(record)
isLinkedToNowApplication ? () => {} : () => record.handleDeletePermitAmendment(record)
}
>
<div className="custom-menu-item">
Expand Down Expand Up @@ -358,7 +359,7 @@ const columns: ColumnsType<MinePermitTableItem> = [
onConfirm={
isDeletionAllowed
? () => record.handleDeletePermit((record.permit as IPermit).permit_guid)
: () => { }
: () => {}
}
okText={isDeletionAllowed ? "Delete" : "Ok"}
cancelText="Cancel"
Expand Down Expand Up @@ -398,27 +399,6 @@ const columns: ColumnsType<MinePermitTableItem> = [
},
];

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 <Badge color={colour} text={badgeText} />;
},
};

columns.splice(5, 0, issuanceColumn);
}

const childColumns: ColumnsType<MinePermitTableItem> = [
{
title: "#",
Expand Down Expand Up @@ -661,6 +641,29 @@ const transformChildRowData = (
});

export const MinePermitTable: React.FC<RouteComponentProps & MinePermitTableProps> = (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 <Badge color={colour} text={badgeText} />;
},
};

columns.splice(5, 0, issuanceColumn);
}

const amendmentHistory = (permit) => {
return permit?.permit_amendments?.map((amendment, index) =>
transformChildRowData(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ import * as MOCK from "@/tests/mocks/dataMocks";
const dispatchProps: any = {};
const props: any = {};

jest.mock("@mds/common/providers/featureFlags/useFeatureFlag", () => ({
useFeatureFlag: () => ({
isFeatureEnabled: () => true,
}),
}));

const setupDispatchProps = () => {
dispatchProps.openEditPermitModal = jest.fn();
dispatchProps.openAddPermitAmendmentModal = jest.fn();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Loading