Skip to content

Commit

Permalink
fix: disable section + hide git pane in cluster mode
Browse files Browse the repository at this point in the history
  • Loading branch information
topliceanurazvan committed Mar 9, 2023
1 parent a74e6a8 commit ed95e24
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export const getPanelId = (panelKey?: string) => `accordion-panel-${panelKey}`;

// Props injected by Collapse when it clones the Panel
export type InjectedPanelProps = {
disabled?: boolean;
isActive?: boolean;
panelKey?: string;
};
Expand All @@ -37,6 +38,7 @@ const AccordionPanel: React.FC<CollapsePanelProps & InjectedPanelProps> = props

return (
<S.Panel
collapsible={props.disabled ? 'disabled' : undefined}
id={id}
$contentHeight={contentHeight < height ? contentHeight : height}
$panelKey={props.panelKey || ''}
Expand Down
7 changes: 6 additions & 1 deletion src/components/organisms/ExplorerPane/ExplorerPane.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {Collapse as RawCollapse} from 'antd';

import styled from 'styled-components';

import {isInClusterModeSelector} from '@redux/appConfig';
import {useAppDispatch, useAppSelector} from '@redux/hooks';
import {setExplorerSelectedSection} from '@redux/reducers/ui';

Expand All @@ -15,13 +16,17 @@ import KustomizePane from './KustomizePane';
const ExplorerPane: React.FC = () => {
const dispatch = useAppDispatch();
const explorerSelectedSection = useAppSelector(state => state.ui.explorerSelectedSection);
const isInClusterMode = useAppSelector(isInClusterModeSelector);

return (
<Collapse
accordion
ghost
activeKey={explorerSelectedSection}
activeKey={isInClusterMode ? 'images' : explorerSelectedSection}
onChange={(key: any) => {
if (isInClusterMode) {
return;
}
dispatch(setExplorerSelectedSection(key));
trackEvent('left-menu/activity-changed', {activity: 'explorer', section: key});
}}
Expand Down
3 changes: 3 additions & 0 deletions src/components/organisms/ExplorerPane/FilePane/FilePane.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {ExclamationCircleOutlined, FolderAddOutlined, ReloadOutlined} from '@ant
import {TOOLTIP_DELAY} from '@constants/constants';
import {CollapseTreeTooltip, ExpandTreeTooltip, FileExplorerChanged, ReloadFolderTooltip} from '@constants/tooltips';

import {isInClusterModeSelector} from '@redux/appConfig';
import {useAppDispatch, useAppSelector} from '@redux/hooks';
import {openCreateFileFolderModal, setFileExplorerExpandedFolders} from '@redux/reducers/ui';
import {setRootFolder} from '@redux/thunks/setRootFolder';
Expand All @@ -30,6 +31,7 @@ const FilePane: React.FC<InjectedPanelProps> = props => {
const fileExplorerExpandedFolders = useAppSelector(state => state.ui.fileExplorerExpandedFolders);
const fileMap = useAppSelector(state => state.main.fileMap);
const isFolderLoading = useAppSelector(state => state.ui.isFolderLoading);
const isInClusterMode = useAppSelector(isInClusterModeSelector);
const isScanExcludesUpdated = useAppSelector(state => state.config.isScanExcludesUpdated);
const rootEntry = useAppSelector(state => state.main.fileMap[ROOT_FILE_ENTRY]);

Expand All @@ -50,6 +52,7 @@ const FilePane: React.FC<InjectedPanelProps> = props => {
return (
<AccordionPanel
{...props}
disabled={isInClusterMode}
showArrow={false}
header={
<AccordionTitleBarContainer>
Expand Down
3 changes: 3 additions & 0 deletions src/components/organisms/ExplorerPane/HelmPane/HelmPane.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {CollapsePanelProps} from 'antd';

import {size} from 'lodash';

import {isInClusterModeSelector} from '@redux/appConfig';
import {useAppSelector} from '@redux/hooks';

import {SectionRenderer} from '@molecules';
Expand All @@ -23,12 +24,14 @@ const HelmPane: React.FC<InjectedPanelProps> = props => {
const {isActive, panelKey} = props;

const helmChartMap = useAppSelector(state => state.main.helmChartMap);
const isInClusterMode = useAppSelector(isInClusterModeSelector);

const [containerRef, {width: containerWidth}] = useMeasure<HTMLDivElement>();

return (
<AccordionPanel
{...props}
disabled={isInClusterMode}
header={
<AccordionTitleBarContainer ref={containerRef}>
<TitleBar
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {useMeasure} from 'react-use';

import {CollapsePanelProps} from 'antd';

import {isInClusterModeSelector} from '@redux/appConfig';
import {useAppSelector} from '@redux/hooks';
import {kustomizationResourcesSelectors} from '@redux/selectors';

Expand All @@ -22,13 +23,15 @@ import {AccordionTitleBarContainer} from '../AccordionPanel/AccordionTitleBarCon
const KustomizePane: React.FC<InjectedPanelProps> = props => {
const {isActive, panelKey} = props;

const isInClusterMode = useAppSelector(isInClusterModeSelector);
const kustomizationsResources = useAppSelector(kustomizationResourcesSelectors);

const [containerRef, {width: containerWidth}] = useMeasure<HTMLDivElement>();

return (
<AccordionPanel
{...props}
disabled={isInClusterMode}
header={
<AccordionTitleBarContainer ref={containerRef}>
<TitleBar
Expand Down
4 changes: 2 additions & 2 deletions src/components/organisms/PaneManager/activities.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {size} from 'lodash';

import {FileExplorerTabTooltip, SettingsTooltip, TerminalPaneTooltip} from '@constants/tooltips';

import {activeProjectSelector} from '@redux/appConfig';
import {activeProjectSelector, isInClusterModeSelector} from '@redux/appConfig';
import {useAppSelector} from '@redux/hooks';
import {problemsSelector, useValidationSelector} from '@redux/validation/validation.selectors';

Expand Down Expand Up @@ -61,7 +61,7 @@ export const activities: ActivityType<LeftMenuSelectionType>[] = [

return {count: changedFiles.length, size: 'small'};
},
isVisible: () => Boolean(useAppSelector(activeProjectSelector)),
isVisible: () => Boolean(useAppSelector(activeProjectSelector)) && !useAppSelector(isInClusterModeSelector),
},
{
type: 'panel',
Expand Down

0 comments on commit ed95e24

Please sign in to comment.