generated from openmcp-project/repository-template
-
Notifications
You must be signed in to change notification settings - Fork 3
fix: Resources on graph based on name AND apiVersion #307
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
Merged
Hubert-Szczepanski-SAP
merged 5 commits into
main
from
fix/visualise-resources-on-graph-by-name-and-version
Oct 7, 2025
Merged
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
3e68da9
create resources on graph based on name AND apiVersion
Hubert-Szczepanski-SAP 887ede8
Merge branch 'main' into fix/visualise-resources-on-graph-by-name-and…
andreaskienle 55b3ad2
separate function + tests
Hubert-Szczepanski-SAP 5eb969d
Merge branch 'main' into fix/visualise-resources-on-graph-by-name-and…
Hubert-Szczepanski-SAP ab25411
Merge branch 'main' into fix/visualise-resources-on-graph-by-name-and…
Hubert-Szczepanski-SAP File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -100,9 +100,12 @@ export function useGraph(colorBy: ColorBy, onYamlClick: (item: ManagedResourceIt | |
const treeData = useMemo(() => { | ||
if (!managedResources || !providerConfigsList) return []; | ||
const allNodesMap = new Map<string, NodeData>(); | ||
|
||
managedResources.forEach((group: ManagedResourceGroup) => { | ||
group.items?.forEach((item: ManagedResourceItem) => { | ||
const id = item?.metadata?.name; | ||
const name = item?.metadata?.name; | ||
const apiVersion = item?.apiVersion ?? ''; | ||
const id = `${name}-${apiVersion}`; | ||
const kind = item?.kind; | ||
const providerConfigName = item?.spec?.providerConfigRef?.name ?? 'unknown'; | ||
const providerType = resolveProviderType(providerConfigName, providerConfigsList); | ||
|
@@ -135,23 +138,10 @@ export function useGraph(colorBy: ColorBy, onYamlClick: (item: ManagedResourceIt | |
globalaccountTrustConfigurationRef, | ||
} = extractRefs(item); | ||
|
||
const parentId = serviceManagerRef || subaccountRef; | ||
const extraRefs = [ | ||
spaceRef, | ||
orgRef, | ||
cloudManagementRef, | ||
directoryRef, | ||
entitlementRef, | ||
globalAccountRef, | ||
orgRoleRef, | ||
spaceMembersRef, | ||
cloudFoundryEnvironmentRef, | ||
kymaEnvironmentRef, | ||
roleCollectionRef, | ||
roleCollectionAssignmentRef, | ||
subaccountTrustConfigurationRef, | ||
globalaccountTrustConfigurationRef, | ||
].filter(Boolean) as string[]; | ||
const createReferenceIdWithApiVersion = (referenceName: string | undefined) => { | ||
if (!referenceName) return undefined; | ||
return `${referenceName}-${apiVersion}`; | ||
|
||
}; | ||
|
||
if (id) { | ||
allNodesMap.set(id, { | ||
|
@@ -164,14 +154,32 @@ export function useGraph(colorBy: ColorBy, onYamlClick: (item: ManagedResourceIt | |
transitionTime: statusCond?.lastTransitionTime ?? '', | ||
statusMessage: statusCond?.reason ?? statusCond?.message ?? '', | ||
fluxName, | ||
parentId, | ||
extraRefs, | ||
parentId: createReferenceIdWithApiVersion(serviceManagerRef || subaccountRef), | ||
extraRefs: [ | ||
spaceRef, | ||
orgRef, | ||
cloudManagementRef, | ||
directoryRef, | ||
entitlementRef, | ||
globalAccountRef, | ||
orgRoleRef, | ||
spaceMembersRef, | ||
cloudFoundryEnvironmentRef, | ||
kymaEnvironmentRef, | ||
roleCollectionRef, | ||
roleCollectionAssignmentRef, | ||
subaccountTrustConfigurationRef, | ||
globalaccountTrustConfigurationRef, | ||
] | ||
.map(createReferenceIdWithApiVersion) | ||
.filter(Boolean) as string[], | ||
item, | ||
onYamlClick, | ||
}); | ||
} | ||
}); | ||
}); | ||
|
||
return Array.from(allNodesMap.values()); | ||
}, [managedResources, providerConfigsList, onYamlClick]); | ||
|
||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The ID generation could create collisions when resource names contain hyphens. For example, 'my-resource' with apiVersion 'v1' would have the same ID as 'my' with apiVersion 'resource-v1'. Consider using a different separator like '::' or implement a more robust encoding scheme.
Copilot uses AI. Check for mistakes.