Skip to content

Commit

Permalink
[grid] Avoiding NPE on the Grid UI
Browse files Browse the repository at this point in the history
  • Loading branch information
diemol committed Feb 20, 2021
1 parent d17ac96 commit d387c91
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ java_library(
deps = [
"//java/client/src/org/openqa/selenium/remote/tracing",
"//java/client/src/org/openqa/selenium/remote/tracing/opentelemetry",
artifact("io.opentelemetry:opentelemetry-api"),
artifact("io.opentelemetry:opentelemetry-api"),
artifact("io.opentelemetry:opentelemetry-context"),
artifact("io.opentelemetry:opentelemetry-sdk"),
artifact("io.opentelemetry:opentelemetry-sdk-common"),
artifact("io.opentelemetry:opentelemetry-sdk-trace"),
artifact("io.opentelemetry:opentelemetry-context"),
],
)
24 changes: 10 additions & 14 deletions javascript/grid-ui/src/components/Node/Stereotypes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,19 @@
// specific language governing permissions and limitations
// under the License.

import {
Box,
createStyles,
Grid,
Theme,
Typography,
withStyles
} from '@material-ui/core';
import {Box, createStyles, Grid, Theme, Typography, withStyles} from '@material-ui/core';
import React from 'react';
import StereotypeInfo from "../../models/stereotype-info";
import BrowserLogo from "../common/BrowserLogo";

const useStyles = (theme: Theme) => createStyles(
{
slotInfo: {
slotCount: {
marginBottom: 5,
marginRight: 10,
},
browserVersion: {
marginBottom: 5,
marginRight: 20,
},
});

Expand All @@ -42,7 +38,7 @@ type StereotypesProps = {

class Stereotypes extends React.Component<StereotypesProps, {}> {

render () {
render() {
const {stereotypes, classes} = this.props;

function CreateStereotypeGridItem(slotStereotype: StereotypeInfo, index: any) {
Expand All @@ -53,12 +49,12 @@ class Stereotypes extends React.Component<StereotypesProps, {}> {
<BrowserLogo browserName={slotStereotype.browserName}/>
</Grid>
<Grid item>
<Typography className={classes.slotInfo}>
<Typography className={classes.slotCount}>
{slotStereotype.slotCount}
</Typography>
</Grid>
<Grid item>
<Typography className={classes.slotInfo}>
<Typography className={classes.browserVersion} variant={"caption"}>
{slotStereotype.browserVersion}
</Typography>
</Grid>
Expand All @@ -82,7 +78,7 @@ class Stereotypes extends React.Component<StereotypesProps, {}> {
{
stereotypes
.sort((a, b) => a.browserName.localeCompare(b.browserName)
|| a.browserVersion.localeCompare(b.browserVersion))
|| a.browserVersion.localeCompare(b.browserVersion))
.map((slotStereotype: any, idx) => {
return (
CreateStereotypeGridItem(slotStereotype, idx)
Expand Down
4 changes: 2 additions & 2 deletions javascript/grid-ui/src/components/common/BrowserLogo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import clsx from "clsx";
const useStyles = (theme: Theme) => (
{
logo: {
marginRight: 5,
marginRight: 0,
},
small: {
width: 24,
Expand Down Expand Up @@ -55,7 +55,7 @@ class BrowserLogo extends React.Component<BrowserLogoProps, {}> {
render() {
const {browserName, size, classes} = this.props;

function sizeMap (size) {
function sizeMap(size) {
if (size === Size.S) {
return classes.small;
}
Expand Down
2 changes: 1 addition & 1 deletion javascript/grid-ui/src/screens/Overview/Overview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ class Overview extends React.Component<OverviewProps, OverviewState> {
</ApolloConsumer>
)
}
const {loading, error, data} = this.state;
const {loading, error, data} = this.state ?? {loading: false, error: "No connection to the Grid", data: []};

if (loading) {
return (
Expand Down

0 comments on commit d387c91

Please sign in to comment.