Dashboard gadget configuration

Hello folks,

Dashboard gadget configuration is related to the DashboardGadgetEdit Jira UI kit component. Function onSubmit has this description:

The onSubmit function must be provided for the gadget configuration to be saved. The values returned from onSubmit are the values that are saved as the gadget configuration.

When I tried to save a gadget configuration which contains an array from select list (Select and Option UI kit components), I’ve noticed, that such array is serialized as a string.

Then I tried to convert this array into object properties (the object returned by the onSubmit method), like this:

  const onSubmit = (values) => {
    return {
      ...values.field.reduce((a, v) => ({ ...a, [v]: true }), {})
    }
  }

Then I noticed that the returned object is not the one saved as the gadget configuration, but the saved configuration is updated using this return value – all the properties previously saved are untouched and I am not able to delete them.

Is this intended behavior or am I missing something?

What is correct way how to handle selects/options (i.e. arrays) in gadget configuration?

2 Likes

Hi @kbujacek. You are right that there seems to be discrepancy between docs and the actual implementation. We took over this feature from other team so I need to make sure what was the intended implementation and how we should handle arrays and will get back to you.

1 Like

@mszpyra , thanks!

In the meantime, it is possible to save base64 encoded JSON: it works, but it is really weird and inconvenient.

Hi @kbujacek, so the documentation is off and we will fix it. The value from submit function is not used as whole configuration object but is added to the existing one.

As for serialisation we fixed the encoding and now the value you get back should be the same that you saved. Arrays should work also. Let me know it works for you and if it solves your use case.

1 Like