Skip to content

Commit

Permalink
Merge branch 'main' into feat/read-license-to-infer-sub-feature-custo…
Browse files Browse the repository at this point in the history
…mization-permission
  • Loading branch information
elasticmachine authored Oct 10, 2024
2 parents 5de1855 + 2bb9c3c commit b4c520c
Show file tree
Hide file tree
Showing 36 changed files with 859 additions and 185 deletions.
2 changes: 1 addition & 1 deletion .buildkite/scripts/steps/cloud/build_and_deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ fi
if is_pr_with_label "ci:cloud-redeploy"; then
echo "--- Shutdown Previous Deployment"
CLOUD_DEPLOYMENT_ID=$(ecctl deployment list --output json | jq -r '.deployments[] | select(.name == "'$CLOUD_DEPLOYMENT_NAME'") | .id')
if [ -z "${CLOUD_DEPLOYMENT_ID}" ]; then
if [ -z "${CLOUD_DEPLOYMENT_ID}" ] || [ "${CLOUD_DEPLOYMENT_ID}" == "null" ]; then
echo "No deployment to remove"
else
echo "Shutting down previous deployment..."
Expand Down
2 changes: 1 addition & 1 deletion .buildkite/scripts/steps/serverless/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ deploy() {

PROJECT_ID=$(jq -r '[.items[] | select(.name == "'$PROJECT_NAME'")] | .[0].id' $PROJECT_EXISTS_LOGS)
if is_pr_with_label "ci:project-redeploy"; then
if [ -z "${PROJECT_ID}" ]; then
if [ -z "${PROJECT_ID}" ] || [ "${PROJECT_ID}" == "null" ]; then
echo "No project to remove"
else
echo "Shutting down previous project..."
Expand Down
4 changes: 3 additions & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,6 @@ When forming the risk matrix, consider some of the following examples and how th

### For maintainers

- [ ] This was checked for breaking API changes and was [labeled appropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)
- [ ] This was checked for breaking API changes and was [labeled appropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#_add_your_labels)
- [ ] This will appear in the **Release Notes** and follow the [guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)

4 changes: 4 additions & 0 deletions dev_docs/nav-kibana-dev.docnav.json
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,10 @@
{
"id": "kibDevReactKibanaContext",
"label": "Kibana React Contexts"
},
{
"id": "kibDevDocsChromeRecentlyAccessed",
"label": "Recently Viewed"
}
]
},
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
---
id: kibDevDocsChromeRecentlyAccessed
slug: /kibana-dev-docs/chrome/recently-accessed
title: Chrome Recently Viewed
description: How to use chrome's recently accessed service to add your links to the recently viewed list in the side navigation.
date: 2024-10-04
tags: ['kibana', 'dev', 'contributor', 'chrome', 'navigation', 'shared-ux']
---

## Introduction

The <DocLink id="kibKbnCoreChromeBrowserPluginApi" section="def-public.ChromeRecentlyAccessed" text="ChromeRecentlyAccessed" /> service allows applications to register recently visited objects. These items are displayed in the "Recently Viewed" section of a side navigation menu, providing users with quick access to their previously visited resources. This service includes methods for adding, retrieving, and subscribing to the recently accessed history.

![Recently viewed section in the sidenav](./chrome_recently_accessed.png)

## Guidelines

The <DocLink id="kibKbnCoreChromeBrowserPluginApi" section="def-public.ChromeRecentlyAccessed" text="ChromeRecentlyAccessed" /> service should be used thoughtfully to provide users with easy access to key resources they've interacted with. Unlike browser history, this feature is for important items that users may want to revisit.

### DOs

- Register important resources that users may want to revisit. Like a dashboard, a saved search, or another specific object.
- Update the link when the state of the current resource changes. For example, if a user changes the time range while on a dashboard, update the recently viewed link to reflect the latest viewed state where possible. See below for instructions on how to update the link when state changes.

### DON'Ts

- Don't register every page view.
- Don't register temporary or transient states as individual items.
- Prevent overloading. Keep the list focused on high-value resources.
- Don't add a recently viewed object without first speaking to relevant Product Managers.

## Usage

To register an item with the `ChromeRecentlyAccessed` service, provide a unique `id`, a `label`, and a `link`. The `id` is used to identify and deduplicate the item, the `label` is displayed in the "Recently Viewed" list and the `link` is used to navigate to the item when selected.

```ts
const link = '/app/map/1234';
const label = 'Map 1234';
const id = 'map-1234';

coreStart.chrome.recentlyAccessed.add(link, label, id);
```

To update the link when state changes, add another item with the same `id`. This will replace the existing item in the "Recently Viewed" list.

```ts
const link = '/app/map/1234';
const label = 'Map 1234';

coreStart.chrome.recentlyAccessed.add(`/app/map/1234`, label, id);

// User changes the time range and we want to update the link in the "Recently Viewed" list
coreStart.chrome.recentlyAccessed.add(
`/app/map/1234?timeRangeFrom=now-30m&timeRangeTo=now`,
label,
id
);
```

## Implementation details

The <DocLink id="kibKbnCoreChromeBrowserPluginApi" section="def-public.ChromeRecentlyAccessed" text="ChromeRecentlyAccessed" /> services is based on <DocLink id="kibKbnRecentlyAccessedPluginApi" text="@kbn/recently-accessed"/> package. This package provides a `RecentlyAccessedService` that uses browser local storage to manage records of recently accessed objects. Internally it implements the queue with a maximum length of 20 items. When the queue is full, the oldest item is removed.
Applications can create their own instance of `RecentlyAccessedService` to manage their own list of recently accessed items scoped to their application.

- <DocLink id="kibKbnCoreChromeBrowserPluginApi" section="def-public.ChromeRecentlyAccessed" text="ChromeRecentlyAccessed" /> is a service available via `coreStart.chrome.recentlyAccessed` and should be used to add items to chrome's sidenav.
- <DocLink id="kibKbnRecentlyAccessedPluginApi" text="@kbn/recently-accessed"/> is package that `ChromeRecentlyAccessed` is using internally and the package can be used to create your own instance and manage your own list of recently accessed items that is independent for chrome's sidenav.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions dev_docs/shared_ux/shared_ux_landing.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -66,5 +66,10 @@ layout: landing
title: 'Kibana React Contexts',
description: 'Learn how to use common React contexts in Kibana',
},
{
pageId: 'kibDevDocsChromeRecentlyAccessed',
title: 'Chrome Recently Viewed',
description: 'Learn how to add recently viewed items to the side navigation',
},
]}
/>
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export const indexTemplates: {
template: {
settings: {
mode: 'logsdb',
default_pipeline: 'logs@default-pipeline',
},
},
priority: 500,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,20 @@
* License v3.0 only", or the "Server Side Public License, v 1".
*/

import { Client } from '@elastic/elasticsearch';
import { Client, estypes } from '@elastic/elasticsearch';
import { pipeline, Readable } from 'stream';
import { LogDocument } from '@kbn/apm-synthtrace-client/src/lib/logs';
import { MappingTypeMapping } from '@elastic/elasticsearch/lib/api/types';
import { IngestProcessorContainer, MappingTypeMapping } from '@elastic/elasticsearch/lib/api/types';
import { ValuesType } from 'utility-types';
import { SynthtraceEsClient, SynthtraceEsClientOptions } from '../shared/base_client';
import { getSerializeTransform } from '../shared/get_serialize_transform';
import { Logger } from '../utils/create_logger';
import { indexTemplates, IndexTemplateName } from './custom_logsdb_index_templates';
import { getRoutingTransform } from '../shared/data_stream_get_routing_transform';

export const LogsIndex = 'logs';
export const LogsCustom = 'logs@custom';

export type LogsSynthtraceEsClientOptions = Omit<SynthtraceEsClientOptions, 'pipeline'>;

export class LogsSynthtraceEsClient extends SynthtraceEsClient<LogDocument> {
Expand Down Expand Up @@ -60,6 +64,47 @@ export class LogsSynthtraceEsClient extends SynthtraceEsClient<LogDocument> {
this.logger.error(`Index creation failed: ${index} - ${err.message}`);
}
}

async updateIndexTemplate(
indexName: string,
modify: (
template: ValuesType<
estypes.IndicesGetIndexTemplateResponse['index_templates']
>['index_template']
) => estypes.IndicesPutIndexTemplateRequest
) {
try {
const response = await this.client.indices.getIndexTemplate({
name: indexName,
});

await Promise.all(
response.index_templates.map((template) => {
return this.client.indices.putIndexTemplate({
...modify(template.index_template),
name: template.name,
});
})
);

this.logger.info(`Updated ${indexName} index template`);
} catch (err) {
this.logger.error(`Update index template failed: ${indexName} - ${err.message}`);
}
}

async createCustomPipeline(processors: IngestProcessorContainer[]) {
try {
this.client.ingest.putPipeline({
id: LogsCustom,
processors,
version: 1,
});
this.logger.info(`Custom pipeline created: ${LogsCustom}`);
} catch (err) {
this.logger.error(`Custom pipeline creation failed: ${LogsCustom} - ${err.message}`);
}
}
}

function logsPipeline() {
Expand Down
4 changes: 1 addition & 3 deletions packages/kbn-apm-synthtrace/src/scenarios/degraded_logs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,10 @@ import {
getCluster,
getCloudRegion,
getCloudProvider,
MORE_THAN_1024_CHARS,
} from './helpers/logs_mock_data';
import { parseLogsScenarioOpts } from './helpers/logs_scenario_opts_parser';

const MORE_THAN_1024_CHARS =
'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?';

// Logs Data logic
const MESSAGE_LOG_LEVELS = [
{ message: 'A simple log', level: 'info' },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,9 @@ import {
} from '@kbn/apm-synthtrace-client';
import { Scenario } from '../cli/scenario';
import { withClient } from '../lib/utils/with_client';
import { getIpAddress } from './helpers/logs_mock_data';
import { MORE_THAN_1024_CHARS, getIpAddress } from './helpers/logs_mock_data';
import { getAtIndexOrRandom } from './helpers/get_at_index_or_random';

const MORE_THAN_1024_CHARS =
'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?';

const MONITOR_NAMES = Array(4)
.fill(null)
.map((_, idx) => `synth-monitor-${idx}`);
Expand Down
Loading

0 comments on commit b4c520c

Please sign in to comment.