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,106 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import { Handle, Position } from 'reactflow';
|
|
3
|
+
import { NodeProps } from 'reactflow';
|
|
4
|
+
import { ConfirmationModal, Button } from 'hise-components';
|
|
5
|
+
import { Label, Description } from '../../CertificateGraph/NodeAttributes';
|
|
6
|
+
import { useGraph } from '../../../../state/GraphContext';
|
|
7
|
+
import { RestrictedAssetObject } from '../../../../@types/CertificateTypes';
|
|
8
|
+
|
|
9
|
+
const NotesAndInstructionsModal = (props: {
|
|
10
|
+
restrictedAsset: RestrictedAssetObject,
|
|
11
|
+
isOpen: boolean,
|
|
12
|
+
toggle: Function,
|
|
13
|
+
}) => {
|
|
14
|
+
const { isOpen, toggle, restrictedAsset } = props;
|
|
15
|
+
|
|
16
|
+
if (!restrictedAsset) return null;
|
|
17
|
+
|
|
18
|
+
const restrictedAssetEntries = Object.entries(restrictedAsset);
|
|
19
|
+
|
|
20
|
+
const NotesAndInstructions = () => {
|
|
21
|
+
const LABELS: { [key: string]: string } = {
|
|
22
|
+
restrictionInstructions: 'Instructions',
|
|
23
|
+
restrictionNotes: 'Notes',
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
return (
|
|
27
|
+
<>
|
|
28
|
+
{restrictedAssetEntries.map(([key, value]: [string, string]) => (
|
|
29
|
+
<>
|
|
30
|
+
<h6>{LABELS[key]}</h6>
|
|
31
|
+
<p>
|
|
32
|
+
{value}
|
|
33
|
+
</p>
|
|
34
|
+
</>
|
|
35
|
+
))}
|
|
36
|
+
</>
|
|
37
|
+
);
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
return (
|
|
41
|
+
<ConfirmationModal
|
|
42
|
+
id="restricted-node-notes-modal"
|
|
43
|
+
isOpen={isOpen}
|
|
44
|
+
onClose={toggle}
|
|
45
|
+
headerContent="This asset has been restricted."
|
|
46
|
+
cancelButtonText="Close"
|
|
47
|
+
noSubmit
|
|
48
|
+
content={<NotesAndInstructions />}
|
|
49
|
+
/>
|
|
50
|
+
);
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
interface RestrictedNode extends NodeProps {
|
|
54
|
+
restrictedAsset: RestrictedAssetObject,
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
const RestrictedNode = (props: RestrictedNode) => {
|
|
58
|
+
const { restrictedAsset } = props;
|
|
59
|
+
const { certificate } = useGraph();
|
|
60
|
+
const { customLabels, generatedLabels } = certificate;
|
|
61
|
+
|
|
62
|
+
const [isModalOpen, setModalOpen] = useState(false);
|
|
63
|
+
const toggle = () => setModalOpen(!isModalOpen);
|
|
64
|
+
|
|
65
|
+
const label = props.id.split('/')[0];
|
|
66
|
+
const description = customLabels[props.id] || generatedLabels[props.id];
|
|
67
|
+
|
|
68
|
+
return (
|
|
69
|
+
<React.Fragment>
|
|
70
|
+
<NotesAndInstructionsModal
|
|
71
|
+
restrictedAsset={restrictedAsset}
|
|
72
|
+
isOpen={isModalOpen}
|
|
73
|
+
toggle={toggle}
|
|
74
|
+
/>
|
|
75
|
+
<Handle
|
|
76
|
+
type="target"
|
|
77
|
+
position={Position.Left}
|
|
78
|
+
/>
|
|
79
|
+
|
|
80
|
+
<div
|
|
81
|
+
style={{ width: '250px' }}
|
|
82
|
+
onClick={toggle}
|
|
83
|
+
>
|
|
84
|
+
<div className="label d-flex p-1">
|
|
85
|
+
<Label label={label} description={description} />
|
|
86
|
+
<Button
|
|
87
|
+
id={`${props.id}-restricted-btn`}
|
|
88
|
+
className="btn-sm text-warning btn-link"
|
|
89
|
+
icon="fas fa-lock"
|
|
90
|
+
noText
|
|
91
|
+
onClick={toggle}
|
|
92
|
+
/>
|
|
93
|
+
</div>
|
|
94
|
+
|
|
95
|
+
<Description label={label} description={description} />
|
|
96
|
+
</div>
|
|
97
|
+
|
|
98
|
+
<Handle
|
|
99
|
+
type="source"
|
|
100
|
+
position={Position.Right}
|
|
101
|
+
/>
|
|
102
|
+
</React.Fragment>
|
|
103
|
+
);
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
export default RestrictedNode;
|
|
@@ -3,11 +3,11 @@ import { NodeProps } from 'reactflow';
|
|
|
3
3
|
import { toast } from 'react-toastify';
|
|
4
4
|
import { ConfirmationModal } from 'hise-components';
|
|
5
5
|
import WorkspaceNode from '../WorkspaceNode';
|
|
6
|
+
import RestrictedNode from '../RestrictedNode';
|
|
6
7
|
import { useGraph } from '../../../../state/GraphContext';
|
|
7
8
|
import { copyFile } from './helpers';
|
|
8
9
|
|
|
9
10
|
const WorkspaceFileNode = (props: NodeProps) => {
|
|
10
|
-
const { refresh } = props.data;
|
|
11
11
|
const { certificate } = useGraph();
|
|
12
12
|
|
|
13
13
|
const [loading, setLoading] = useState<boolean>(false);
|
|
@@ -15,6 +15,10 @@ const WorkspaceFileNode = (props: NodeProps) => {
|
|
|
15
15
|
const [isFileModalOpen, setIsFileModalOpen] = useState(false);
|
|
16
16
|
const toggleFileModal = () => setIsFileModalOpen(!isFileModalOpen);
|
|
17
17
|
|
|
18
|
+
const restrictedAsset = certificate.restrictedAssets[props.id];
|
|
19
|
+
|
|
20
|
+
if (restrictedAsset) return <RestrictedNode {...props} restrictedAsset={restrictedAsset} />;
|
|
21
|
+
|
|
18
22
|
const onCopyFile = async () => {
|
|
19
23
|
setLoading(true);
|
|
20
24
|
|
|
@@ -22,7 +26,7 @@ const WorkspaceFileNode = (props: NodeProps) => {
|
|
|
22
26
|
await copyFile(props.id, certificate.id)
|
|
23
27
|
.then(async (resp) => {
|
|
24
28
|
if (resp.ok) {
|
|
25
|
-
refresh();
|
|
29
|
+
props.data.refresh();
|
|
26
30
|
toast.success('Copied file into exploration.')
|
|
27
31
|
} else {
|
|
28
32
|
const error: any = await resp.json();
|
|
@@ -3,14 +3,11 @@ import { NodeProps } from 'reactflow';
|
|
|
3
3
|
import { ConfirmationModal } from 'hise-components';
|
|
4
4
|
import WorkspaceNode from '../WorkspaceNode';
|
|
5
5
|
import ReplicaIDENode from '../ReplicaIDENode';
|
|
6
|
+
import RestrictedNode from '../RestrictedNode';
|
|
6
7
|
import { useGraph } from '../../../../state/GraphContext';
|
|
7
8
|
import { startIDE } from './helpers';
|
|
8
9
|
|
|
9
10
|
const WorkspaceIDENode = (props: NodeProps) => {
|
|
10
|
-
const { refresh, isReplicated } = props.data;
|
|
11
|
-
|
|
12
|
-
if (isReplicated) return <ReplicaIDENode {...props} />
|
|
13
|
-
|
|
14
11
|
const { certificate, replica } = useGraph();
|
|
15
12
|
|
|
16
13
|
const [loading, setLoading] = useState<boolean>(false);
|
|
@@ -18,6 +15,14 @@ const WorkspaceIDENode = (props: NodeProps) => {
|
|
|
18
15
|
const [isIDEModalOpen, setIsIDEModalOpen] = useState(false);
|
|
19
16
|
const toggleIDEModal = () => setIsIDEModalOpen(!isIDEModalOpen);
|
|
20
17
|
|
|
18
|
+
const restrictedAsset = certificate.restrictedAssets[props.id];
|
|
19
|
+
|
|
20
|
+
if (restrictedAsset) return <RestrictedNode {...props} restrictedAsset={restrictedAsset} />;
|
|
21
|
+
|
|
22
|
+
const isReplicated = replica.matches[props.id];
|
|
23
|
+
|
|
24
|
+
if (isReplicated) return <ReplicaIDENode {...props} />;
|
|
25
|
+
|
|
21
26
|
const onStartIDE = async () => {
|
|
22
27
|
setLoading(true);
|
|
23
28
|
|
|
@@ -27,7 +32,7 @@ const WorkspaceIDENode = (props: NodeProps) => {
|
|
|
27
32
|
certificate.id,
|
|
28
33
|
certificate.edges,
|
|
29
34
|
replica.matches,
|
|
30
|
-
refresh,
|
|
35
|
+
props.data.refresh,
|
|
31
36
|
toggleIDEModal,
|
|
32
37
|
);
|
|
33
38
|
} catch (error: any) {
|
|
@@ -1,17 +1,23 @@
|
|
|
1
1
|
import React, { useState } from 'react';
|
|
2
|
-
import { Handle, Position,
|
|
2
|
+
import { Handle, Position, Node } from 'reactflow';
|
|
3
3
|
import { Label, Description } from '../../CertificateGraph/NodeAttributes';
|
|
4
|
+
import { useGraph } from '../../../../state/GraphContext';
|
|
4
5
|
|
|
5
6
|
const WorkspaceNode = (props: {
|
|
6
7
|
id: string,
|
|
7
|
-
data:
|
|
8
|
+
data: Node['data'],
|
|
8
9
|
modal: React.ReactNode,
|
|
9
10
|
toggle: Function,
|
|
10
11
|
}) => {
|
|
11
|
-
const {
|
|
12
|
+
const { certificate, replica } = useGraph();
|
|
13
|
+
const { customLabels, generatedLabels } = certificate;
|
|
12
14
|
|
|
13
15
|
const [isHover, setIsHover] = useState(false);
|
|
14
16
|
|
|
17
|
+
const label = props.id.split('/')[0];
|
|
18
|
+
const description = customLabels[props.id] || generatedLabels[props.id];
|
|
19
|
+
const isReplicated = replica.matches[props.id];
|
|
20
|
+
|
|
15
21
|
return (
|
|
16
22
|
<React.Fragment>
|
|
17
23
|
{props.modal}
|
|
@@ -7,10 +7,6 @@ import PipelineModal from './PipelineModal';
|
|
|
7
7
|
import { startPipeline } from './helpers';
|
|
8
8
|
|
|
9
9
|
const WorkspacePipelineNode = (props: NodeProps) => {
|
|
10
|
-
const { refresh, isReplicated } = props.data;
|
|
11
|
-
|
|
12
|
-
if (isReplicated) return <ReplicaPipelineNode {...props} />
|
|
13
|
-
|
|
14
10
|
const { certificate, replica } = useGraph();
|
|
15
11
|
|
|
16
12
|
const [loading, setLoading] = useState<boolean>(false);
|
|
@@ -18,6 +14,10 @@ const WorkspacePipelineNode = (props: NodeProps) => {
|
|
|
18
14
|
const [isPipelineModalOpen, setIsPipelineModalOpen] = useState(false);
|
|
19
15
|
const togglePipelineModal = () => setIsPipelineModalOpen(!isPipelineModalOpen);
|
|
20
16
|
|
|
17
|
+
const isReplicated = replica.matches[props.id];
|
|
18
|
+
|
|
19
|
+
if (isReplicated) return <ReplicaPipelineNode {...props} />;
|
|
20
|
+
|
|
21
21
|
const onStartPipeline = async () => {
|
|
22
22
|
setLoading(true);
|
|
23
23
|
|
|
@@ -27,7 +27,7 @@ const WorkspacePipelineNode = (props: NodeProps) => {
|
|
|
27
27
|
certificate.id,
|
|
28
28
|
certificate.edges,
|
|
29
29
|
replica.matches,
|
|
30
|
-
refresh,
|
|
30
|
+
props.data.refresh,
|
|
31
31
|
togglePipelineModal,
|
|
32
32
|
);
|
|
33
33
|
} catch (error: any) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as R from 'ramda';
|
|
2
2
|
import { Edge, Node } from 'reactflow';
|
|
3
|
-
import { getStyle
|
|
3
|
+
import { getStyle } from '../CertificateGraph/helpers';
|
|
4
4
|
import { getLayoutedElements } from '../CertificateGraph/helpers';
|
|
5
5
|
import { Certificate, Replica } from '../../../@types/CertificateTypes';
|
|
6
6
|
|
|
@@ -38,45 +38,9 @@ const getWorkspaceStyle = (label: string, isReplicated: string | undefined) => {
|
|
|
38
38
|
return getStyle(label);
|
|
39
39
|
};
|
|
40
40
|
|
|
41
|
-
export const getWorkspaceData = (
|
|
42
|
-
vertices: Certificate['vertices'],
|
|
43
|
-
certificate: Certificate,
|
|
44
|
-
replica: Replica,
|
|
45
|
-
refresh: Function,
|
|
46
|
-
) => {
|
|
47
|
-
const data: { [key: string]: Node['data'] } = {};
|
|
48
|
-
|
|
49
|
-
const {
|
|
50
|
-
generatedLabels,
|
|
51
|
-
customLabels,
|
|
52
|
-
serviceLabels,
|
|
53
|
-
schemes,
|
|
54
|
-
metadata,
|
|
55
|
-
} = certificate;
|
|
56
|
-
|
|
57
|
-
if (R.isEmpty(vertices) || R.isNil(vertices)) return data;
|
|
58
|
-
|
|
59
|
-
vertices.forEach((vertex: string) => {
|
|
60
|
-
const label = vertex.split('/')[0];
|
|
61
|
-
const description = customLabels[vertex] || generatedLabels[vertex];
|
|
62
|
-
const isReplicated = replica.matches[vertex];
|
|
63
|
-
|
|
64
|
-
data[vertex] = {
|
|
65
|
-
label,
|
|
66
|
-
description,
|
|
67
|
-
customLabels,
|
|
68
|
-
metadata: metadata ? metadata[vertex] : null,
|
|
69
|
-
schemes: getSchemes(vertex, serviceLabels, schemes),
|
|
70
|
-
isReplicated,
|
|
71
|
-
refresh,
|
|
72
|
-
};
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
return data;
|
|
76
|
-
};
|
|
77
|
-
|
|
78
41
|
const getNodes = (
|
|
79
42
|
vertices: Certificate['vertices'],
|
|
43
|
+
replica: Replica,
|
|
80
44
|
data: { [key: string]: Node['data'] },
|
|
81
45
|
) => {
|
|
82
46
|
const position = { x: 0, y: 0 };
|
|
@@ -87,13 +51,14 @@ const getNodes = (
|
|
|
87
51
|
|
|
88
52
|
vertices.forEach((vertex: string) => {
|
|
89
53
|
const label = vertex.split('/')[0];
|
|
54
|
+
const isReplicated = replica.matches[vertex];
|
|
90
55
|
|
|
91
56
|
nodes.push({
|
|
92
57
|
id: vertex,
|
|
93
58
|
position,
|
|
94
59
|
type: getNodeType(label),
|
|
95
|
-
data
|
|
96
|
-
style: getWorkspaceStyle(label,
|
|
60
|
+
data,
|
|
61
|
+
style: getWorkspaceStyle(label, isReplicated),
|
|
97
62
|
});
|
|
98
63
|
});
|
|
99
64
|
|
|
@@ -132,9 +97,10 @@ const getCertificateAndReplicaEdges = (edges: Certificate['edges']) => {
|
|
|
132
97
|
export const getWorkspaceNodesAndEdges = (
|
|
133
98
|
vertices: Certificate['vertices'],
|
|
134
99
|
edges: Certificate['edges'],
|
|
100
|
+
replica: Replica,
|
|
135
101
|
data: { [key: string]: Node['data'] },
|
|
136
102
|
) => {
|
|
137
|
-
const initialNodes = getNodes(vertices, data);
|
|
103
|
+
const initialNodes = getNodes(vertices, replica, data);
|
|
138
104
|
const initialEdges = getCertificateAndReplicaEdges(edges);
|
|
139
105
|
|
|
140
106
|
const {
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import * as R from 'ramda';
|
|
3
|
-
import NodeProvider from '../../../state/GraphContext';
|
|
4
3
|
import CertificateGraph from '../CertificateGraph';
|
|
5
|
-
import {
|
|
4
|
+
import { getWorkspaceNodesAndEdges } from './helpers';
|
|
6
5
|
import { Certificate, Replica } from '../../../@types/CertificateTypes';
|
|
7
6
|
import './style.css';
|
|
8
7
|
|
|
@@ -14,22 +13,22 @@ const WorkspaceCertificate = ({ certificate, replica, refresh }: {
|
|
|
14
13
|
if (R.isNil(certificate) || R.isEmpty(certificate)) return;
|
|
15
14
|
if (R.isNil(replica) || R.isEmpty(replica)) return;
|
|
16
15
|
|
|
17
|
-
const
|
|
16
|
+
const type = "fileLayerNode";
|
|
17
|
+
const data = { refresh };
|
|
18
18
|
const graph = getWorkspaceNodesAndEdges(
|
|
19
19
|
certificate.vertices,
|
|
20
20
|
certificate.edges,
|
|
21
|
+
replica,
|
|
21
22
|
data,
|
|
22
23
|
);
|
|
23
24
|
|
|
24
25
|
return (
|
|
25
|
-
<
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
/>
|
|
32
|
-
</NodeProvider>
|
|
26
|
+
<CertificateGraph
|
|
27
|
+
type={type}
|
|
28
|
+
certificate={certificate}
|
|
29
|
+
replica={replica}
|
|
30
|
+
graph={graph}
|
|
31
|
+
/>
|
|
33
32
|
);
|
|
34
33
|
};
|
|
35
34
|
|
|
@@ -1,13 +1,3 @@
|
|
|
1
|
-
/* .workspace-certificate {
|
|
2
|
-
|
|
3
|
-
.react-flow__node-pipelineNode:hover,
|
|
4
|
-
.react-flow__node-IDENode:hover,
|
|
5
|
-
.react-flow__node-visualizationNode:hover,
|
|
6
|
-
.react-flow__node-fileNode:hover {
|
|
7
|
-
box-shadow: 0 0 0 8px yellow !important;
|
|
8
|
-
}
|
|
9
|
-
} */
|
|
10
|
-
|
|
11
1
|
.action-hover {
|
|
12
2
|
box-shadow: 0 0 2px 8px yellow !important;
|
|
13
3
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import ReadCertificate from './components/Certificates/ReadCertificate/index';
|
|
2
2
|
import EditCertificate from './components/Certificates/EditCertificate/index';
|
|
3
3
|
import ReviewCertificate from './components/Certificates/ReviewCertificate/index';
|
|
4
|
-
import AllNodesModal from './components/Certificates/ReviewCertificate/ReviewNodes/AllNodesModal';
|
|
5
4
|
import WorkspaceCertificate from './components/Certificates/WorkspaceCertificate/index';
|
|
5
|
+
import getCertificateBody from './utils/getCertificateBody';
|
|
6
6
|
|
|
7
7
|
export {
|
|
8
8
|
ReadCertificate,
|
|
9
9
|
EditCertificate,
|
|
10
10
|
ReviewCertificate,
|
|
11
|
-
AllNodesModal,
|
|
12
11
|
WorkspaceCertificate,
|
|
12
|
+
getCertificateBody,
|
|
13
13
|
};
|
|
@@ -2,19 +2,17 @@ import React, {
|
|
|
2
2
|
useState,
|
|
3
3
|
useContext,
|
|
4
4
|
createContext,
|
|
5
|
+
useMemo,
|
|
5
6
|
} from 'react';
|
|
6
7
|
import { useNodesState, useEdgesState, Node } from 'reactflow';
|
|
7
8
|
import { Certificate, Replica, NodeLayers } from '../@types/CertificateTypes';
|
|
8
9
|
|
|
9
10
|
type GraphContextType = {
|
|
10
11
|
certificate: Certificate | any,
|
|
11
|
-
setCertificate: (p: Certificate) => void,
|
|
12
12
|
node: Node | any,
|
|
13
13
|
setNode: (p: Node | object) => void,
|
|
14
14
|
type: string,
|
|
15
|
-
setType: (p: string) => void,
|
|
16
15
|
replica: Replica | any,
|
|
17
|
-
setReplica: (p: Replica | object) => void,
|
|
18
16
|
nodesState: any,
|
|
19
17
|
edgesState: any,
|
|
20
18
|
nodeLayers: NodeLayers,
|
|
@@ -23,13 +21,10 @@ type GraphContextType = {
|
|
|
23
21
|
|
|
24
22
|
const GraphContext = createContext<GraphContextType>({
|
|
25
23
|
certificate: {},
|
|
26
|
-
setCertificate: () => { },
|
|
27
24
|
node: {},
|
|
28
25
|
setNode: () => { },
|
|
29
26
|
type: 'readNode',
|
|
30
|
-
setType: () => { },
|
|
31
27
|
replica: {},
|
|
32
|
-
setReplica: () => { },
|
|
33
28
|
nodesState: [],
|
|
34
29
|
edgesState: [],
|
|
35
30
|
nodeLayers: {
|
|
@@ -45,14 +40,13 @@ const GraphContext = createContext<GraphContextType>({
|
|
|
45
40
|
setNodeLayers: () => { },
|
|
46
41
|
});
|
|
47
42
|
|
|
48
|
-
const GraphProvider = (
|
|
43
|
+
const GraphProvider = (props: {
|
|
44
|
+
type: string,
|
|
45
|
+
certificate: Certificate,
|
|
46
|
+
replica?: Replica,
|
|
47
|
+
children: React.ReactNode,
|
|
48
|
+
}) => {
|
|
49
49
|
const [node, setNode] = useState({});
|
|
50
|
-
|
|
51
|
-
const [type, setType] = useState('readNode');
|
|
52
|
-
|
|
53
|
-
const [certificate, setCertificate] = useState({});
|
|
54
|
-
const [replica, setReplica] = useState({});
|
|
55
|
-
|
|
56
50
|
const [nodeLayers, setNodeLayers] = useState<NodeLayers>({
|
|
57
51
|
previous: {
|
|
58
52
|
nodes: [],
|
|
@@ -67,24 +61,31 @@ const GraphProvider = ({ children }: any) => {
|
|
|
67
61
|
const nodesState = useNodesState([]); // [nodes, setNodes, onNodesChange]
|
|
68
62
|
const edgesState = useEdgesState([]); // [edges, setEdges, onEdgesChange]
|
|
69
63
|
|
|
70
|
-
const contextValue = {
|
|
64
|
+
const contextValue = useMemo(() => ({
|
|
65
|
+
node,
|
|
66
|
+
setNode,
|
|
67
|
+
type: props.type,
|
|
68
|
+
certificate: props.certificate,
|
|
69
|
+
replica: props.replica,
|
|
70
|
+
nodeLayers,
|
|
71
|
+
setNodeLayers,
|
|
72
|
+
nodesState,
|
|
73
|
+
edgesState,
|
|
74
|
+
}), [
|
|
71
75
|
node,
|
|
72
76
|
setNode,
|
|
73
|
-
type,
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
setCertificate,
|
|
77
|
-
replica,
|
|
78
|
-
setReplica,
|
|
77
|
+
props.type,
|
|
78
|
+
props.certificate,
|
|
79
|
+
props.replica,
|
|
79
80
|
nodeLayers,
|
|
80
81
|
setNodeLayers,
|
|
81
82
|
nodesState,
|
|
82
83
|
edgesState,
|
|
83
|
-
|
|
84
|
+
]);
|
|
84
85
|
|
|
85
86
|
return (
|
|
86
87
|
<GraphContext.Provider value={contextValue}>
|
|
87
|
-
{children}
|
|
88
|
+
{props.children}
|
|
88
89
|
</GraphContext.Provider>
|
|
89
90
|
);
|
|
90
91
|
};
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import process from 'process';
|
|
2
|
+
|
|
3
|
+
const hasValidId = (id: string) => {
|
|
4
|
+
if (!id) return true;
|
|
5
|
+
return (id !== 'ffffffff-ffff-ffff-ffff-ffffffffffff');
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
const certificateEndpoint = (certId: string, isPublic: boolean) => (
|
|
9
|
+
`${process.env.REACT_APP_HISE_BASE_URL}`
|
|
10
|
+
+ `/${isPublic ? 'public' : 'publishing'}/certificate/${certId}`
|
|
11
|
+
);
|
|
12
|
+
|
|
13
|
+
const certificateLabelsEndpoint = (labelsId: string, isPublic: boolean) => (
|
|
14
|
+
`${process.env.REACT_APP_HISE_BASE_URL}`
|
|
15
|
+
+ `/${isPublic ? 'public' : 'publishing'}/certificate/labels/${labelsId}`
|
|
16
|
+
);
|
|
17
|
+
|
|
18
|
+
const certificateMetadataEndpoint = (metadataId: string, isPublic: boolean) => (
|
|
19
|
+
`${process.env.REACT_APP_HISE_BASE_URL}`
|
|
20
|
+
+ `/${isPublic ? 'public' : 'publishing'}/certificate/metadata/${metadataId}`
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
export const certificateSchemesEndpoint = (schemesId: string, isPublic: boolean) => (
|
|
24
|
+
`${process.env.REACT_APP_HISE_BASE_URL}`
|
|
25
|
+
+ `/${isPublic ? 'public' : 'publishing'}/certificate/schemes/${schemesId}`
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
const getCertificateBody = async (certificateId: string, isPublic: boolean = true, setResponse?: Function) => {
|
|
29
|
+
const certificateResponse = await fetch(
|
|
30
|
+
certificateEndpoint(certificateId, isPublic),
|
|
31
|
+
{ credentials: 'include' },
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
if (setResponse) setResponse(certificateResponse);
|
|
35
|
+
|
|
36
|
+
const certificateData = await certificateResponse.json();
|
|
37
|
+
|
|
38
|
+
let mergedCertificate = { ...certificateData };
|
|
39
|
+
|
|
40
|
+
const { labelsId, metadataId, schemesId } = certificateData;
|
|
41
|
+
|
|
42
|
+
if (hasValidId(labelsId)) {
|
|
43
|
+
const labelsResponse = await fetch(
|
|
44
|
+
certificateLabelsEndpoint(labelsId, isPublic),
|
|
45
|
+
{ credentials: 'include' },
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
const labelsData = await labelsResponse.json();
|
|
49
|
+
|
|
50
|
+
mergedCertificate = {
|
|
51
|
+
...mergedCertificate,
|
|
52
|
+
customLabels: labelsData.customLabels,
|
|
53
|
+
generatedLabels: labelsData.generatedLabels,
|
|
54
|
+
serviceLabels: labelsData.serviceLabels,
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
if (hasValidId(metadataId)) {
|
|
59
|
+
const metadataResponse = await fetch(
|
|
60
|
+
certificateMetadataEndpoint(metadataId, isPublic),
|
|
61
|
+
{ credentials: 'include' },
|
|
62
|
+
);
|
|
63
|
+
|
|
64
|
+
const metadataData = await metadataResponse.json();
|
|
65
|
+
|
|
66
|
+
mergedCertificate = {
|
|
67
|
+
...mergedCertificate,
|
|
68
|
+
metadata: metadataData.metadata,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if (hasValidId(schemesId)) {
|
|
73
|
+
const schemesResponse = await fetch(
|
|
74
|
+
certificateSchemesEndpoint(schemesId, isPublic),
|
|
75
|
+
{ credentials: 'include' },
|
|
76
|
+
);
|
|
77
|
+
|
|
78
|
+
const schemesData = await schemesResponse.json();
|
|
79
|
+
|
|
80
|
+
mergedCertificate = {
|
|
81
|
+
...mergedCertificate,
|
|
82
|
+
schemes: schemesData.schemes,
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
return mergedCertificate;
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
export default getCertificateBody;
|