Skip to content

Commit 619ddb0

Browse files
committed
feat: Add delete functionality for draft screenshots
- Add delete button in AssetEditModal with confirmation dialog - Add handleDeleteAsset function to remove screenshots from IndexedDB - Add CSS styling for delete button
1 parent 5ca61c7 commit 619ddb0

2 files changed

Lines changed: 64 additions & 0 deletions

File tree

src/popup/popup.css

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -804,4 +804,34 @@
804804
border-radius: 8px;
805805
color: #DC2626;
806806
font-size: 12px;
807+
}
808+
809+
/* Delete button styles */
810+
.edit-modal-delete {
811+
padding: 0 16px 16px;
812+
text-align: center;
813+
}
814+
815+
.edit-modal-delete .btn-delete {
816+
background: transparent;
817+
border: none;
818+
color: #DC2626;
819+
font-size: 13px;
820+
font-weight: 500;
821+
cursor: pointer;
822+
padding: 8px 12px;
823+
border-radius: 6px;
824+
display: inline-flex;
825+
align-items: center;
826+
gap: 6px;
827+
transition: background 0.2s, color 0.2s;
828+
}
829+
830+
.edit-modal-delete .btn-delete:hover:not(:disabled) {
831+
background: #FEF2F2;
832+
}
833+
834+
.edit-modal-delete .btn-delete:disabled {
835+
opacity: 0.5;
836+
cursor: not-allowed;
807837
}

src/popup/popup.tsx

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,21 @@ function PopupApp() {
184184
}
185185
}
186186

187+
async function handleDeleteAsset(assetId: string) {
188+
if (!confirm('Are you sure you want to delete this screenshot?')) {
189+
return;
190+
}
191+
try {
192+
await indexedDBService.deleteAsset(assetId);
193+
const updatedAssets = await indexedDBService.getAllAssets();
194+
setAssets(updatedAssets);
195+
setEditingAsset(null);
196+
} catch (error) {
197+
console.error('Failed to delete asset:', error);
198+
alert('Failed to delete screenshot');
199+
}
200+
}
201+
187202
function openOptions() {
188203
chrome.runtime.openOptionsPage();
189204
}
@@ -323,6 +338,7 @@ function PopupApp() {
323338
asset={editingAsset}
324339
onSave={handleUpdateAssetMetadata}
325340
onUpload={handleUpload}
341+
onDelete={handleDeleteAsset}
326342
onClose={() => setEditingAsset(null)}
327343
/>
328344
)}
@@ -782,11 +798,13 @@ function AssetEditModal({
782798
asset,
783799
onSave,
784800
onUpload,
801+
onDelete,
785802
onClose,
786803
}: {
787804
asset: Asset;
788805
onSave: (assetId: string, headline: string, caption: string) => Promise<void>;
789806
onUpload: (assetId: string) => void;
807+
onDelete: (assetId: string) => void;
790808
onClose: () => void;
791809
}) {
792810
const [headline, setHeadline] = useState(asset.metadata?.headline || '');
@@ -880,6 +898,22 @@ function AssetEditModal({
880898
</button>
881899
</div>
882900

901+
<div className="edit-modal-delete">
902+
<button
903+
className="btn-delete"
904+
onClick={() => onDelete(asset.id)}
905+
disabled={isSaving}
906+
>
907+
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
908+
<polyline points="3 6 5 6 21 6"></polyline>
909+
<path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"></path>
910+
<line x1="10" y1="11" x2="10" y2="17"></line>
911+
<line x1="14" y1="11" x2="14" y2="17"></line>
912+
</svg>
913+
Delete Screenshot
914+
</button>
915+
</div>
916+
883917
{asset.status === 'failed' && asset.metadata?.error && (
884918
<div className="edit-modal-error">
885919
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">

0 commit comments

Comments
 (0)