Skip to content

Commit

Permalink
restricted and tags edit
Browse files Browse the repository at this point in the history
  • Loading branch information
ErykKul committed Jun 18, 2024
1 parent b5d04fb commit 5228ce9
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 4 deletions.
10 changes: 8 additions & 2 deletions src/files/domain/models/FileUploadState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ export interface FileUploadState {
fileType: string
key: string
description?: string
tags: string[]
restricted: boolean
}

export interface FileUploaderState {
Expand All @@ -40,7 +42,9 @@ export class FileUploadTools {
fileName: file.name,
fileDir: this.toDir(file.webkitRelativePath),
fileType: file.type,
key: key
key: key,
tags: [],
restricted: false
}
newState.set(key, newValue)
})
Expand Down Expand Up @@ -68,7 +72,9 @@ export class FileUploadTools {
fileName: file.name,
fileDir: this.toDir(file.webkitRelativePath),
fileType: file.type,
key: this.key(file)
key: this.key(file),
tags: [],
restricted: false
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/files/infrastructure/FileJSDataverseRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ export class FileJSDataverseRepository implements FileRepository {
file: {
lastModified: file.fileLastModified,
name: file.fileName,
webkitRelativePath: file.fileDir ? (file.fileDir + '/' + file.fileName) : file.fileName,
webkitRelativePath: file.fileDir ? file.fileDir + '/' + file.fileName : file.fileName,
size: file.fileSize,
type: file.fileType,
arrayBuffer: function (): Promise<ArrayBuffer> {
Expand Down
34 changes: 33 additions & 1 deletion src/sections/upload-dataset-files/UploadedFiles.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Button, Card, Col, Form } from '@iqss/dataverse-design-system'
import { X } from 'react-bootstrap-icons'
import { Plus, X } from 'react-bootstrap-icons'
import { FileUploadState } from '../../files/domain/models/FileUploadState'
import styles from './FileUploader.module.scss'
import { FormEvent, useState } from 'react'
Expand Down Expand Up @@ -42,6 +42,15 @@ export function UploadedFiles({
file.description = updated
updateFile(file)
}
const updateFileRestricted = (file: FileUploadState, updated: boolean) => {
file.restricted = updated
updateFile(file)
// TODO: show dialog for restriction
}

const addTag = (file: FileUploadState) => {
// TODO: show dialog for tag
}

return (
<div hidden={fileUploadState.length === 0}>
Expand Down Expand Up @@ -111,6 +120,29 @@ export function UploadedFiles({
/>
</Col>
</Form.Group>
<Form.Group>
<Form.Group.Label column sm={3}>
Restricted
</Form.Group.Label>
<Col sm={9}>
<Form.Group.Checkbox
label=""
id={'restricted-' + file.key}
defaultChecked={file.restricted}
onChange={(event: FormEvent<HTMLInputElement>) =>
updateFileRestricted(file, event.currentTarget.checked)
}
/>
</Col>
</Form.Group>
<Button
variant="secondary"
{...{ size: 'sm' }}
withSpacing
onClick={() => addTag(file)}>
<Plus className={styles.icon} title="Add tag" />
Tag
</Button>
</Form>
</div>
<div className={styles.file_size}>{file.fileSizeString}</div>
Expand Down

0 comments on commit 5228ce9

Please sign in to comment.