Skip to content

Commit

Permalink
Merge branch 'master' into bug/data-streams-deep-link-state
Browse files Browse the repository at this point in the history
  • Loading branch information
elasticmachine authored Jul 7, 2020
2 parents cfe0b7a + f18002c commit 74bd3aa
Show file tree
Hide file tree
Showing 244 changed files with 6,555 additions and 1,807 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ export declare class IndexPattern implements IIndexPattern
| [\_fetchFields()](./kibana-plugin-plugins-data-public.indexpattern._fetchfields.md) | | |
| [addScriptedField(name, script, fieldType, lang)](./kibana-plugin-plugins-data-public.indexpattern.addscriptedfield.md) | | |
| [create(allowOverride)](./kibana-plugin-plugins-data-public.indexpattern.create.md) | | |
| [destroy()](./kibana-plugin-plugins-data-public.indexpattern.destroy.md) | | |
| [getAggregationRestrictions()](./kibana-plugin-plugins-data-public.indexpattern.getaggregationrestrictions.md) | | |
| [getComputedFields()](./kibana-plugin-plugins-data-public.indexpattern.getcomputedfields.md) | | |
| [getFieldByName(name)](./kibana-plugin-plugins-data-public.indexpattern.getfieldbyname.md) | | |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ two out-of-the box connectors: <<slack-action-type, Slack>> and <<webhook-action
my-slack1: <1>
actionTypeId: .slack <2>
name: 'Slack #xyz' <3>
secrets: <4>
secrets:
webhookUrl: 'https://hooks.slack.com/services/abcd/efgh/ijklmnopqrstuvwxyz'
webhook-service:
actionTypeId: .webhook
name: 'Email service'
config:
config: <4>
url: 'https://email-alert-service.elastic.co'
method: post
headers:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ export class IndexPattern implements IIndexPattern {
this.sourceFilters = spec.sourceFilters;

// ignoring this because the same thing happens elsewhere but via _.assign
// @ts-ignore
// @ts-expect-error
this.fields = spec.fields || [];
this.typeMeta = spec.typeMeta;
this.fieldFormatMap = _.mapValues(fieldFormatMap, (mapping) => {
Expand Down Expand Up @@ -473,21 +473,8 @@ export class IndexPattern implements IIndexPattern {
async create(allowOverride: boolean = false) {
const _create = async (duplicateId?: string) => {
if (duplicateId) {
const duplicatePattern = new IndexPattern(duplicateId, {
getConfig: this.getConfig,
savedObjectsClient: this.savedObjectsClient,
apiClient: this.apiClient,
patternCache: this.patternCache,
fieldFormats: this.fieldFormats,
onNotification: this.onNotification,
onError: this.onError,
uiSettingsValues: {
shortDotsEnable: this.shortDotsEnable,
metaFields: this.metaFields,
},
});

await duplicatePattern.destroy();
this.patternCache.clear(duplicateId);
await this.savedObjectsClient.delete(savedObjectType, duplicateId);
}

const body = this.prepBody();
Expand Down Expand Up @@ -634,11 +621,4 @@ export class IndexPattern implements IIndexPattern {
toString() {
return '' + this.toJSON();
}

destroy() {
if (this.id) {
this.patternCache.clear(this.id);
return this.savedObjectsClient.delete(savedObjectType, this.id);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ describe('IndexPatterns', () => {
Array<SavedObject<any>>
>
);
savedObjectsClient.delete = jest.fn(() => Promise.resolve({}) as Promise<any>);

indexPatterns = new IndexPatternsService({
uiSettings: ({
Expand Down Expand Up @@ -98,4 +99,13 @@ describe('IndexPatterns', () => {
await indexPatterns.getFields(['id', 'title'], true);
expect(savedObjectsClient.find).toHaveBeenCalledTimes(3);
});

test('deletes the index pattern', async () => {
const id = '1';
const indexPattern = await indexPatterns.get(id);

expect(indexPattern).toBeDefined();
await indexPatterns.delete(id);
expect(indexPattern).not.toBe(await indexPatterns.get(id));
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,15 @@ export class IndexPatternsService {

return indexPattern.init();
}

/**
* Deletes an index pattern from .kibana index
* @param indexPatternId: Id of kibana Index Pattern to delete
*/
async delete(indexPatternId: string) {
indexPatternCache.clear(indexPatternId);
return this.savedObjectsClient.delete('index-pattern', indexPatternId);
}
}

export type IndexPatternsContract = PublicMethodsOf<IndexPatternsService>;
2 changes: 0 additions & 2 deletions src/plugins/data/public/public.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -988,8 +988,6 @@ export class IndexPattern implements IIndexPattern {
// (undocumented)
create(allowOverride?: boolean): Promise<string | false>;
// (undocumented)
destroy(): Promise<{}> | undefined;
// (undocumented)
_fetchFields(): Promise<void>;
// (undocumented)
fieldFormatMap: any;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,14 @@ const confirmModalOptionsDelete = {

export const EditIndexPattern = withRouter(
({ indexPattern, history, location }: EditIndexPatternProps) => {
const { uiSettings, indexPatternManagementStart, overlays, savedObjects, chrome } = useKibana<
IndexPatternManagmentContext
>().services;
const {
uiSettings,
indexPatternManagementStart,
overlays,
savedObjects,
chrome,
data,
} = useKibana<IndexPatternManagmentContext>().services;
const [fields, setFields] = useState<IndexPatternField[]>(indexPattern.getNonScriptedFields());
const [conflictedFields, setConflictedFields] = useState<IndexPatternField[]>(
indexPattern.fields.filter((field) => field.type === 'conflict')
Expand Down Expand Up @@ -138,10 +143,11 @@ export const EditIndexPattern = withRouter(
uiSettings.set('defaultIndex', otherPatterns[0].id);
}
}

Promise.resolve(indexPattern.destroy()).then(function () {
history.push('');
});
if (indexPattern.id) {
Promise.resolve(data.indexPatterns.delete(indexPattern.id)).then(function () {
history.push('');
});
}
}

overlays.openConfirm('', confirmModalOptionsDelete).then((isConfirmed) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,7 @@ export class IndexPatternsTestPlugin
const [, { data }] = await core.getStartServices();
const id = (req.params as Record<string, string>).id;
const service = await data.indexPatterns.indexPatternsServiceFactory(req);
const ip = await service.get(id);
await ip.destroy();
await service.delete(id);
return res.ok();
}
);
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/actions/server/actions_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ export class ActionsClient {

this.actionTypeRegistry.ensureActionTypeEnabled(actionTypeId);

const result = await this.savedObjectsClient.update('action', id, {
const result = await this.savedObjectsClient.update<RawAction>('action', id, {
actionTypeId,
name,
config: validatedActionTypeConfig as SavedObjectAttributes,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const pushToServiceHandler = async ({
}

const fields = prepareFieldsForTransformation({
params,
externalCase: params.externalCase,
mapping,
defaultPipes,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export const ExecutorSubActionSchema = schema.oneOf([
]);

export const ExecutorSubActionPushParamsSchema = schema.object({
caseId: schema.string(),
savedObjectId: schema.string(),
title: schema.string(),
description: schema.nullable(schema.string()),
comments: schema.nullable(schema.arrayOf(CommentSchema)),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ export interface PipedField {
}

export interface PrepareFieldsForTransformArgs {
params: PushToServiceApiParams;
externalCase: Record<string, any>;
mapping: Map<string, MapRecord>;
defaultPipes?: string[];
}
Expand Down
Loading

0 comments on commit 74bd3aa

Please sign in to comment.