Add adding files to upload zone
[arvados-workbench2.git] / src / models / collection-file.ts
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4
5 import { Tree } from './tree';
6
7 export type CollectionFilesTree = Tree<CollectionDirectory | CollectionFile>;
8
9 export enum CollectionFileType {
10     DIRECTORY = 'directory',
11     FILE = 'file'
12 }
13
14 export interface CollectionDirectory {
15     path: string;
16     id: string;
17     name: string;
18     type: CollectionFileType.DIRECTORY;
19 }
20
21 export interface CollectionFile {
22     path: string;
23     id: string;
24     name: string;
25     size: number;
26     type: CollectionFileType.FILE;
27 }
28
29 export interface CollectionUploadFile {
30     name: string;
31 }
32
33 export const createCollectionDirectory = (data: Partial<CollectionDirectory>): CollectionDirectory => ({
34     id: '',
35     name: '',
36     path: '',
37     type: CollectionFileType.DIRECTORY,
38     ...data
39 });
40
41 export const createCollectionFile = (data: Partial<CollectionFile>): CollectionFile => ({
42     id: '',
43     name: '',
44     path: '',
45     size: 0,
46     type: CollectionFileType.FILE,
47     ...data
48 });