vmware-tanzu-labs / educates-training-platform

A platform for hosting interactive workshop environments in Kubernetes, or on top of a local container runtime.
https://docs.educates.dev
Apache License 2.0
63 stars 15 forks source link

Clickable action to replace YAML element in editor. #428

Open GrahamDumpleton opened 3 weeks ago

GrahamDumpleton commented 3 weeks ago

Is your feature request related to a problem? Please describe.

One can currently do:

```editor:insert-value-into-yaml
file: ~/lab-demo-workshop/resources/workshop.yaml
path: spec.session
value:
  objects:
  - apiVersion: apps/v1
    kind: Deployment
    ...
```

This will always insert a new element under the specified dictionary by using a path into the YAML, but it will result in a duplicate if a named sub property already exists.

This cannot be used to replace an existing element.

Describe the solution you'd like

Want a clickable action that can replace an existing element in the target YAML document.

```editor:replace-value-in-yaml
file: ~/lab-demo-workshop/resources/workshop.yaml
path: spec.applications.console
value:
  console:
    enabled: true
```

Describe alternatives you've considered

No response

Additional information

No response

GrahamDumpleton commented 3 weeks ago

Although might be able to be done with this, perhaps could also have an action to delete a YAML element.

jorgemoralespou commented 5 days ago

AN alternative, to not have so many different clickable actions could be to implement one edit-value-in-yaml and add an attribute with what needs to be done: action: add, action:replace, action:delete so that we only need to maintain one clickable action.

GrahamDumpleton commented 5 days ago

You would still have one server side implementation to maintain in the main where can. Having many clickable actions in front end which map to it with a hidden parameter for type of action is easy if can do that. Having more than one clickable name for different operations makes it more obvious the intent than a sub property. Overloading lots into one may also become more unmaintainable after a while if the YAML input for each sub type of operation are disparate and you are cramming them under one action.