2021-05-21 07:32:51 -04:00
|
|
|
import { ContextRoot } from '../js/shared/context/root-context'
|
2021-06-10 07:26:04 -04:00
|
|
|
import FileView from '../js/features/file-view/components/file-view'
|
2021-05-11 10:25:22 -04:00
|
|
|
import useFetchMock from './hooks/use-fetch-mock'
|
2021-04-28 07:41:20 -04:00
|
|
|
|
2021-05-11 10:25:22 -04:00
|
|
|
const setupFetchMock = fetchMock => {
|
|
|
|
fetchMock
|
|
|
|
.head('express:/project/:project_id/file/:file_id', {
|
|
|
|
status: 201,
|
|
|
|
headers: { 'Content-Length': 10000 },
|
|
|
|
})
|
|
|
|
.get('express:/project/:project_id/file/:file_id', 'Text file content')
|
|
|
|
.post('express:/project/:project_id/linked_file/:file_id/refresh', {
|
|
|
|
status: 204,
|
|
|
|
})
|
|
|
|
.post('express:/project/:project_id/references/indexAll', {
|
|
|
|
status: 204,
|
|
|
|
})
|
|
|
|
}
|
2021-04-28 07:41:20 -04:00
|
|
|
|
2021-05-04 07:36:32 -04:00
|
|
|
const fileData = {
|
|
|
|
id: 'file-id',
|
|
|
|
name: 'file.tex',
|
2021-05-21 07:32:51 -04:00
|
|
|
created: new Date().toISOString(),
|
2021-05-04 07:36:32 -04:00
|
|
|
}
|
|
|
|
|
2021-04-28 07:41:20 -04:00
|
|
|
export const FileFromUrl = args => {
|
2021-06-10 07:26:04 -04:00
|
|
|
return <FileView {...args} />
|
2021-04-28 07:41:20 -04:00
|
|
|
}
|
|
|
|
FileFromUrl.args = {
|
|
|
|
file: {
|
2021-05-04 07:36:32 -04:00
|
|
|
...fileData,
|
2021-04-28 07:41:20 -04:00
|
|
|
linkedFileData: {
|
|
|
|
url: 'https://overleaf.com',
|
|
|
|
provider: 'url',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
export const FileFromProjectWithLinkableProjectId = args => {
|
2021-06-10 07:26:04 -04:00
|
|
|
return <FileView {...args} />
|
2021-04-28 07:41:20 -04:00
|
|
|
}
|
|
|
|
FileFromProjectWithLinkableProjectId.args = {
|
|
|
|
file: {
|
2021-05-04 07:36:32 -04:00
|
|
|
...fileData,
|
2021-04-28 07:41:20 -04:00
|
|
|
linkedFileData: {
|
|
|
|
source_project_id: 'source-project-id',
|
|
|
|
source_entity_path: '/source-entity-path.ext',
|
|
|
|
provider: 'project_file',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
export const FileFromProjectWithoutLinkableProjectId = args => {
|
2021-06-10 07:26:04 -04:00
|
|
|
return <FileView {...args} />
|
2021-04-28 07:41:20 -04:00
|
|
|
}
|
|
|
|
FileFromProjectWithoutLinkableProjectId.args = {
|
|
|
|
file: {
|
2021-05-04 07:36:32 -04:00
|
|
|
...fileData,
|
2021-04-28 07:41:20 -04:00
|
|
|
linkedFileData: {
|
|
|
|
v1_source_doc_id: 'v1-source-id',
|
|
|
|
source_entity_path: '/source-entity-path.ext',
|
|
|
|
provider: 'project_file',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
export const FileFromProjectOutputWithLinkableProject = args => {
|
2021-06-10 07:26:04 -04:00
|
|
|
return <FileView {...args} />
|
2021-04-28 07:41:20 -04:00
|
|
|
}
|
|
|
|
FileFromProjectOutputWithLinkableProject.args = {
|
|
|
|
file: {
|
2021-05-04 07:36:32 -04:00
|
|
|
...fileData,
|
2021-04-28 07:41:20 -04:00
|
|
|
linkedFileData: {
|
|
|
|
source_project_id: 'source_project_id',
|
|
|
|
source_output_file_path: '/source-entity-path.ext',
|
|
|
|
provider: 'project_output_file',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
export const FileFromProjectOutputWithoutLinkableProjectId = args => {
|
2021-06-10 07:26:04 -04:00
|
|
|
return <FileView {...args} />
|
2021-04-28 07:41:20 -04:00
|
|
|
}
|
|
|
|
FileFromProjectOutputWithoutLinkableProjectId.args = {
|
|
|
|
file: {
|
2021-05-04 07:36:32 -04:00
|
|
|
...fileData,
|
2021-04-28 07:41:20 -04:00
|
|
|
linkedFileData: {
|
|
|
|
v1_source_doc_id: 'v1-source-id',
|
|
|
|
source_output_file_path: '/source-entity-path.ext',
|
|
|
|
provider: 'project_output_file',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
export const ImageFile = args => {
|
2021-06-10 07:26:04 -04:00
|
|
|
return <FileView {...args} />
|
2021-04-28 07:41:20 -04:00
|
|
|
}
|
|
|
|
ImageFile.args = {
|
|
|
|
file: {
|
2021-05-04 07:36:32 -04:00
|
|
|
...fileData,
|
2021-04-28 07:41:20 -04:00
|
|
|
id: '60097ca20454610027c442a8',
|
|
|
|
name: 'file.jpg',
|
|
|
|
linkedFileData: {
|
|
|
|
source_project_id: 'source_project_id',
|
|
|
|
source_entity_path: '/source-entity-path',
|
|
|
|
provider: 'project_file',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
export const ThirdPartyReferenceFile = args => {
|
2021-06-10 07:26:04 -04:00
|
|
|
return <FileView {...args} />
|
2021-04-28 07:41:20 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
ThirdPartyReferenceFile.args = {
|
|
|
|
file: {
|
2021-05-04 07:36:32 -04:00
|
|
|
...fileData,
|
2021-04-28 07:41:20 -04:00
|
|
|
name: 'example.tex',
|
|
|
|
linkedFileData: {
|
|
|
|
provider: 'zotero',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
export const ThirdPartyReferenceFileWithError = args => {
|
2021-06-10 07:26:04 -04:00
|
|
|
return <FileView {...args} />
|
2021-04-28 07:41:20 -04:00
|
|
|
}
|
|
|
|
ThirdPartyReferenceFileWithError.args = {
|
|
|
|
file: {
|
2021-05-04 07:36:32 -04:00
|
|
|
...fileData,
|
2021-04-28 07:41:20 -04:00
|
|
|
id: '500500500500500500500500',
|
|
|
|
name: 'example.tex',
|
|
|
|
linkedFileData: {
|
|
|
|
provider: 'zotero',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
export const TextFile = args => {
|
2021-06-10 07:26:04 -04:00
|
|
|
return <FileView {...args} />
|
2021-04-28 07:41:20 -04:00
|
|
|
}
|
|
|
|
TextFile.args = {
|
|
|
|
file: {
|
2021-05-04 07:36:32 -04:00
|
|
|
...fileData,
|
2021-04-28 07:41:20 -04:00
|
|
|
linkedFileData: {
|
|
|
|
source_project_id: 'source-project-id',
|
|
|
|
source_entity_path: '/source-entity-path.ext',
|
|
|
|
provider: 'project_file',
|
|
|
|
},
|
|
|
|
name: 'file.txt',
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
export const UploadedFile = args => {
|
2021-06-10 07:26:04 -04:00
|
|
|
return <FileView {...args} />
|
2021-04-28 07:41:20 -04:00
|
|
|
}
|
|
|
|
UploadedFile.args = {
|
|
|
|
file: {
|
2021-05-04 07:36:32 -04:00
|
|
|
...fileData,
|
2021-04-28 07:41:20 -04:00
|
|
|
linkedFileData: null,
|
|
|
|
name: 'file.jpg',
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
export default {
|
2021-06-10 07:26:04 -04:00
|
|
|
title: 'FileView',
|
|
|
|
component: FileView,
|
2021-04-28 07:41:20 -04:00
|
|
|
args: {
|
|
|
|
storeReferencesKeys: () => {},
|
|
|
|
},
|
|
|
|
decorators: [
|
2021-05-11 10:25:22 -04:00
|
|
|
Story => {
|
|
|
|
useFetchMock(setupFetchMock)
|
|
|
|
return <Story />
|
|
|
|
},
|
|
|
|
Story => (
|
2021-04-28 07:41:20 -04:00
|
|
|
<>
|
|
|
|
<style>{'html, body { height: 100%; }'}</style>
|
2021-05-21 07:32:51 -04:00
|
|
|
<ContextRoot ide={window._ide} settings={{}}>
|
|
|
|
<Story />
|
|
|
|
</ContextRoot>
|
2021-04-28 07:41:20 -04:00
|
|
|
</>
|
|
|
|
),
|
|
|
|
],
|
|
|
|
}
|