1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import React from 'react';
6 import { Location } from 'history';
7 import { CustomStyleRulesCallback } from 'common/custom-theme';
8 import { Paper, Grid } from '@mui/material';
9 import { WithStyles } from '@mui/styles';
10 import withStyles from '@mui/styles/withStyles';
11 import { ArvadosTheme } from 'common/custom-theme';
12 import { ClusterConfigJSON } from 'common/config';
14 export type CssRules = 'root' | 'title' | 'active';
16 const styles: CustomStyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
23 paddingLeft: theme.spacing(3),
24 paddingTop: theme.spacing(3),
25 paddingBottom: theme.spacing(3),
29 color: theme.customs.colors.grey700,
30 textDecoration: 'none',
34 export interface NotFoundPanelOwnProps {
38 export interface NotFoundPanelRootDataProps {
39 location: Location<any> | null;
40 clusterConfig: ClusterConfigJSON;
43 type NotFoundPanelRootProps = NotFoundPanelRootDataProps & NotFoundPanelOwnProps & WithStyles<CssRules>;
45 const getAdditionalMessage = (location: Location | null) => {
50 const { pathname } = location;
52 if (pathname.indexOf('collections') > -1) {
53 const uuidHash = pathname.replace('/collections/', '');
57 Please make sure that provided UUID/ObjectHash '{uuidHash}' is valid.
65 const getEmailLink = (email: string, classes: Record<CssRules, string>) => {
66 const { location: { href: windowHref } } = window;
67 const href = `mailto:${email}?body=${encodeURIComponent('Problem while viewing page ')}${encodeURIComponent(windowHref)}&subject=${encodeURIComponent('Workbench problem report')}`;
70 className={classes.active}
77 export const NotFoundPanelRoot = withStyles(styles)(
78 ({ classes, clusterConfig, location, notWrapped }: NotFoundPanelRootProps) => {
80 const content = <Grid container justifyContent="space-between" wrap="nowrap" alignItems="center">
81 <div data-cy="not-found-content" className={classes.title}>
83 {getAdditionalMessage(location)}
85 The page you requested was not found,
87 !!clusterConfig.Mail && clusterConfig.Mail.SupportEmailAddress ?
88 getEmailLink(clusterConfig.Mail.SupportEmailAddress, classes) :
91 if you suspect this is a bug.
96 return !notWrapped ? <Paper data-cy="not-found-page"> {content}</Paper> : content;