Skip to content

Commit

Permalink
Disable navigation during the build. Add notification for users that …
Browse files Browse the repository at this point in the history
…it is normal for builds to take longer
  • Loading branch information
jurgelenas committed Feb 14, 2021
1 parent 9fdc231 commit 975edc4
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 5 deletions.
1 change: 0 additions & 1 deletion CHANGELOG.md

This file was deleted.

8 changes: 7 additions & 1 deletion src/ui/components/Sidebar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@ const useStyles = makeStyles((theme) => ({
},
}));

const Sidebar: FunctionComponent = () => {
interface SidebarProps {
navigationEnabled: boolean;
}

const Sidebar: FunctionComponent<SidebarProps> = ({ navigationEnabled }) => {
const styles = useStyles();

const location = useLocation();
Expand All @@ -59,6 +63,7 @@ const Sidebar: FunctionComponent = () => {
selected={configuratorActive}
className={styles.menuItem}
button
disabled={!navigationEnabled}
>
<ListItemIcon>
<BuildIcon />
Expand All @@ -85,6 +90,7 @@ const Sidebar: FunctionComponent = () => {
selected={logsActive}
className={styles.menuItem}
button
disabled={!navigationEnabled}
>
<ListItemIcon>
<ListIcon />
Expand Down
38 changes: 37 additions & 1 deletion src/ui/views/ConfiguratorView/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ const useStyles = makeStyles((theme) => ({
button: {
marginRight: `${theme.spacing(2)} !important`,
},
longBuildDurationWarning: {
marginBottom: theme.spacing(1),
},
}));

enum ViewState {
Expand Down Expand Up @@ -238,6 +241,31 @@ const ConfiguratorView: FunctionComponent = () => {
}
}, [response]);

const [
longBuildDurationWarning,
setLongBuildDurationWarning,
] = useState<boolean>(false);
const buildInProgressRef = useRef(buildInProgress);
buildInProgressRef.current = buildInProgress;
const slowBuildTimeoutRef = useRef<number | null>(null);
useEffect(() => {
if (buildInProgressRef.current) {
slowBuildTimeoutRef.current = window.setTimeout(() => {
setLongBuildDurationWarning(true);
}, 15 * 1000);
} else {
setLongBuildDurationWarning(false);
if (slowBuildTimeoutRef.current !== null) {
clearTimeout(slowBuildTimeoutRef.current);
}
}
return () => {
if (slowBuildTimeoutRef.current !== null) {
clearTimeout(slowBuildTimeoutRef.current);
}
};
}, [buildInProgress]);

const reset = () => {
logsRef.current = [];
progressNotificationsRef.current = [];
Expand Down Expand Up @@ -333,7 +361,7 @@ const ConfiguratorView: FunctionComponent = () => {

return (
<main className={styles.root}>
<Sidebar />
<Sidebar navigationEnabled={!buildInProgress} />
<div className={styles.content}>
<Header />
<Container className={styles.main}>
Expand Down Expand Up @@ -428,6 +456,14 @@ const ConfiguratorView: FunctionComponent = () => {
<CardTitle icon={<SettingsIcon />} title="Logs" />
<Divider />
<CardContent>
{longBuildDurationWarning && (
<div className={styles.longBuildDurationWarning}>
<ShowAlerts
severity="warning"
messages="Sometimes builds take at least a few minutes. It is normal, especially for the first time builds."
/>
</div>
)}
<Logs data={logs} />
</CardContent>
<Divider />
Expand Down
2 changes: 1 addition & 1 deletion src/ui/views/LogsView/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const LogsView: FunctionComponent = () => {
};
return (
<main className={styles.root}>
<Sidebar />
<Sidebar navigationEnabled />
<div className={styles.content}>
<Header />
<Container className={styles.main}>
Expand Down
2 changes: 1 addition & 1 deletion src/ui/views/SettingsView/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const SettingsView: FunctionComponent = () => {
const styles = useStyles();
return (
<main className={styles.root}>
<Sidebar />
<Sidebar navigationEnabled />
<div className={styles.content}>
<Header />
<Container className={styles.main}>
Expand Down

0 comments on commit 975edc4

Please sign in to comment.