Skip to content

Commit

Permalink
fix: selection after deleteMultipleClusteResources
Browse files Browse the repository at this point in the history
  • Loading branch information
devcatalin committed Apr 24, 2023
1 parent 0d8f3e4 commit 2bc3810
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/redux/reducers/main/mainSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ import {
} from '@shared/models/k8sResource';
import {PreviewType} from '@shared/models/preview';
import {RootState} from '@shared/models/rootState';
import {AppSelection} from '@shared/models/selection';
import {AppSelection, isResourceSelection} from '@shared/models/selection';
import electronStore from '@shared/utils/electronStore';
import {isEqual} from '@shared/utils/isEqual';
import {trackEvent} from '@shared/utils/telemetry';
Expand Down Expand Up @@ -305,6 +305,18 @@ export const mainSlice = createSlice({
delete state.resourceMetaMapByStorage.cluster[r.id];
delete state.resourceContentMapByStorage.cluster[r.id];
});
// clear the selection if the selected resource has been deleted
const selection = state.selection;
if (isResourceSelection(selection)) {
const selectedResourceIdentifier = selection.resourceIdentifier;
if (
action.payload.some(
r => r.id === selectedResourceIdentifier.id && r.storage === selectedResourceIdentifier.storage
)
) {
clearSelectionReducer(state);
}
}
},
setActiveEditorTab: (state: Draft<AppState>, action: PayloadAction<ActionPaneTab>) => {
state.activeEditorTab = action.payload;
Expand Down

0 comments on commit 2bc3810

Please sign in to comment.