Merge branch '21764-project-picker-crash' into main. Closes #21764
[arvados.git] / services / workbench2 / src / views / not-found-panel / not-found-panel.tsx
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4
5 import { RootState } from 'store/store';
6 import React from 'react';
7 import { connect } from 'react-redux';
8 import { NotFoundPanelRoot, NotFoundPanelRootDataProps } from 'views/not-found-panel/not-found-panel-root';
9 import { Grid } from '@material-ui/core';
10 import { DefaultView } from "components/default-view/default-view";
11 import { IconType } from 'components/icon/icon';
12
13 const mapStateToProps = (state: RootState): NotFoundPanelRootDataProps => {
14     return {
15         location: state.router.location,
16         clusterConfig: state.auth.config.clusterConfig,
17     };
18 };
19
20 const mapDispatchToProps = null;
21
22 export const NotFoundPanel = connect(mapStateToProps, mapDispatchToProps)
23     (NotFoundPanelRoot) as any;
24
25 export interface NotFoundViewDataProps {
26     messages: string[];
27     icon?: IconType;
28 }
29
30 // TODO: optionally pass in the UUID and check if the
31 // reason the item is not found is because
32 // it or a parent project is actually in the trash.
33 // If so, offer to untrash the item or the parent project.
34 export const NotFoundView =
35     ({ messages, icon: Icon }: NotFoundViewDataProps) =>
36         <Grid
37             container
38             alignItems="center"
39             justify="center"
40             style={{ minHeight: "100%" }}
41             data-cy="not-found-view">
42             <DefaultView
43                 icon={Icon}
44                 messages={messages}
45             />
46         </Grid>;