Make New Dashboard the default dashboard (#26996)

Add UsageStats alert to new dashboard
Update wording of "back to legacy dashboard", "try new dashboard" buttons

Signed-off-by: Alan Guo aguo@anyscale.com
This commit is contained in:
Alan Guo 2022-07-27 07:04:34 -07:00 committed by GitHub
parent 028684032b
commit a7dca17973
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 56 additions and 46 deletions

View file

@ -2,7 +2,7 @@ import { CssBaseline } from "@material-ui/core";
import { ThemeProvider } from "@material-ui/core/styles"; import { ThemeProvider } from "@material-ui/core/styles";
import React, { Suspense, useEffect, useState } from "react"; import React, { Suspense, useEffect, useState } from "react";
import { Provider } from "react-redux"; import { Provider } from "react-redux";
import { HashRouter, Route, Switch } from "react-router-dom"; import { HashRouter, Redirect, Route, Switch } from "react-router-dom";
import Dashboard from "./pages/dashboard/Dashboard"; import Dashboard from "./pages/dashboard/Dashboard";
import Events from "./pages/event/Events"; import Events from "./pages/event/Events";
import Loading from "./pages/exception/Loading"; import Loading from "./pages/exception/Loading";
@ -83,7 +83,12 @@ const App = () => {
<CssBaseline /> <CssBaseline />
<HashRouter> <HashRouter>
<Switch> <Switch>
<Route component={Dashboard} exact path="/" /> <Route
component={() => <Redirect to="/node" />}
exact
path="/"
/>
<Route component={Dashboard} exact path="/legacy" />
<Route <Route
render={(props) => ( render={(props) => (
<BasicLayout {...props} setTheme={setTheme} theme={theme}> <BasicLayout {...props} setTheme={setTheme} theme={theme}>

View file

@ -0,0 +1,37 @@
import { Alert } from "@material-ui/lab";
import React, { useEffect, useState } from "react";
import { getUsageStatsEnabled } from "../api";
export const UsageStatsAlert = () => {
const [usageStatsPromptEnabled, setUsageStatsPromptEnabled] = useState(false);
const [usageStatsEnabled, setUsageStatsEnabled] = useState(false);
useEffect(() => {
getUsageStatsEnabled().then((res) => {
setUsageStatsPromptEnabled(res.usageStatsPromptEnabled);
setUsageStatsEnabled(res.usageStatsEnabled);
});
}, []);
return usageStatsPromptEnabled ? (
<Alert style={{ marginTop: 30 }} severity="info">
{usageStatsEnabled ? (
<span>
Usage stats collection is enabled. To disable this, add
`--disable-usage-stats` to the command that starts the cluster, or run
the following command: `ray disable-usage-stats` before starting the
cluster. See{" "}
<a
href="https://docs.ray.io/en/master/cluster/usage-stats.html"
target="_blank"
rel="noreferrer"
>
https://docs.ray.io/en/master/cluster/usage-stats.html
</a>{" "}
for more details.
</span>
) : (
<span>Usage stats collection is disabled.</span>
)}
</Alert>
) : null;
};

View file

@ -7,16 +7,11 @@ import {
Theme, Theme,
Typography, Typography,
} from "@material-ui/core"; } from "@material-ui/core";
import { Alert } from "@material-ui/lab"; import React, { useCallback, useEffect, useRef } from "react";
import React, { useCallback, useEffect, useRef, useState } from "react";
import { useDispatch, useSelector } from "react-redux"; import { useDispatch, useSelector } from "react-redux";
import { useHistory } from "react-router-dom"; import { useHistory } from "react-router-dom";
import { import { getActorGroups, getNodeInfo, getTuneAvailability } from "../../api";
getActorGroups, import { UsageStatsAlert } from "../../common/UsageStatsAlert";
getNodeInfo,
getTuneAvailability,
getUsageStatsEnabled,
} from "../../api";
import { StoreState } from "../../store"; import { StoreState } from "../../store";
import LastUpdated from "./LastUpdated"; import LastUpdated from "./LastUpdated";
import LogicalView from "./logical-view/LogicalView"; import LogicalView from "./logical-view/LogicalView";
@ -105,14 +100,6 @@ const Dashboard: React.FC = () => {
} }
const SelectedComponent = tabs[tab].component; const SelectedComponent = tabs[tab].component;
const [usageStatsPromptEnabled, setUsageStatsPromptEnabled] = useState(false);
const [usageStatsEnabled, setUsageStatsEnabled] = useState(false);
useEffect(() => {
getUsageStatsEnabled().then((res) => {
setUsageStatsPromptEnabled(res.usageStatsPromptEnabled);
setUsageStatsEnabled(res.usageStatsEnabled);
});
}, []);
return ( return (
<div className={classes.root}> <div className={classes.root}>
<Typography variant="h5">Ray Dashboard</Typography> <Typography variant="h5">Ray Dashboard</Typography>
@ -123,7 +110,7 @@ const Dashboard: React.FC = () => {
color="primary" color="primary"
onClick={() => history.push("/node")} onClick={() => history.push("/node")}
> >
Try Experimental Dashboard Back to new dashboard
</Button> </Button>
<Tabs <Tabs
className={classes.tabs} className={classes.tabs}
@ -137,28 +124,7 @@ const Dashboard: React.FC = () => {
))} ))}
</Tabs> </Tabs>
<SelectedComponent /> <SelectedComponent />
{usageStatsPromptEnabled ? ( <UsageStatsAlert />
<Alert style={{ marginTop: 30 }} severity="info">
{usageStatsEnabled ? (
<span>
Usage stats collection is enabled. To disable this, add
`--disable-usage-stats` to the command that starts the cluster, or
run the following command: `ray disable-usage-stats` before
starting the cluster. See{" "}
<a
href="https://docs.ray.io/en/master/cluster/usage-stats.html"
target="_blank"
rel="noreferrer"
>
https://docs.ray.io/en/master/cluster/usage-stats.html
</a>{" "}
for more details.
</span>
) : (
<span>Usage stats collection is disabled.</span>
)}
</Alert>
) : null}
<LastUpdated /> <LastUpdated />
</div> </div>
); );

View file

@ -9,6 +9,7 @@ import { NightsStay, VerticalAlignTop, WbSunny } from "@material-ui/icons";
import classnames from "classnames"; import classnames from "classnames";
import React, { PropsWithChildren } from "react"; import React, { PropsWithChildren } from "react";
import { RouteComponentProps } from "react-router-dom"; import { RouteComponentProps } from "react-router-dom";
import { UsageStatsAlert } from "../../common/UsageStatsAlert";
import SpeedTools from "../../components/SpeedTools"; import SpeedTools from "../../components/SpeedTools";
import Logo from "../../logo.svg"; import Logo from "../../logo.svg";
@ -130,9 +131,9 @@ const BasicLayout = (
<ListItem <ListItem
button button
className={classnames(classes.menuItem)} className={classnames(classes.menuItem)}
onClick={() => history.push("/")} onClick={() => history.push("/legacy")}
> >
<ListItemText>BACK TO LEGACY DASHBOARD</ListItemText> <ListItemText>TO LEGACY DASHBOARD</ListItemText>
</ListItem> </ListItem>
<ListItem> <ListItem>
<IconButton <IconButton
@ -159,7 +160,10 @@ const BasicLayout = (
<SpeedTools /> <SpeedTools />
</List> </List>
</Drawer> </Drawer>
<div className={classes.child}>{children}</div> <div className={classes.child}>
{children}
<UsageStatsAlert />
</div>
</div> </div>
); );
}; };

View file

@ -2,7 +2,5 @@ describe('Ray Dashboard Test', () => {
it('opens a new Ray dashboard', () => { it('opens a new Ray dashboard', () => {
cy.visit('localhost:8653') cy.visit('localhost:8653')
cy.contains('Ray') cy.contains('Ray')
cy.contains('Memory').click()
cy.contains('Tune').click()
}) })
}) })