Skip to content

Commit

Permalink
fix(Preview): show PreviewNotFound when we don't have access to the…
Browse files Browse the repository at this point in the history
… version

if we don't have access to the particular version the user is trying to view, because the original owner of the dataset has not published it, show the `PreviewNotFound` component which explains the circumstances.
  • Loading branch information
ramfox committed Mar 2, 2020
1 parent 22480ea commit ce42883
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 2 deletions.
Binary file added app/assets/lost_blob.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 5 additions & 2 deletions app/components/dataset/Preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { FetchOptions } from '../../store/api'
import { BACKEND_URL } from '../../constants'

import Dataset from './Dataset'
import PreviewNotFound from './PreviewNotFound'
import SpinnerWithIcon from '../chrome/SpinnerWithIcon'

interface PreviewProps {
Expand Down Expand Up @@ -50,9 +51,11 @@ const Preview: React.FunctionComponent<PreviewProps> = (props) => {
fetchDataset()
}, [peername, name, path])

// TODO (ramfox): what does an error screen look like here? or do we just nav
// back to the network/home & pop up a toast?
if (error !== '') {
if (error.includes('not found')) {
return <PreviewNotFound />
}

return (
<div
style={{
Expand Down
16 changes: 16 additions & 0 deletions app/components/dataset/PreviewNotFound.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import React from 'react'
export const lostBlob = require('../../assets/lost_blob.png') // eslint-disable-line

const PreviewNotFound: React.FC = () => {
return (
<div className="preview-not-found">
<div className="container">
<img className='graphic' src={lostBlob} />
<h3>We can&apos;t get you this version... because we don&apos;t have it!</h3>
<p>This isn&apos;t a problem or error with Qri. It just means that, although we know this version exists, the author of this dataset hasn&apos;t published it :)</p>
</div>
</div>
)
}

export default PreviewNotFound
16 changes: 16 additions & 0 deletions app/scss/0.4.0/preview.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
.preview-not-found {
display: flex;
justify-content: center;
align-items: center;
height: 100%;
.container {
width: 400px;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
.graphic {
width: 200px;
}
}
}
1 change: 1 addition & 0 deletions app/scss/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,4 @@
@import "0.4.0/form";
@import "0.4.0/network";
@import "0.4.0/dataset";
@import "0.4.0/preview";

0 comments on commit ce42883

Please sign in to comment.