Skip to content

Commit 04c1209

Browse files
committed
[grid] Showing more stereotype details in the Grid UI
1 parent 17c0c01 commit 04c1209

File tree

7 files changed

+44
-28
lines changed

7 files changed

+44
-28
lines changed

javascript/grid-ui/src/components/Node/NodeDetailsDialog.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ import {
2424
DialogContent,
2525
DialogTitle,
2626
IconButton,
27-
Theme,
2827
Typography,
2928
withStyles
3029
} from '@material-ui/core'
@@ -34,7 +33,7 @@ import InfoIcon from '@material-ui/icons/Info'
3433
import OsLogo from '../common/OsLogo'
3534
import { StyleRules } from '@material-ui/core/styles'
3635

37-
const useStyles = (theme: Theme): StyleRules => createStyles(
36+
const useStyles = (): StyleRules => createStyles(
3837
{
3938
buttonMargin: {
4039
padding: 1

javascript/grid-ui/src/components/Node/Stereotypes.tsx

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -16,26 +16,31 @@
1616
// under the License.
1717

1818
import {
19+
Badge,
1920
Box,
2021
createStyles,
2122
Grid,
22-
Theme,
23+
Tooltip,
2324
Typography,
2425
withStyles
2526
} from '@material-ui/core'
2627
import React, { ReactNode } from 'react'
2728
import StereotypeInfo from '../../models/stereotype-info'
2829
import BrowserLogo from '../common/BrowserLogo'
2930
import { StyleRules } from '@material-ui/core/styles'
31+
import OsLogo from '../common/OsLogo'
32+
import { Size } from '../../models/size'
3033

31-
const useStyles = (theme: Theme): StyleRules => createStyles(
34+
const useStyles = (): StyleRules => createStyles(
3235
{
33-
slotCount: {
34-
marginBottom: 5
36+
boxStyle: {
37+
marginBottom: 5,
38+
marginTop: 20,
39+
marginRight: 35
3540
},
3641
browserVersion: {
3742
marginBottom: 5,
38-
marginRight: 20
43+
marginRight: 7
3944
}
4045
})
4146

@@ -51,20 +56,19 @@ class Stereotypes extends React.Component<StereotypesProps, {}> {
5156
function CreateStereotypeGridItem (slotStereotype: StereotypeInfo, index: any): JSX.Element {
5257
return (
5358
<Grid item key={index}>
54-
<Grid container alignItems='center' spacing={1}>
55-
<Grid item>
56-
<BrowserLogo browserName={slotStereotype.browserName} />
57-
</Grid>
58-
<Grid item>
59-
<Typography className={classes.slotCount}>
60-
{slotStereotype.slotCount}
61-
</Typography>
62-
</Grid>
63-
<Grid item>
64-
<Typography className={classes.browserVersion} variant='caption'>
65-
{slotStereotype.browserVersion}
66-
</Typography>
67-
</Grid>
59+
<Grid container alignItems="center" spacing={1}>
60+
<Tooltip title={JSON.stringify(slotStereotype.rawData.stereotype)}>
61+
<Badge badgeContent={slotStereotype.slotCount} color={'primary'}
62+
className={classes.boxStyle}>
63+
<Grid item className={classes.browserVersion}>
64+
<OsLogo osName={slotStereotype.platformName} size={Size.XS}/>
65+
<BrowserLogo browserName={slotStereotype.browserName}/>
66+
<Typography variant="caption">
67+
{slotStereotype.browserVersion}
68+
</Typography>
69+
</Grid>
70+
</Badge>
71+
</Tooltip>
6872
</Grid>
6973
</Grid>
7074
)

javascript/grid-ui/src/components/common/BrowserLogo.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,16 @@
1616
// under the License.
1717

1818
import React, { ReactNode } from 'react'
19-
import { StyleRules, Theme, withStyles } from '@material-ui/core/styles'
19+
import { StyleRules, withStyles } from '@material-ui/core/styles'
2020
import browserLogo from '../../util/browser-logo'
2121
import { Size } from '../../models/size'
2222
import clsx from 'clsx'
2323

24-
const useStyles = (theme: Theme): StyleRules => (
24+
const useStyles = (): StyleRules => (
2525
{
2626
logo: {
27-
marginRight: 0
27+
marginRight: 0,
28+
marginLeft: 0
2829
},
2930
small: {
3031
width: 24,

javascript/grid-ui/src/components/common/OsLogo.tsx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,20 @@
1616
// under the License.
1717

1818
import React, { ReactNode } from 'react'
19-
import { StyleRules, Theme, withStyles } from '@material-ui/core/styles'
19+
import { StyleRules, withStyles } from '@material-ui/core/styles'
2020
import { Size } from '../../models/size'
2121
import osLogo from '../../util/os-logo'
2222
import clsx from 'clsx'
2323

24-
const useStyles = (theme: Theme): StyleRules => (
24+
const useStyles = (): StyleRules => (
2525
{
2626
logo: {
27-
marginRight: 5
27+
marginRight: 0,
28+
marginLeft: 0
29+
},
30+
xs: {
31+
width: 16,
32+
height: 16
2833
},
2934
small: {
3035
width: 24,
@@ -55,6 +60,9 @@ class OsLogo extends React.Component<OsLogoProps, {}> {
5560
const { osName, size, classes } = this.props ?? { osName: '' }
5661

5762
function sizeMap (size): string {
63+
if (size === Size.XS) {
64+
return classes.xs
65+
}
5866
if (size === Size.S) {
5967
return classes.small
6068
}

javascript/grid-ui/src/models/size.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
// under the License.
1717

1818
export enum Size {
19+
XS,
1920
S,
2021
M,
2122
L,

javascript/grid-ui/src/models/stereotype-info.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
interface StereotypeInfo {
1919
browserName: string
2020
browserVersion: string
21+
platformName: string
2122
slotCount: number
2223
rawData: any
2324
}

javascript/grid-ui/src/screens/Overview/Overview.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,9 +148,11 @@ class Overview extends React.Component<OverviewProps, OverviewState> {
148148

149149
const slotStereotypes = (JSON.parse(node.stereotypes) as Array<StereoTypeData>).map((item) => {
150150
const slotStereotype: StereotypeInfo = {
151-
browserName: item.stereotype.browserName,
151+
browserName: item.stereotype.browserName ?? '',
152152
browserVersion: browserVersion(
153153
item.stereotype.browserVersion ?? item.stereotype.version),
154+
platformName: (item.stereotype.platformName
155+
?? item.stereotype.platform) ?? '',
154156
slotCount: item.slots,
155157
rawData: item
156158
}

0 commit comments

Comments
 (0)