Skip to content

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 type is enum, choices is a string[]
  • When type is anything but enum, choices is null
  • When type is group, parent_id can only be null (groups cannot be nested)
  • When type is not int, float, string, worker_version or element_type, then many can only be false
  • The type of default depends on the type of the field:
    • bool: boolean
    • int, float: number
    • string, text, enum: string
    • dict: Record<string, string>
    • When many is true, the type of default is an array of the type defined above.
    • For all types not defined above, default can only be null.
    • When editable is true, default is 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 the key
  • Description: A human-readable representation of the type, then a line break, then the help_text (if the help_text is empty, don't include a line break)
  • Required: Either Non-editable, Required or Optional, depending on the values of editable or required.
  • 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 (&mdash;, —).

The last two columns should be shrunk to give as much space as possible to the name and description.