Skip to content

Commit

Permalink
Merge branch 'main' into fleet/openapi-tags
Browse files Browse the repository at this point in the history
  • Loading branch information
kibanamachine authored Feb 28, 2023
2 parents 27b1479 + e4ea635 commit ba4a97f
Show file tree
Hide file tree
Showing 160 changed files with 3,749 additions and 1,860 deletions.
2 changes: 1 addition & 1 deletion .buildkite/scripts/steps/storybooks/build_and_upload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const STORYBOOKS = [
'cloud_chat',
'coloring',
'chart_icons',
'content_management_plugin',
'content_management_examples',
'controls',
'custom_integrations',
'dashboard_enhanced',
Expand Down
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ packages/kbn-config-mocks @elastic/kibana-core
packages/kbn-config-schema @elastic/kibana-core
src/plugins/console @elastic/platform-deployment-management
packages/content-management/content_editor @elastic/appex-sharedux
examples/content_management_examples @elastic/appex-sharedux
src/plugins/content_management @elastic/appex-sharedux
packages/content-management/table_list @elastic/appex-sharedux
examples/controls_example @elastic/kibana-presentation
Expand Down
670 changes: 335 additions & 335 deletions docs/api-generated/cases/case-apis-passthru.asciidoc

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions docs/api/cases.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ these APIs:
* <<cases-api-create>>
* <<cases-api-delete-cases>>
* <<cases-api-delete-comments>>
* <<cases-api-find-case-activity>>
* <<cases-api-find-cases>>
* <<cases-api-find-connectors>>
* <<cases-api-get-alerts>>
Expand All @@ -33,6 +34,7 @@ include::cases/cases-api-create.asciidoc[leveloffset=+1]
include::cases/cases-api-delete-cases.asciidoc[leveloffset=+1]
include::cases/cases-api-delete-comments.asciidoc[leveloffset=+1]
//FIND
include::cases/cases-api-find-case-activity.asciidoc[leveloffset=+1]
include::cases/cases-api-find-cases.asciidoc[leveloffset=+1]
include::cases/cases-api-find-connectors.asciidoc[leveloffset=+1]
//GET
Expand Down
20 changes: 20 additions & 0 deletions docs/api/cases/cases-api-find-case-activity.asciidoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[[cases-api-find-case-activity]]
== Find case activity API
++++
<titleabbrev>Find case activity</titleabbrev>
++++

Finds user activity for a case.

[NOTE]
====
For the most up-to-date API details, refer to the
{kib-repo}/tree/{branch}/x-pack/plugins/cases/docs/openapi[open API specification]. For a preview, check out <<case-apis>>.
====

=== {api-request-title}

`GET <kibana host>:<port>/api/cases/<case_id>/user_actions/_find`

`GET <kibana host>:<port>/s/<space_id>/api/cases/<case_id>/user_actions/_find`

2 changes: 1 addition & 1 deletion docs/api/cases/cases-api-get-case-activity.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

Returns all user activity for a case.

deprecated::[8.1.0]
deprecated::[8.1.0,Use <<cases-api-find-case-activity>> instead.]

[NOTE]
====
Expand Down
3 changes: 3 additions & 0 deletions examples/content_management_examples/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Content Management Examples

An example plugin that shows how to integrate with the Kibana "content management" plugin.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

export * from './todos';
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

import { schema } from '@kbn/config-schema';
import {
CreateIn,
DeleteIn,
GetIn,
SearchIn,
UpdateIn,
} from '@kbn/content-management-plugin/common';

export const TODO_CONTENT_ID = 'todos';
export interface Todo {
id: string;
title: string;
completed: boolean;
}
const todoSchema = schema.object({
id: schema.string(),
title: schema.string(),
completed: schema.boolean(),
});

export type TodoCreateIn = CreateIn<'todos', { title: string }>;
export type TodoCreateOut = Todo; // TODO: Is this correct?
export const createInSchema = schema.object({ title: schema.string() });
export const createOutSchema = todoSchema;

export type TodoUpdateIn = UpdateIn<'todos', Partial<Omit<Todo, 'id'>>>;
export type TodoUpdateOut = Todo;
export const updateInSchema = schema.object({
title: schema.maybe(schema.string()),
completed: schema.maybe(schema.boolean()),
});
export const updateOutSchema = todoSchema;

export type TodoDeleteIn = DeleteIn<'todos', { id: string }>;
export type TodoDeleteOut = void;

export type TodoGetIn = GetIn<'todos'>;
export type TodoGetOut = Todo;
export const getOutSchema = todoSchema;

export type TodoSearchIn = SearchIn<'todos', { filter?: 'todo' | 'completed' }>;
export interface TodoSearchOut {
hits: Todo[];
}
export const searchInSchema = schema.object({
filter: schema.maybe(
schema.oneOf([schema.literal('todo'), schema.literal('completed')], {
defaultValue: undefined,
})
),
});
export const searchOutSchema = schema.object({
hits: schema.arrayOf(todoSchema),
});
13 changes: 13 additions & 0 deletions examples/content_management_examples/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

module.exports = {
preset: '@kbn/test',
rootDir: '../..',
roots: ['<rootDir>/examples/content_management_examples'],
};
15 changes: 15 additions & 0 deletions examples/content_management_examples/kibana.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"type": "plugin",
"id": "@kbn/content-management-examples-plugin",
"owner": "@elastic/appex-sharedux",
"description": "Example plugin integrating with content management plugin",
"plugin": {
"id": "contentManagementExamples",
"server": true,
"browser": true,
"requiredPlugins": [
"contentManagement",
"developerExamples"
]
}
}
31 changes: 31 additions & 0 deletions examples/content_management_examples/public/examples/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

import React from 'react';
import ReactDOM from 'react-dom';
import { EuiPageTemplate } from '@elastic/eui';
import { AppMountParameters, CoreStart } from '@kbn/core/public';
import { StartDeps } from '../types';
import { TodoApp } from './todos';

export const renderApp = (
{ notifications }: CoreStart,
{ contentManagement }: StartDeps,
{ element }: AppMountParameters
) => {
ReactDOM.render(
<EuiPageTemplate offset={0}>
<EuiPageTemplate.Section>
<TodoApp contentClient={contentManagement.client} />
</EuiPageTemplate.Section>
</EuiPageTemplate>,
element
);

return () => ReactDOM.unmountComponentAtNode(element);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

export { TodoApp } from './todo_app';
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
*/

import * as React from 'react';
import { Todos } from './todos';
import { ContentClientProvider, ContentClient } from '../../public/content_client';
import { ContentClientProvider, ContentClient } from '@kbn/content-management-plugin/public';

import { Todos } from '../todos';
import { TodosClient } from './todos_client';

export default {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,32 @@
*/

import { v4 as uuidv4 } from 'uuid';
import type { CrudClient } from '../../public/crud_client';
import type { CreateIn, DeleteIn, GetIn, SearchIn, UpdateIn } from '../../common';

export interface Todo {
id: string;
title: string;
completed: boolean;
}

export type TodoCreateIn = CreateIn<'todos', { title: string }>;
export type TodoUpdateIn = UpdateIn<'todos', Partial<Omit<Todo, 'id'>>>;
export type TodoDeleteIn = DeleteIn<'todos', { id: string }>;
export type TodoGetIn = GetIn<'todos'>;
export type TodoSearchIn = SearchIn<'todos', { filter?: 'todo' | 'completed' }>;
import type { CrudClient } from '@kbn/content-management-plugin/public';
import type {
TodoCreateIn,
TodoUpdateIn,
TodoDeleteIn,
TodoGetIn,
TodoSearchIn,
TodoUpdateOut,
TodoCreateOut,
TodoSearchOut,
TodoDeleteOut,
Todo,
TodoGetOut,
} from '../../../../common/examples/todos';

/**
* This client is used in the storybook examples to simulate a server-side registry client
* and to show how a content type can have a custom client-side CRUD client without using the server-side registry
*/
export class TodosClient implements CrudClient {
private todos: Todo[] = [
{ id: uuidv4(), title: 'Learn Elasticsearch', completed: true },
{ id: uuidv4(), title: 'Learn Kibana', completed: false },
];

async create(input: TodoCreateIn): Promise<Todo> {
async create(input: TodoCreateIn): Promise<TodoCreateOut> {
const todo = {
id: uuidv4(),
title: input.data.title,
Expand All @@ -38,22 +42,22 @@ export class TodosClient implements CrudClient {
return todo;
}

async delete(input: TodoDeleteIn): Promise<void> {
async delete(input: TodoDeleteIn): Promise<TodoDeleteOut> {
this.todos = this.todos.filter((todo) => todo.id !== input.id);
}

async get(input: TodoGetIn): Promise<Todo> {
async get(input: TodoGetIn): Promise<TodoGetOut> {
return this.todos.find((todo) => todo.id === input.id)!;
}

async search(input: TodoSearchIn): Promise<{ hits: Todo[] }> {
async search(input: TodoSearchIn): Promise<TodoSearchOut> {
const filter = input.query.filter;
if (filter === 'todo') return { hits: this.todos.filter((t) => !t.completed) };
if (filter === 'completed') return { hits: this.todos.filter((t) => t.completed) };
return { hits: [...this.todos] };
}

async update(input: TodoUpdateIn): Promise<Todo> {
async update(input: TodoUpdateIn): Promise<TodoUpdateOut> {
const idToUpdate = input.id;
const todoToUpdate = this.todos.find((todo) => todo.id === idToUpdate)!;
if (todoToUpdate) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

import React from 'react';
import { ContentClientProvider, type ContentClient } from '@kbn/content-management-plugin/public';
import { Todos } from './todos';

export const TodoApp = (props: { contentClient: ContentClient }) => {
return (
<ContentClientProvider contentClient={props.contentClient}>
<Todos />
</ContentClientProvider>
);
};
Loading

0 comments on commit ba4a97f

Please sign in to comment.