Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Component templates] Form wizard #69732

Merged
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
cd83f7a
init commit: component template wizard
alisonelizabeth Jun 23, 2020
6ea26f5
build out logistics form
alisonelizabeth Jun 24, 2020
5ec3380
implement save + cleanup
alisonelizabeth Jun 24, 2020
bb5db5f
Merge branch 'master' of github.com:elastic/kibana into feature/compo…
alisonelizabeth Jun 25, 2020
7a97ce9
add edit flow
alisonelizabeth Jun 25, 2020
45e910b
add clone flow
alisonelizabeth Jun 25, 2020
dc0ff0b
add support for breadcrumbs
alisonelizabeth Jun 26, 2020
a6ccd7a
fix api integration tests
alisonelizabeth Jun 26, 2020
ea27f11
i18n fix
alisonelizabeth Jun 26, 2020
84ce7c3
Merge branch 'master' of github.com:elastic/kibana into feature/compo…
alisonelizabeth Jun 26, 2020
18655a1
properly encode/decode component template name
alisonelizabeth Jun 26, 2020
87b0155
cleanup
alisonelizabeth Jun 27, 2020
332a009
uncomment code
alisonelizabeth Jun 28, 2020
875eaef
Merge branch 'master' of github.com:elastic/kibana into feature/compo…
alisonelizabeth Jun 28, 2020
74091bc
Merge branch 'master' of github.com:elastic/kibana into feature/compo…
alisonelizabeth Jun 30, 2020
5fb083b
fix bug when editing component template
alisonelizabeth Jun 30, 2020
be67388
component integration tests
alisonelizabeth Jul 1, 2020
78de4d7
Merge branch 'master' into feature/component_templates_wizard
elasticmachine Jul 2, 2020
0e7c342
fix version field
alisonelizabeth Jul 2, 2020
2116798
clean up tests
alisonelizabeth Jul 2, 2020
b0b68e0
remove version field toggle
alisonelizabeth Jul 2, 2020
868fe72
Merge branch 'master' of github.com:elastic/kibana into feature/compo…
alisonelizabeth Jul 3, 2020
2a4c47d
fix test
alisonelizabeth Jul 4, 2020
a2c04c1
Merge branch 'master' of github.com:elastic/kibana into feature/compo…
alisonelizabeth Jul 4, 2020
936115b
fix TS and tests
alisonelizabeth Jul 5, 2020
638cb17
Merge branch 'master' into feature/component_templates_wizard
elasticmachine Jul 6, 2020
cacf0a5
Merge branch 'master' into feature/component_templates_wizard
elasticmachine Jul 6, 2020
9470201
Merge branch 'master' of github.com:elastic/kibana into feature/compo…
alisonelizabeth Jul 6, 2020
ce140d5
address review feedback
alisonelizabeth Jul 6, 2020
5d22378
fix TS
alisonelizabeth Jul 6, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,91 +4,164 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { deserializeComponentTemplate } from './component_template_serialization';
import {
deserializeComponentTemplate,
serializeComponentTemplate,
} from './component_template_serialization';

describe('deserializeComponentTemplate', () => {
test('deserializes a component template', () => {
expect(
deserializeComponentTemplate(
{
name: 'my_component_template',
component_template: {
version: 1,
_meta: {
serialization: {
id: 10,
class: 'MyComponentTemplate',
},
description: 'set number of shards to one',
},
template: {
settings: {
number_of_shards: 1,
describe('Component template serialization', () => {
describe('deserializeComponentTemplate()', () => {
test('deserializes a component template', () => {
expect(
deserializeComponentTemplate(
{
name: 'my_component_template',
component_template: {
version: 1,
_meta: {
serialization: {
id: 10,
class: 'MyComponentTemplate',
},
description: 'set number of shards to one',
},
mappings: {
_source: {
enabled: false,
template: {
settings: {
number_of_shards: 1,
},
properties: {
host_name: {
type: 'keyword',
mappings: {
_source: {
enabled: false,
},
created_at: {
type: 'date',
format: 'EEE MMM dd HH:mm:ss Z yyyy',
properties: {
host_name: {
type: 'keyword',
},
created_at: {
type: 'date',
format: 'EEE MMM dd HH:mm:ss Z yyyy',
},
},
},
},
},
},
},
[
{
name: 'my_index_template',
index_template: {
index_patterns: ['foo'],
template: {
settings: {
number_of_replicas: 2,
[
{
name: 'my_index_template',
index_template: {
index_patterns: ['foo'],
template: {
settings: {
number_of_replicas: 2,
},
},
composed_of: ['my_component_template'],
},
},
]
)
).toEqual({
name: 'my_component_template',
version: 1,
_meta: {
serialization: {
id: 10,
class: 'MyComponentTemplate',
},
description: 'set number of shards to one',
},
template: {
settings: {
number_of_shards: 1,
},
mappings: {
_source: {
enabled: false,
},
properties: {
host_name: {
type: 'keyword',
},
created_at: {
type: 'date',
format: 'EEE MMM dd HH:mm:ss Z yyyy',
},
composed_of: ['my_component_template'],
},
},
]
)
).toEqual({
name: 'my_component_template',
version: 1,
_meta: {
serialization: {
id: 10,
class: 'MyComponentTemplate',
},
description: 'set number of shards to one',
},
template: {
settings: {
number_of_shards: 1,
_kbnMeta: {
usedBy: ['my_index_template'],
},
mappings: {
_source: {
enabled: false,
});
});
});

describe('serializeComponentTemplate()', () => {
test('serialize a component template', () => {
expect(
serializeComponentTemplate({
name: 'my_component_template',
version: 1,
_kbnMeta: {
usedBy: [],
},
_meta: {
serialization: {
id: 10,
class: 'MyComponentTemplate',
},
description: 'set number of shards to one',
},
template: {
settings: {
number_of_shards: 1,
},
mappings: {
_source: {
enabled: false,
},
properties: {
host_name: {
type: 'keyword',
},
created_at: {
type: 'date',
format: 'EEE MMM dd HH:mm:ss Z yyyy',
},
},
},
},
})
).toEqual({
version: 1,
_meta: {
serialization: {
id: 10,
class: 'MyComponentTemplate',
},
properties: {
host_name: {
type: 'keyword',
description: 'set number of shards to one',
},
template: {
settings: {
number_of_shards: 1,
},
mappings: {
_source: {
enabled: false,
},
created_at: {
type: 'date',
format: 'EEE MMM dd HH:mm:ss Z yyyy',
properties: {
host_name: {
type: 'keyword',
},
created_at: {
type: 'date',
format: 'EEE MMM dd HH:mm:ss Z yyyy',
},
},
},
},
},
_kbnMeta: {
usedBy: ['my_index_template'],
},
});
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
ComponentTemplateFromEs,
ComponentTemplateDeserialized,
ComponentTemplateListItem,
ComponentTemplateSerialized,
} from '../types';

const hasEntries = (data: object = {}) => Object.entries(data).length > 0;
Expand Down Expand Up @@ -84,3 +85,15 @@ export function deserializeComponenTemplateList(

return componentTemplateListItem;
}

export function serializeComponentTemplate(
componentTemplateDeserialized: ComponentTemplateDeserialized
): ComponentTemplateSerialized {
const { version, template, _meta } = componentTemplateDeserialized;

return {
version,
template,
_meta,
};
}
1 change: 1 addition & 0 deletions x-pack/plugins/index_management/common/lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ export { getTemplateParameter } from './utils';
export {
deserializeComponentTemplate,
deserializeComponenTemplateList,
serializeComponentTemplate,
} from './component_template_serialization';
12 changes: 12 additions & 0 deletions x-pack/plugins/index_management/public/application/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ import { TemplateClone } from './sections/template_clone';
import { TemplateEdit } from './sections/template_edit';

import { useServices } from './app_context';
import {
ComponentTemplateCreate,
ComponentTemplateEdit,
ComponentTemplateClone,
} from './components';

export const App = ({ history }: { history: ScopedHistory }) => {
const { uiMetricService } = useServices();
Expand All @@ -34,6 +39,13 @@ export const AppWithoutRouter = () => (
<Route exact path="/create_template" component={TemplateCreate} />
<Route exact path="/clone_template/:name*" component={TemplateClone} />
<Route exact path="/edit_template/:name*" component={TemplateEdit} />
<Route exact path="/create_component_template" component={ComponentTemplateCreate} />
<Route
exact
path="/create_component_template/:sourceComponentTemplateName"
component={ComponentTemplateClone}
/>
<Route exact path="/edit_component_template/:name*" component={ComponentTemplateEdit} />
<Route path={`/:section(${homeSections.join('|')})`} component={IndexManagementHome} />
<Redirect from={`/`} to={`/indices`} />
</Switch>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@

import React, { createContext, useContext } from 'react';
import { ScopedHistory } from 'kibana/public';
import { ManagementAppMountParams } from 'src/plugins/management/public';
import { UsageCollectionSetup } from 'src/plugins/usage_collection/public';

import { CoreStart } from '../../../../../src/core/public';

import { IngestManagerSetup } from '../../../ingest_manager/public';
import { IndexMgmtMetricsType } from '../types';
import { UiMetricService, NotificationService, HttpService } from './services';
Expand All @@ -32,6 +33,7 @@ export interface AppDependencies {
notificationService: NotificationService;
};
history: ScopedHistory;
setBreadcrumbs: ManagementAppMountParams['setBreadcrumbs'];
}

export const AppContextProvider = ({
Expand Down
Loading