redhat-developer / vscode-wizard

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Manage binding between model and UI

angelozerr opened this issue · comments

Today wizard accept only Map as data model. It should be nice that wizard accept any object and bind the UI with the object without extra code (without coding initialValue or without coding populate of data map).

When perform finish or validate is processed, the idea is to work with the object (that we can cast it) and not with data parameters array.

Here some databinding that I would liek to manage in vscode-kafka:

Checkbox with cluster#ssl

I have cluster instance with ssl property which is a boolean (which can be undefined), today I write that:

{
   id: "ssl",
   label: "Enable SSL",
   initialValue: !(cluster?.ssl === undefined || cluster?.ssl === false) ? 'true' : undefined,
   type: "checkbox"
}

See https://github.com/jlandersen/vscode-kafka/blob/86f0b7326d8f2c67c7eaba2a69861b4b4e6252cb/src/wizards/clusters.ts#L283

I would like just to write:

{
   id: "ssl",
   label: "Enable SSL",
   type: "checkbox"
}

and in validate instead of writing

function isSSLEnabled(data: any) {
   return (data[CLUSTER_SSL_FIELD] === true || data[CLUSTER_SSL_FIELD] === 'true');
}

See https://github.com/jlandersen/vscode-kafka/blob/86f0b7326d8f2c67c7eaba2a69861b4b4e6252cb/src/wizards/clusters.ts#L381

I would like to write:

function isSSLEnabled(data: Cluster) {
   return data.ssl;
}

Nested properties

I have cluster instance with saslOption.username nested property which is a boolean (which can be undefined), today I write that:

{
  id: "saslOption.username",
  label: "Username:",
  initialValue: `${cluster?.saslOption?.username || ''}`,
  type: "textbox"
}

See https://github.com/jlandersen/vscode-kafka/blob/86f0b7326d8f2c67c7eaba2a69861b4b4e6252cb/src/wizards/clusters.ts#L265

I would like just to write:

{
  id: "saslOption.username",
  label: "Username:",
  type: "textbox"
}

And validator and perform finish should populuate the nested property saslOption.