Skip to content

Commit

Permalink
Merge pull request #77 from SquirrelCorporation/fix-protected-directory
Browse files Browse the repository at this point in the history
[BUG] Fix protected directory
  • Loading branch information
SquirrelDeveloper authored Jul 3, 2024
2 parents 9fb0092 + 8af79de commit 3dcdef5
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ const DirectoryTreeView: React.FC<DirectoryTreeViewProps> = (props) => {
}}
callbacks={props.callbacks}
remoteRootNode={node.remoteRootNode}
cannotDelete={!node.custom || node.rootNode}
>
<Typography.Text
style={{ maxWidth: 150 - 10 * node.depth }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ type PlaybookDropdownMenuType = {
};

type PlaybookDrownMenuItemType = {
fileType: DirectoryTree.CONSTANTS | 'any';
fileType: DirectoryTree.CONSTANTS | 'any' | 'deletable';
playbookQuickRef?: string;
icon?: React.JSX.Element;
label: string;
Expand All @@ -49,7 +49,7 @@ const menuItems: PlaybookDrownMenuItemType[] = [
label: 'Delete',
icon: <DeleteOutlined />,
key: '3',
fileType: 'any',
fileType: 'deletable',
},
];

Expand All @@ -73,7 +73,7 @@ const PlaybookDropdownMenu: React.FC<PlaybookDropdownMenuType> = (props) => {
const items = menuItems
.filter(
(e) =>
(e.fileType === 'any' && !props.cannotDelete) ||
(e.fileType === 'deletable' && !props.cannotDelete) ||
e.fileType === props.type,
)
.map((e) => {
Expand Down
14 changes: 12 additions & 2 deletions client/src/pages/Playbooks/components/TreeComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@ import {
SimpleIconsGit,
StreamlineLocalStorageFolderSolid,
} from '@/components/Icons/CustomIcons';
import { Typography } from 'antd';
import React, { ReactNode } from 'react';
import {
API,
DirectoryTree,
DirectoryTree as DT,
Playbooks,
} from 'ssm-shared-lib';
import PlaybookDropdownMenu from './PlaybookDropdownMenu';

export type ClientPlaybooksTrees = {
isLeaf?: boolean;
Expand Down Expand Up @@ -83,11 +81,21 @@ export function recursiveTreeTransform(
key: child.path,
_name: child.name,
nodeType: child.type,
rootNode: false,
playbookRepository: {
basePath: playbookRepository.basePath,
name: playbookRepository.name,
uuid: playbookRepository.uuid,
},
// TODO ugly fix to prevent user breaking the system
custom:
(child as DirectoryTree.ExtendedTreeNode).custom === undefined &&
!child.path.includes(
'/server/src/ansible/00000000-0000-0000-0000-000000000000/agent',
) &&
!child.path.includes(
'/server/src/ansible/00000000-0000-0000-0000-000000000000/device',
),
depth: depth,
selectable: false,
children: recursiveTreeTransform(
Expand All @@ -102,6 +110,7 @@ export function recursiveTreeTransform(
key: child.path,
_name: child.name,
nodeType: DirectoryTree.CONSTANTS.FILE,
rootNode: false,
playbookRepository: {
basePath: playbookRepository.basePath,
name: playbookRepository.name,
Expand All @@ -120,6 +129,7 @@ export function recursiveTreeTransform(
newTree.push({
key: node.path,
_name: node.name,
rootNode: false,
nodeType: DirectoryTree.CONSTANTS.FILE,
playbookRepository: {
basePath: playbookRepository.basePath,
Expand Down

0 comments on commit 3dcdef5

Please sign in to comment.