Skip to content
This repository has been archived by the owner on Oct 25, 2024. It is now read-only.

Commit

Permalink
fix: 🔥 Windows Clean Up
Browse files Browse the repository at this point in the history
  • Loading branch information
ahwelgemoed committed Mar 13, 2021
1 parent 3222773 commit 4cbcee7
Show file tree
Hide file tree
Showing 15 changed files with 516 additions and 546 deletions.
44 changes: 19 additions & 25 deletions src/renderer/App.tsx
Original file line number Diff line number Diff line change
@@ -1,28 +1,22 @@
import React from 'react'

import './App.css'
import { hot } from 'react-hot-loader/root'
import { remote } from 'electron'
import { HashRouter as Router } from 'react-router-dom'
import Layout from './Layout'
import {
ChakraProvider,
ColorModeScript,
useColorMode,
Button
} from '@chakra-ui/react'
import theme from './theme'
import React from "react";
import "./App.css";
import { hot } from "react-hot-loader/root";
// import { remote } from 'electron'
import { HashRouter as Router } from "react-router-dom";
import Layout from "./Layout";
import { ChakraProvider, ColorModeScript } from "@chakra-ui/react";
import theme from "./theme";

const App: React.FC = () => {
const electron = process.versions.electron
const node = process.versions.node
const platform = require('os').platform()
const version = require('../../package.json').version
// const electron = process.versions.electron
// const node = process.versions.node
// const platform = require('os').platform()
// const version = require('../../package.json').version

const handleLinkClick = (e: React.MouseEvent<HTMLAnchorElement>) => {
e.preventDefault()
remote.shell.openExternal(e.currentTarget.href)
}
// const handleLinkClick = (e: React.MouseEvent<HTMLAnchorElement>) => {
// e.preventDefault()
// remote.shell.openExternal(e.currentTarget.href)
// }

return (
<ChakraProvider theme={theme}>
Expand All @@ -31,7 +25,7 @@ const App: React.FC = () => {
<Layout />
</Router>
</ChakraProvider>
)
}
);
};

export default hot(App)
export default hot(App);
41 changes: 17 additions & 24 deletions src/renderer/Components/AddProjectListModal.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React from "react";

import {
Stack,
Button,
Expand All @@ -18,11 +17,12 @@ import {
useDisclosure,
} from "@chakra-ui/react";
import { SettingsIcon } from "@chakra-ui/icons";
import { RootStoreContext } from "../stores/RootStore";
import { observer } from "mobx-react-lite";
import { RootStoreContext } from "../stores/RootStore";
import { FolderSortEnum } from "../types/projectTypes";
const platform = require("os").platform();
const slash = platform === "darwin" ? "/" : "\\";

import { slash } from "../utils";

export const AddProjectListModal: React.FC = observer(({}) => {
const { isOpen, onOpen, onClose } = useDisclosure();
const [folderSort, setFolderSort] = React.useState<FolderSortEnum>(
Expand All @@ -32,9 +32,10 @@ export const AddProjectListModal: React.FC = observer(({}) => {
const [mendixAppsPath, setMendixAppsPath] = React.useState<
string | undefined
>();

React.useEffect(() => {
if (projectStore.projectsStore.mendixProjectsPathMac) {
setMendixAppsPath(projectStore.projectsStore.mendixProjectsPathMac);
if (projectStore.projectsStore.mendixProjectsPathOnWindows) {
setMendixAppsPath(projectStore.projectsStore.mendixProjectsPathOnWindows);
if (projectStore.projectsStore.sortOption) {
setFolderSort(projectStore.projectsStore.sortOption);
} else {
Expand All @@ -44,25 +45,23 @@ export const AddProjectListModal: React.FC = observer(({}) => {
onOpen();
}
}, []);
const locateGulpFile = (event: any) => {
if (event.target.files[0]) {
const pathToGulp = event.target.files[0].path;
}
};
const locateMendixAppsPath = (event: any) => {
if (event.target.files[0]) {
const pathToThisMendixProject = event.target.files[0].path;

const locateMendixAppsPath = (
e: React.ChangeEvent<HTMLInputElement>
): void => {
if (e.target.files && e.target.files.length && e.target.files[0]) {
const pathToThisMendixProject = e.target.files[0].path;
const split = pathToThisMendixProject.split(slash);
split.splice(split.length - 2, 2);
const joinMendixPath = split.join(slash);
setMendixAppsPath(joinMendixPath);
}
};
const setAndSave = (e: FolderSortEnum) => {
const setAndSave = (e: FolderSortEnum): void => {
setFolderSort(e);
projectStore.projectsStore.setSortPath(e);
};
const acceptAndAddProjects = () => {
const acceptAndAddProjects = (): void => {
if (mendixAppsPath) {
// Set Project Path To Mem
projectStore.projectsStore.setProjectPath(mendixAppsPath);
Expand Down Expand Up @@ -97,14 +96,9 @@ export const AddProjectListModal: React.FC = observer(({}) => {
folder:
</Heading>

<Button onChange={locateMendixAppsPath}>
<Button onChange={locateMendixAppsPath as any}>
<label className="custom-file-upload">
<input
id="path-picker"
type="file"
// @ts-ignore
// webkitdirectory="true"
/>
<input id="path-picker" type="file" />
Choose Mendix Folder Path
</label>
</Button>
Expand All @@ -118,7 +112,6 @@ export const AddProjectListModal: React.FC = observer(({}) => {
mb={4}
size="sm"
colorScheme="teal"
// @ts-ignore
onChange={setAndSave}
value={folderSort}
>
Expand Down
50 changes: 25 additions & 25 deletions src/renderer/Components/ListOfProjects.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState } from "react";
import React, { useState } from 'react'
import {
Button,
Box,
Expand All @@ -14,13 +14,13 @@ import {
Flex,
List,
ListItem,
Divider,
} from "@chakra-ui/react";
import { ChevronRightIcon, ChevronDownIcon } from "@chakra-ui/icons";
import { observer } from "mobx-react-lite";
import { FolderNamesType, ProjectType } from "../types/projectTypes";
import { format } from "date-fns";
const platform = require("os").platform();
Divider
} from '@chakra-ui/react'
import { ChevronRightIcon, ChevronDownIcon } from '@chakra-ui/icons'
import { observer } from 'mobx-react-lite'
import { FolderNamesType, ProjectType } from '../types/projectTypes'
import { format } from 'date-fns'
const platform = require('os').platform()

const ListOfProjects = observer(
({
Expand All @@ -29,10 +29,10 @@ const ListOfProjects = observer(
openInVsCodeBase,
openInVsCodeStyles,
openInMacTerminal,
openInWindowsTerminal,
openInWindowsTerminal
}: any) => {
const [projectsState, setProjectsState] = useState<ProjectType[]>([]);
const [openState, setopenState] = useState<number | undefined>();
const [projectsState, setProjectsState] = useState<ProjectType[]>([])
const [openState, setopenState] = useState<number | undefined>()

React.useEffect(() => {
if (projectsSorted && projectsSorted.length) {
Expand All @@ -43,11 +43,11 @@ const ListOfProjects = observer(
return (
new Date(b.lastModified).getTime() -
new Date(a.lastModified).getTime()
);
});
setProjectsState(x);
)
})
setProjectsState(x)
}
}, [projectsSorted]);
}, [projectsSorted])
return (
<>
<List spacing={3}>
Expand All @@ -58,14 +58,14 @@ const ListOfProjects = observer(
<Box>
<ListItem>
<Badge mr="2" borderRadius="4px">
{item.folderNames ? item.folderNames.length : ""}
{item.folderNames ? item.folderNames.length : ''}
</Badge>
{item.name}
</ListItem>
</Box>
<Spacer />
<Box mr="4" color="teal.700">
{format(new Date(item.lastModified), "dd/MM/yyyy")}
{format(new Date(item.lastModified), 'dd/MM/yyyy')}
</Box>
<Box>
<Button
Expand Down Expand Up @@ -109,7 +109,7 @@ const ListOfProjects = observer(
<Td>
{format(
new Date(fileNames.lastModified),
"dd/MM/yyyy"
'dd/MM/yyyy'
)}
</Td>
<Td>
Expand Down Expand Up @@ -157,7 +157,7 @@ const ListOfProjects = observer(
isAttached
variant="outline"
>
{platform === "darwin" && (
{platform === 'darwin' && (
<Button
colorScheme="teal"
size="xs"
Expand Down Expand Up @@ -187,7 +187,7 @@ const ListOfProjects = observer(
<Tr>
<Td>{item.name}</Td>
<Td>
{format(new Date(item.lastModified), "dd/MM/yyyy")}
{format(new Date(item.lastModified), 'dd/MM/yyyy')}
</Td>
<Td>
<Button
Expand Down Expand Up @@ -220,7 +220,7 @@ const ListOfProjects = observer(
</Td>
<Td>
<ButtonGroup size="sm" isAttached variant="outline">
{platform === "darwin" && (
{platform === 'darwin' && (
<Button
colorScheme="teal"
size="xs"
Expand All @@ -246,12 +246,12 @@ const ListOfProjects = observer(
</Table>
)}
</div>
);
)
})}
</List>
</>
);
)
}
);
)

export default ListOfProjects;
export default ListOfProjects
42 changes: 21 additions & 21 deletions src/renderer/Components/ParallelsSettings.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react'
import React from "react";

import {
Stack,
Expand All @@ -17,24 +17,24 @@ import {
useClipboard,
Icon,
Flex,
Input
} from '@chakra-ui/react'
Input,
} from "@chakra-ui/react";
// import messenger from "messenger";
import spawnAsync from '@expo/spawn-async'
import { getWindowsIp } from '../utils'
import { MdComputer } from 'react-icons/md'
import { RootStoreContext } from '../stores/RootStore'
import { observer } from 'mobx-react-lite'
import spawnAsync from "@expo/spawn-async";
import { getWindowsIp } from "../utils";
import { MdComputer } from "react-icons/md";
import { RootStoreContext } from "../stores/RootStore";
import { observer } from "mobx-react-lite";

export const ParallelsSettings: React.FC = observer(({}) => {
const iPWindows = getWindowsIp().address
const { hasCopied, onCopy } = useClipboard(iPWindows)
const { isOpen, onOpen, onClose } = useDisclosure()
const projectStore = React.useContext(RootStoreContext)
const [allVms, setAllVms] = React.useState<string | undefined>()
const iPWindows = getWindowsIp();
const { hasCopied, onCopy } = useClipboard(iPWindows);
const { isOpen, onOpen, onClose } = useDisclosure();
const projectStore = React.useContext(RootStoreContext);
const [allVms, setAllVms] = React.useState<string | undefined>();

React.useEffect(() => {
findAllVMs()
findAllVMs();

// here we have 4 servers listening on 4 different ports
// var server1 = messenger.createListener(8001);
Expand All @@ -50,7 +50,7 @@ export const ParallelsSettings: React.FC = observer(({}) => {
// setInterval(function () {
// client.shout("a message came", { some: "data" });
// }, 1000);
}, [])
}, []);

const findAllVMs = async () => {
// const ffmpeg$ = spawnAsync("prlctl", ["list", "-a"]);
Expand All @@ -61,9 +61,9 @@ export const ParallelsSettings: React.FC = observer(({}) => {
// });
// const result = await ffmpeg$;
// setAllVms(result.output[0]);
}
console.log('allVms', allVms && allVms.split(/(\r\n|\n|\r)/gm))
console.log('allVms', allVms && allVms.split('\n')[1].replace(/\s/g, ''))
};
console.log("allVms", allVms && allVms.split(/(\r\n|\n|\r)/gm));
console.log("allVms", allVms && allVms.split("\n")[1].replace(/\s/g, ""));
return (
<>
<Button mr="-px" onClick={onOpen}>
Expand Down Expand Up @@ -91,7 +91,7 @@ export const ParallelsSettings: React.FC = observer(({}) => {
placeholder="Welcome"
/>
<Button onClick={onCopy}>
{hasCopied ? 'Copied' : 'Copy'}
{hasCopied ? "Copied" : "Copy"}
</Button>
</Flex>
</Stack>
Expand All @@ -103,5 +103,5 @@ export const ParallelsSettings: React.FC = observer(({}) => {
</ModalContent>
</Modal>
</>
)
})
);
});
Loading

0 comments on commit 4cbcee7

Please sign in to comment.