1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import * as React from 'react';
6 import { connect, DispatchProp } from 'react-redux';
7 import { push } from 'react-router-redux';
8 import { LinearProgress, Grid } from '@material-ui/core';
9 import { StyleRulesCallback, WithStyles, withStyles } from '@material-ui/core/styles';
10 import { ArvadosTheme } from '~/common/custom-theme';
11 import { isSystemWorking } from '~/store/progress-indicator/progress-indicator-reducer';
12 import { RootState } from '~/store/store';
13 import { User } from '~/models/user';
14 import { WorkbenchPanel } from '~/views/workbench/workbench';
15 import { LoginPanel } from '~/views/login-panel/login-panel';
16 import { MainAppBar } from '~/views-components/main-app-bar/main-app-bar';
18 type CssRules = 'root';
20 const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
28 interface MainPanelDataProps {
33 interface MainPanelGeneralProps {
37 interface MainPanelState {
41 type MainPanelProps = MainPanelDataProps & MainPanelGeneralProps & DispatchProp<any> & WithStyles<CssRules>;
43 export const MainPanel = withStyles(styles)(
44 connect<MainPanelDataProps>(
45 (state: RootState) => ({
46 user: state.auth.user,
47 working: isSystemWorking(state.progressIndicator)
50 class extends React.Component<MainPanelProps, MainPanelState> {
56 const { classes, user, buildInfo, working } = this.props;
57 const { searchText } = this.state;
60 searchText={searchText}
62 onSearch={this.onSearch}
63 buildInfo={buildInfo}>
64 {working ? <LinearProgress color="secondary" /> : null}
66 <Grid container direction="column" className={classes.root}>
67 {user ? <WorkbenchPanel /> : <LoginPanel />}
72 onSearch = (searchText: string) => {
73 this.setState({ searchText });
74 this.props.dispatch(push(`/search?q=${searchText}`));