Skip to content

Commit

Permalink
refactor: simplify dry runs item renderers
Browse files Browse the repository at this point in the history
  • Loading branch information
devcatalin committed Oct 5, 2023
1 parent 92ba3b2 commit a46d489
Show file tree
Hide file tree
Showing 24 changed files with 142 additions and 1,315 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const ResourceRefsIconPopover = ({
}: {
resourceMeta: ResourceMeta;
type: 'incoming' | 'outgoing';
isDisabled: boolean;
isDisabled?: boolean;
isSelected: boolean;
placeholderWidth?: number;
}) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import {memo, useState} from 'react';

import {useAppDispatch, useAppSelector} from '@redux/hooks';
import {startPreview} from '@redux/thunks/preview';

import * as S from './styled';

type IProps = {
id: string;
};

const CommandRenderer: React.FC<IProps> = props => {
const {id} = props;

const command = useAppSelector(state => state.config.projectConfig?.savedCommandMap?.[id]);

const dispatch = useAppDispatch();
const isPreviewed = useAppSelector(
state => state.main.preview?.type === 'command' && state.main.preview.commandId === command?.id
);

const [isHovered, setIsHovered] = useState<boolean>(false);

if (!command) {
return null;
}

return (
<S.ItemContainer
indent={22}
isHovered={isHovered}
isPreviewed={isPreviewed}
onMouseEnter={() => setIsHovered(true)}
onMouseLeave={() => setIsHovered(false)}
onClick={() => {
dispatch(startPreview({type: 'command', commandId: id}));
}}
>
<S.ItemName isPreviewed={isPreviewed}>{command.label}</S.ItemName>
</S.ItemContainer>
);
};

export default memo(CommandRenderer);

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ import {Colors} from '@shared/styles/colors';
import {elementScroll, useVirtualizer} from '@tanstack/react-virtual';

import CommandRenderer from './CommandRenderer';
import HelmConfigRenderer from './HelmConfigRenderer';
import HelmValueRenderer from './HelmValueRenderer';
import KustomizeRenderer from './KustomizeRenderer';
import PreviewConfigurationRenderer from './PreviewConfigurationRenderer';

const ROW_HEIGHT = 26;

Expand Down Expand Up @@ -87,7 +87,7 @@ const DryRunsPane: React.FC = () => {
) : node.type === 'helm-values' ? (
<HelmValueRenderer id={node.valuesId} />
) : node.type === 'helm-config' ? (
<PreviewConfigurationRenderer id={node.configId} />
<HelmConfigRenderer id={node.configId} />
) : node.type === 'command' ? (
<CommandRenderer id={node.commandId} />
) : null}
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit a46d489

Please sign in to comment.