Skip to content

Commit

Permalink
'fix' last TS errors for flyout
Browse files Browse the repository at this point in the history
  • Loading branch information
pgayvallet committed Mar 5, 2020
1 parent ff87632 commit b773e8d
Showing 1 changed file with 18 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -298,13 +298,13 @@ export class Flyout extends Component<FlyoutProps, FlyoutState> {
overlays
);

const byId = {};
const byId: Record<string, any[]> = {};
conflictedIndexPatterns
.map(({ doc, obj }) => {
return { doc, obj: obj._serialize() };
})
.forEach(({ doc, obj }) =>
obj.references.forEach(ref => {
obj.references.forEach((ref: Record<string, any>) => {
byId[ref.id] = byId[ref.id] != null ? byId[ref.id].concat({ doc, obj }) : [{ doc, obj }];
})
);
Expand All @@ -321,7 +321,7 @@ export class Flyout extends Component<FlyoutProps, FlyoutState> {
});
return accum;
},
[]
[] as any[]
);

this.setState({
Expand Down Expand Up @@ -387,7 +387,7 @@ export class Flyout extends Component<FlyoutProps, FlyoutState> {
if (resolutions.length) {
importCount += await resolveIndexPatternConflicts(
resolutions,
conflictedIndexPatterns,
conflictedIndexPatterns!,
isOverwriteAllChecked
);
}
Expand All @@ -398,7 +398,7 @@ export class Flyout extends Component<FlyoutProps, FlyoutState> {
),
});
importCount += await saveObjects(
conflictedSavedObjectsLinkedToSavedSearches,
conflictedSavedObjectsLinkedToSavedSearches!,
isOverwriteAllChecked
);
this.setState({
Expand All @@ -408,7 +408,7 @@ export class Flyout extends Component<FlyoutProps, FlyoutState> {
),
});
importCount += await resolveSavedSearches(
conflictedSearchDocs,
conflictedSearchDocs!,
serviceRegistry.all().map(e => e.service),
indexPatterns,
isOverwriteAllChecked
Expand All @@ -420,7 +420,7 @@ export class Flyout extends Component<FlyoutProps, FlyoutState> {
),
});
importCount += await saveObjects(
failedImports.map(({ obj }) => obj),
failedImports!.map(({ obj }) => obj) as any[],
isOverwriteAllChecked
);
} catch (e) {
Expand All @@ -439,23 +439,23 @@ export class Flyout extends Component<FlyoutProps, FlyoutState> {
onIndexChanged = (id: string, e: any) => {
const value = e.target.value;
this.setState(state => {
const conflictIndex = state.unmatchedReferences.findIndex(
const conflictIndex = state.unmatchedReferences?.findIndex(
conflict => conflict.existingIndexPatternId === id
);
if (conflictIndex === -1) {
if (conflictIndex === undefined || conflictIndex === -1) {
return state;
}

return {
unmatchedReferences: [
...state.unmatchedReferences.slice(0, conflictIndex),
...state.unmatchedReferences!.slice(0, conflictIndex),
{
...state.unmatchedReferences[conflictIndex],
...state.unmatchedReferences![conflictIndex],
newIndexPatternId: value,
},
...state.unmatchedReferences.slice(conflictIndex + 1),
...state.unmatchedReferences!.slice(conflictIndex + 1),
],
};
} as any;
});
};

Expand Down Expand Up @@ -489,7 +489,7 @@ export class Flyout extends Component<FlyoutProps, FlyoutState> {
'kbn.management.objects.objectsTable.flyout.renderConflicts.columnCountDescription',
{ defaultMessage: 'How many affected objects' }
),
render: list => {
render: (list: any[]) => {
return <Fragment>{list.length}</Fragment>;
},
},
Expand All @@ -503,7 +503,7 @@ export class Flyout extends Component<FlyoutProps, FlyoutState> {
'kbn.management.objects.objectsTable.flyout.renderConflicts.columnSampleOfAffectedObjectsDescription',
{ defaultMessage: 'Sample of affected objects' }
),
render: list => {
render: (list: any[]) => {
return (
<ul style={{ listStyle: 'none' }}>
{take(list, 3).map((obj, key) => (
Expand All @@ -529,7 +529,7 @@ export class Flyout extends Component<FlyoutProps, FlyoutState> {
options.unshift({
text: '-- Skip Import --',
value: '',
});
} as any);

return (
<EuiSelect
Expand Down Expand Up @@ -900,11 +900,11 @@ export class Flyout extends Component<FlyoutProps, FlyoutState> {
}

overwriteConfirmed() {
this.state.conflictingRecord.done(true);
this.state.conflictingRecord!.done(true);
}

overwriteSkipped() {
this.state.conflictingRecord.done(false);
this.state.conflictingRecord!.done(false);
}

render() {
Expand Down

0 comments on commit b773e8d

Please sign in to comment.