To make dataset management easy, we provide users three main dataset action buttons in UI which they can use to quickly add or remove downloadable samples to/from their datasets.
The dataset action buttons have three different states, which are as follows:
"Add to Dataset" (adds all the samples in the selected experiment to a user's dataset)
"Add Remaining" (displays the number of samples currently added to a user's dataset, and adds the rest)
"Remove" (removes all the samples in the selected experiment from a user's dataset)
Problem or idea
We'll implement the hook useDatasetAction which contains methods to render the correct button state in UI and to perform its corresponding dataset action. Each method corresponds to a specific application behavior.
❚ Parameters
Use of this hook requires the following parameters:
data1: a data object in a dataset with datasetId stored in a user's localStorage
data2: a data object in the API response selected by a user in UI (e.g., from the search results)
❚ Method
Following are the implementation details and pseudocode (parameters marked with * are required):
anyProcessedSamples() return boolean
returns true if any samples that are processed and available for download in data2, otherwise false
allProcessedInDataset() return boolean
returns true if all the processed samples in data2 were added to data1, otherwise false
anyProcessedInDataset() return boolean
returns true if any processed samples in data2 were added in data1, otherwise false
getAddedSamples() return samples
returns the samples in data2 that were added in data1
getSamplesInDatasets() return samples
returns all the samples that are in both data1 and data2
hasSameSamples(d1*, d2*) return boolean
returns true if two given datasets have the same samples, otherwise false
intersectDatasets(d1*, d2*) return object
returns the intersection of two given datasets
totalSamplesInDataset() return number
returns the total samples added in data1
Example: To use this hook, pass the required arguments and destructure the method(s) you want to use:
Context
To make dataset management easy, we provide users three main dataset action buttons in UI which they can use to quickly add or remove downloadable samples to/from their datasets.
The dataset action buttons have three different states, which are as follows:
Problem or idea
We'll implement the hook
useDatasetAction
which contains methods to render the correct button state in UI and to perform its corresponding dataset action. Each method corresponds to a specific application behavior.❚ Parameters
Use of this hook requires the following parameters:
data1
: a data object in a dataset withdatasetId
stored in a user's localStoragedata2
: a data object in the API response selected by a user in UI (e.g., from the search results)❚ Method
Following are the implementation details and pseudocode (parameters marked with * are required):
anyProcessedSamples() return boolean
returns true if any samples that are processed and available for download indata2
, otherwise falseallProcessedInDataset() return boolean
returns true if all the processed samples indata2
were added todata1
, otherwise falseanyProcessedInDataset() return boolean
returns true if any processed samples indata2
were added indata1
, otherwise falsegetAddedSamples() return samples
returns the samples indata2
that were added indata1
getSamplesInDatasets() return samples
returns all the samples that are in bothdata1
anddata2
hasSameSamples(d1*, d2*) return boolean
returns true if two given datasets have the same samples, otherwise falseintersectDatasets(d1*, d2*) return object
returns the intersection of two given datasetstotalSamplesInDataset() return number
returns the total samples added indata1
Example: To use this hook, pass the required arguments and destructure the method(s) you want to use:
Solution or next step
Based on the above requirements, implement the hook.