Skip to content

armgit / mimik

Public Imported from GitHub
0

🎬 A browser extension and desktop app that turns your clicks into step-by-step guides with annotated screenshots πŸ“–

refactor(ui): move version history to the toolbar and drop the sidepanel entry

Luis Ortiz48341fa369ab
diff --git a/src/ui/fullview/App.tsx b/src/ui/fullview/App.tsx
index e6df69d..7fe8e27 100644
--- a/src/ui/fullview/App.tsx
+++ b/src/ui/fullview/App.tsx
@@ -38,12 +38,7 @@ export default function FullViewApp() {
{route.page === 'guide' && (
<main className="flex-1 py-10 px-6">
<div className={`mx-auto ${historyOpen ? 'max-w-[1032px]' : 'max-w-[720px]'}`}>
- <GuideContent
- guideId={route.guideId}
- initialStepId={route.stepId}
- initialTool={route.tool}
- initialHistory={route.history}
- />
+ <GuideContent guideId={route.guideId} initialStepId={route.stepId} initialTool={route.tool} />
</div>
</main>
)}
diff --git a/src/ui/fullview/GuideContent.tsx b/src/ui/fullview/GuideContent.tsx
index a46f622..3eedf6c 100644
--- a/src/ui/fullview/GuideContent.tsx
+++ b/src/ui/fullview/GuideContent.tsx
@@ -27,7 +27,6 @@ interface GuideContentProps {
guideId: string;
initialStepId?: string;
initialTool?: 'annotate' | 'redact' | 'crop' | 'target';
- initialHistory?: boolean;
}
interface GuideData {
@@ -57,7 +56,7 @@ async function buildPreview(snapshot: Snapshot): Promise<PreviewData> {
return { snapshotId: snapshot.id, steps, screenshots };
}
-export default function GuideContent({ guideId, initialStepId, initialTool, initialHistory }: GuideContentProps) {
+export default function GuideContent({ guideId, initialStepId, initialTool }: GuideContentProps) {
const {
setGuideTitle,
setGuideStepCount,
@@ -88,7 +87,6 @@ export default function GuideContent({ guideId, initialStepId, initialTool, init
const [previewData, setPreviewData] = useState<PreviewData | null>(null);
const titleRef = useRef('');
const appliedInitialRef = useRef(false);
- const appliedHistoryRef = useRef(false);
const loadGuide = useCallback(async () => {
const result = await getGuide(guideId);
@@ -198,12 +196,6 @@ export default function GuideContent({ guideId, initialStepId, initialTool, init
}
}, [data, initialStepId, initialTool, scrollToStep]);
- useEffect(() => {
- if (appliedHistoryRef.current || !data || !initialHistory) return;
- appliedHistoryRef.current = true;
- setHistoryOpen(true);
- }, [data, initialHistory, setHistoryOpen]);
-
const live = useMemo<SnapshotLike>(
() => ({
title: data?.guide.title ?? '',
diff --git a/src/ui/fullview/TopNav.tsx b/src/ui/fullview/TopNav.tsx
index c5306b1..6892c1d 100644
--- a/src/ui/fullview/TopNav.tsx
+++ b/src/ui/fullview/TopNav.tsx
@@ -1,27 +1,10 @@
-import {
- Check,
- ChevronRight,
- Download,
- FileText,
- History,
- MoreHorizontal,
- Pencil,
- Search,
- Star,
- Trash2,
-} from 'lucide-react';
+import { Check, ChevronRight, Download, FileText, History, Pencil, Search, Star, Trash2 } from 'lucide-react';
import { useState } from 'react';
import { i18n } from '#imports';
import { createSnapshot } from '@/core/guides/service';
import { logger } from '@/lib/logger';
import { useFullview } from '@/stores/fullview';
import { Button } from '@/ui/components/ui/button';
-import {
- DropdownMenu,
- DropdownMenuContent,
- DropdownMenuItem,
- DropdownMenuTrigger,
-} from '@/ui/components/ui/dropdown-menu';
import MascotIcon from '@/ui/shared/MascotIcon';
import ExportPreviewModal from './ExportPreviewModal';
import type { Route } from './router';
@@ -144,6 +127,19 @@ export default function TopNav({ route }: TopNavProps) {
{editing ? <Check size={14} /> : <Pencil size={14} />}
{editing ? i18n.t('editor.done') : i18n.t('editor.edit')}
</Button>
+ <Button
+ size="icon-sm"
+ variant="ghost"
+ onClick={() => {
+ setHistoryOpen(true);
+ setEditing(false);
+ }}
+ aria-label={i18n.t('editor.versionHistory')}
+ title={i18n.t('editor.versionHistory')}
+ className="text-foreground hover:bg-foreground/10"
+ >
+ <History size={16} />
+ </Button>
<Button size="sm" onClick={() => setExportOpen(true)}>
<Download size={14} />
{i18n.t('common.export')}
@@ -155,30 +151,6 @@ export default function TopNav({ route }: TopNavProps) {
steps={exportData.steps}
screenshots={exportData.screenshots}
/>
- <DropdownMenu>
- <DropdownMenuTrigger asChild>
- <Button
- size="icon-sm"
- variant="ghost"
- aria-label={i18n.t('editor.moreActions')}
- title={i18n.t('editor.moreActions')}
- className="text-foreground hover:bg-foreground/10"
- >
- <MoreHorizontal size={16} />
- </Button>
- </DropdownMenuTrigger>
- <DropdownMenuContent align="end">
- <DropdownMenuItem
- onSelect={() => {
- setHistoryOpen(true);
- setEditing(false);
- }}
- >
- <History size={14} />
- {i18n.t('editor.versionHistory')}
- </DropdownMenuItem>
- </DropdownMenuContent>
- </DropdownMenu>
</>
)}
</div>
diff --git a/src/ui/fullview/router.ts b/src/ui/fullview/router.ts
index 017606f..43eb525 100644
--- a/src/ui/fullview/router.ts
+++ b/src/ui/fullview/router.ts
@@ -7,7 +7,6 @@ export type Route =
guideId: string;
stepId?: string;
tool?: 'annotate' | 'redact' | 'crop' | 'target';
- history?: boolean;
};
function parseHash(hash: string): Route {
@@ -42,9 +41,8 @@ export function useRoute(): Route {
toolParam === 'annotate' || toolParam === 'redact' || toolParam === 'crop' || toolParam === 'target'
? toolParam
: undefined;
- const showHistory = params.get('history') === '1';
window.history.replaceState(null, '', `${window.location.pathname}#guide/${guideId}`);
- return { page: 'guide', guideId, stepId, tool, history: showHistory };
+ return { page: 'guide', guideId, stepId, tool };
}
return parseHash(window.location.hash);
});
diff --git a/src/ui/sidepanel/GuideEditor.tsx b/src/ui/sidepanel/GuideEditor.tsx
index 3f7f110..45cfa5e 100644
--- a/src/ui/sidepanel/GuideEditor.tsx
+++ b/src/ui/sidepanel/GuideEditor.tsx
@@ -1,4 +1,4 @@
-import { ArrowLeft, Check, History, Layers, Maximize2, MoreHorizontal, Pencil, Play } from 'lucide-react';
+import { ArrowLeft, Check, Layers, Maximize2, Pencil, Play } from 'lucide-react';
import { useCallback, useEffect, useState } from 'react';
import { i18n } from '#imports';
import {
@@ -15,12 +15,6 @@ import { createTab, focusWindow, getExtensionURL, queryTabs, updateTab } from '@
import { logger } from '@/lib/logger';
import { sendMessage } from '@/lib/messaging';
import { getMostCommonDomain } from '@/lib/utils';
-import {
- DropdownMenu,
- DropdownMenuContent,
- DropdownMenuItem,
- DropdownMenuTrigger,
-} from '@/ui/components/ui/dropdown-menu';
import { Input } from '@/ui/components/ui/input';
import EmptyGuideState from '@/ui/shared/EmptyGuideState';
import FaviconImg from '@/ui/shared/FaviconImg';
@@ -37,7 +31,6 @@ interface GuideEditorProps {
interface OpenInFullViewOptions {
stepId?: string;
tool?: 'annotate' | 'redact' | 'crop' | 'target';
- history?: boolean;
}
interface GuideData {
@@ -116,7 +109,6 @@ export default function GuideEditor({ guideId, onBack, onGuideMe }: GuideEditorP
const params = new URLSearchParams({ guideId: targetGuideId });
if (options?.stepId) params.set('stepId', options.stepId);
if (options?.tool) params.set('tool', options.tool);
- if (options?.history) params.set('history', '1');
const url = getExtensionURL(`/fullview.html?${params.toString()}`);
queryTabs({ url: getExtensionURL('/fullview.html') }).then((tabs) => {
if (tabs.length > 0 && tabs[0].id) {
@@ -138,12 +130,6 @@ export default function GuideEditor({ guideId, onBack, onGuideMe }: GuideEditorP
createSnapshot(guideId).catch((err) => logger.error(' Snapshot before editing failed', err));
}, [editing, guideId]);
- const openVersionHistory = useCallback(() => {
- flushFocusedField();
- setEditing(false);
- openInFullView(guideId, { history: true });
- }, [guideId, openInFullView]);
-
if (loading) return <p className="text-sm text-purple p-4">{i18n.t('common.loading')}</p>;
if (notFound || !data) {
@@ -211,25 +197,6 @@ export default function GuideEditor({ guideId, onBack, onGuideMe }: GuideEditorP
{editing ? <Check size={15} /> : <Pencil size={15} />}
</button>
<ExportMenu guideId={guideId} guide={data.guide} steps={data.steps} screenshots={data.screenshots} />
- <DropdownMenu>
- <DropdownMenuTrigger asChild>
- <button
- type="button"
- onPointerDown={flushFocusedField}
- className="shrink-0 p-1.5 rounded-md transition-colors text-purple hover:text-accent hover:bg-secondary"
- title={i18n.t('editor.moreActions')}
- aria-label={i18n.t('editor.moreActions')}
- >
- <MoreHorizontal size={15} />
- </button>
- </DropdownMenuTrigger>
- <DropdownMenuContent align="end">
- <DropdownMenuItem onSelect={openVersionHistory}>
- <History size={14} />
- {i18n.t('editor.versionHistory')}
- </DropdownMenuItem>
- </DropdownMenuContent>
- </DropdownMenu>
</div>
</div>
<div className="text-[11px] flex items-center gap-2 text-muted-foreground" style={{ marginLeft: '34px' }}>