Skip to content
This repository has been archived by the owner on Mar 1, 2024. It is now read-only.

Use uniqe prop for resource in WithResource component. #183

Merged
merged 1 commit into from
Jan 22, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions frontend/public/kubevirt/components/utils/withResources.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class Resources extends React.Component {
Object.keys(resourceMap).forEach(resourceKey => {
const resourceConfig = resourceMap[resourceKey];
const configResource = resourceConfig.resource;
const resource = _.get(resources, resourceConfig.resource.kind);
const resource = _.get(resources, resourceKey);

if (resource) {
if (resource.loaded) {
Expand Down Expand Up @@ -99,7 +99,11 @@ Resources.propTypes = {
};

const stateToProps = ({k8s}, {resourceMap}) => {
const resources = Object.keys(resourceMap).map(k => resourceMap[k].resource);
const resources = Object.keys(resourceMap).map(k => {
// We can have more queries for the same kind so lets set resource.prop to key to make sure its unique
resourceMap[k].resource.prop = k;
return resourceMap[k].resource;
});
return {
k8sModels: resources.reduce((models, {kind}) => models.set(kind, k8s.getIn(['RESOURCES', 'models', kind])), ImmutableMap()),
};
Expand Down
3 changes: 1 addition & 2 deletions frontend/public/kubevirt/components/vm/vm-detail.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import {
} from '../../models/index';
import {
getResource,
getLabelMatcher,
findPod,
findImporterPods,
findVMIMigration,
Expand Down Expand Up @@ -69,7 +68,7 @@ const ConnectedVmDetails = ({ obj: vm }) => {
ignoreErrors: true,
},
pods: {
resource: getResource(PodModel, {namespace, matchLabels: getLabelMatcher(vm)}),
resource: getResource(PodModel, { namespace, matchExpressions: [{key: 'kubevirt.io', operator: 'Exists' }] }),
},
importerPods: {
resource: getResource(PodModel, {namespace, matchLabels: {[CDI_KUBEVIRT_IO]: 'importer'}}),
Expand Down