Skip to content

Commit 4c22a48

Browse files
authored
Merge pull request #256 from Open-STEM/kq-bugs
Kq bugs
2 parents 4f40315 + 7354999 commit 4c22a48

5 files changed

Lines changed: 144 additions & 54 deletions

File tree

README.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,37 @@ The XRP software platform is an integrated development environment where you can
1212
- **Python** (v3.8 or higher)
1313
- **npm** or **yarn**
1414

15+
### Development Environment Setup
16+
17+
- Install VSCode or Google Antigravity
18+
- Install IDE Extensions
19+
- Pylance
20+
- Python
21+
- ESLint
22+
- Prettier
23+
- Git Graph
24+
- Tailwind CSS IntelliSense
25+
- Install NodeJS
26+
- Install Python
27+
- Setup Python Virtual Environment
28+
29+
#### Debugging
30+
31+
- Create a launch.json file in the .vscode directory to debug the frontend
32+
```json
33+
{
34+
"configurations": [
35+
{
36+
"name": "XRP Web",
37+
"type": "chrome",
38+
"request": "launch",
39+
"url": "http://localhost:3000",
40+
"webRoot": "${workspaceFolder}"
41+
}
42+
]
43+
}
44+
```
45+
1546
### Frontend Setup
1647

1748
1. **Clone the repository**

public/lib/XRPLib/puppet.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ def _stop_poll_timer(self):
232232
"""
233233
if self._poll_timer_running:
234234
self._poll_timer.deinit()
235-
kbd_intr(03) #start watching for ctrl-c again
235+
kbd_intr(3) #start watching for ctrl-c again
236236
self._poll_timer_running = False
237237
if self._stdin_poll is not None:
238238
try:
Lines changed: 1 addition & 0 deletions
Loading

src/components/navbar.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,6 @@ function NavBar({ layoutref }: NavBarProps) {
299299
});
300300

301301
AppMgr.getInstance().on(EventType.EVENT_HIDE_BLUETOOTH_CONNECTING, () => {
302-
setDialogContent(<div />);
303302
toggleDialog();
304303
});
305304

src/components/xrplayout.tsx

Lines changed: 111 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,19 @@
1-
import { Layout, Model, IJsonModel, TabNode, Action, Actions, ITabRenderValues } from 'flexlayout-react';
1+
import {
2+
Layout,
3+
Model,
4+
IJsonModel,
5+
TabNode,
6+
Action,
7+
Actions,
8+
ITabRenderValues,
9+
} from 'flexlayout-react';
210
import React, { useEffect, useRef, useState } from 'react';
311
import BlocklyEditor from '@components/blockly';
412
import MonacoEditor from '@components/MonacoEditor';
513
import XRPShell from '@components/xrpshell';
614
import FolderIcon from '@assets/images/folder-24.png';
715
import ShellIcon from '@assets/images/shell.svg';
16+
import GoogleDriveLogo from '@assets/images/Google_Drive-Logo.svg';
817
//import treeDaaJson from '@/utils/testdata';
918
import AppMgr, { EventType, Themes } from '@/managers/appmgr';
1019
import FolderTree from './folder-tree';
@@ -28,7 +37,7 @@ const layout_json: IJsonModel = {
2837
tabEnablePopout: false,
2938
tabSetEnableDrag: false,
3039
tabSetEnableDrop: false,
31-
tabEnableRename: false
40+
tabEnableRename: false,
3241
},
3342
borders: [
3443
{
@@ -85,7 +94,7 @@ const layout_json: IJsonModel = {
8594
component: 'xterm',
8695
enableClose: false,
8796
enableDrag: false,
88-
enablePopout: false
97+
enablePopout: false,
8998
},
9099
],
91100
},
@@ -104,7 +113,14 @@ let layoutRef: React.RefObject<Layout> = {
104113
const factory = (node: TabNode) => {
105114
const component = node.getComponent();
106115
if (component == 'editor') {
107-
return <MonacoEditor tabId={node.getId()} tabname={node.getName()} width="100vw" height="100vh" />;
116+
return (
117+
<MonacoEditor
118+
tabId={node.getId()}
119+
tabname={node.getName()}
120+
width="100vw"
121+
height="100vh"
122+
/>
123+
);
108124
} else if (component == 'xterm') {
109125
return <XRPShell />;
110126
} else if (component == 'folders') {
@@ -127,17 +143,17 @@ let hasSubscribed = false;
127143

128144
/**
129145
* useOnceCall - call the function once
130-
* @param cb
131-
* @param condition
146+
* @param cb
147+
* @param condition
132148
*/
133149
function useOnceCall(cb: () => void, condition = true) {
134150
const isCalledRef = React.useRef(false);
135-
151+
136152
React.useEffect(() => {
137-
if (condition && !isCalledRef.current) {
138-
isCalledRef.current = true;
139-
cb();
140-
}
153+
if (condition && !isCalledRef.current) {
154+
isCalledRef.current = true;
155+
cb();
156+
}
141157
}, [cb, condition]);
142158
}
143159

@@ -223,7 +239,7 @@ function XRPLayout({ forwardedref }: XRPLayoutProps) {
223239
gpath: store.gpath,
224240
filetype: store.isBlockly ? FileType.BLOCKLY : FileType.PYTHON,
225241
content: store.content,
226-
}
242+
};
227243
CreateEditorTab(fileData, layoutRef);
228244
let content: string | undefined;
229245
if (fileData.filetype === FileType.BLOCKLY) {
@@ -233,12 +249,18 @@ function XRPLayout({ forwardedref }: XRPLayoutProps) {
233249
content = store.content;
234250
}
235251
const loadContent = { name: store.name, path: store.path, content: content };
236-
AppMgr.getInstance().emit(EventType.EVENT_EDITOR_LOAD, JSON.stringify(loadContent));
252+
AppMgr.getInstance().emit(
253+
EventType.EVENT_EDITOR_LOAD,
254+
JSON.stringify(loadContent),
255+
);
237256
if (!store.isSavedToXRP) {
238257
// update the editor session and update the tab dirty status
239258
const editorSession = EditorMgr.getInstance().getEditorSession(store.id);
240259
if (editorSession) {
241-
EditorMgr.getInstance().updateEditorSessionChange(store.id, !store.isSavedToXRP);
260+
EditorMgr.getInstance().updateEditorSessionChange(
261+
store.id,
262+
!store.isSavedToXRP,
263+
);
242264
}
243265
}
244266
setActiveTab(store.id);
@@ -250,7 +272,7 @@ function XRPLayout({ forwardedref }: XRPLayoutProps) {
250272
const currentVersion = Constants.APP_VERSION;
251273
if (version === null || version !== currentVersion) {
252274
AppMgr.getInstance().emit(EventType.EVENT_SHOWCHANGELOG, Constants.SHOW_CHANGELOG);
253-
}
275+
}
254276
localStorage.setItem(StorageKeys.VERSION, currentVersion || '');
255277
};
256278

@@ -261,7 +283,7 @@ function XRPLayout({ forwardedref }: XRPLayoutProps) {
261283
}
262284
return () => {
263285
window.removeEventListener('load', handleWindowLoad);
264-
}
286+
};
265287
});
266288

267289
/**
@@ -273,8 +295,7 @@ function XRPLayout({ forwardedref }: XRPLayoutProps) {
273295
}
274296
if (dialogRef.current.hasAttribute('open')) {
275297
dialogRef.current.close();
276-
}
277-
else dialogRef.current.showModal();
298+
} else dialogRef.current.showModal();
278299
};
279300

280301
/**
@@ -291,7 +312,7 @@ function XRPLayout({ forwardedref }: XRPLayoutProps) {
291312
setActiveTab(id);
292313
}
293314
}
294-
}
315+
};
295316

296317
/**
297318
* handleActions - handle the actions from the layout
@@ -301,64 +322,102 @@ function XRPLayout({ forwardedref }: XRPLayoutProps) {
301322
function handleActions(action: Action): Action | undefined {
302323
console.log('Handle Action: Action Type:', action.type, activeTab);
303324
switch (action.type) {
304-
case Actions.SELECT_TAB: {
305-
console.log('Selected Tab:', action.data.tabNode);
306-
if (EditorMgr.getInstance().hasEditorSession(action.data.tabNode)) {
307-
const editorType = EditorMgr.getInstance().getEditorSession(action.data.tabNode)?.type;
308-
if (editorType !== undefined) {
309-
AppMgr.getInstance().emit(EventType.EVENT_EDITOR, editorType);
325+
case Actions.SELECT_TAB:
326+
{
327+
console.log('Selected Tab:', action.data.tabNode);
328+
if (EditorMgr.getInstance().hasEditorSession(action.data.tabNode)) {
329+
const editorType = EditorMgr.getInstance().getEditorSession(
330+
action.data.tabNode,
331+
)?.type;
332+
if (editorType !== undefined) {
333+
AppMgr.getInstance().emit(EventType.EVENT_EDITOR, editorType);
334+
}
335+
setActiveTab(action.data.tabNode);
310336
}
311-
setActiveTab(action.data.tabNode);
312-
}
313-
}
314-
break;
315-
case Actions.DELETE_TAB: {
316-
console.log('Delete Node:', action.data);
317-
const isDirty = EditorMgr.getInstance().hasSessionChanged(action.data.node);
318-
if (isDirty) {
319-
setDialogContent(<ConfirmationDlg acceptCallback={handleDeleteTabConfirmation} toggleDialog={toggleDialog} confirmationMessage={t('confirmDeleteTab', { name: action.data.node })} name={action.data.node}/>);
320-
toggleDialog();
321-
322-
return undefined;
323337
}
338+
break;
339+
case Actions.DELETE_TAB:
340+
{
341+
console.log('Delete Node:', action.data);
342+
const isDirty = EditorMgr.getInstance().hasSessionChanged(action.data.node);
343+
if (isDirty) {
344+
setDialogContent(
345+
<ConfirmationDlg
346+
acceptCallback={handleDeleteTabConfirmation}
347+
toggleDialog={toggleDialog}
348+
confirmationMessage={t('confirmDeleteTab', {
349+
name: action.data.node,
350+
})}
351+
name={action.data.node}
352+
/>,
353+
);
354+
toggleDialog();
324355

325-
const name = EditorMgr.getInstance().RemoveEditor(action.data.node);
326-
if (name) {
327-
setActiveTab(name);
356+
return undefined;
357+
}
358+
359+
const name = EditorMgr.getInstance().RemoveEditor(action.data.node);
360+
if (name) {
361+
setActiveTab(name);
362+
}
328363
}
329-
}
330-
break;
331-
default: {
332-
console.log('Default Action:', action);
333-
}
334-
break;
364+
break;
365+
default:
366+
{
367+
console.log('Default Action:', action);
368+
}
369+
break;
335370
}
336371
return action;
337372
}
338373

339374
/**
340375
* onRenderTab - render the tab with custom functionality
341-
* @param node
376+
* @param node
342377
* @param renderValues
343-
* @returns
378+
* @returns
344379
*/
345380
const onRenderTab = (node: TabNode, renderValues: ITabRenderValues) => {
346381
// Override the content to use the translated tab names
347382
if (node.getId() === Constants.FOLDER_TAB_ID) {
348-
renderValues.leading = <img src={FolderIcon} alt="icon" style={{ width: '16px', height: '16px', marginRight: '16px' }} />;
383+
renderValues.leading = (
384+
<img
385+
src={FolderIcon}
386+
alt="icon"
387+
style={{ width: '16px', height: '16px', marginRight: '16px' }}
388+
/>
389+
);
349390
} else if (node.getId() === Constants.SHELL_TAB_ID) {
350-
renderValues.leading = <img src={ShellIcon} alt="icon" style={{ width: '16px', height: '16px', marginRight: '0px' }} />;
391+
renderValues.leading = (
392+
<img
393+
src={ShellIcon}
394+
alt="icon"
395+
style={{ width: '16px', height: '16px', marginRight: '0px' }}
396+
/>
397+
);
398+
} else if (EditorMgr.getInstance().getEditorSession(node.getId())?.gpath !== undefined) {
399+
renderValues.leading = (
400+
<img src={GoogleDriveLogo} alt="icon" style={{ width: '16px', height: '16px' }} />
401+
);
351402
}
352403
renderValues.content = t(node.getName());
353404
if (EditorMgr.getInstance().hasSessionChanged(node.getId())) {
354-
renderValues.buttons.push(<div className='w-2 h-2 bg-shark-800 dark:bg-shark-200 rounded-full' />)
405+
renderValues.buttons.push(
406+
<div className={`h-2 w-2 rounded-full bg-shark-800 dark:bg-shark-200`} />,
407+
);
355408
}
356409
return renderValues;
357410
};
358411

359412
return (
360413
<>
361-
<Layout ref={forwardedref} model={model} factory={factory} onAction={handleActions} onRenderTab={onRenderTab}/>
414+
<Layout
415+
ref={forwardedref}
416+
model={model}
417+
factory={factory}
418+
onAction={handleActions}
419+
onRenderTab={onRenderTab}
420+
/>
362421
<Dialog isOpen={false} toggleDialog={toggleDialog} ref={dialogRef}>
363422
{dialogContent}
364423
</Dialog>

0 commit comments

Comments
 (0)