kibana/packages/home
Pierre Gayvallet c713b91e66
[HTTP] Add server/browser side http.staticAssets service (#171003)
## Summary

Part of https://github.com/elastic/kibana/issues/170421

### 1. Introduce the `http.staticAssets` service

Which can be used to generate hrefs to Kibana's static assets in a
CDN-friendly way (based on the CDN url if defined in the config, and the
Kibana's basePath otherwise)

The service is exposed both on the browser and server-side.

For now a single API is exposed: `getPluginAssetHref`

```ts
// returns "/plugins/{pluginId}/assets/some_folder/asset.png" when CDN isn't configured
core.http.statisAssets.getPluginAssetHref('some_folder/asset.png');
```

### 2. Plug it on some of the `home` plugin assets

Adapt the sample data sets and tutorial schemas to use the service for
links to the associated assets

## How to test

#### 1. Edit`/etc/hosts`

add a line `127.0.0.1       local.cdn`

#### 2. Edit `kibana.yaml`

Add `server.cdn.url: "http://local.cdn:5601"`

#### 3. Boot kibana and navigate to sample data set installation

(if started in dev mode, use `--no-base-path`)

Confirm that the sample data set presentation images are pointing to the
CDN url and properly displayed:

<img width="1565" alt="Screenshot 2023-11-13 at 09 28 51"
src="23a887af-00cb-400c-9ab1-511ba463495f">

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
2023-11-16 08:13:00 -07:00
..
sample_data_card [HTTP] Add server/browser side http.staticAssets service (#171003) 2023-11-16 08:13:00 -07:00
sample_data_tab [codeowners] rename global experience to @elastic/appex-sharedux 2023-01-18 10:02:49 -07:00
sample_data_types [codeowners] rename global experience to @elastic/appex-sharedux 2023-01-18 10:02:49 -07:00