hise-flow-graphs 1.0.21 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.env.dev +1 -0
- package/.env.prod +1 -0
- package/.env.stage +1 -0
- package/dist/main.js +1 -1
- package/package.json +7 -2
- package/src/@types/CertificateTypes.ts +25 -15
- package/src/components/Certificates/CertificateGraph/LayerBackButton.tsx +1 -1
- package/src/components/Certificates/CertificateGraph/NodeAttributes.tsx +10 -10
- package/src/components/Certificates/CertificateGraph/helpers.tsx +24 -17
- package/src/components/Certificates/CertificateGraph/index.tsx +23 -28
- package/src/components/Certificates/EditCertificate/EditNode.tsx +8 -12
- package/src/components/Certificates/EditCertificate/{EditNodeModal.jsx → EditNodeModal.tsx} +57 -50
- package/src/components/Certificates/EditCertificate/MaskMetadataModal/EMRMaskingTables.tsx +69 -0
- package/src/components/Certificates/EditCertificate/MaskMetadataModal/MaskMetadataTable.tsx +105 -0
- package/src/components/Certificates/EditCertificate/MaskMetadataModal/helpers.ts +41 -0
- package/src/components/Certificates/EditCertificate/MaskMetadataModal/index.tsx +167 -0
- package/src/components/Certificates/EditCertificate/helpers.ts +2 -44
- package/src/components/Certificates/EditCertificate/{index.jsx → index.tsx} +9 -4
- package/src/components/Certificates/FileLayerNode/index.tsx +12 -23
- package/src/components/Certificates/ReadCertificate/MetadataModal/MetadataTable.tsx +100 -0
- package/src/components/Certificates/ReadCertificate/MetadataModal/helpers.tsx +46 -0
- package/src/components/Certificates/ReadCertificate/MetadataModal/index.tsx +142 -0
- package/src/components/Certificates/ReadCertificate/ReadNode.tsx +7 -2
- package/src/components/Certificates/ReadCertificate/index.tsx +2 -3
- package/src/components/Certificates/ReviewCertificate/RestrictNode/index.tsx +161 -0
- package/src/components/Certificates/ReviewCertificate/ReviewNode.tsx +8 -5
- package/src/components/Certificates/ReviewCertificate/ReviewNodes/index.tsx +5 -4
- package/src/components/Certificates/ReviewCertificate/helpers.ts +18 -60
- package/src/components/Certificates/ReviewCertificate/{index.jsx → index.tsx} +14 -10
- package/src/components/Certificates/WorkspaceCertificate/ReplicaIDENode/index.tsx +5 -2
- package/src/components/Certificates/WorkspaceCertificate/ReplicaPipelineNode/index.tsx +4 -2
- package/src/components/Certificates/WorkspaceCertificate/RestrictedNode/index.tsx +106 -0
- package/src/components/Certificates/WorkspaceCertificate/WorkspaceFileNode/index.tsx +6 -2
- package/src/components/Certificates/WorkspaceCertificate/WorkspaceIDENode/index.tsx +10 -5
- package/src/components/Certificates/WorkspaceCertificate/WorkspaceNode/index.tsx +9 -3
- package/src/components/Certificates/WorkspaceCertificate/WorkspacePipelineNode/index.tsx +5 -5
- package/src/components/Certificates/WorkspaceCertificate/helpers.ts +7 -41
- package/src/components/Certificates/WorkspaceCertificate/index.tsx +10 -11
- package/src/components/Certificates/WorkspaceCertificate/style.css +0 -10
- package/src/index.ts +2 -2
- package/src/state/GraphContext.tsx +23 -22
- package/src/utils/getCertificateBody.ts +89 -0
- package/webpack.config.js +71 -54
- package/src/components/Certificates/EditCertificate/MaskMetadataModal.jsx +0 -299
- package/src/components/Certificates/FileLayerNode/helpers.ts +0 -31
- package/src/components/Certificates/ReadCertificate/MetadataModal/helpers.jsx +0 -22
- package/src/components/Certificates/ReadCertificate/MetadataModal/index.jsx +0 -169
- package/src/components/Certificates/ReadCertificate/helpers.ts +0 -38
- package/src/components/Certificates/ReviewCertificate/ReviewNodes/AllNodesModal.jsx +0 -63
- package/src/components/Certificates/ReviewCertificate/ReviewNodes/SingleNodeModal.jsx +0 -83
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import React, { useEffect, useState } from 'react';
|
|
2
|
+
import { NodeProps } from 'reactflow';
|
|
3
|
+
import * as R from 'ramda';
|
|
4
|
+
import { Button, ConfirmationModal } from 'hise-components';
|
|
5
|
+
import { useGraph } from '../../../../state/GraphContext';
|
|
6
|
+
import MetadataTable from './MetadataTable';
|
|
7
|
+
import { getHeader, getTabs, hasMetadata } from './helpers';
|
|
8
|
+
import { getSchemes } from '../../CertificateGraph/helpers';
|
|
9
|
+
|
|
10
|
+
const Tabs = ({ tabs, activeTab, setActiveTab }: {
|
|
11
|
+
tabs: Array<string>,
|
|
12
|
+
activeTab: string,
|
|
13
|
+
setActiveTab: Function,
|
|
14
|
+
}) => (
|
|
15
|
+
<ul className="nav justify-content-center">
|
|
16
|
+
{tabs.map((tab) => (
|
|
17
|
+
<li className="nav-item" key={tab}>
|
|
18
|
+
<button
|
|
19
|
+
type="button"
|
|
20
|
+
className={`nav-link btn btn-link ${(activeTab === tab) && 'font-weight-bold'}`}
|
|
21
|
+
onClick={() => setActiveTab(tab)}
|
|
22
|
+
>
|
|
23
|
+
{tab.split(/(?=[A-Z])/).join(' ').toUpperCase()}
|
|
24
|
+
</button>
|
|
25
|
+
</li>
|
|
26
|
+
))}
|
|
27
|
+
</ul>
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
export const MetadataButton = ({ label, node }: {
|
|
31
|
+
label: string,
|
|
32
|
+
node: NodeProps,
|
|
33
|
+
}) => {
|
|
34
|
+
const { certificate, setNode } = useGraph();
|
|
35
|
+
|
|
36
|
+
if (!['Sample', 'Subject'].includes(label)) return null;
|
|
37
|
+
|
|
38
|
+
const { metadata } = certificate;
|
|
39
|
+
const { toggleMetadataModal } = node.data;
|
|
40
|
+
|
|
41
|
+
const showButton = hasMetadata(metadata, node.id);
|
|
42
|
+
|
|
43
|
+
if (!showButton || !toggleMetadataModal) return null;
|
|
44
|
+
|
|
45
|
+
return (
|
|
46
|
+
<Button
|
|
47
|
+
id="metadata-btn"
|
|
48
|
+
key="metadata-btn"
|
|
49
|
+
color="link"
|
|
50
|
+
className="p-0"
|
|
51
|
+
style={{ lineHeight: 'normal' }}
|
|
52
|
+
onClick={() => {
|
|
53
|
+
toggleMetadataModal();
|
|
54
|
+
setNode(node);
|
|
55
|
+
}}
|
|
56
|
+
>
|
|
57
|
+
<span style={{ fontSize: '1.75rem' }}>≡</span>
|
|
58
|
+
</Button>
|
|
59
|
+
);
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
interface Modal {
|
|
63
|
+
activeTab: string,
|
|
64
|
+
description: string,
|
|
65
|
+
header: string,
|
|
66
|
+
tabs: Array<string>,
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
const MetadataModal = ({ isOpen, toggle }: {
|
|
70
|
+
isOpen: boolean,
|
|
71
|
+
toggle: Function,
|
|
72
|
+
}) => {
|
|
73
|
+
const { node, certificate } = useGraph();
|
|
74
|
+
const { id } = node;
|
|
75
|
+
const {
|
|
76
|
+
metadata,
|
|
77
|
+
schemes,
|
|
78
|
+
serviceLabels,
|
|
79
|
+
customLabels,
|
|
80
|
+
generatedLabels,
|
|
81
|
+
} = certificate;
|
|
82
|
+
|
|
83
|
+
const [nodeMetadata, setNodeMetadata] = useState({});
|
|
84
|
+
const [nodeSchemes, setNodeSchemes] = useState({});
|
|
85
|
+
const [modal, setModal] = useState<Modal>({
|
|
86
|
+
activeTab: '',
|
|
87
|
+
description: '',
|
|
88
|
+
header: '',
|
|
89
|
+
tabs: [],
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
useEffect(() => {
|
|
93
|
+
if (!isOpen || R.isEmpty(metadata) || R.isEmpty(node)) return;
|
|
94
|
+
|
|
95
|
+
const md = metadata[node.id];
|
|
96
|
+
|
|
97
|
+
const label = id?.split('/')[0];
|
|
98
|
+
const description = customLabels[id] || generatedLabels[id];
|
|
99
|
+
const header = getHeader(label, description);
|
|
100
|
+
const metadataTabs: string[] = getTabs(md);
|
|
101
|
+
|
|
102
|
+
const schemeObject = getSchemes(label, id, serviceLabels, schemes);
|
|
103
|
+
|
|
104
|
+
setNodeMetadata(md);
|
|
105
|
+
setNodeSchemes(schemeObject);
|
|
106
|
+
setModal((prevState) => ({
|
|
107
|
+
...prevState,
|
|
108
|
+
activeTab: metadataTabs[0],
|
|
109
|
+
description: description,
|
|
110
|
+
header: header,
|
|
111
|
+
tabs: metadataTabs,
|
|
112
|
+
}));
|
|
113
|
+
}, [isOpen, node, metadata]);
|
|
114
|
+
|
|
115
|
+
const setActiveTab = (tab: string) => setModal((prevState) => ({ ...prevState, activeTab: tab }));
|
|
116
|
+
|
|
117
|
+
return (
|
|
118
|
+
<ConfirmationModal
|
|
119
|
+
scrollable
|
|
120
|
+
isOpen={isOpen}
|
|
121
|
+
onClose={toggle}
|
|
122
|
+
headerContent={modal.header}
|
|
123
|
+
noSubmit
|
|
124
|
+
cancelButtonText="Close"
|
|
125
|
+
content={(
|
|
126
|
+
<>
|
|
127
|
+
<Tabs tabs={modal.tabs} activeTab={modal.activeTab} setActiveTab={setActiveTab} />
|
|
128
|
+
|
|
129
|
+
<div className="mt-2">
|
|
130
|
+
<MetadataTable
|
|
131
|
+
metadata={nodeMetadata}
|
|
132
|
+
scheme={nodeSchemes}
|
|
133
|
+
activeTab={modal.activeTab}
|
|
134
|
+
/>
|
|
135
|
+
</div>
|
|
136
|
+
</>
|
|
137
|
+
)}
|
|
138
|
+
/>
|
|
139
|
+
);
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
export default MetadataModal;
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { Handle, Position, NodeProps } from 'reactflow';
|
|
3
|
+
import { useGraph } from '../../../state/GraphContext';
|
|
3
4
|
import { MetadataButton } from './MetadataModal/index';
|
|
4
5
|
import { Description, Label } from '../CertificateGraph/NodeAttributes';
|
|
5
6
|
|
|
6
7
|
const ReadNode = (props: NodeProps) => {
|
|
7
|
-
const {
|
|
8
|
+
const { id } = props;
|
|
9
|
+
const { customLabels, generatedLabels } = useGraph().certificate;
|
|
10
|
+
|
|
11
|
+
const label = id.split('/')[0];
|
|
12
|
+
const description = customLabels[id] || generatedLabels[id];
|
|
8
13
|
|
|
9
14
|
return (
|
|
10
15
|
<React.Fragment>
|
|
@@ -17,7 +22,7 @@ const ReadNode = (props: NodeProps) => {
|
|
|
17
22
|
<div className="d-flex align-items-center">
|
|
18
23
|
<Label label={label} description={description} />
|
|
19
24
|
|
|
20
|
-
<MetadataButton node={props
|
|
25
|
+
<MetadataButton label={label} node={props} />
|
|
21
26
|
</div>
|
|
22
27
|
|
|
23
28
|
<Description label={label} description={description} />
|
|
@@ -2,7 +2,6 @@ import React, { useState } from 'react';
|
|
|
2
2
|
import CertificateGraph from '../CertificateGraph/index';
|
|
3
3
|
import MetadataModal from './MetadataModal/index';
|
|
4
4
|
import { getNodesAndEdges } from '../CertificateGraph/helpers';
|
|
5
|
-
import { getReadNodeData } from './helpers';
|
|
6
5
|
import { Certificate } from '../../../@types/CertificateTypes';
|
|
7
6
|
|
|
8
7
|
const ReadCertificate = ({ certificate }: { certificate: Certificate }) => {
|
|
@@ -10,11 +9,11 @@ const ReadCertificate = ({ certificate }: { certificate: Certificate }) => {
|
|
|
10
9
|
const toggle = () => setIsMetadataModalOpen(!isMetadataModalOpen);
|
|
11
10
|
|
|
12
11
|
const type = 'readNode';
|
|
13
|
-
const data =
|
|
12
|
+
const data = { toggleMetadataModal: toggle };
|
|
14
13
|
const graph = getNodesAndEdges(
|
|
15
14
|
certificate.vertices,
|
|
16
15
|
certificate.edges,
|
|
17
|
-
certificate.
|
|
16
|
+
certificate.restrictedAssets,
|
|
18
17
|
type,
|
|
19
18
|
data,
|
|
20
19
|
);
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import React, { useEffect, useState } from 'react';
|
|
2
|
+
import { toast } from 'react-toastify';
|
|
3
|
+
import { Button, ConfirmationModal, ResourceEditor } from 'hise-components';
|
|
4
|
+
import { useGraph } from '../../../../state/GraphContext';
|
|
5
|
+
import { getFilteredRestrictedAssets, getFormControls } from '../helpers';
|
|
6
|
+
|
|
7
|
+
type ModalProps = {
|
|
8
|
+
isOpen: boolean,
|
|
9
|
+
onClose: Function,
|
|
10
|
+
refresh: Function,
|
|
11
|
+
handleUpdate: Function,
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const RestrictNodeModal: React.FC<ModalProps> = ({
|
|
15
|
+
isOpen,
|
|
16
|
+
onClose,
|
|
17
|
+
refresh,
|
|
18
|
+
handleUpdate,
|
|
19
|
+
}) => {
|
|
20
|
+
const { node, certificate } = useGraph();
|
|
21
|
+
const { restrictedAssets } = certificate;
|
|
22
|
+
|
|
23
|
+
const restrictionObject = restrictedAssets ? restrictedAssets[node.id] : undefined;
|
|
24
|
+
|
|
25
|
+
const initialFormData = {
|
|
26
|
+
restrictionNotes: restrictionObject ? restrictionObject.restrictionNotes : '',
|
|
27
|
+
restrictionInstructions: restrictionObject ? restrictionObject.restrictionInstructions : ''
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const [formData, setFormData] = useState(initialFormData);
|
|
31
|
+
const [isLoading, setIsLoading] = useState(false);
|
|
32
|
+
|
|
33
|
+
const [
|
|
34
|
+
isConfirmRemoveRestrictionModalOpen,
|
|
35
|
+
setIsConfirmRemoveRestrictionModalOpen
|
|
36
|
+
] = useState(false);
|
|
37
|
+
|
|
38
|
+
useEffect(() => {
|
|
39
|
+
setFormData(initialFormData);
|
|
40
|
+
}, [restrictionObject]);
|
|
41
|
+
|
|
42
|
+
const clearForm = () => {
|
|
43
|
+
setFormData(initialFormData);
|
|
44
|
+
setIsLoading(false);
|
|
45
|
+
onClose();
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const handleRemoveRestriction = async () => {
|
|
49
|
+
setIsLoading(true);
|
|
50
|
+
|
|
51
|
+
handleUpdate({
|
|
52
|
+
restrictedAssets: getFilteredRestrictedAssets(node.id, restrictedAssets)
|
|
53
|
+
}).then((response: Response) => {
|
|
54
|
+
if (response?.status === 200) {
|
|
55
|
+
toast.success('Successfully removed restrictions!');
|
|
56
|
+
setIsLoading(false);
|
|
57
|
+
setIsConfirmRemoveRestrictionModalOpen(false);
|
|
58
|
+
onClose();
|
|
59
|
+
refresh();
|
|
60
|
+
} else {
|
|
61
|
+
setIsLoading(false);
|
|
62
|
+
}
|
|
63
|
+
}).catch((error: any) => {
|
|
64
|
+
setIsLoading(false);
|
|
65
|
+
toast.error(`Request failed, ${error.toString()}`);
|
|
66
|
+
})
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
const handleRestrict = async () => {
|
|
70
|
+
if (formData.restrictionInstructions.length < 1 || formData.restrictionNotes.length < 1) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
setIsLoading(true);
|
|
75
|
+
|
|
76
|
+
const preparedData = {
|
|
77
|
+
[node.id]: formData
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
handleUpdate({
|
|
81
|
+
restrictedAssets: {
|
|
82
|
+
...restrictedAssets,
|
|
83
|
+
...preparedData,
|
|
84
|
+
},
|
|
85
|
+
}).then((response: Response) => {
|
|
86
|
+
if (response?.status === 200) {
|
|
87
|
+
toast.success('Asset has been successfully restricted!')
|
|
88
|
+
setIsLoading(false);
|
|
89
|
+
onClose();
|
|
90
|
+
setFormData(initialFormData);
|
|
91
|
+
refresh();
|
|
92
|
+
} else {
|
|
93
|
+
setIsLoading(false);
|
|
94
|
+
toast.error(`Request failed...`);
|
|
95
|
+
}
|
|
96
|
+
}).catch((error: any) => {
|
|
97
|
+
setIsLoading(false);
|
|
98
|
+
toast.error(`Request failed, ${error.toString()}`);
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
return (
|
|
103
|
+
<>
|
|
104
|
+
<ConfirmationModal
|
|
105
|
+
id='restrict-removal-confirmation'
|
|
106
|
+
isOpen={isConfirmRemoveRestrictionModalOpen}
|
|
107
|
+
onClose={() => setIsConfirmRemoveRestrictionModalOpen(false)}
|
|
108
|
+
onSubmit={handleRemoveRestriction}
|
|
109
|
+
submitButtonText='Confirm'
|
|
110
|
+
pending={isLoading}
|
|
111
|
+
headerContent='Do you confirm the removal of restrictions for this node?'
|
|
112
|
+
/>
|
|
113
|
+
<ConfirmationModal
|
|
114
|
+
id="restrict-single-node-modal"
|
|
115
|
+
isOpen={isOpen}
|
|
116
|
+
onClose={onClose}
|
|
117
|
+
size='lg'
|
|
118
|
+
headerContent="Change Node Restrictions"
|
|
119
|
+
noSubmit
|
|
120
|
+
noCancel
|
|
121
|
+
disabled={isLoading}
|
|
122
|
+
content={<>
|
|
123
|
+
<ResourceEditor
|
|
124
|
+
className=""
|
|
125
|
+
onChange={(l: any) => setFormData(l)}
|
|
126
|
+
editedResource={formData}
|
|
127
|
+
controls={getFormControls()}
|
|
128
|
+
/>
|
|
129
|
+
<div
|
|
130
|
+
className="float-right mt-3 d-flex flex-wrap"
|
|
131
|
+
style={{ gap: '0.5rem', padding: '0 15px' }}
|
|
132
|
+
>
|
|
133
|
+
<Button onClick={clearForm}>
|
|
134
|
+
Cancel
|
|
135
|
+
</Button>
|
|
136
|
+
{restrictionObject && (
|
|
137
|
+
<Button
|
|
138
|
+
color='danger'
|
|
139
|
+
onClick={() => setIsConfirmRemoveRestrictionModalOpen(true)}
|
|
140
|
+
pending={isLoading}
|
|
141
|
+
>
|
|
142
|
+
Remove Restrictions
|
|
143
|
+
</Button>
|
|
144
|
+
)}
|
|
145
|
+
<Button
|
|
146
|
+
color='primary'
|
|
147
|
+
onClick={handleRestrict}
|
|
148
|
+
pending={isLoading}
|
|
149
|
+
>
|
|
150
|
+
{restrictionObject && ('Update Restrictions')}
|
|
151
|
+
{!restrictionObject && ('Restrict')}
|
|
152
|
+
</Button>
|
|
153
|
+
</div>
|
|
154
|
+
</>}
|
|
155
|
+
>
|
|
156
|
+
</ConfirmationModal>
|
|
157
|
+
</>
|
|
158
|
+
)
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
export default RestrictNodeModal;
|
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { Handle, Position, NodeProps } from 'reactflow';
|
|
3
|
+
import { useGraph } from '../../../state/GraphContext';
|
|
3
4
|
import { ReviewBtn } from './ReviewNodes';
|
|
4
5
|
import { Description, Label } from '../CertificateGraph/NodeAttributes';
|
|
5
6
|
import { MetadataButton } from '../ReadCertificate/MetadataModal';
|
|
6
7
|
import { getLabelLink } from '../CertificateGraph/helpers';
|
|
7
8
|
|
|
8
9
|
const ReviewNode = (props: NodeProps) => {
|
|
9
|
-
const {
|
|
10
|
+
const { certificate } = useGraph();
|
|
11
|
+
const { id } = props;
|
|
10
12
|
|
|
11
|
-
const [label, guid] =
|
|
12
|
-
const
|
|
13
|
+
const [label, guid] = id.split('/');
|
|
14
|
+
const description = certificate.customLabels[id] || certificate.generatedLabels[id];
|
|
15
|
+
const link = getLabelLink(label, guid, certificate.isExecutable);
|
|
13
16
|
|
|
14
17
|
return (
|
|
15
18
|
<>
|
|
@@ -22,9 +25,9 @@ const ReviewNode = (props: NodeProps) => {
|
|
|
22
25
|
<div className="d-flex align-items-center">
|
|
23
26
|
<Label link={link} label={label} description={description} />
|
|
24
27
|
|
|
25
|
-
<ReviewBtn node={props
|
|
28
|
+
<ReviewBtn node={props} />
|
|
26
29
|
|
|
27
|
-
<MetadataButton node={props
|
|
30
|
+
<MetadataButton label={label} node={props} />
|
|
28
31
|
</div>
|
|
29
32
|
|
|
30
33
|
<Description label={label} description={description} />
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import React, { useState } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { NodeProps } from 'reactflow';
|
|
3
3
|
import { Button, ConfirmationModal, ResourceEditor, MessageStripe } from 'hise-components';
|
|
4
4
|
import { useGraph } from '../../../../state/GraphContext';
|
|
5
5
|
import { getFormControls } from '../helpers';
|
|
6
6
|
import { Response } from '../../../../@types/GeneralTypes';
|
|
7
7
|
|
|
8
|
-
export const ReviewBtn = ({ node }: { node:
|
|
8
|
+
export const ReviewBtn = ({ node }: { node: NodeProps }) => {
|
|
9
9
|
const { setNode } = useGraph();
|
|
10
|
+
const { toggleReviewModal } = node.data;
|
|
10
11
|
|
|
11
|
-
const
|
|
12
|
+
const label = node.id.split('/')[0];
|
|
12
13
|
|
|
13
14
|
if (!['File', 'IDE'].includes(label)) return null;
|
|
14
15
|
|
|
@@ -21,7 +22,7 @@ export const ReviewBtn = ({ node }: { node: Node['data'] }) => {
|
|
|
21
22
|
icon="fa-edit"
|
|
22
23
|
noText
|
|
23
24
|
onClick={() => {
|
|
24
|
-
toggleReviewModal
|
|
25
|
+
toggleReviewModal();
|
|
25
26
|
setNode(node);
|
|
26
27
|
}}
|
|
27
28
|
/>
|
|
@@ -1,58 +1,6 @@
|
|
|
1
1
|
import { CSSProperties } from 'react';
|
|
2
|
-
import { Node } from 'reactflow';
|
|
3
|
-
import * as R from 'ramda';
|
|
4
|
-
import { getSchemes } from '../CertificateGraph/helpers';
|
|
5
|
-
import { Certificate, AssetReview, AssetReviewStatus } from '../../../@types/CertificateTypes';
|
|
6
2
|
|
|
7
|
-
export const
|
|
8
|
-
vertices: Certificate['vertices'],
|
|
9
|
-
certificate: Certificate,
|
|
10
|
-
toggleReviewModal: Function,
|
|
11
|
-
toggleMetadataModal: Function,
|
|
12
|
-
) => {
|
|
13
|
-
const data: { [key: string]: Node['data'] } = {};
|
|
14
|
-
|
|
15
|
-
const {
|
|
16
|
-
id,
|
|
17
|
-
isExecutable,
|
|
18
|
-
generatedLabels,
|
|
19
|
-
customLabels,
|
|
20
|
-
serviceLabels,
|
|
21
|
-
schemes,
|
|
22
|
-
metadata,
|
|
23
|
-
assetReviews,
|
|
24
|
-
} = certificate;
|
|
25
|
-
|
|
26
|
-
if (R.isEmpty(vertices) || R.isNil(vertices)) return data;
|
|
27
|
-
|
|
28
|
-
vertices.forEach((vertex: string) => {
|
|
29
|
-
const label = vertex.split('/')[0];
|
|
30
|
-
const description = customLabels[vertex] || generatedLabels[vertex];
|
|
31
|
-
const assetReview = ['File', 'IDE'].includes(label)
|
|
32
|
-
? R.find(R.propEq('vertex', vertex))(assetReviews)
|
|
33
|
-
: {};
|
|
34
|
-
const otherReviews = R.reject((review: AssetReview) => (review.vertex === vertex), assetReviews);
|
|
35
|
-
|
|
36
|
-
data[vertex] = {
|
|
37
|
-
vertex,
|
|
38
|
-
label,
|
|
39
|
-
description,
|
|
40
|
-
assetReview,
|
|
41
|
-
otherReviews,
|
|
42
|
-
certificate,
|
|
43
|
-
schemes: getSchemes(vertex, serviceLabels, schemes),
|
|
44
|
-
metadata: metadata ? metadata[vertex] : null,
|
|
45
|
-
certId: id,
|
|
46
|
-
toggleReviewModal,
|
|
47
|
-
toggleMetadataModal,
|
|
48
|
-
isExecutable,
|
|
49
|
-
};
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
return data;
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
export const getStyle = (type: string, assetReview: AssetReview | null) => {
|
|
3
|
+
export const getStyle = (type: string, isAssetRestricted: boolean) => {
|
|
56
4
|
const style: CSSProperties = {
|
|
57
5
|
backgroundColor: 'white',
|
|
58
6
|
borderRadius: '3px',
|
|
@@ -68,13 +16,10 @@ export const getStyle = (type: string, assetReview: AssetReview | null) => {
|
|
|
68
16
|
|
|
69
17
|
case 'File':
|
|
70
18
|
case 'IDE':
|
|
71
|
-
style.borderColor = '
|
|
19
|
+
style.borderColor = 'lightblue';
|
|
72
20
|
|
|
73
|
-
if (
|
|
21
|
+
if (isAssetRestricted) style.borderColor = 'orange';
|
|
74
22
|
|
|
75
|
-
if (assetReview.reviewStatus === AssetReviewStatus.Restricted) style.borderColor = 'blue';
|
|
76
|
-
if (assetReview.reviewStatus === AssetReviewStatus.Approved) style.borderColor = 'green';
|
|
77
|
-
if (assetReview.reviewStatus === AssetReviewStatus.Rejected) style.borderColor = 'red';
|
|
78
23
|
break;
|
|
79
24
|
|
|
80
25
|
default:
|
|
@@ -89,13 +34,26 @@ export const getFormControls = () => (
|
|
|
89
34
|
[
|
|
90
35
|
{
|
|
91
36
|
type: 'text',
|
|
92
|
-
key: '
|
|
93
|
-
label: '
|
|
37
|
+
key: 'restrictionNotes',
|
|
38
|
+
label: 'Restriction Notes',
|
|
39
|
+
invalid: (d: any) => d.restrictionNotes.length < 1
|
|
94
40
|
},
|
|
95
41
|
{
|
|
96
42
|
type: 'text',
|
|
97
43
|
key: 'restrictionInstructions',
|
|
98
44
|
label: 'Restriction Instructions',
|
|
45
|
+
invalid: (d: any) => d.restrictionInstructions.length < 1
|
|
99
46
|
},
|
|
100
47
|
]
|
|
101
48
|
);
|
|
49
|
+
|
|
50
|
+
export const getFilteredRestrictedAssets = (assetBeingRemoved: string, restrictedAssets: any) => {
|
|
51
|
+
const filtered = Object.keys(restrictedAssets)
|
|
52
|
+
.filter(key => key !== assetBeingRemoved)
|
|
53
|
+
.reduce((obj: any, key: any) => {
|
|
54
|
+
obj[key] = restrictedAssets[key];
|
|
55
|
+
return obj;
|
|
56
|
+
}, {});
|
|
57
|
+
|
|
58
|
+
return filtered;
|
|
59
|
+
}
|
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
import React, { useState } from 'react';
|
|
2
2
|
import CertificateGraph from '../CertificateGraph';
|
|
3
|
-
import
|
|
3
|
+
import RestrictNodeModal from './RestrictNode/index';
|
|
4
4
|
import MetadataModal from '../ReadCertificate/MetadataModal';
|
|
5
5
|
import { getNodesAndEdges } from '../CertificateGraph/helpers';
|
|
6
|
-
import {
|
|
6
|
+
import { Certificate } from '../../../@types/CertificateTypes';
|
|
7
7
|
|
|
8
|
-
const ReviewCertificate = ({ certificate, loading, userEmail, handleUpdate, refresh }
|
|
8
|
+
const ReviewCertificate = ({ certificate, loading, userEmail, handleUpdate, refresh }: {
|
|
9
|
+
certificate: Certificate,
|
|
10
|
+
loading: boolean,
|
|
11
|
+
userEmail: string,
|
|
12
|
+
handleUpdate: Function,
|
|
13
|
+
refresh: Function,
|
|
14
|
+
}) => {
|
|
9
15
|
const [isReviewModalOpen, setIsReviewModalOpen] = useState(false);
|
|
10
16
|
const toggleReviewModal = () => setIsReviewModalOpen(!isReviewModalOpen);
|
|
11
17
|
|
|
@@ -13,11 +19,11 @@ const ReviewCertificate = ({ certificate, loading, userEmail, handleUpdate, refr
|
|
|
13
19
|
const toggleMetadataModal = () => setIsMetadataModalOpen(!isMetadataModalOpen);
|
|
14
20
|
|
|
15
21
|
const type = 'reviewNode';
|
|
16
|
-
const data =
|
|
22
|
+
const data = { toggleReviewModal, toggleMetadataModal };
|
|
17
23
|
const graph = getNodesAndEdges(
|
|
18
24
|
certificate.vertices,
|
|
19
25
|
certificate.edges,
|
|
20
|
-
certificate.
|
|
26
|
+
certificate.restrictedAssets,
|
|
21
27
|
type,
|
|
22
28
|
data,
|
|
23
29
|
);
|
|
@@ -28,13 +34,11 @@ const ReviewCertificate = ({ certificate, loading, userEmail, handleUpdate, refr
|
|
|
28
34
|
certificate={certificate}
|
|
29
35
|
graph={graph}
|
|
30
36
|
>
|
|
31
|
-
<
|
|
37
|
+
<RestrictNodeModal
|
|
32
38
|
isOpen={isReviewModalOpen}
|
|
33
|
-
|
|
34
|
-
toggle={toggleReviewModal}
|
|
35
|
-
userEmail={userEmail}
|
|
36
|
-
handleUpdate={handleUpdate}
|
|
39
|
+
onClose={toggleReviewModal}
|
|
37
40
|
refresh={refresh}
|
|
41
|
+
handleUpdate={handleUpdate}
|
|
38
42
|
/>
|
|
39
43
|
|
|
40
44
|
<MetadataModal isOpen={isMetadataModalOpen} toggle={toggleMetadataModal} />
|
|
@@ -4,8 +4,11 @@ import { useGraph } from '../../../../state/GraphContext';
|
|
|
4
4
|
import { Description, Label } from '../../CertificateGraph/NodeAttributes';
|
|
5
5
|
|
|
6
6
|
const ReplicaIDENode = (props: NodeProps) => {
|
|
7
|
-
const {
|
|
8
|
-
const {
|
|
7
|
+
const { replica, certificate } = useGraph();
|
|
8
|
+
const { customLabels, generatedLabels } = certificate;
|
|
9
|
+
|
|
10
|
+
const label = props.id.split('/')[0];
|
|
11
|
+
const description = customLabels[props.id] || generatedLabels[props.id];
|
|
9
12
|
|
|
10
13
|
const originalIDEId = props.id.replace('-replica', '');
|
|
11
14
|
const ideId = replica?.matches[originalIDEId];
|
|
@@ -58,11 +58,13 @@ const ReplicaPipelineInfo = ({ pipeline }: { pipeline: Pipeline | null }) => {
|
|
|
58
58
|
};
|
|
59
59
|
|
|
60
60
|
const ReplicaPipelineNode = (props: NodeProps) => {
|
|
61
|
-
const {
|
|
62
|
-
const {
|
|
61
|
+
const { replica, certificate } = useGraph();
|
|
62
|
+
const { customLabels, generatedLabels } = certificate;
|
|
63
63
|
|
|
64
64
|
const [data, setData] = useState<Pipeline | null>(null);
|
|
65
65
|
|
|
66
|
+
const label = props.id.split('/')[0];
|
|
67
|
+
const description = customLabels[props.id] || generatedLabels[props.id];
|
|
66
68
|
const replicaPipelineId = props.id.replace('-replica', '');
|
|
67
69
|
|
|
68
70
|
const pipelineId = replica?.matches[replicaPipelineId];
|