Skip to content

Commit eff3665

Browse files
committed
Add ifs and export buttons
1 parent 150bdb2 commit eff3665

File tree

4 files changed

+28
-6
lines changed

4 files changed

+28
-6
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "jderobot-ide-interface",
3-
"version": "0.1.20",
3+
"version": "0.1.21",
44
"main": "dist/main.js",
55
"typings": "dist/index.d.ts",
66
"files": [

src/components/Button/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export { default as Button, MenuButton } from "./Button";
1+
export { default as Button, MenuButton, MenuButtonStroke } from "./Button";

src/components/Explorer/Explorer.tsx

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import {
2525
StyledSidebarEntry,
2626
StyledSidebarEntryMenu,
2727
} from "./Explorer.styles";
28-
import { MenuButtonStroke } from "../Button/Button";
28+
import { MenuButtonStroke } from "Components";
2929

3030
function getParentDir(file: Entry) {
3131
// Check if is a directory and if not get the parent directory of the file
@@ -55,7 +55,7 @@ const Explorer = ({
5555
const [deleteEntry, setDeleteEntry] = useState<Entry | undefined>(undefined);
5656
const [renameEntry, setRenameEntry] = useState<Entry | undefined>(undefined);
5757
const [selectedEntry, setSelectedEntry] = useState<Entry | undefined>(
58-
undefined,
58+
undefined
5959
);
6060
const [selectedLocation, setSelectedLocation] = useState("");
6161

@@ -105,6 +105,23 @@ const Explorer = ({
105105
}
106106
};
107107

108+
const inFileList = (list: Entry[], file?: Entry) => {
109+
if (file === undefined) {
110+
return false
111+
}
112+
113+
for (const entry of list) {
114+
if (entry === file) {
115+
return true;
116+
}
117+
if (entry.is_dir) {
118+
if (inFileList(entry.files, file)) {
119+
return true;
120+
}
121+
}
122+
}
123+
};
124+
108125
///////////////// CREATE FILES ///////////////////////////////////////////////
109126

110127
const handleCreateFile = (file?: Entry) => {
@@ -188,7 +205,9 @@ const Explorer = ({
188205
const handleDeleteCurrentFile = () => {
189206
//currentFile === Absolute File path
190207
if (currentFile) {
208+
if (inFileList(fileList, currentFile)) {
191209
handleDeleteModal(currentFile, false);
210+
}
192211
} else {
193212
warning("No file is currently selected.");
194213
}
@@ -212,7 +231,7 @@ const Explorer = ({
212231

213232
const handleCreateFolderSubmit = async (
214233
location: string,
215-
folder_name: string,
234+
folder_name: string
216235
) => {
217236
if (folder_name !== "") {
218237
try {
@@ -276,7 +295,9 @@ const Explorer = ({
276295

277296
const handleRenameCurrentFile = async () => {
278297
if (currentFile) {
279-
handleRename(currentFile);
298+
if (inFileList(fileList, currentFile)) {
299+
handleRename(currentFile);
300+
}
280301
} else {
281302
warning("No file is currently selected.");
282303
}

src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { IdeInterface } from "./components";
22
export default IdeInterface;
33

44
export { VncViewer } from "./components";
5+
export { Button, MenuButton, MenuButtonStroke } from "./components";
56
export {
67
ThemeProvider,
78
useTheme,

0 commit comments

Comments
 (0)