-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathResourcesTreeNode.tsx
120 lines (117 loc) · 4.28 KB
/
ResourcesTreeNode.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
// SPDX-FileCopyrightText: Meta Platforms, Inc. and its affiliates
// SPDX-FileCopyrightText: TNG Technology Consulting GmbH <https://www.tngtech.com>
//
// SPDX-License-Identifier: Apache-2.0
import { useAppSelector } from '../../../../state/hooks';
import {
getAttributionBreakpoints,
getClassifications,
getExternalAttributions,
getFilesWithChildren,
getManualAttributions,
getResolvedExternalAttributions,
getResourcesToExternalAttributions,
getResourcesToManualAttributions,
getResourcesWithExternalAttributedChildren,
getResourcesWithManualAttributedChildren,
} from '../../../../state/selectors/resource-selectors';
import { useShowClassifications } from '../../../../state/variables/use-show-classifications';
import { useShowCriticality } from '../../../../state/variables/use-show-criticality';
import { TreeNode } from '../../../VirtualizedTree/VirtualizedTreeNode/VirtualizedTreeNode';
import {
containsExternalAttribution,
containsManualAttribution,
containsResourcesWithOnlyExternalAttribution,
getClassification,
getCriticality,
getDisplayName,
hasExternalAttribution,
hasManualAttribution,
hasParentWithManualAttributionAndNoOwnAttribution,
hasUnresolvedExternalAttribution,
} from './ResourcesTreeNode.util';
import { ResourcesTreeNodeLabel } from './ResourcesTreeNodeLabel/ResourcesTreeNodeLabel';
export function ResourcesTreeNode({ node, nodeId, nodeName }: TreeNode) {
const manualAttributions = useAppSelector(getManualAttributions);
const externalAttributions = useAppSelector(getExternalAttributions);
const resourcesToManualAttributions = useAppSelector(
getResourcesToManualAttributions,
);
const resourcesWithManualAttributedChildren = useAppSelector(
getResourcesWithManualAttributedChildren,
);
const resourcesToExternalAttributions = useAppSelector(
getResourcesToExternalAttributions,
);
const resourcesWithExternalAttributedChildren = useAppSelector(
getResourcesWithExternalAttributedChildren,
);
const resolvedExternalAttributions = useAppSelector(
getResolvedExternalAttributions,
);
const attributionBreakpoints = useAppSelector(getAttributionBreakpoints);
const filesWithChildren = useAppSelector(getFilesWithChildren);
const canHaveChildren = node !== 1;
const classification_mapping = useAppSelector(getClassifications);
const showClassifications = useShowClassifications();
const showCriticality = useShowCriticality();
return (
<ResourcesTreeNodeLabel
labelText={getDisplayName(nodeName)}
canHaveChildren={canHaveChildren}
hasManualAttribution={hasManualAttribution(
nodeId,
resourcesToManualAttributions,
)}
hasExternalAttribution={hasExternalAttribution(
nodeId,
resourcesToExternalAttributions,
)}
hasUnresolvedExternalAttribution={hasUnresolvedExternalAttribution(
nodeId,
resourcesToExternalAttributions,
resolvedExternalAttributions,
)}
hasParentWithManualAttribution={hasParentWithManualAttributionAndNoOwnAttribution(
nodeId,
manualAttributions,
resourcesToManualAttributions,
attributionBreakpoints,
)}
containsExternalAttribution={containsExternalAttribution(
nodeId,
resourcesWithExternalAttributedChildren,
)}
containsManualAttribution={containsManualAttribution(
nodeId,
resourcesWithManualAttributedChildren,
)}
criticality={getCriticality(
nodeId,
resourcesToExternalAttributions,
externalAttributions,
resolvedExternalAttributions,
)}
classification={getClassification(
nodeId,
resourcesToExternalAttributions,
externalAttributions,
resolvedExternalAttributions,
)}
classificationsConfig={classification_mapping}
isAttributionBreakpoint={attributionBreakpoints.has(nodeId)}
showFolderIcon={canHaveChildren && !filesWithChildren.has(nodeId)}
containsResourcesWithOnlyExternalAttribution={
canHaveChildren &&
containsResourcesWithOnlyExternalAttribution(
nodeId,
resourcesToManualAttributions,
resourcesToExternalAttributions,
node,
)
}
showClassifications={showClassifications}
showCriticality={showCriticality}
/>
);
}