-
Notifications
You must be signed in to change notification settings - Fork 16
IRSA-7274: Download Dialog & Checkbox improvements #1855
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
Conversation
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’m approving this PR since it works as expected. However, I’m not sold on the implementation or the presentation of the “All Data” checkbox. I think it would be good for someone else to review that part as well.
//ensure '_all_' ("All data") is always included, even as a fallback when semList is empty | ||
//and make it the first option | ||
options.unshift({ label: 'All Data', value: '_all_' }); |
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 don’t like the idea of presenting an “All data” checkbox that looks identical to the other checkboxes. Typically, a “Select All” control isn’t presented in the same way as the rest of the checkboxes.
I also don’t like the weak coupling of _all_
as a reserved value of the CheckboxGroup.
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.
Yes you're right. I tried separating the All Data
out onto a separate line and keeping the other options nested under it, but I ran into some weird bugs with separating out the checkbox groups that way. Let me give it a try again, though.
The other option is removing All Data
as an option for now. What I don't like is how it works now (before this PR), where when you can select All Data
and, say, 2 other options (out of 6 total options). But since you have All Data
selected, it's anyway going to download all the data (even though you only have 2 other options selected).
So in my opinion, we either fix All Data
to work like a Select all
checkbox or we remove it altogether as an option (which is logic that we do have elsewhere on firefly as well).
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.
If you need a reusable Select All
widget, you can export one from CheckboxGroupInputField
. It should only take fieldKey
and the optional props groupKey
and label
. That’s all the information required to fully control the checkbox group. You can then render it anywhere you like. An option for your case is next to the Products to Download
label.
e89f3a7
to
7f579fb
Compare
@loitly new changes are ready for review (tomorrow or Monday when you get a chance). A summary of changes:
Let me know what you think. And if it looks good then, should I document some of this usage in the code as comments above BTW: testing instructions are same as above. I just changed
|
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.
Please keep the 'Select All' logic confined to SelectAllCheckbox component.
return !isDatalink && ( | ||
<Stack spacing={2}> |
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.
Minor: I thought you show Products to Download
when it is a datalink table.
Also, since isDatalink
is static, does it make sense to reserve a prop for it? Logic could be
isDatalink && <ProductTypesBlock/>
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.
Yes that's intended to be !isDatalink
. But I can see why that's confusing based on our conversation yesterday. We want to show Products to Download
for rows pointing to datalink (so rows containing an access_url
). For example when you do an Image search on Euclid. So by looking at the datalink we can get a list of the products available to download, and then we display them to the user.
But when you actually have a datalink table directly, like so:

(you get to this by extracting the current row and doing Show table of all Euclid products
)
Since this table is directly datalink, and users can see the semantics directly (and download each one), there's no point of showing the Products to Download
here.
I agree about the prop logic, it's unnecessary there. I'll change to:
!isDatalink && <ProductTypesBlock/>
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.
Oh and BTW I notice the bug there. Generate Download Script
& Prepare Download
both showing up for the datalink table. Unfortunately on ops. I had fixed this bug, but after having made some more changes (and fixing a spherex bug related to this), it must have creeped back in. Creating a bug ticket for myself.
<Stack spacing={1} m={1}> | ||
<CheckboxGroupInputField | ||
fieldKey='productTypes' | ||
options={dynamicOptions.filter((op) => op.value !== '_all_')} |
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.
There should not be any reference to _all_
.
<FieldGroup groupKey={tbl_id}> | ||
<Stack> | ||
<DownloadButton key={keysToWatch} | ||
buttonText = {downloadType === 'script' ? 'Generate Download Script' : 'Prepare Download'}> | ||
<DownloadOptionPanel {...{ |
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.
Minor: it's a good idea to move this into a separate component. It makes it easier to read as well as identifying props(input).
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.
Not sure about this one, let's talk briefly on Monday morning before the meeting?
function handleOnChange(ev, viewProps, fireValueChange) { | ||
// when a checkbox is checked or unchecked | ||
// the array, representing the value of the group, | ||
// needs to be updated | ||
const value= convertValue(viewProps.value,viewProps.options); | ||
|
||
const val = ev.target.value; | ||
const checked = ev.target.checked; | ||
const curValueArr = getCurrentValueArr(value); | ||
const idx = curValueArr.indexOf(val); | ||
if (checked) { | ||
if (idx < 0) curValueArr.push(val); // add val to the array | ||
const allValues = (viewProps.options ?? []).map((option) => option.value); | ||
|
||
//expand '_all_' into the full options list and use that as the list of curr values array | ||
const normalizedValue = convertValue(viewProps.value, viewProps.options); | ||
const curValueArr = getCurrentValueArr(normalizedValue); |
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.
Logic should not be here. It should be in the SelectAllCheckbox
component.
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.
Ok yes I understand this now. Separation of concern as well! I'll implement this.
b7e24b5
to
b398e87
Compare
Thanks for the feedback again @loitly. This revision should be a lot cleaner:
I'll work on fixing the styling (bit too much space between the product types and the flattened file structure option, even more when you see the cutout size line). Let me know what you think? |
b398e87
to
598f00f
Compare
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.
Tested the changes and it works as expected.
Okay to merge when ready.
const isCutoutSelected = (() => { | ||
if (!productTypes) return false; | ||
const vals = productTypes.split(',').map((val) => val.trim()); | ||
return vals.includes('#cutout'); | ||
})(); |
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.
Out of curiosity, is there a reason this is defined as a function and then called right away? Isn't this the same as ...
const isCutoutSelected = productTypes?.split(',').map((val) => val.trim()).includes('#cutout');
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.
Yes,I was doing some more stuff in it in previous iterations (like checking for #all in addition to #cutout) - but it's now simple enough to have it be the one line variable instead of function like you suggested. So I'll make the change.
return ( | ||
<Stack direction='row' alignItems='center'> | ||
<Checkbox | ||
size='sm' |
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.
The code looks good. Thanks for the changes.
If you want to make it more reusable, consider removing the root Stack component and adding a props parameter. Then, spread those props into the Checkbox. This will allow users of the component to customize its styling more easily.
e430668
to
7a69fc1
Compare
@loitly I only made minor changes, but if you want to take a look at the latest commit, here's what it essentially does:
|
@robyww the bug I found in firefly is that if we initialize
If this is too verbose, we can discuss briefly tomorrow morning on zoom. I'd like to just put this fix into the PR as well before merging then. |
7a69fc1
to
a7b11c2
Compare
a7b11c2
to
57ccaa9
Compare
Ticket: https://jira.ipac.caltech.edu/browse/IRSA-7274
cutout
from the download dialog, we now notify them of the current cutout size (and point them to the cutout dialog if they need to change it)CheckboxGroupInputField
that allowAll Data
to basically operate as aSelect All
buttonCheckboxGroupInputField
CheckboxGroupInputField
, this logic was partially in place (e.g. it does expect_all_
and_none_
as options).Select all
type option, which when selected, selects all other options, and is automatically unselected when you unselect any of the other options.CheckboxGroupInputField
is usedTesting:
All Data
selection (select/unselect it, manually select all other options whenAll Data
is unselected, etc.)All Data
is selected, or when you manually selectCutout
, you should see the cutout size show up dynamicallyCheckboxGroupInputField
, a couple of instances are:X label
orY label
likegrid, reverse, top, log
(select/unselect any of these and apply to make sure it works as expected)Select Data Set
on theImages
tab.Mission
:Wise
and thenWise ALLWISE Atlas
(the first option). Make sure all of the nested options under it are also selected.