Skip to content

Commit 0bc694b

Browse files
authored
fix(compass-indexes): fix indexes ux issues COMPASS-7084 COMPASS-4744 (#6084)
* update collection stats when indexes are refreshed * delete failed in-progress indexes
1 parent 4925401 commit 0bc694b

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

packages/compass-collection/src/stores/collection-tab.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,10 @@ export function activatePlugin(
8989
}
9090
});
9191

92+
on(localAppRegistry, 'refresh-collection-stats', () => {
93+
void collectionModel.fetch({ dataService, force: true });
94+
});
95+
9296
void collectionModel.fetchMetadata({ dataService }).then((metadata) => {
9397
store.dispatch(collectionMetadataFetched(metadata));
9498
});

packages/compass-indexes/src/modules/regular-indexes.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,9 +162,16 @@ export default function reducer(state = INITIAL_STATE, action: AnyAction) {
162162
},
163163
};
164164

165+
// When an inprogress index fails to create, we also have to update it in
166+
// the state.indexes list to correctly update the UI with error state.
167+
const newIndexes = _mergeInProgressIndexes(
168+
state.indexes,
169+
newInProgressIndexes
170+
);
165171
return {
166172
...state,
167173
inProgressIndexes: newInProgressIndexes,
174+
indexes: newIndexes,
168175
};
169176
}
170177

@@ -279,8 +286,7 @@ export const dropIndex = (name: string): IndexesThunkAction<void> => {
279286
}
280287

281288
if (index.extra.status === 'failed') {
282-
// todo: COMPASS-7084 (existing bug)
283-
dispatch(inProgressIndexRemoved(String(index.extra.id)));
289+
dispatch(inProgressIndexRemoved(String((index as InProgressIndex).id)));
284290
void dispatch(fetchIndexes());
285291
return;
286292
}

packages/compass-indexes/src/stores/store.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ export function activateIndexesPlugin(
101101
);
102102

103103
on(localAppRegistry, 'refresh-regular-indexes', () => {
104+
localAppRegistry.emit('refresh-collection-stats');
104105
void store.dispatch(fetchIndexes());
105106
});
106107

0 commit comments

Comments
 (0)