Skip to content

Commit

Permalink
remove force refresh on index pattern class init (#76248)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattkime authored Aug 31, 2020
1 parent dc37cca commit e7951eb
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,8 @@
<b>Signature:</b>

```typescript
init(forceFieldRefresh?: boolean): Promise<this>;
init(): Promise<this>;
```

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| forceFieldRefresh | <code>boolean</code> | |

<b>Returns:</b>

`Promise<this>`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export declare class IndexPattern implements IIndexPattern
| [getScriptedFields()](./kibana-plugin-plugins-data-public.indexpattern.getscriptedfields.md) | | |
| [getSourceFiltering()](./kibana-plugin-plugins-data-public.indexpattern.getsourcefiltering.md) | | |
| [getTimeField()](./kibana-plugin-plugins-data-public.indexpattern.gettimefield.md) | | |
| [init(forceFieldRefresh)](./kibana-plugin-plugins-data-public.indexpattern.init.md) | | |
| [init()](./kibana-plugin-plugins-data-public.indexpattern.init.md) | | |
| [initFromSpec(spec)](./kibana-plugin-plugins-data-public.indexpattern.initfromspec.md) | | |
| [isTimeBased()](./kibana-plugin-plugins-data-public.indexpattern.istimebased.md) | | |
| [isTimeBasedWildcard()](./kibana-plugin-plugins-data-public.indexpattern.istimebasedwildcard.md) | | |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,12 +172,12 @@ export class IndexPattern implements IIndexPattern {
});
}

private async indexFields(forceFieldRefresh: boolean = false, specs?: FieldSpec[]) {
private async indexFields(specs?: FieldSpec[]) {
if (!this.id) {
return;
}

if (forceFieldRefresh || this.isFieldRefreshRequired(specs)) {
if (this.isFieldRefreshRequired(specs)) {
await this.refreshFields();
} else {
if (specs) {
Expand Down Expand Up @@ -213,7 +213,7 @@ export class IndexPattern implements IIndexPattern {
return this;
}

private updateFromElasticSearch(response: any, forceFieldRefresh: boolean = false) {
private updateFromElasticSearch(response: any) {
if (!response.found) {
throw new SavedObjectNotFound(savedObjectType, this.id, 'management/kibana/indexPatterns');
}
Expand All @@ -239,7 +239,7 @@ export class IndexPattern implements IIndexPattern {
}
this.version = response.version;

return this.indexFields(forceFieldRefresh, response.fields);
return this.indexFields(response.fields);
}

getComputedFields() {
Expand Down Expand Up @@ -283,7 +283,7 @@ export class IndexPattern implements IIndexPattern {
};
}

async init(forceFieldRefresh = false) {
async init() {
if (!this.id) {
return this; // no id === no elasticsearch document
}
Expand All @@ -307,7 +307,7 @@ export class IndexPattern implements IIndexPattern {
};
// Do this before we attempt to update from ES since that call can potentially perform a save
this.originalBody = this.prepBody();
await this.updateFromElasticSearch(response, forceFieldRefresh);
await this.updateFromElasticSearch(response);
// Do it after to ensure we have the most up to date information
this.originalBody = this.prepBody();

Expand Down
2 changes: 1 addition & 1 deletion src/plugins/data/public/public.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -1006,7 +1006,7 @@ export class IndexPattern implements IIndexPattern {
// (undocumented)
id?: string;
// (undocumented)
init(forceFieldRefresh?: boolean): Promise<this>;
init(): Promise<this>;
// Warning: (ae-forgotten-export) The symbol "IndexPatternSpec" needs to be exported by the entry point index.d.ts
//
// (undocumented)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ export const EditIndexPattern = withRouter(
const refreshFields = () => {
overlays.openConfirm(confirmMessage, confirmModalOptionsRefresh).then(async (isConfirmed) => {
if (isConfirmed) {
await indexPattern.init(true);
await indexPattern.refreshFields();
setFields(indexPattern.getNonScriptedFields());
}
});
Expand Down

0 comments on commit e7951eb

Please sign in to comment.