Skip to content

Commit 2d83eca

Browse files
authored
refactor: remove unused devtools component (#101)
* refactor: clean up useless comments * refactor: remove DevTools component and related styles - Deleted the DevTools component and its associated SCSS file to streamline the codebase. - Updated the CustomEmbeddableRenderer to remove references to DevTools, enhancing clarity and maintainability. - Removed DevTools entry from the pad index file and MainMenu, simplifying the user interface.
1 parent 3da1788 commit 2d83eca

File tree

8 files changed

+10
-172
lines changed

8 files changed

+10
-172
lines changed

src/frontend/src/CustomEmbeddableRenderer.tsx

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import {
99
ControlButton,
1010
Editor,
1111
Terminal,
12-
DevTools,
1312
} from './pad';
1413
import { ActionButton } from './pad/buttons';
1514
import "./CustomEmbeddableRenderer.scss";
@@ -36,7 +35,7 @@ export const renderCustomEmbeddable = (
3635
title = "HTML Editor";
3736
break;
3837
case 'editor':
39-
content = <Editor element={element} appState={appState} excalidrawAPI={excalidrawAPI} />;
38+
content = <Editor element={element} excalidrawAPI={excalidrawAPI} />;
4039
title = "Code Editor";
4140
break;
4241
case 'terminal':
@@ -64,10 +63,6 @@ export const renderCustomEmbeddable = (
6463
content = <Dashboard element={element} appState={appState} excalidrawAPI={excalidrawAPI} />;
6564
title = "Dashboard";
6665
break;
67-
case 'dev':
68-
content = <DevTools element={element} appState={appState} excalidrawAPI={excalidrawAPI} />;
69-
title = "Dev Tools";
70-
break;
7166
default:
7267
title = "Untitled";
7368
return null;

src/frontend/src/pad/DevTools.scss

Lines changed: 0 additions & 86 deletions
This file was deleted.

src/frontend/src/pad/DevTools.tsx

Lines changed: 0 additions & 47 deletions
This file was deleted.

src/frontend/src/pad/editors/HtmlEditor.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export const useHtmlEditor = (
3333
element: NonDeleted<ExcalidrawEmbeddableElement> | undefined,
3434
editorRef: React.RefObject<any>,
3535
excalidrawAPI?: any,
36-
isActive: boolean = true // New parameter to control if the hook is active
36+
isActive: boolean = true
3737
) => {
3838
// Always initialize these hooks regardless of isActive
3939
const [createNew, setCreateNew] = useState(false);

src/frontend/src/pad/index.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,9 @@ export * from './Dashboard';
55
export * from './Terminal';
66
export * from './buttons';
77
export * from './editors';
8-
export * from './DevTools';
98

109
// Default exports
1110
export { default as ControlButton } from './buttons/ControlButton';
1211
export { default as StateIndicator } from './StateIndicator';
1312
export { default as Dashboard } from './Dashboard';
1413
export { default as Terminal } from './Terminal';
15-
export { default as DevTools } from './DevTools';

src/frontend/src/ui/MainMenu.tsx

Lines changed: 4 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { LogOut, SquarePlus, LayoutDashboard, User, Text, Settings, Terminal, Fi
77
import md5 from 'crypto-js/md5';
88

99
// Components
10-
import SettingsDialog from './SettingsDialog'; // Added import
10+
import SettingsDialog from './SettingsDialog';
1111

1212
import { useLogout } from '../hooks/useLogout';
1313
import { useAuthStatus } from '../hooks/useAuthStatus';
@@ -67,22 +67,6 @@ export const MainMenuConfig: React.FC<MainMenuConfigProps> = ({
6767
});
6868
};
6969

70-
const handleDevToolsClick = () => {
71-
if (!excalidrawAPI) return;
72-
73-
const devToolsElement = ExcalidrawElementFactory.createEmbeddableElement({
74-
link: "!dev",
75-
width: 800,
76-
height: 500
77-
});
78-
79-
ExcalidrawElementFactory.placeInScene(devToolsElement, excalidrawAPI, {
80-
mode: PlacementMode.NEAR_VIEWPORT_CENTER,
81-
bufferPercentage: 10,
82-
scrollToView: true
83-
});
84-
};
85-
8670
const handleInsertButtonClick = () => {
8771
if (!excalidrawAPI) return;
8872

@@ -135,7 +119,7 @@ export const MainMenuConfig: React.FC<MainMenuConfigProps> = ({
135119
setShowSettingsModal(true);
136120
};
137121

138-
const handleCloseSettingsModal = () => { // Added handler to close settings modal
122+
const handleCloseSettingsModal = () => {
139123
setShowSettingsModal(false);
140124
};
141125

@@ -151,7 +135,7 @@ export const MainMenuConfig: React.FC<MainMenuConfigProps> = ({
151135
const keycloakLogoutUrl = data.logout_url;
152136

153137
const createIframeLoader = (url: string, debugName: string): Promise<void> => {
154-
return new Promise<void>((resolve, reject) => { // Added reject for error handling
138+
return new Promise<void>((resolve, reject) => {
155139
const iframe = document.createElement("iframe");
156140
iframe.style.display = "none";
157141
iframe.src = url;
@@ -204,7 +188,7 @@ export const MainMenuConfig: React.FC<MainMenuConfigProps> = ({
204188
onClose={() => setShowAccountModal(false)}
205189
/>
206190
)}
207-
{showSettingsModal && ( // Added conditional rendering for SettingsDialog
191+
{showSettingsModal && (
208192
<SettingsDialog
209193
excalidrawAPI={excalidrawAPI}
210194
onClose={handleCloseSettingsModal}
@@ -262,12 +246,6 @@ export const MainMenuConfig: React.FC<MainMenuConfigProps> = ({
262246
>
263247
Action Button
264248
</MainMenu.Item>
265-
<MainMenu.Item
266-
icon={<FlaskConical />}
267-
onClick={handleDevToolsClick}
268-
>
269-
Dev. Tools
270-
</MainMenu.Item>
271249
</MainMenu.Group>
272250

273251
<MainMenu.Separator />

src/frontend/src/ui/TabContextMenu.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ class TabActionManager implements ActionManager {
219219
onRename: (padId: string, newName: string) => void,
220220
onDelete: (padId: string) => void, // This is for deleteOwnedPad
221221
onUpdateSharingPolicy: (padId: string, policy: string) => void,
222-
onLeaveSharedPad: (padId: string) => void, // Moved before optional param
222+
onLeaveSharedPad: (padId: string) => void,
223223
sharingPolicy?: string
224224
) {
225225
this.padId = padId;
@@ -244,7 +244,7 @@ class TabActionManager implements ActionManager {
244244
console.debug('[pad.ws] User confirmed delete, calling onDelete');
245245
this.onDelete(this.padId); // Calls original onDelete for owned pads
246246
}
247-
} else if (action.name === 'leaveSharedPad') { // New action for leaving
247+
} else if (action.name === 'leaveSharedPad') {
248248
console.debug('[pad.ws] Attempting to leave shared pad:', this.padId, this.padName);
249249
if (window.confirm(`Are you sure you want to leave "${this.padName}"? This will remove it from your list of open pads.`)) {
250250
this.onLeaveSharedPad(this.padId); // Calls the new handler

src/frontend/src/ui/Tabs.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ interface TabsProps {
2020
createNewPadAsync: () => Promise<Tab | null | undefined>;
2121
renamePad: (args: { padId: string; newName: string }) => void;
2222
deletePad: (padId: string) => void;
23-
leaveSharedPad: (padId: string) => void; // Added prop
23+
leaveSharedPad: (padId: string) => void;
2424
updateSharingPolicy: (args: { padId: string; policy: string }) => void;
2525
selectTab: (tabId: string) => void;
2626
}
@@ -470,7 +470,7 @@ const Tabs: React.FC<TabsProps> = ({
470470
}
471471
deletePad(padId); // Calls the prop for deleting owned pad
472472
}}
473-
onLeaveSharedPad={(padId: string) => { // New prop for 'leaveSharedPad'
473+
onLeaveSharedPad={(padId: string) => {
474474
leaveSharedPad(padId); // Calls the prop for leaving shared pad
475475
}}
476476
onUpdateSharingPolicy={(padId: string, policy: string) => {

0 commit comments

Comments
 (0)