1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import * as React from 'react';
6 import { Location } from 'history';
7 import { StyleRulesCallback, WithStyles, withStyles, Paper, Grid } from '@material-ui/core';
8 import { ArvadosTheme } from '~/common/custom-theme';
9 import { ClusterConfigJSON } from '~/common/config';
11 export type CssRules = 'root' | 'title' | 'active';
13 const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
20 paddingLeft: theme.spacing.unit * 3,
21 paddingTop: theme.spacing.unit * 3,
22 paddingBottom: theme.spacing.unit * 3,
26 color: theme.customs.colors.green700,
27 textDecoration: 'none',
31 export interface NotFoundPanelOwnProps {
35 export interface NotFoundPanelRootDataProps {
36 location: Location<any> | null;
37 clusterConfig: ClusterConfigJSON;
40 type NotFoundPanelRootProps = NotFoundPanelRootDataProps & NotFoundPanelOwnProps & WithStyles<CssRules>;
42 const getAdditionalMessage = (location: Location | null) => {
47 const { pathname } = location;
49 if (pathname.indexOf('collections') > -1) {
50 const uuidHash = pathname.replace('/collections/', '');
54 Please make sure that provided UUID/ObjectHash '{uuidHash}' is valid.
62 const getEmailLink = (email: string, classes: Record<CssRules, string>) => {
63 const { location: { href: windowHref } } = window;
64 const href = `mailto:${email}?body=${encodeURIComponent('Problem while viewing page ')}${encodeURIComponent(windowHref)}&subject=${encodeURIComponent('Workbench problem report')}`;
67 className={classes.active}
74 export const NotFoundPanelRoot = withStyles(styles)(
75 ({ classes, clusterConfig, location, notWrapped }: NotFoundPanelRootProps) => {
77 const content = <Grid container justify="space-between" wrap="nowrap" alignItems="center">
78 <div data-cy="not-found-content" className={classes.title}>
80 {getAdditionalMessage(location)}
82 The page you requested was not found,
84 !!clusterConfig.Mail && clusterConfig.Mail.SupportEmailAddress ?
85 getEmailLink(clusterConfig.Mail.SupportEmailAddress, classes) :
88 if you suspect this is a bug.
93 return !notWrapped ? <Paper data-cy="not-found-page"> {content}</Paper> : content;