-
Notifications
You must be signed in to change notification settings - Fork 593
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug 1803213: Update collapsed groups in topology to match designs
- Loading branch information
1 parent
94ad5e4
commit 44dc0f6
Showing
8 changed files
with
124 additions
and
64 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
29 changes: 29 additions & 0 deletions
29
...tend/packages/dev-console/src/components/topology/components/nodes/ResourceKindsInfo.scss
This file contains 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 |
---|---|---|
@@ -0,0 +1,29 @@ | ||
.odc-resource-kinds-info { | ||
padding: var(--pf-global--spacer--md) var(--pf-global--spacer--md) var(--pf-global--spacer--md) 0; | ||
width: 100%; | ||
height: 100%; | ||
overflow-y: auto; | ||
|
||
&__table { | ||
width: 100%; | ||
td { | ||
padding-bottom: var(--pf-global--spacer--sm); | ||
padding-right: var(--pf-global--spacer--sm); | ||
&:last-of-type { | ||
padding-right: 0; | ||
} | ||
} | ||
} | ||
|
||
&__resource-icon { | ||
width: 1%; | ||
.co-m-resource-icon { | ||
font-size: 80%; | ||
margin-right: 0; | ||
} | ||
} | ||
&__count { | ||
text-align: end; | ||
width: 1%; | ||
} | ||
} |
79 changes: 47 additions & 32 deletions
79
frontend/packages/dev-console/src/components/topology/components/nodes/ResourceKindsInfo.tsx
This file contains 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 |
---|---|---|
@@ -1,52 +1,67 @@ | ||
import * as React from 'react'; | ||
import * as _ from 'lodash'; | ||
import { modelFor, referenceForOwnerRef } from '@console/internal/module/k8s'; | ||
import { modelFor, referenceFor, referenceForModel } from '@console/internal/module/k8s'; | ||
import { getTopologyResourceObject } from '../../topology-utils'; | ||
import { TopologyDataObject } from '../../topology-types'; | ||
import { ResourceIcon } from '@console/internal/components/utils'; | ||
|
||
import './ResourceKindsInfo.scss'; | ||
|
||
type ResourceKindsInfoProps = { | ||
groupResources: TopologyDataObject; | ||
emptyKind?: string; | ||
emptyValue?: React.ReactNode; | ||
width: number; | ||
height: number; | ||
}; | ||
|
||
const TEXT_MARGIN = 10; | ||
const ROW_HEIGHT = 20 + TEXT_MARGIN; | ||
|
||
const ResourceKindsInfo: React.FC<ResourceKindsInfoProps> = ({ groupResources, emptyKind }) => { | ||
const ResourceKindsInfo: React.FC<ResourceKindsInfoProps> = ({ | ||
groupResources, | ||
emptyValue, | ||
width, | ||
height, | ||
}) => { | ||
const resourcesData = {}; | ||
_.forEach(groupResources, (res: TopologyDataObject) => { | ||
const a = getTopologyResourceObject(res); | ||
resourcesData[a.kind] = [...(resourcesData[a.kind] ? resourcesData[a.kind] : []), a]; | ||
const kindObj = modelFor(referenceFor(a)); | ||
const key = kindObj.abbr || a.kind; | ||
resourcesData[key] = [...(resourcesData[key] ? resourcesData[key] : []), a]; | ||
}); | ||
|
||
const resourceTypes = _.keys(resourcesData); | ||
let resources = null; | ||
if (resourceTypes.length) { | ||
resources = _.map(resourceTypes, (key, index) => { | ||
const kindObj = modelFor(referenceForOwnerRef(resourcesData[key][0])); | ||
const rowY = ROW_HEIGHT * index; | ||
return ( | ||
<g key={key}> | ||
<text y={rowY} textAnchor="end"> | ||
{resourcesData[key].length} | ||
</text> | ||
<text x={TEXT_MARGIN} y={rowY}> | ||
{resourcesData[key].length > 1 ? kindObj.labelPlural : kindObj.label} | ||
</text> | ||
</g> | ||
); | ||
}); | ||
} else if (emptyKind) { | ||
const kindObj = modelFor(emptyKind); | ||
resources = ( | ||
<g> | ||
<text textAnchor="end">0</text> | ||
<text x={TEXT_MARGIN}>{kindObj ? kindObj.labelPlural : emptyKind}</text> | ||
</g> | ||
|
||
if (!resourceTypes.length) { | ||
return ( | ||
<foreignObject width={width} height={height}> | ||
<div className="odc-resource-kinds-info">{emptyValue}</div> | ||
</foreignObject> | ||
); | ||
} | ||
|
||
return <g className="odc-resource-kinds-info__resources">{resources}</g>; | ||
return ( | ||
<foreignObject width={width} height={height}> | ||
<div className="odc-resource-kinds-info"> | ||
<table className="odc-resource-kinds-info__table"> | ||
<tbody className="odc-resource-kinds-info__body"> | ||
{resourceTypes.map((key) => { | ||
const kindObj = modelFor(referenceFor(resourcesData[key][0])); | ||
return ( | ||
<tr key={key} className="odc-resource-kinds-info__row"> | ||
<td className="odc-resource-kinds-info__count">{resourcesData[key].length}</td> | ||
<td className="odc-resource-kinds-info__resource-icon"> | ||
<ResourceIcon kind={kindObj.crd ? referenceForModel(kindObj) : kindObj.kind} /> | ||
</td> | ||
<td className="odc-resource-kinds-info__kind"> | ||
{resourcesData[key].length > 1 ? kindObj.labelPlural : kindObj.label} | ||
</td> | ||
</tr> | ||
); | ||
})} | ||
</tbody> | ||
</table> | ||
</div> | ||
</foreignObject> | ||
); | ||
// return <g className="odc-resource-kinds-info__resources">{resources}</g>; | ||
}; | ||
|
||
export default ResourceKindsInfo; |
This file contains 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