diff --git a/x-pack/plugins/code/public/components/main/content.tsx b/x-pack/plugins/code/public/components/main/content.tsx index 3b119a6dc44a7..7927ac54a006e 100644 --- a/x-pack/plugins/code/public/components/main/content.tsx +++ b/x-pack/plugins/code/public/components/main/content.tsx @@ -31,12 +31,12 @@ import { } from '../../selectors'; import { history } from '../../utils/url'; import { Editor } from '../editor/editor'; -import { UnsupportedFileIcon } from '../shared/icons'; import { CloneStatus } from './clone_status'; import { CommitHistory, CommitHistoryLoading } from './commit_history'; import { Directory } from './directory'; +import { ErrorPanel } from './error_panel'; +import { NotFound } from './not_found'; import { TopBar } from './top_bar'; -import { UnsupportedFile } from './unsupported_file'; const ButtonsContainer = styled.div` display: flex; @@ -70,6 +70,7 @@ const Root = styled.div` `; interface Props extends RouteComponentProps { + isNotFound: boolean; repoStatus?: RepoStatus; tree: FileTree; file: FetchFileResponse | undefined; @@ -267,6 +268,9 @@ class CodeContent extends React.PureComponent { } public renderContent() { + if (this.props.isNotFound) { + return ; + } if (this.shouldRenderProgress()) { return this.renderProgress(); } @@ -306,8 +310,7 @@ class CodeContent extends React.PureComponent { const { lang: fileLanguage, content: fileContent, url, isUnsupported, isOversize } = file; if (isUnsupported) { return ( - } + Unsupported File} content="Unfortunately that’s an unsupported file type and we’re unable to render it here." /> @@ -315,8 +318,7 @@ class CodeContent extends React.PureComponent { } if (isOversize) { return ( - } + File is too big} content="Sorry about that, but we can’t show files that are this big right now." /> @@ -374,6 +376,7 @@ class CodeContent extends React.PureComponent { } const mapStateToProps = (state: RootState) => ({ + isNotFound: state.file.isNotFound, file: state.file.file, tree: state.file.tree, currentTree: currentTreeSelector(state), diff --git a/x-pack/plugins/code/public/components/main/unsupported_file.tsx b/x-pack/plugins/code/public/components/main/error_panel.tsx similarity index 86% rename from x-pack/plugins/code/public/components/main/unsupported_file.tsx rename to x-pack/plugins/code/public/components/main/error_panel.tsx index 9fa3a7967216f..f9deedfd2010f 100644 --- a/x-pack/plugins/code/public/components/main/unsupported_file.tsx +++ b/x-pack/plugins/code/public/components/main/error_panel.tsx @@ -8,20 +8,23 @@ import { EuiButton, EuiPanel, EuiSpacer, EuiText, EuiTextColor } from '@elastic/ import React, { ReactNode } from 'react'; import styled from 'styled-components'; import { history } from '../../utils/url'; +import { ErrorIcon } from '../shared/icons'; const Root = styled.div` width: 31rem; margin: auto; `; -export const UnsupportedFile = (props: { icon: ReactNode; title: ReactNode; content: string }) => { +export const ErrorPanel = (props: { title: ReactNode; content: string }) => { return ( {/* // @ts-ignore */} - {props.icon} + + + {/* // @ts-ignore */} {props.title} diff --git a/x-pack/plugins/code/public/components/main/main.tsx b/x-pack/plugins/code/public/components/main/main.tsx index 91f42d418396d..598fc59a31543 100644 --- a/x-pack/plugins/code/public/components/main/main.tsx +++ b/x-pack/plugins/code/public/components/main/main.tsx @@ -14,7 +14,6 @@ import { MainRouteParams } from '../../common/types'; import { RootState } from '../../reducers'; import { ShortcutsProvider } from '../shortcuts'; import { Content } from './content'; -import { NotFound } from './not_found'; import { SideTabs } from './side_tabs'; const Root = styled.div` @@ -32,7 +31,6 @@ const Container = styled.div` `; interface Props extends RouteComponentProps { - isNotFound: boolean; loadingFileTree: boolean; loadingStructureTree: boolean; } @@ -67,10 +65,7 @@ class CodeMain extends React.Component { } public render() { - const { loadingFileTree, loadingStructureTree, isNotFound } = this.props; - if (isNotFound) { - return ; - } + const { loadingFileTree, loadingStructureTree } = this.props; return ( @@ -89,7 +84,6 @@ class CodeMain extends React.Component { } const mapStateToProps = (state: RootState) => ({ - isNotFound: state.file.isNotFound, loadingFileTree: state.file.loading, loadingStructureTree: state.symbol.loading, }); diff --git a/x-pack/plugins/code/public/components/main/not_found.tsx b/x-pack/plugins/code/public/components/main/not_found.tsx index 20ed05c2d2ca0..aa7a03f978da9 100644 --- a/x-pack/plugins/code/public/components/main/not_found.tsx +++ b/x-pack/plugins/code/public/components/main/not_found.tsx @@ -7,9 +7,18 @@ import React from 'react'; import styled from 'styled-components'; import { fontSizes } from '../../style/variables'; +import { ErrorPanel } from './error_panel'; const Container = styled.div` margin: auto; fontsize: ${fontSizes.xlarge}; `; -export const NotFound = () => 404, Not Found; + +export const NotFound = () => ( + + 404} + content="Unfortunately that page doesn’t exist. You can try searching to find what you’re looking for." + /> + +); diff --git a/x-pack/plugins/code/public/components/shared/icons.tsx b/x-pack/plugins/code/public/components/shared/icons.tsx index 2e9448a75b81f..9e4e51eef97ac 100644 --- a/x-pack/plugins/code/public/components/shared/icons.tsx +++ b/x-pack/plugins/code/public/components/shared/icons.tsx @@ -171,7 +171,7 @@ export const BinaryFileIcon = () => ( ); -export const UnsupportedFileIcon = () => ( +export const ErrorIcon = () => (