Skip to content

Commit 071ef49

Browse files
committed
Cleanup of File Management
1 parent b868907 commit 071ef49

File tree

3 files changed

+35
-28
lines changed

3 files changed

+35
-28
lines changed

src/App.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -583,9 +583,14 @@ const AppContent: React.FC<AppContentProps> = ({ project, setProject }): React.J
583583
if (project) {
584584
const tabs = createTabItemsFromProject(project);
585585
setTabItems(tabs);
586-
setActiveTab(project.robot.modulePath);
586+
587+
// Only set active tab to robot if no active tab is set or if the current active tab no longer exists
588+
const currentActiveTabExists = tabs.some(tab => tab.key === activeTab);
589+
if (!activeTab || !currentActiveTabExists) {
590+
setActiveTab(project.robot.modulePath);
591+
}
587592
}
588-
}, [modulePathToContentText]);
593+
}, [modulePathToContentText, activeTab]);
589594

590595
const { Sider, Content } = Antd.Layout;
591596

src/reactComponents/FileManageModal.tsx

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ interface Module {
3838
/** Props for the FileManageModal component. */
3939
interface FileManageModalProps {
4040
isOpen: boolean;
41-
onCancel: () => void;
41+
onClose: () => void;
4242
project: storageProject.Project | null;
4343
setProject: (project: storageProject.Project | null) => void;
4444
gotoTab: (path: string) => void;
@@ -200,7 +200,12 @@ export default function FileManageModal(props: FileManageModalProps) {
200200
}
201201

202202
setNewItemName('');
203-
triggerProjectUpdate();};
203+
if(newModule){
204+
props.gotoTab(newModule.modulePath);
205+
}
206+
triggerProjectUpdate();
207+
props.onClose();
208+
};
204209

205210
/** Handles delete confirmation for a module. */
206211
const handleDeleteConfirm = async (record: Module): Promise<void> => {
@@ -225,7 +230,7 @@ export default function FileManageModal(props: FileManageModalProps) {
225230
/** Handles row double-click to open module in tab. */
226231
const handleRowDoubleClick = (record: Module): void => {
227232
props.gotoTab(record.path);
228-
props.onCancel();
233+
props.onClose();
229234
};
230235

231236
/** Opens the rename modal for a specific module. */
@@ -398,30 +403,10 @@ export default function FileManageModal(props: FileManageModalProps) {
398403
<Antd.Modal
399404
title={getModalTitle()}
400405
open={props.isOpen}
401-
onCancel={props.onCancel}
402-
footer={[
403-
<Antd.Button key="close" onClick={props.onCancel}>
404-
{t('Close')}
405-
</Antd.Button>,
406-
]}
406+
onCancel={props.onClose}
407+
footer={null}
407408
width={MODAL_WIDTH}
408409
>
409-
<div style={{
410-
marginBottom: 16,
411-
border: `1px solid ${token.colorBorder}`,
412-
borderRadius: '6px',
413-
padding: '12px',
414-
}}>
415-
<ClassNameComponent
416-
tabType={props.tabType}
417-
newItemName={newItemName}
418-
setNewItemName={setNewItemName}
419-
onAddNewItem={handleAddNewItem}
420-
project={props.project}
421-
storage={props.storage}
422-
buttonLabel={t('New')}
423-
/>
424-
</div>
425410
<Antd.Table<Module>
426411
columns={columns}
427412
dataSource={modules}
@@ -442,6 +427,23 @@ export default function FileManageModal(props: FileManageModalProps) {
442427
onDoubleClick: () => handleRowDoubleClick(record),
443428
})}
444429
/>
430+
<div style={{
431+
marginBottom: 16,
432+
border: `1px solid ${token.colorBorder}`,
433+
borderRadius: '6px',
434+
padding: '12px',
435+
}}>
436+
<br />
437+
<ClassNameComponent
438+
tabType={props.tabType}
439+
newItemName={newItemName}
440+
setNewItemName={setNewItemName}
441+
onAddNewItem={handleAddNewItem}
442+
project={props.project}
443+
storage={props.storage}
444+
buttonLabel={t('CREATE')}
445+
/>
446+
</div>
445447
</Antd.Modal>
446448
</>
447449
);

src/reactComponents/Menu.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ export function Component(props: MenuProps): React.JSX.Element {
443443
<>
444444
<FileManageModal
445445
isOpen={fileModalOpen}
446-
onCancel={handleFileModalClose}
446+
onClose={handleFileModalClose}
447447
project={props.project}
448448
storage={props.storage}
449449
tabType={tabType}

0 commit comments

Comments
 (0)