mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
When an index is deleted, and it's selected in the table, then it's removed from the selection. (#22242)
This commit is contained in:
parent
db089ea5ce
commit
019703cadc
1 changed files with 24 additions and 2 deletions
|
@ -68,6 +68,24 @@ const HEADERS = {
|
|||
};
|
||||
|
||||
export class IndexTableUi extends Component {
|
||||
static getDerivedStateFromProps(props, state) {
|
||||
// Deselct any indices which no longer exist, e.g. they've been deleted.
|
||||
const { selectedIndicesMap } = state;
|
||||
const indexNames = props.indices.map(index => index.name);
|
||||
const selectedIndexNames = Object.keys(selectedIndicesMap);
|
||||
const missingIndexNames = selectedIndexNames.filter(selectedIndexName => {
|
||||
return !indexNames.includes(selectedIndexName);
|
||||
});
|
||||
|
||||
if (missingIndexNames.length) {
|
||||
const newMap = { ...selectedIndicesMap };
|
||||
missingIndexNames.forEach(missingIndexName => delete newMap[missingIndexName]);
|
||||
return { selectedIndicesMap: newMap };
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
constructor(props) {
|
||||
super(props);
|
||||
|
||||
|
@ -82,6 +100,7 @@ export class IndexTableUi extends Component {
|
|||
const newIsSortAscending = sortField === column ? !isSortAscending : true;
|
||||
sortChanged(column, newIsSortAscending);
|
||||
};
|
||||
|
||||
toggleAll = () => {
|
||||
const allSelected = this.areAllItemsSelected();
|
||||
if (allSelected) {
|
||||
|
@ -96,6 +115,7 @@ export class IndexTableUi extends Component {
|
|||
selectedIndicesMap
|
||||
});
|
||||
};
|
||||
|
||||
toggleItem = name => {
|
||||
this.setState(({ selectedIndicesMap }) => {
|
||||
const newMap = { ...selectedIndicesMap };
|
||||
|
@ -109,6 +129,7 @@ export class IndexTableUi extends Component {
|
|||
};
|
||||
});
|
||||
};
|
||||
|
||||
isItemSelected = name => {
|
||||
return !!this.state.selectedIndicesMap[name];
|
||||
};
|
||||
|
@ -159,6 +180,7 @@ export class IndexTableUi extends Component {
|
|||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
buildRowCells(index) {
|
||||
return Object.keys(HEADERS).map(fieldName => {
|
||||
const { name } = index;
|
||||
|
@ -174,6 +196,7 @@ export class IndexTableUi extends Component {
|
|||
);
|
||||
});
|
||||
}
|
||||
|
||||
buildRows() {
|
||||
const { indices = [], detailPanelIndexName } = this.props;
|
||||
return indices.map(index => {
|
||||
|
@ -221,7 +244,6 @@ export class IndexTableUi extends Component {
|
|||
};
|
||||
|
||||
render() {
|
||||
|
||||
const {
|
||||
filterChanged,
|
||||
filter,
|
||||
|
@ -336,4 +358,4 @@ export class IndexTableUi extends Component {
|
|||
}
|
||||
}
|
||||
|
||||
export const IndexTable = injectI18n(IndexTableUi);
|
||||
export const IndexTable = injectI18n(IndexTableUi);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue