Skip to content

Commit e8e66e9

Browse files
authored
Merge pull request #104 from Open-STEM/kq-bugs
Addressed issue 101, 103.
2 parents 77d6ac7 + b472f6e commit e8e66e9

File tree

7 files changed

+26
-18
lines changed

7 files changed

+26
-18
lines changed

src/components/dialogs/settings.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ function SettingsDlg({ isXrpConnected, toggleDialog }: SettingsProps) {
179179
* handleSave - saving the settings into localstorage
180180
*/
181181
const handleSave = async () => {
182+
toggleDialog();
182183
if (adminData !== undefined) {
183184
adminData.mode = settings?.mode ?? ModeType.SYSTEM;
184185
await CommandToXRPMgr.getInstance().uploadFile(
@@ -188,7 +189,6 @@ function SettingsDlg({ isXrpConnected, toggleDialog }: SettingsProps) {
188189
}
189190
setModeValue(settings?.mode ?? -1);
190191
setLSXrpUser(xrpUser);
191-
toggleDialog();
192192
};
193193

194194
/**

src/components/navbar.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ function NavBar({ layoutref }: NavBarProps) {
8484
const [isConnected, setConnected] = useState(false);
8585
const [isRunning, setRunning] = useState(false);
8686
const [isBlockly, setBlockly] = useState(false);
87+
const [isOtherTab, setIsOtherTab] = useState(false);
8788
const dialogRef = useRef<HTMLDialogElement>(null);
8889
const [isDlgOpen, setDlgOpen] = useState(false);
8990
const [isGamepadConnected, setGamepadConnected] = useState<boolean>(false);
@@ -131,8 +132,12 @@ function NavBar({ layoutref }: NavBarProps) {
131132
AppMgr.getInstance().on(EventType.EVENT_EDITOR, (type: EditorType) => {
132133
if (type === EditorType.BLOCKLY) {
133134
setBlockly(true);
135+
setIsOtherTab(false);
134136
} else if (type === EditorType.PYTHON) {
135137
setBlockly(false);
138+
setIsOtherTab(false);
139+
} else {
140+
setIsOtherTab(true);
136141
}
137142
});
138143

@@ -572,6 +577,7 @@ function NavBar({ layoutref }: NavBarProps) {
572577
helpText: t('dashboard')
573578
};
574579
layoutref!.current?.addTabToTabSet(Constants.EDITOR_TABSET_ID, tabInfo);
580+
setIsOtherTab(true);
575581
setActiveTab('Dashboard');
576582
}
577583

@@ -587,6 +593,7 @@ function NavBar({ layoutref }: NavBarProps) {
587593
helpText: 'Chat with AI models from Hugging Face',
588594
};
589595
layoutref!.current?.addTabToTabSet(Constants.EDITOR_TABSET_ID, tabInfo);
596+
setIsOtherTab(true);
590597
setActiveTab('AI Chat');
591598
}
592599

@@ -907,7 +914,7 @@ function NavBar({ layoutref }: NavBarProps) {
907914
{item.children.map((child, ci) => (
908915
<li
909916
key={ci}
910-
className={`text-neutral-200 py-1 pl-4 pr-10 hover:bg-matisse-400 dark:hover:bg-shark-500 ${child.isFile && !isConnected ? 'pointer-events-none' : 'pointer-events-auto'} ${child.isView && !isBlockly ? 'hidden' : 'visible'}`}
917+
className={`text-neutral-200 py-1 pl-4 pr-10 hover:bg-matisse-400 dark:hover:bg-shark-500 ${child.isFile && !isConnected ? 'pointer-events-none' : 'pointer-events-auto'} ${child.isView && !isBlockly || isOtherTab ? 'hidden' : 'visible'}`}
911918
onClick={child.clicked}
912919
>
913920
<MenuItem
@@ -920,7 +927,8 @@ function NavBar({ layoutref }: NavBarProps) {
920927
{item.childrenExt && (
921928
<ul
922929
id="blockId"
923-
className={`${isBlockly ? 'hidden' : 'visible'} cursor-pointer flex-col`}
930+
className={`${isBlockly || isOtherTab ? 'hidden' : 'visible'} cursor-pointer flex-col`}
931+
924932
>
925933
{item.childrenExt?.map((child, ci) => (
926934
<li

src/components/xrplayout.tsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -244,13 +244,12 @@ function XRPLayout({ forwardedref }: XRPLayoutProps) {
244244
case Actions.SELECT_TAB: {
245245
console.log('Selected Tab:', action.data.tabNode);
246246
const blockly = action.data.tabNode.includes('.blocks');
247+
let editorEventType = EditorType.OTHER;
247248
if (EditorMgr.getInstance().hasEditorSession(action.data.tabNode)) {
248-
AppMgr.getInstance().emit(
249-
EventType.EVENT_EDITOR,
250-
blockly ? EditorType.BLOCKLY : EditorType.PYTHON,
251-
);
252-
setActiveTab(action.data.tabNode);
249+
editorEventType = blockly ? EditorType.BLOCKLY : EditorType.PYTHON;
253250
}
251+
AppMgr.getInstance().emit(EventType.EVENT_EDITOR, editorEventType);
252+
setActiveTab(action.data.tabNode);
254253
}
255254
break;
256255
case Actions.DELETE_TAB: {

src/utils/constants.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export class Constants {
1111
static SHOW_PROGRESS = 'show-progress';
1212
static readonly ADMIN_FILE = 'admin.json';
1313
static readonly GUSERS_FOLDER = '/gusers/';
14-
static readonly XRPCODES = 'XRPCodes';
14+
static readonly XRPCODE = 'XRPCode';
1515
static readonly LIBDIR = '/lib/';
1616
static readonly CONNECTED = "Connected";
1717
static readonly DISCONNECTED = "Disconnected";

src/utils/google-utils.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,12 @@ const transformGDriveTreeToFolderTree = (username: string, driveItem: GoogleDriv
3131
};
3232

3333
/**
34-
* fireGoogleUserTree - get a list of Google files in XRPCodes folder and generate a folder tree
34+
* fireGoogleUserTree - get a list of Google files in XRPCode folder and generate a folder tree
3535
*/
3636
export const fireGoogleUserTree = async (username: string) => {
3737
const driveService = AppMgr.getInstance().driveService;
3838

39-
await driveService.buildTree(Constants.XRPCODES).then((tree) => {
39+
await driveService.buildTree(Constants.XRPCODE).then((tree) => {
4040
if (tree) {
4141
const folderTree = transformGDriveTreeToFolderTree(username, tree);
4242
AppMgr.getInstance().emit(EventType.EVENT_FILESYS, JSON.stringify([folderTree]));

src/utils/types.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ export enum ModeType {
1717

1818
export enum EditorType {
1919
BLOCKLY = 'blockly',
20-
PYTHON = 'python'
20+
PYTHON = 'python',
21+
OTHER = 'other'
2122
}
2223

2324
export enum ConnectionCMD {

src/widgets/login.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import AppMgr from '@/managers/appmgr';
55
import logger from '@/utils/logger';
66
import { UserProfile } from '@/services/google-auth';
77
import { useTranslation } from 'react-i18next';
8+
import { Constants } from '@/utils/constants';
89

910
type LoginProps = {
1011
logoutCallback: () => void;
@@ -40,7 +41,6 @@ function Login({ logoutCallback, onSuccess }: LoginProps) {
4041
const authService = AppMgr.getInstance().authService;
4142
const driveService = AppMgr.getInstance().driveService;
4243
const loginLogger = logger.child({ module: 'login' });
43-
const XRPCODES = 'XRPCodes';
4444

4545
const SCOPE = 'https://mail.google.com https://www.googleapis.com/auth/drive';
4646

@@ -61,17 +61,17 @@ function Login({ logoutCallback, onSuccess }: LoginProps) {
6161
expire_in: token.expires_in,
6262
}));
6363
driveService.setAccessToken(token.access_token);
64-
// check if XRPCodes folder exists, if not create it
64+
// check if XRPCode folder exists, if not create it
6565
try {
66-
const folder = await driveService.findFolderByName(XRPCODES);
66+
const folder = await driveService.findFolderByName(Constants.XRPCODE);
6767
if (!folder) {
68-
await driveService.createFolder(XRPCODES);
68+
await driveService.createFolder(Constants.XRPCODE);
6969
}
7070
} catch (error) {
7171
if (error instanceof Error) {
72-
loginLogger.error(`Error checking or creating XRPCodes folder: ${error.stack ?? error.message}`);
72+
loginLogger.error(`Error checking or creating XRPCode folder: ${error.stack ?? error.message}`);
7373
} else {
74-
loginLogger.error(`Error checking or creating XRPCodes folder: ${String(error)}`);
74+
loginLogger.error(`Error checking or creating XRPCode folder: ${String(error)}`);
7575
}
7676
}
7777
});

0 commit comments

Comments
 (0)