-
Notifications
You must be signed in to change notification settings - Fork 136
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: improved handling of file updates and automatic termination of k…
…ustomize dry-runs
- Loading branch information
Showing
5 changed files
with
40 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
src/redux/thunks/listeners/shouldStopKustomizeDryRunListener.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import {isAnyOf} from '@reduxjs/toolkit'; | ||
|
||
import {AppListenerFn} from '@redux/listeners/base'; | ||
import {multiplePathsChanged} from '@redux/thunks/multiplePathsChanged'; | ||
import {stopPreview} from '@redux/thunks/preview'; | ||
import {updateFileEntry} from '@redux/thunks/updateFileEntry'; | ||
|
||
export const shouldStopKustomizeDryRunListener: AppListenerFn = listen => { | ||
listen({ | ||
matcher: isAnyOf(updateFileEntry.fulfilled, multiplePathsChanged.fulfilled), | ||
effect: (action, listenerApi) => { | ||
listenerApi.cancelActiveListeners(); | ||
|
||
const mainState = listenerApi.getState().main; | ||
|
||
// check if the update resulted in the removal of the currently dry-run kustomize overlay | ||
if ( | ||
mainState.preview?.type === 'kustomize' && | ||
!mainState.resourceMetaMapByStorage.local[mainState.preview.kustomizationId] | ||
) { | ||
listenerApi.dispatch(stopPreview()); | ||
} | ||
}, | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters