Skip to content

Commit

Permalink
fix: cluster diff on helm/kustomize previews
Browse files Browse the repository at this point in the history
  • Loading branch information
devcatalin committed Nov 2, 2021
1 parent 0077b92 commit 54f9e14
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {NavigatorDiff} from '@molecules';
import {loadNavigatorDiff} from '@redux/thunks/loadNavigatorDiff';
import {Skeleton} from 'antd';
import styled from 'styled-components';
import {isInPreviewModeSelector} from '@redux/selectors';

const Container = styled.div`
display: block;
Expand All @@ -24,6 +25,12 @@ function NavigatorDiffPane() {
const hasNavigatorDiffLoaded = useAppSelector(state => state.main.navigatorDiff.hasLoaded);
const hasNavigatorDiffFailed = useAppSelector(state => state.main.navigatorDiff.hasFailed);
const isNavigatorDiffVisible = useAppSelector(state => state.ui.isNavigatorDiffVisible);
const isInPreviewMode = useAppSelector(isInPreviewModeSelector);

useEffect(() => {
dispatch(loadNavigatorDiff());
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [isInPreviewMode]);

const closeDrawer = useCallback(() => {
dispatch(closeNavigatorDiff());
Expand Down
9 changes: 8 additions & 1 deletion src/redux/reducers/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -533,13 +533,20 @@ export const mainSlice = createSlice({
return;
}

const localResources = Object.values(state.resourceMap).filter(
const isInPreviewMode = Boolean(state.previewResourceId) || Boolean(state.previewValuesFileId);

let localResources: K8sResource[] = [];
localResources = Object.values(state.resourceMap).filter(
resource =>
!resource.filePath.startsWith(CLUSTER_DIFF_PREFIX) &&
!resource.name.startsWith('Patch:') &&
resource.kind !== KUSTOMIZATION_KIND
);

if (isInPreviewMode) {
localResources = localResources.filter(resource => resource.filePath.startsWith(PREVIEW_PREFIX));
}

const groupedLocalResources = groupResourcesByIdentifier(
localResources,
makeResourceNameKindNamespaceIdentifier
Expand Down

0 comments on commit 54f9e14

Please sign in to comment.