Skip to content

refactor: remove unused devtools component #101

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions src/frontend/src/CustomEmbeddableRenderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {
ControlButton,
Editor,
Terminal,
DevTools,
} from './pad';
import { ActionButton } from './pad/buttons';
import "./CustomEmbeddableRenderer.scss";
Expand All @@ -36,7 +35,7 @@ export const renderCustomEmbeddable = (
title = "HTML Editor";
break;
case 'editor':
content = <Editor element={element} appState={appState} excalidrawAPI={excalidrawAPI} />;
content = <Editor element={element} excalidrawAPI={excalidrawAPI} />;
title = "Code Editor";
break;
case 'terminal':
Expand Down Expand Up @@ -64,10 +63,6 @@ export const renderCustomEmbeddable = (
content = <Dashboard element={element} appState={appState} excalidrawAPI={excalidrawAPI} />;
title = "Dashboard";
break;
case 'dev':
content = <DevTools element={element} appState={appState} excalidrawAPI={excalidrawAPI} />;
title = "Dev Tools";
break;
default:
title = "Untitled";
return null;
Expand Down
86 changes: 0 additions & 86 deletions src/frontend/src/pad/DevTools.scss

This file was deleted.

47 changes: 0 additions & 47 deletions src/frontend/src/pad/DevTools.tsx

This file was deleted.

2 changes: 1 addition & 1 deletion src/frontend/src/pad/editors/HtmlEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export const useHtmlEditor = (
element: NonDeleted<ExcalidrawEmbeddableElement> | undefined,
editorRef: React.RefObject<any>,
excalidrawAPI?: any,
isActive: boolean = true // New parameter to control if the hook is active
isActive: boolean = true
) => {
// Always initialize these hooks regardless of isActive
const [createNew, setCreateNew] = useState(false);
Expand Down
2 changes: 0 additions & 2 deletions src/frontend/src/pad/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@ export * from './Dashboard';
export * from './Terminal';
export * from './buttons';
export * from './editors';
export * from './DevTools';

// Default exports
export { default as ControlButton } from './buttons/ControlButton';
export { default as StateIndicator } from './StateIndicator';
export { default as Dashboard } from './Dashboard';
export { default as Terminal } from './Terminal';
export { default as DevTools } from './DevTools';
30 changes: 4 additions & 26 deletions src/frontend/src/ui/MainMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { LogOut, SquarePlus, LayoutDashboard, User, Text, Settings, Terminal, Fi
import md5 from 'crypto-js/md5';

// Components
import SettingsDialog from './SettingsDialog'; // Added import
import SettingsDialog from './SettingsDialog';

import { useLogout } from '../hooks/useLogout';
import { useAuthStatus } from '../hooks/useAuthStatus';
Expand Down Expand Up @@ -67,22 +67,6 @@ export const MainMenuConfig: React.FC<MainMenuConfigProps> = ({
});
};

const handleDevToolsClick = () => {
if (!excalidrawAPI) return;

const devToolsElement = ExcalidrawElementFactory.createEmbeddableElement({
link: "!dev",
width: 800,
height: 500
});

ExcalidrawElementFactory.placeInScene(devToolsElement, excalidrawAPI, {
mode: PlacementMode.NEAR_VIEWPORT_CENTER,
bufferPercentage: 10,
scrollToView: true
});
};

const handleInsertButtonClick = () => {
if (!excalidrawAPI) return;

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

const handleCloseSettingsModal = () => { // Added handler to close settings modal
const handleCloseSettingsModal = () => {
setShowSettingsModal(false);
};

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

const createIframeLoader = (url: string, debugName: string): Promise<void> => {
return new Promise<void>((resolve, reject) => { // Added reject for error handling
return new Promise<void>((resolve, reject) => {
const iframe = document.createElement("iframe");
iframe.style.display = "none";
iframe.src = url;
Expand Down Expand Up @@ -204,7 +188,7 @@ export const MainMenuConfig: React.FC<MainMenuConfigProps> = ({
onClose={() => setShowAccountModal(false)}
/>
)}
{showSettingsModal && ( // Added conditional rendering for SettingsDialog
{showSettingsModal && (
<SettingsDialog
excalidrawAPI={excalidrawAPI}
onClose={handleCloseSettingsModal}
Expand Down Expand Up @@ -262,12 +246,6 @@ export const MainMenuConfig: React.FC<MainMenuConfigProps> = ({
>
Action Button
</MainMenu.Item>
<MainMenu.Item
icon={<FlaskConical />}
onClick={handleDevToolsClick}
>
Dev. Tools
</MainMenu.Item>
</MainMenu.Group>

<MainMenu.Separator />
Expand Down
4 changes: 2 additions & 2 deletions src/frontend/src/ui/TabContextMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ class TabActionManager implements ActionManager {
onRename: (padId: string, newName: string) => void,
onDelete: (padId: string) => void, // This is for deleteOwnedPad
onUpdateSharingPolicy: (padId: string, policy: string) => void,
onLeaveSharedPad: (padId: string) => void, // Moved before optional param
onLeaveSharedPad: (padId: string) => void,
sharingPolicy?: string
) {
this.padId = padId;
Expand All @@ -244,7 +244,7 @@ class TabActionManager implements ActionManager {
console.debug('[pad.ws] User confirmed delete, calling onDelete');
this.onDelete(this.padId); // Calls original onDelete for owned pads
}
} else if (action.name === 'leaveSharedPad') { // New action for leaving
} else if (action.name === 'leaveSharedPad') {
console.debug('[pad.ws] Attempting to leave shared pad:', this.padId, this.padName);
if (window.confirm(`Are you sure you want to leave "${this.padName}"? This will remove it from your list of open pads.`)) {
this.onLeaveSharedPad(this.padId); // Calls the new handler
Expand Down
4 changes: 2 additions & 2 deletions src/frontend/src/ui/Tabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ interface TabsProps {
createNewPadAsync: () => Promise<Tab | null | undefined>;
renamePad: (args: { padId: string; newName: string }) => void;
deletePad: (padId: string) => void;
leaveSharedPad: (padId: string) => void; // Added prop
leaveSharedPad: (padId: string) => void;
updateSharingPolicy: (args: { padId: string; policy: string }) => void;
selectTab: (tabId: string) => void;
}
Expand Down Expand Up @@ -470,7 +470,7 @@ const Tabs: React.FC<TabsProps> = ({
}
deletePad(padId); // Calls the prop for deleting owned pad
}}
onLeaveSharedPad={(padId: string) => { // New prop for 'leaveSharedPad'
onLeaveSharedPad={(padId: string) => {
leaveSharedPad(padId); // Calls the prop for leaving shared pad
}}
onUpdateSharingPolicy={(padId: string, policy: string) => {
Expand Down