ui icon indicating copy to clipboard operation
ui copied to clipboard

Nested attributes in objects

Open max06 opened this issue 1 year ago • 3 comments

Description

Hello there - sorry for the title, no idea how to phrase that....

There are multiple ui components taking an array of objects as input. In this case I want to talk about the SelectMenu.

<USelectMenu
  placeholder="Select an object"
  :options="flatObjects"
  option-attribute="name"
/>

This works great with flat objects. For unknown reason, I'm unable to specify a nested property (like metadata.name).

For these cases I have to create a computed, flat version of my original input array. Since I'm basically exclusively working with kubernetes manifests as input objects, I have to add a lot of wrappers for those.

I'm fine with that; however, I at least wanted to ask. 😅

Additional context

For reproduction, one of those objects, simplified:

  const specs = [{
    apiVersion: "some.api.io/v1alpha1",
    kind: "Spec",
    metadata: {
      creationTimestamp: "2024-02-26T13:42:36Z",
      generation: 3,
      name: "m1-small",
      namespace: "project",
      resourceVersion: "76533369",
      uid: "6567b033-b6fc-4ac7-ac56-1ed22853eea1"
    },
    spec: {
      disk: 20,
      ephemeral: 0,
      id: "5c48b89a-94b9-4e71-a838-69cdc09fb13e",
      name: "m1.small",
      public: true,
      ram: 2048,
      vcpus: 1
    },
    status: {
      status: "active"
    }
  }]

max06 avatar May 17 '24 20:05 max06

I have the same query but related to InputMenu component. I added a reproduction.

The docs say that search-attributes can be used with dot.notaton to access nested attributes, but it's not clear that it is only for the search-attributes until you try it out yourself. I would really like to be able to use it also for option-attribute and value-attribute to avoid unnecessary flattening when we have big nested objects.

Is this supported, or planned? Thanks :sunny:

mrjakebaker avatar Jun 03 '24 08:06 mrjakebaker

This issue is stale because it has been open for 30 days with no activity.

github-actions[bot] avatar Jul 18 '24 11:07 github-actions[bot]

This issue is not stale.

max06 avatar Jul 18 '24 12:07 max06

This issue is stale because it has been open for 30 days with no activity.

github-actions[bot] avatar Aug 19 '24 01:08 github-actions[bot]

Nope, it's not...

max06 avatar Aug 19 '24 10:08 max06

This issue is stale because it has been open for 30 days with no activity.

github-actions[bot] avatar Oct 07 '24 02:10 github-actions[bot]

@benjamincanac sorry for the ping - could you please clarify if this is something that could/should be done?

max06 avatar Oct 07 '24 09:10 max06

@max06 This is something that can be improved indeed 😊

benjamincanac avatar Oct 07 '24 09:10 benjamincanac

@benjamincanac lovely! Thanks for looking into it 🙇🏼

max06 avatar Oct 07 '24 11:10 max06