Open axelboc opened 4 weeks ago
The idea is that a method needs to be set to true
in available_methods
to be available. It has in most cases little meaning for the standard datacollection
and characterisation
. Its true that available_methods
is not yet respected on the sample list page and that is something we should address. There are probably some details to this that we should discuss to make this a bit more clear, but you are right that the current logic is quite convoluted and the concept only partially implemented. I'll pass by tomorrow and we can have a look at some of this to get the cleanup continued.
Thanks, okay, so basically:
datacollection
and characterisation
)true
in the config)I'd also argue that we don't actually need to expose available_methods
to the UI, since it's only used by the sample view's context menu and the same information can be inferred from the taskForm.defaultParameters
object (if a method is present in this object then it's available). I could make a hook like useMethodAvailable()
to abstract this so it's clear in the code.
Thanks @axelboc thats a good and clear summary :). It also a good idea to not expose available_methods
, taskForm.defaultParameters
would contain the same information.
I'm trying to refactor the
ContextMenu
component and some of the code relies on the beamline configuration below, so I'd like to understand its purpose a bit better:This
available_methods
configuration is first made available to the front-end through thebeamline.availableMethod
global state, which is used to hide options from the sample view's context menu.The code that does this is unnecessarily convoluted, but basically it removes any option with a matching key in
available_methods
that is set tofalse
. So if we have:... then the context menu action with key
datacollection
doesn't get displayed. The current logic cares only about "methods" that are set tofalse
and ignores the others (i.e. it's an opt-out mechanism).Now the
available_methods
configuration is also used inQueue#get_available_tasks()
. In this case, it's an opt-in mechanism: each task is made available only if its corresponding key is defined and set totrue
inavailable_methods
.Available tasks are made available to the front-end through the
taskForm.defaultParameters
global state:When a "method" is set to
false
(or not set all) inavailable_methods
, the corresponding task no longer appears in thedefaultParameters
object.Okay, so with all this in mind, I'm curious to know how the
available_methods
is actually used in practice:datacollection
tofalse
, for instance, it removes the Data Collection option from the sample view's context menu, but not from the drop-downs and context menus on the Samples page (e.g. Add Task to Samples button) ... in fact it makes those remaining Data Collection options inoperable (error in the console).true
inavailable_methods
for it to be exposed to the UI, then isn't this simply incompatible with the opt-out mechanism of the sample view's context menu? Is there a way that I'm not seeing to expose a task but also hide it from the context menu? Is this even a need in practice?