microsoft / microsoft/AzureTRE
Support dynamic template properties
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 235
- Forks
- 192
- Avg merge
- 1d 23h
- Merged PRs (30d)
- 13
Description
I have a custom workspace template that (during initialisation via the TRE UI) requires a TRE admin to specify a string property value, that is an ID of a previously created TRE workspace . However, ideally I'd like to display a list of existing TRE workspace IDs in a dropdown, to avoid the user entering an ID of workspace that doesn't exist.
While it's possible to specify custom workspace template properties by including properties with an enum attribute to generate such a list of options. As far as I can tell its only possible to define an enum for a property statically in the template_schema.json file of the workspace template.
From looking at the code, one way to do this dynamically might be to define a property in template_schema.json that indicates that the property is dynamic and that the TRE UI app when rendering the workspace template form should make an additional API calls to populate the enum of the property with the relevant data e.g.
"primary_workspace_id": {
"type": "string",
"title": "Primary Workspace Identifier",
"description": "List of existing workspace IDs",
"dynamic_enum": {
"api_call":"api/workspaces",
"property_name":"workspace_id"
}
}
I'm not a React developer but the rendering appears to happen here >> https://github.com/microsoft/AzureTRE/blob/de141651ad9fb9f58e7b78e383edf263eaa549d1/ui/app/src/components/shared/create-update-resource/ResourceForm.tsx#L31C2-L50C1
So once the chooen workspace template is returned from cosmosdb, the list of properties are processed and where a dynamic property is found an additional handler performs the nessasary API call to populate the enum before the form data is set. For my specific case I'm able to reuse the existing TRE API calls (i.e. api/workspaces) without modification.
Any thoughts on this or best approaches to supporting this feature in the TRE?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with ui/app/src/components/shared/create-update-resource/ResourceForm.tsx and the workspace template_schema.json property handling, focusing on how static enum values are rendered. Trace the existing api/workspaces call and determine how a dynamic property could populate its options before the form is initialized. Done means a template can declare a dynamic property and the TRE UI displays current workspace IDs for selection.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- azure, react, typescript
- Domain
- api, backend, frontend
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100