-
Notifications
You must be signed in to change notification settings - Fork 26
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
Add folders to dataset table #6996
Conversation
…-folders-to-dataset-table
…-folders-to-dataset-table
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think everything should be working. Additionally, I looked through the code and it should be review ready.
@philippotto do you have time to take on this review? The pr is quite big/medium-sized. Or should I ask daniel?
button { | ||
color: white | ||
color: white; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this was prettier correcting the syntax
.icon-open-demo { | ||
background-image: url(/assets/images/icon-open-demo.svg); | ||
}; | ||
.icon-open-demo { | ||
background-image: url(/assets/images/icon-open-demo.svg); | ||
} | ||
.icon-import-own-data { | ||
background-image: url(/assets/images/icon-import-own-data.svg); | ||
background-image: url(/assets/images/icon-import-own-data.svg); | ||
background-size: 94px; | ||
}; | ||
} | ||
.icon-annotate { | ||
background-image: url(/assets/images/icon-annotate.svg); | ||
}; | ||
background-image: url(/assets/images/icon-annotate.svg); | ||
} | ||
.icon-invite-colleagues { | ||
background-image: url(/assets/images/icon-invite-colleagues.svg); | ||
}; | ||
background-image: url(/assets/images/icon-invite-colleagues.svg); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this was prettier correcting the syntax
Same here.
…ds/webknossos into add-folders-to-dataset-table
Yes, I think so :) |
Oh btw: My suggestion to tackle this would be to write a class for datasets and one for folders that have the same interface but depending on their implementation behave/render differently:
And the folder class would look like:
And then we could just render the name column with:
But as we usually do not create classes for such cases I did not implement this in the first version and decided to simply propose this first. IMO this would make the code cleaner and also easier to read and in case another type of row is added, this would be easier to extend upon. What do you think @philippotto? |
I agree in principle, but I'm a bit hesitant, since this would be a new pattern in this code base. However, I think, that this would be alright as long as those instances don't live in the react state. Otherwise, this would seem weird to me since these instances would only be dumb wrappers with some rendering behavior living in react state (I wouldn't want the caching context to be responsible for constructing these instances). I imagine something like this: class DatasetRendering {
renderNameColumn() {
return ...;
}
}
class FolderRendering {
renderNameColumn() {
return ...;
}
}
function getRenderer(datasetOrFolder) {
if (datasetOrFolder ... is dataset) {
return DatasetRendering(datasetOrFolder);
} else {
...
}
}
renderSomething() {
return getRenderer(datasetOrFolder).renderNameColumn();
} I'd hope that the browser can optimize these short lived objects away. But maybe you could make a micro benchmark to test that this only has a negligible impact when being compared to a simple if-else. What do you think? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome! Only commented some smaller stuff :) Also one other small thing: The "New Folder" in the Actions column might be clearer as "New Subfolder".
I know that the original issue outlined that dnd-features should come in another iteration. However, I noticed one particular dnd use case (that I just added to the issue) which is something I immediately tried out because it seemed intuitive. Namely: dragging a dataset from the dataset table to a folder within the same table. Could you have a look whether this is easy to achieve? I think, it's easier than the other dnd-features, because the dragged items (the datasets) are already implemented. the drag-target definition in the sidebar might be easy to reuse for the drag targets in the dataset table. if it takes more than 30 minutes, feel free to defer this to another PR :)
frontend/javascripts/dashboard/dataset/dataset_collection_context.tsx
Outdated
Show resolved
Hide resolved
frontend/javascripts/dashboard/advanced_dataset/dataset_table.tsx
Outdated
Show resolved
Hide resolved
Co-authored-by: Philipp Otto <[email protected]>
…-folders-to-dataset-table
I am also fine with keeping the code as it is right now and only implementing my suggestion in case another type of rows is added.
To fix that we could have a single instance of const datasetRenderer = new DatasetRender();
const folderRenderer = new FolderRender();
function getRenderer(datasetOrFolder) {
if (datasetOrFolder ... is dataset) {
return datasetRenderer;
} else {
...
}
}
renderSomething() {
return getRenderer(datasetOrFolder).renderNameColumn(datasetOrFolder); //<-- Needed as an argument as the method is static.
} My preferred version would be working with objects: const datasetRenderer = {
renderColumnA: (record) => {...},
renderColumnB: (record) => {...},
...
}
const folderRenderer = {
renderColumnA: (record) => {...},
renderColumnB: (record) => {...},
...
} in the render function map the renders to each record: render () {
// ...
const sortedDataSourceWithRenderer = sortedDataSource.map(record => isADataset(record) ? {...record, renderer: datasetRenderer} : {...record, renderer: folderRenderer});
//...
<FixedExpandableTable
dataSource={sortedDataSource}
//... Independent from which solution we choose, I'll do a micro-benchmark 👍 |
Yes, I like that one, too 👍 |
- Renaming, fixing potential issues, minor improvements etc.
TODO for me:
|
Results of the micro-benchmark with the classes version (Mapping each data to a class wrapping this data)Mapping more then 98 rows takes less then 0.1 milliseconds on my laptop (framework with very new hardware). I'd guess that this should also take up to ~2ms at max on a standard machine.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
great to see the refactoring worked out :)
frontend/javascripts/dashboard/advanced_dataset/dataset_table.tsx
Outdated
Show resolved
Hide resolved
frontend/javascripts/dashboard/advanced_dataset/dataset_table.tsx
Outdated
Show resolved
Hide resolved
Hi @philippotto, A short discussion with daniel resulted in only highlighting the folders in the dataset table if the user drags datasets over them and not all the time as done in the left folder hierarchy view. We did this, because in the artificial scenario, where I had only 2 datasets but 70 folders due to the benchmark mentioned above, having all folders highlighted looked confusing. Additionally, it is not ideal that the "drop area highlight color" is the same color used to mark datasets in the table as selected. |
…-folders-to-dataset-table
Awesome, works great 👍
I think the current way is absolutely fine 👍 The left sidebar is only highlighted during drag, so that the user knows that they can use the sidebar as a drop target (since the table and the sidebar are two visually disconnected components I found this sensible when I implemented this). Dragging a DS from the table to a folder in the table feels way more intuitive, since source and target are in the same component. Therefore, there's no need to highlight all valid drag targets in my opinion. Thus, only highlighting a folder while dragging a DS over it feels like the right approach to me 👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent as usual 👍 :)
|
||
const { canDrop, isOver } = collectedProps; | ||
console.log("canDrop", canDrop, "isOver", isOver); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove before merging
…-folders-to-dataset-table
This PR adds the child folders of the currently active folder in the dashboard to the dataset table. This pr should include all changes mentioned in #6883, except for the drag & drop feature. I disabled this for the folders as suggested to maybe not include this in the first iteration. Although if you think this should already be included, I can do it. I do not have an opinion on this except that leaving this feature away makes this pr earlier merge ready
URL of deployed dev instance (used for testing):
TODOs:
Optionally:
[ ] allow dragging dataset rows into a folder rowBugs
Steps to test:
Issues:
(Please delete unneeded items, merge only when none are left open)