Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Manage binding between model and UI #85

Open
angelozerr opened this issue Aug 3, 2021 · 0 comments
Open

Manage binding between model and UI #85

angelozerr opened this issue Aug 3, 2021 · 0 comments

Comments

@angelozerr
Copy link
Collaborator

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant