Display worker configuration fields
https://redmine.teklia.com/issues/10348
Requires backend#1911 (closed) and backend#1912 (closed)
A new useWorkerConfigurationStore Pinia store at src/stores/workerConfiguration.ts will allow to manage the newer worker configuration system. It will for now only define a listFields(id: UUID) action, which calls ListWorkerConfigurationFields and stores the result in a fields state defined as { [versionId: UUID]: WorkerConfigurationField[] }.
The WorkerConfigurationField type should be defined in the existing src/types/workerConfiguration.ts. It should use type unions and intersections to make the various relations between fields clearer, which will make implementing the configuration forms much easier later:
- When
typeisenum,choicesis astring[] - When
typeis anything butenum,choicesisnull - When
typeisgroup,parent_idcan only benull(groups cannot be nested) - When
typeis notint,float,string,worker_versionorelement_type, thenmanycan only befalse - The type of
defaultdepends on thetypeof the field:-
bool:boolean -
int,float:number -
string,text,enum:string -
dict:Record<string, string> - When
manyis true, the type ofdefaultis an array of the type defined above. - For all types not defined above,
defaultcan only benull. - When
editableis true,defaultis also nullable.
-
This last part is certainly the most complex but will be very useful for the configuration form.
The worker version details view in src/views/Process/Workers/Version.vue should now use the Tabs component. A Details tab shows the current contents of the worker version page, with the state, creation date, version, branch, tag and configuration. When modern_configuration is enabled on the worker version, a new Configuration tab contains a new component, src/components/WorkerConfiguration/Fields.vue.
This component calls useWorkerConfigurationStore().listFields to list the fields of the current worker version. While the fields are loading, a loading spinner is shown. When there are no fields, a warning notification states that there are no configuration fields on this version. When an error occurs, an error notification states that
When fields are available, the component shows a table with four columns:
-
Name:
display_name, then a line break, then thekey -
Description: A human-readable representation of the
type, then a line break, then thehelp_text(if thehelp_textis empty, don't include a line break) -
Required: Either
Non-editable,RequiredorOptional, depending on the values ofeditableorrequired. -
Default value: For dicts, an unordered list of
<strong>key</strong>: value, and for other values, just the value itself. When there is no default, an em-dash is shown (—, —).
The last two columns should be shrunk to give as much space as possible to the name and description.