Skip to content

Commit 40c7635

Browse files
authored
Merge pull request #119 from FlowTestAI/windows-compliant
feat: make app platform agnostic to allow windows support
2 parents f2b2d9a + d20fb8b commit 40c7635

13 files changed

Lines changed: 69 additions & 73 deletions

File tree

.changeset/silent-sheep-shake.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'flowtestai': minor
3+
---
4+
5+
make app platform agnostic to allow windows platform support

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
"eslint-plugin-import": "^2.29.1",
5858
"immer": "^10.0.4",
5959
"lodash": "^4.17.21",
60+
"mousetrap": "^1.6.5",
6061
"notistack": "^3.0.1",
6162
"postcss": "^8.4.35",
6263
"react": "^18.2.0",

packages/flowtest-cli/graph/Graph.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ class Graph {
127127
this.logger.add(LogLevel.INFO, '', { type: 'delayNode', data: { delay } });
128128
result = {
129129
status: 'Success',
130+
data: prevNodeOutputData,
130131
};
131132
}
132133

@@ -136,6 +137,7 @@ class Graph {
136137
this.auth = node.data.type ? aNode.evaluate() : undefined;
137138
result = {
138139
status: 'Success',
140+
data: prevNodeOutputData,
139141
};
140142
}
141143

@@ -170,6 +172,7 @@ class Graph {
170172
} else {
171173
result = {
172174
status: 'Success',
175+
data: prevNodeOutputData,
173176
};
174177
}
175178
}
@@ -194,6 +197,7 @@ class Graph {
194197
}
195198
result = {
196199
status: 'Success',
200+
data: prevNodeOutputData,
197201
};
198202
}
199203

packages/flowtest-electron/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
"start": "electron .",
1616
"test": "jest",
1717
"pack": "NODE_ENV=production electron-builder --dir",
18-
"dist": "NODE_ENV=production electron-builder"
18+
"dist:mac": "NODE_ENV=production electron-builder --mac",
19+
"dist:win": "SET NODE_ENV=production & electron-builder --win"
1920
},
2021
"author": "Sajal Jain <jsajal1993@gmail.com>",
2122
"license": "MIT",
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
const { ipcRenderer, contextBridge } = require('electron');
22
const path = require('path');
3+
const { isMacOS } = require('./src/utils/filemanager/filesystem');
34

45
contextBridge.exposeInMainWorld('ipcRenderer', {
56
invoke: (channel, ...args) => ipcRenderer.invoke(channel, ...args),
67
on: (channel, handler) => ipcRenderer.on(channel, (event, ...args) => handler(...args)),
78
join: (...args) => path.join(...args),
89
relative: (...args) => path.relative(...args),
910
dirname: (...args) => path.dirname(...args),
11+
isMacOs: isMacOS,
1012
});

packages/flowtest-electron/src/utils/filemanager/createdirectory.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,24 @@
11
const fs = require('fs');
2-
const { isDirectory, concatRoute, pathExists } = require('./filesystem');
2+
const { isDirectory, pathExists } = require('./filesystem');
3+
const path = require('path');
34

4-
const createDirectory = (name, path) => {
5+
const createDirectory = (name, basePath) => {
56
// now validate the name and path
67
if (!name) {
78
throw new Error('Directory name is required');
89
}
910

10-
if (!path) {
11+
if (!basePath) {
1112
throw new Error('Directory path is required');
1213
}
1314

1415
// check if the directory exists
15-
if (!isDirectory(path)) {
16+
if (!isDirectory(basePath)) {
1617
throw new Error('Path is not a directory');
1718
}
1819

1920
// check if the directory already exists
20-
const directoryPath = concatRoute(path, name);
21+
const directoryPath = path.join(basePath, name);
2122

2223
if (isDirectory(directoryPath)) {
2324
throw new Error('The directory already exists');

packages/flowtest-electron/src/utils/filemanager/filesystem.js

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -25,25 +25,6 @@ const pathExists = (path) => {
2525
}
2626
};
2727

28-
function trim(text) {
29-
return String(text).replace(/^\/|\/$/g, '');
30-
}
31-
32-
/**
33-
* Concatenate the given paths to one single path
34-
*
35-
* @param {...string} segments
36-
* @returns {string}
37-
*/
38-
const concatRoute = (...segments) => {
39-
let path = segments
40-
.filter((value) => value && String(value).length > 0)
41-
.map((segment) => '/' + trim(segment))
42-
.join('');
43-
44-
return '/' + trim(path.replace(/(\/)+/g, '/'));
45-
};
46-
4728
const getSubdirectoriesFromRoot = (rootPath, pathname) => {
4829
// convert to unix style path
4930
pathname = slash(pathname);
@@ -68,6 +49,8 @@ const isMacOS = () => {
6849
return process.platform === 'darwin';
6950
};
7051

52+
const PATH_SEPARATOR = isWindowsOS() ? '\\' : '/';
53+
7154
const slash = (path) => {
7255
const isExtendedLengthPath = /^\\\\\?\\/.test(path);
7356

@@ -78,13 +61,11 @@ const slash = (path) => {
7861
return path.replace(/\\/g, '/');
7962
};
8063

81-
const PATH_SEPARATOR = isWindowsOS() ? '\\' : '/';
82-
8364
module.exports = {
8465
isDirectory,
8566
pathExists,
86-
concatRoute,
8767
getSubdirectoriesFromRoot,
8868
getDirectoryName,
69+
isMacOS,
8970
PATH_SEPARATOR,
9071
};

pnpm-lock.yaml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/molecules/environment/index.js

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { BUTTON_TYPES, OBJ_TYPES } from 'constants/Common';
99
import EditEnvVariableModal from '../modals/EditEnvVariableModal';
1010
import { useKeyPress } from 'reactflow';
1111
import { saveHandle } from '../modals/SaveFlowModal';
12+
import Mousetrap from 'mousetrap';
1213

1314
const Env = ({ tab }) => {
1415
const variables = useEnvStore((state) => state.variables);
@@ -23,45 +24,50 @@ const Env = ({ tab }) => {
2324
const [editKey, setEditKey] = useState('');
2425
const [editValue, setEditValue] = useState('');
2526

26-
const cmdAndSPressed = useKeyPress(['Meta+s', 'Strg+s']);
27+
//const cmdAndSPressed = useKeyPress(['Meta+s', 'Strg+s']);
28+
// Bind Ctrl+S and Cmd+S
29+
Mousetrap.bind(['ctrl+s', 'command+s'], function (e) {
30+
e.preventDefault();
31+
saveHandle(tab);
32+
return false;
33+
});
2734

2835
return (
2936
<div className='p-4'>
30-
{cmdAndSPressed && saveHandle(tab)}
3137
<table className='w-full leading-normal'>
3238
<thead>
33-
<tr className='text-xs font-bold tracking-wider text-left uppercase bg-ghost-50 text-ghost-600'>
34-
<th className='p-5 border border-ghost-200 max-w-4'>S. No.</th>
35-
<th className='p-5 border border-ghost-200 '>Key</th>
36-
<th className='p-5 border border-ghost-200'>Value</th>
37-
<th className='p-5 border border-ghost-200 max-w-4'>Action</th>
39+
<tr className='bg-ghost-50 text-ghost-600 text-left text-xs font-bold uppercase tracking-wider'>
40+
<th className='border-ghost-200 max-w-4 border p-5'>S. No.</th>
41+
<th className='border-ghost-200 border p-5 '>Key</th>
42+
<th className='border-ghost-200 border p-5'>Value</th>
43+
<th className='border-ghost-200 max-w-4 border p-5'>Action</th>
3844
</tr>
3945
</thead>
4046
<tbody>
4147
{Object.entries(variables).map(([key, value], index) => (
42-
<tr key={index} className='text-sm border-b border-gray-200 text-ghost-700 hover:bg-ghost-50'>
43-
<td className='p-5 whitespace-no-wrap max-w-4'>{index + 1}</td>
44-
<td className='p-5 whitespace-no-wrap'>{key}</td>
45-
<td className='p-5 whitespace-no-wrap'>{value}</td>
46-
<td className='p-5 whitespace-no-wrap max-w-4'>
48+
<tr key={index} className='text-ghost-700 hover:bg-ghost-50 border-b border-gray-200 text-sm'>
49+
<td className='whitespace-no-wrap max-w-4 p-5'>{index + 1}</td>
50+
<td className='whitespace-no-wrap p-5'>{key}</td>
51+
<td className='whitespace-no-wrap p-5'>{value}</td>
52+
<td className='whitespace-no-wrap max-w-4 p-5'>
4753
<div
48-
className='relative inline-block p-2 text-left transition duration-200 ease-out rounded-md cursor-pointer hover:bg-ghost-200'
54+
className='hover:bg-ghost-200 relative inline-block cursor-pointer rounded-md p-2 text-left transition duration-200 ease-out'
4955
onClick={() => {
5056
setDeleteKey(key);
5157
setConfirmActionModalOpen(true);
5258
}}
5359
>
54-
<TrashIcon className='w-4 h-4' aria-hidden='true' />
60+
<TrashIcon className='h-4 w-4' aria-hidden='true' />
5561
</div>
5662
<div
57-
className='relative inline-block p-2 text-left transition duration-200 ease-out rounded-md cursor-pointer hover:bg-ghost-200'
63+
className='hover:bg-ghost-200 relative inline-block cursor-pointer rounded-md p-2 text-left transition duration-200 ease-out'
5864
onClick={() => {
5965
setEditKey(key);
6066
setEditValue(value);
6167
setEditVariableModalOpen(true);
6268
}}
6369
>
64-
<PencilSquareIcon className='w-4 h-4' aria-hidden='true' />
70+
<PencilSquareIcon className='h-4 w-4' aria-hidden='true' />
6571
</div>
6672
</td>
6773
</tr>
@@ -75,7 +81,7 @@ const Env = ({ tab }) => {
7581
onClickHandle={() => setAddVariableModalOpen(true)}
7682
fullWidth={true}
7783
>
78-
<PlusIcon className='w-5 h-5' />
84+
<PlusIcon className='h-5 w-5' />
7985
<span>Add Variable</span>
8086
</Button>
8187
</div>

src/components/molecules/flow/graph/Graph.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ class Graph {
112112
this.logger.add(LogLevel.INFO, '', { type: 'delayNode', data: delay });
113113
result = {
114114
status: 'Success',
115+
data: prevNodeOutputData,
115116
};
116117
}
117118

@@ -120,6 +121,7 @@ class Graph {
120121
this.auth = node.data.type ? aNode.evaluate() : undefined;
121122
result = {
122123
status: 'Success',
124+
data: prevNodeOutputData,
123125
};
124126
}
125127

@@ -151,6 +153,7 @@ class Graph {
151153
} else {
152154
result = {
153155
status: 'Success',
156+
data: prevNodeOutputData,
154157
};
155158
}
156159
}
@@ -173,6 +176,7 @@ class Graph {
173176
}
174177
result = {
175178
status: 'Success',
179+
data: prevNodeOutputData,
176180
};
177181
}
178182

0 commit comments

Comments
 (0)