Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 42 #57

Closed
wants to merge 6 commits into from
Closed

Issue 42 #57

wants to merge 6 commits into from

Conversation

ariannmichael
Copy link
Member

Description

Closes #42

  • Functions and types to integrate with api
  • Dataset view using data from the api
  • Create, Edit and Delete Dataset

Checklist

Copy link
Collaborator

@tcp tcp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @ariannmichael!

However, there is several points to improve before accepting this PR. Possibly extract some components, remove the use of overly specified modals, API calls that do not throw which breaks react-query and correct how state is updated.

setTensors(newTensors)
}

const toBase64 = file =>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

POST /dcfl/datasets accepts a file or a (plain) string but not base64 — @IonesioJunior can you confirm?


const renderTensorInputs = () => {
return tensors.map((el, i) => (
<div key={i}>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Disposable divs.

return tensors.map((el, i) => (
<div key={i}>
<div>
<label htmlFor="tensor_name" className="text-sm block font-bold pb-2">
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apply DRY here - inputs can be components or use an array to denote the form inputs and map over it. This becomes a lot of code real fast.

const {name, value} = event.target

const newFormObject = formObject
newFormObject[name] = value
Copy link
Collaborator

@tcp tcp Mar 21, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do not mutate state directly.

React will not go through the motions as expected if you update the state directly. It does strict equality comparison and you're changing a property but not the object itself — a re-render is not triggered.

}

const EditDatasetModal: FunctionComponent<IEditDatasetModalProps> = ({isOpen, onClose, onConfirm, dataset}) => {
const [formObject, setFormObject] = useState({
Copy link
Collaborator

@tcp tcp Mar 21, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, I think useReducer might make more sense here.

However, this is not needed at all — use react-hook-form to handle the form instead.

<strong>Schema</strong>:{' '}
<span className="text-gray-400">
<ul className="list-horizontal">
{tensor.manifest.split(',').map(el => (
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Free text.

<strong>File</strong>: <FileIcon className="h-4 text-gray-400" /> <span>{name}</span>
</span>
<span>
<strong>Shape</strong>: <span className="text-gray-400">{JSON.stringify(tensor.shape)}</span>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why use stringify here?

<span className="text-gray-400">
<ul className="list-horizontal">
{tensor.manifest.split(',').map(el => (
<li key={`${el}-element`}>{el}</li>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This causes problems as el is potentially not unique in tensor.manifest.split(',')

const router = useRouter()
const {slug} = router.query

const [openDeleteDatasetModal, setOpenDeleteDatasetModal] = useState(false)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use react-use-disclosure

@@ -24,6 +27,18 @@ export interface ICreateGroupResponse {
message: string
}

export interface ICreateDatasetResponse {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Several identical types. Is it possible to generalize?

@tcp tcp closed this Apr 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants