Skip to content

Commit

Permalink
Feat: #16 There shall be an option to view data sources
Browse files Browse the repository at this point in the history
  • Loading branch information
MARZOOQUE authored and georgepadayatti committed Sep 30, 2024
1 parent 4de5995 commit 03e6884
Show file tree
Hide file tree
Showing 8 changed files with 180 additions and 48 deletions.
43 changes: 41 additions & 2 deletions src/Components/CollapseUsage/PanelHeader.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { withNamespaces } from "react-i18next";
import { Popover } from "antd";
import { ModalComponentWithNamespace } from "../modals/modal";
import { DataAgreementDetailsWithNamespace } from "../modals/detailsContainer/dataAgreementDetails";
import { DataSourcesDetailsWithNamespace } from "../modals/detailsContainer/dataSourcesDetails";

const content = (description) => (
<div>
Expand Down Expand Up @@ -32,10 +33,18 @@ export const PanelHeader = ({
geographicRestriction,
retentionPeriod,
storageLocation,
methodOfUse,
dataAgreement,
}) => {
const [openViewDataAgreementModal, setOpenViewDataAgreementModal] = useState(
false
);
const [openDataSources, setOpenViewDataSources] = useState(false);

const disableDataAttrubutes =
methodOfUse !== "data_using_service" ||
(!dataAgreement["dataSources"] ||
dataAgreement["dataSources"] === undefined || dataAgreement["dataSources"].length === 0);

return (
<>
Expand Down Expand Up @@ -75,13 +84,34 @@ export const PanelHeader = ({
</p>
)}
<div className="panel-header-count">
{t("userRequests.panelAllow")}
{` ${consented} of ${total}`}
<p>
{" "}
{t("userRequests.panelAllow")}
{` ${consented} of ${total}`}
</p>
{showDescription && (
<p
style={{
textDecoration: "underline",
color: disableDataAttrubutes ? "grey" : "#1890FF",
cursor: disableDataAttrubutes ? "not-allowed" : "pointer",
}}
onClick={(e) => {
e.stopPropagation();
if (!disableDataAttrubutes) {
setOpenViewDataSources(true);
}
}}
>
{t("dataAgreements.dataSources")}
</p>
)}
</div>
</div>
</div>
</Popover>

{/* View Data agreements */}
<ModalComponentWithNamespace
open={openViewDataAgreementModal}
setOpen={setOpenViewDataAgreementModal}
Expand All @@ -100,6 +130,15 @@ export const PanelHeader = ({
storageLocation={storageLocation}
/>
</ModalComponentWithNamespace>

{/* View Data Sources */}
<ModalComponentWithNamespace
open={openDataSources}
setOpen={setOpenViewDataSources}
header={t("dataAgreements.dataSources")}
>
<DataSourcesDetailsWithNamespace dataAgreement={dataAgreement} />
</ModalComponentWithNamespace>
</>
);
};
Expand Down
4 changes: 4 additions & 0 deletions src/Components/CollapseUsage/collapse.css
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@
margin: 0;
padding: 0;
color: gray;
display: flex;
justify-content: space-between;
align-items: top;
width:97%
}

.panel-header > button {
Expand Down
2 changes: 1 addition & 1 deletion src/Components/CollapseUsage/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ class CollapseUsage extends Component {
{!data
? null
: data.map((dataAgreement, i) => {
console.log("dataAgreement", dataAgreement["consentRecords"]);
const consented =
dataAgreement["consentRecords"] === null
? 0
Expand Down Expand Up @@ -150,6 +149,7 @@ class CollapseUsage extends Component {
storageLocation={
dataAgreement["policy"]["storageLocation"]
}
methodOfUse={`${dataAgreement["methodOfUse"]}`}
/>
</Spin>
}
Expand Down
81 changes: 81 additions & 0 deletions src/Components/modals/detailsContainer/dataSourcesDetails.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
import React, { useState, useMemo } from "react";
import { withNamespaces } from "react-i18next";
import "antd/dist/antd.css";
import { Menu, Dropdown, Icon } from "antd";

const cardStyle = {
width: "100%",
border: "none",
borderRadius: "10px",
backgroundColor: "#F7F6F6",
marginTop: "10px",
padding: 10,
paddingLeft: "30px",
paddingRight: "30px",
};

export const DataSourcesDetails = ({ t, dataAgreement }) => {
const [selectedSector, setSelectedSector] = useState(null);

const sectors = useMemo(() => {
if (!dataAgreement.dataSources) return [];
const sectorSet = new Set(dataAgreement.dataSources.map((ds) => ds.sector));
return Array.from(sectorSet);
}, [dataAgreement.dataSources]);

const menu = (
<Menu onClick={({ key }) => setSelectedSector(key === "all" ? null : key)}>
<Menu.Item key="all">All Sectors</Menu.Item>
{sectors.map((sector) => (
<Menu.Item key={sector}>{sector}</Menu.Item>
))}
</Menu>
);

const filteredDataSources = useMemo(() => {
if (!selectedSector) return dataAgreement.dataSources;
return dataAgreement.dataSources.filter(
(ds) => ds.sector === selectedSector
);
}, [dataAgreement.dataSources, selectedSector]);

return (
<div>
<Dropdown overlay={menu} trigger={["click"]}>
<p
style={{ color: "grey", fontSize: "15px", cursor: "pointer" }}
onClick={(e) => {
e.stopPropagation();
e.preventDefault();
}}
>
{t("dataAgreements.sector")}: {selectedSector || "All"}{" "}
<Icon type="down" />
</p>
</Dropdown>

{filteredDataSources &&
filteredDataSources.map((dataSource, i) => (
<div style={cardStyle} key={i}>
<p style={{ fontSize: "14px" }}>{dataSource.name}</p>

<div style={{ display: "flex", flexWrap: "wrap" }}>
<p style={{ margin: 0, color: "grey" }}>{dataSource.sector},</p>
<p style={{ margin: 0, color: "grey", marginLeft: 5 }}>
{dataSource.location},
</p>
<p style={{ margin: 0, color: "grey", marginLeft: 5 }}>
{dataSource.privacyDashboardUrl}
</p>
</div>
</div>
))}
</div>
);
};

export const DataSourcesDetailsWithNamespace = withNamespaces()(
DataSourcesDetails
);

export default DataSourcesDetails;
2 changes: 2 additions & 0 deletions src/Provider/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,8 @@ class Store {
consentRecords: associatedConsentRecords.length === 0 ? null : associatedConsentRecords[0],
isDisabled: isNotConsentOrLegitimateInterest,
isUpdate: associatedConsentRecords.length !== 0,
methodOfUse: dataAgreement.methodOfUse,
dataSources: dataAgreement.dataSources,
};
}));

Expand Down
32 changes: 17 additions & 15 deletions src/localization/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,20 +84,22 @@
"logs": "History",
"userRequest": "User requests"
},
"dataAgreements" : {
"read" : "Read",
"daDetails" : "data agreement details.",
"daataAgreement" : "Data Agreement",
"dataAgreements": {
"read": "Read",
"daDetails": "data agreement details.",
"daataAgreement": "Data Agreement",
"close": "Close",
"purpose" : "Purpose",
"purposeDescription" : "Purpose Description",
"lawfulBasisOfProcessing" : "Lawful Basis of Processing",
"policyURL" : "Policy URL",
"jurisdiction" : "Jurisdiction",
"thirdPartyDisclosure" : "Third Party Disclosure",
"industryScope" : "Industry Scope",
"geographicRestriction" : "Geographic Restriction",
"retentionPeriod" : "Retention Period",
"storageLocation" : "Storage location"
"purpose": "Purpose",
"purposeDescription": "Purpose Description",
"lawfulBasisOfProcessing": "Lawful Basis of Processing",
"policyURL": "Policy URL",
"jurisdiction": "Jurisdiction",
"thirdPartyDisclosure": "Third Party Disclosure",
"industryScope": "Industry Scope",
"geographicRestriction": "Geographic Restriction",
"retentionPeriod": "Retention Period",
"storageLocation": "Storage location",
"dataSources": "Data Sources",
"sector": "Sector"
}
}
}
32 changes: 17 additions & 15 deletions src/localization/locales/pt/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,20 +84,22 @@
"userPurposes": {
"fetchingMessage": "Objetivos de busca..."
},
"dataAgreements" : {
"read" : "Read",
"daDetails" : "data agreement details.",
"daataAgreement" : "Data Agreement",
"dataAgreements": {
"read": "Read",
"daDetails": "data agreement details.",
"daataAgreement": "Data Agreement",
"close": "Close",
"purpose" : "Purpose",
"purposeDescription" : "Purpose Description",
"lawfulBasisOfProcessing" : "Lawful Basis of Processing",
"policyURL" : "Policy URL",
"jurisdiction" : "Jurisdiction",
"thirdPartyDisclosure" : "Third Party Disclosure",
"industryScope" : "Industry Scope",
"geographicRestriction" : "Geographic Restriction",
"retentionPeriod" : "Retention Period",
"storageLocation" : "Storage location"
"purpose": "Purpose",
"purposeDescription": "Purpose Description",
"lawfulBasisOfProcessing": "Lawful Basis of Processing",
"policyURL": "Policy URL",
"jurisdiction": "Jurisdiction",
"thirdPartyDisclosure": "Third Party Disclosure",
"industryScope": "Industry Scope",
"geographicRestriction": "Geographic Restriction",
"retentionPeriod": "Retention Period",
"storageLocation": "Storage location",
"dataSources": "Data Sources",
"sector": "Sector"
}
}
}
32 changes: 17 additions & 15 deletions src/localization/locales/sv/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,20 +84,22 @@
"logs": "Historik",
"userRequest": "Användarförfrågningar"
},
"dataAgreements" : {
"read" : "Read",
"daDetails" : "data agreement details.",
"daataAgreement" : "Data Agreement",
"dataAgreements": {
"read": "Read",
"daDetails": "data agreement details.",
"daataAgreement": "Data Agreement",
"close": "Close",
"purpose" : "Purpose",
"purposeDescription" : "Purpose Description",
"lawfulBasisOfProcessing" : "Lawful Basis of Processing",
"policyURL" : "Policy URL",
"jurisdiction" : "Jurisdiction",
"thirdPartyDisclosure" : "Third Party Disclosure",
"industryScope" : "Industry Scope",
"geographicRestriction" : "Geographic Restriction",
"retentionPeriod" : "Retention Period",
"storageLocation" : "Storage location"
"purpose": "Purpose",
"purposeDescription": "Purpose Description",
"lawfulBasisOfProcessing": "Lawful Basis of Processing",
"policyURL": "Policy URL",
"jurisdiction": "Jurisdiction",
"thirdPartyDisclosure": "Third Party Disclosure",
"industryScope": "Industry Scope",
"geographicRestriction": "Geographic Restriction",
"retentionPeriod": "Retention Period",
"storageLocation": "Storage location",
"dataSources": "Data Sources",
"sector": "Sector"
}
}
}

0 comments on commit 03e6884

Please sign in to comment.