Skip to content

[8.x] [Dashboard] Inject / extract tag references (#214788)#217590

Merged
nickpeihl merged 2 commits intoelastic:8.xfrom
nickpeihl:backport/8.x/pr-214788
Apr 9, 2025
Merged

[8.x] [Dashboard] Inject / extract tag references (#214788)#217590
nickpeihl merged 2 commits intoelastic:8.xfrom
nickpeihl:backport/8.x/pr-214788

Conversation

@nickpeihl
Copy link
Copy Markdown
Contributor

Backport

This will backport the following commits from main to 8.x:

Questions ?

Please refer to the Backport tool documentation

Fixes elastic#210619

## Summary

Provides a tags array on the request and response bodies of dashboards.

This allows consumers of the Dashboards HTTP API and internal RPC API to
add an array of tag names to the attributes in the body of create and
update endpoints. The dashboard server will be responsible for
converting the tag names into references in the saved object.

If, during creation or update, a tag name does not have a matching tag
saved object, a new tag saved object will be created. If the user lacks
permissions to manage tags, then an error will be logged in the server
and the tag will not be added to the dashboard.

The server also injects the tag references as an array of tag names in
the attributes of the response body of get and search endpoints of the
HTTP and RPC APIs.

For backwards compatibility in create and update endpoints, tags can
alternatively be specified in the `references` array in the options
instead of (or in addition to) the `attributes.tags` in the request
body. Similarly, for backwards compatibility, tag references are
returned in the `references` of the response body of get and search
endpoints.

Client-side tag handling is out of scope for this PR. Dashboards listing
page and dashboard settings continue to use the tag references and do
not use the `tags` attribute in the response.

For example:

Here's how we currently create a dashboard with tag references.
```
## Creating a dashboard with tag references
POST kbn:/api/dashboards/dashboard
{
  "attributes": {
    "title": "my tagged dashboard"
  },
  "references": [
    {
      "type": "tag",
      "id": "37aab5de-a34d-47cb-9aa5-9375d5db595f",
      "name": "tag-ref-37aab5de-a34d-47cb-9aa5-9375d5db595f"
    },
    {
      "type": "tag",
      "id": "5ed29bba-c14d-4302-9a8c-9602e40dbc2a",
      "name": "tag-ref-5ed29bba-c14d-4302-9a8c-9602e40dbc2a"
    },
    {
      "type": "tag",
      "id": "fc7890e8-c00f-44a1-88a2-250e4d27e61d",
      "name": "tag-ref-fc7890e8-c00f-44a1-88a2-250e4d27e61d"
    }
  ]
}
```

With this PR, creating a dashboard with tags is much simpler.

```
## Creating a dashboard with tag names
POST kbn:/api/dashboards/dashboard
{
  "attributes": {
    "title": "my tagged dashboard",
    "tags": [
      "boo",
      "foo",
      "bingo",
      "bongo"
    ]
  }
}

```

### Checklist

Check the PR satisfies following conditions.

Reviewers should verify this PR satisfies this list as well.

- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
- [x] The PR description includes the appropriate Release Notes section,
and the correct `release_note:*` label is applied per the
[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)

### Identify risks

Does this PR introduce any risks? For example, consider risks like hard
to test bugs, performance regression, potential of data loss.

Describe the risk, its severity, and mitigation for each identified
risk. Invite stakeholders and evaluate how to proceed before merging.

- [ ] If there are more than one tag saved objects with the same name,
only one of the tag references will be added to the saved object when
creating a dashboard. Creating tags with duplicate names are not
permitted via the UI. But there is no such restrictions when creating
tags from imported saved objects. Having multiple tags with the same
name is an edge case that Kibana guards against with reasonable
restrictions, so I think we should not be too concerned about it.
- [ ] ...

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
(cherry picked from commit c4f7c64)

# Conflicts:
#	src/platform/plugins/shared/dashboard/server/content_management/dashboard_storage.ts
#	src/platform/plugins/shared/dashboard/server/plugin.ts
@nickpeihl nickpeihl requested a review from kibanamachine as a code owner April 8, 2025 20:48
@nickpeihl nickpeihl added the backport This PR is a backport of another PR label Apr 8, 2025
@nickpeihl nickpeihl enabled auto-merge (squash) April 8, 2025 20:48
@elasticmachine
Copy link
Copy Markdown
Contributor

💛 Build succeeded, but was flaky

Failed CI Steps

Metrics [docs]

✅ unchanged

History

@nickpeihl nickpeihl merged commit b078ff2 into elastic:8.x Apr 9, 2025
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport This PR is a backport of another PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants