Skip to content

Commit

Permalink
Merge pull request meshery#12385 from amitamrutiya/fix-component-count
Browse files Browse the repository at this point in the history
fix: relationsihp and component count show 0 issue
  • Loading branch information
Yashsharma1911 authored Oct 19, 2024
2 parents 72ea9c5 + 7439c56 commit 2adb668
Showing 1 changed file with 10 additions and 14 deletions.
24 changes: 10 additions & 14 deletions ui/components/MeshModelRegistry/MeshModelDetails.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ import RemoveCircleIcon from '@mui/icons-material/RemoveCircle';
import AssignmentTurnedInIcon from '@mui/icons-material/AssignmentTurnedIn';
import {
useUpdateEntityStatusMutation,
useGetModelByNameQuery,
useGetComponentByNameQuery,
useGetComponentsQuery,
useGetMeshModelsQuery,
} from '@/rtk-query/meshModel';
import _ from 'lodash';
import { JustifyAndAlignCenter } from './MeshModel.style';
Expand Down Expand Up @@ -156,16 +156,12 @@ const ModelContents = withSuppressedErrorBoundary(({ modelDef }) => {
let relationships = 0;
if (modelDef?.versionBasedData) {
modelDef?.versionBasedData.forEach((modelDefVersion) => {
components =
components +
(modelDefVersion?.components === null ? 0 : modelDefVersion.components.length);
relationships =
relationships +
(modelDefVersion?.relationships === null ? 0 : modelDefVersion.relationships.length);
components = components + modelDefVersion?.components_count;
relationships = relationships + modelDefVersion?.relationships_count;
});
} else {
components = modelDef?.components === null ? 0 : modelDef?.components?.length;
relationships = modelDef?.relationships === null ? 0 : modelDef?.relationships?.length;
components = modelDef?.components_count;
relationships = modelDef?.relationships_count;
}
return {
components,
Expand Down Expand Up @@ -238,9 +234,9 @@ const ModelContents = withSuppressedErrorBoundary(({ modelDef }) => {
});

const ComponentContents = withSuppressedErrorBoundary(({ componentDef }) => {
const { data, isSuccess } = useGetComponentByNameQuery({
name: componentDef.component.kind,
const { data, isSuccess } = useGetComponentsQuery({
params: {
id: componentDef.id,
apiVersion: componentDef.component.version,
trim: false,
},
Expand Down Expand Up @@ -418,9 +414,9 @@ const StatusChip = withSuppressedErrorBoundary(
withStyles(styles)(({ classes, entityData, entityType }) => {
const nextStatus = Object.values(REGISTRY_ITEM_STATES);
const [updateEntityStatus] = useUpdateEntityStatusMutation();
const { data: modelData, isSuccess } = useGetModelByNameQuery({
name: entityData.name,
const { data: modelData, isSuccess } = useGetMeshModelsQuery({
params: {
id: entityData.model.id,
version: entityData.model.version,
},
});
Expand Down

0 comments on commit 2adb668

Please sign in to comment.