mirror of
https://github.com/jlengrand/Maestro.git
synced 2026-03-10 08:31:19 +00:00
MAESTRO: Remove X close button from FilePreview control panel
The file tab system now handles closing via the tab's X button,
making the close button in the FilePreview header redundant.
- Removed X icon import (no longer needed)
- Removed showCloseButton prop from FilePreviewProps interface
- Removed close button JSX from FilePreview header
- Removed showCloseButton={false} prop from MainPanel.tsx
- Updated FilePreview tests (removed close button tests)
Note: onClose prop remains for Escape key handling and unsaved
changes modal confirmation.
This commit is contained in:
@@ -6,7 +6,6 @@ import { FilePreview } from '../../../renderer/components/FilePreview';
|
||||
// Mock lucide-react icons
|
||||
vi.mock('lucide-react', () => ({
|
||||
FileCode: () => <span data-testid="file-code-icon">FileCode</span>,
|
||||
X: () => <span data-testid="x-icon">X</span>,
|
||||
Eye: () => <span data-testid="eye-icon">Eye</span>,
|
||||
ChevronUp: () => <span data-testid="chevron-up">ChevronUp</span>,
|
||||
ChevronDown: () => <span data-testid="chevron-down">ChevronDown</span>,
|
||||
@@ -302,21 +301,8 @@ describe('FilePreview', () => {
|
||||
expect(screen.getByText('test.md')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('renders close button', () => {
|
||||
render(<FilePreview {...defaultProps} />);
|
||||
|
||||
expect(screen.getByTestId('x-icon')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('calls onClose when close button is clicked', () => {
|
||||
const onClose = vi.fn();
|
||||
render(<FilePreview {...defaultProps} onClose={onClose} />);
|
||||
|
||||
const closeButton = screen.getByTestId('x-icon').parentElement;
|
||||
fireEvent.click(closeButton!);
|
||||
|
||||
expect(onClose).toHaveBeenCalledOnce();
|
||||
});
|
||||
// Close button was removed - now handled by file tab's X button
|
||||
// See Phase 8: Cleanup & Polish task for details
|
||||
|
||||
it('renders nothing when file is null', () => {
|
||||
const { container } = render(<FilePreview {...defaultProps} file={null} />);
|
||||
|
||||
@@ -15,7 +15,6 @@ import { Prism as SyntaxHighlighter } from 'react-syntax-highlighter';
|
||||
import { vscDarkPlus } from 'react-syntax-highlighter/dist/esm/styles/prism';
|
||||
import {
|
||||
FileCode,
|
||||
X,
|
||||
Eye,
|
||||
ChevronUp,
|
||||
ChevronDown,
|
||||
@@ -97,8 +96,6 @@ interface FilePreviewProps {
|
||||
onOpenInGraph?: () => void;
|
||||
/** SSH remote ID for remote file operations */
|
||||
sshRemoteId?: string;
|
||||
/** Whether to show the close button in the header (default: true, set to false when rendered as tab) */
|
||||
showCloseButton?: boolean;
|
||||
/** Current edit content (used for file tab persistence) - if provided, overrides internal state */
|
||||
externalEditContent?: string;
|
||||
/** Callback when edit content changes (used for file tab persistence) */
|
||||
@@ -569,7 +566,6 @@ export const FilePreview = forwardRef<FilePreviewHandle, FilePreviewProps>(funct
|
||||
hasGist,
|
||||
onOpenInGraph,
|
||||
sshRemoteId,
|
||||
showCloseButton = true, // Default to true for backwards compatibility
|
||||
externalEditContent,
|
||||
onEditContentChange,
|
||||
initialScrollTop,
|
||||
@@ -1702,16 +1698,6 @@ export const FilePreview = forwardRef<FilePreviewHandle, FilePreviewProps>(funct
|
||||
>
|
||||
<FolderOpen className="w-4 h-4" />
|
||||
</button>
|
||||
{/* Close button - hidden when rendered as tab (tab's X handles closing) */}
|
||||
{showCloseButton && (
|
||||
<button
|
||||
onClick={onClose}
|
||||
className="p-2 rounded hover:bg-white/10 transition-colors"
|
||||
style={{ color: theme.colors.textDim }}
|
||||
>
|
||||
<X className="w-5 h-5" />
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
{/* File Stats subbar - hidden on scroll */}
|
||||
|
||||
@@ -1597,7 +1597,6 @@ export const MainPanel = React.memo(
|
||||
activeSession?.sessionSshRemoteConfig?.remoteId ||
|
||||
undefined
|
||||
}
|
||||
showCloseButton={false}
|
||||
// Pass external edit content for persistence across tab switches
|
||||
externalEditContent={activeFileTab.editContent}
|
||||
onEditContentChange={(content) => {
|
||||
|
||||
Reference in New Issue
Block a user