Skip to content
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
22 changes: 15 additions & 7 deletions src/renderer/components/Storage/ConfirmExclusionDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,24 @@ const HIGH_IMPACT_RATIO = 0.5
export default function ConfirmExclusionDialog({ title, preview, totalSessions, isApplying, onConfirm, onCancel }: Props) {
const { t } = useI18n()
const [acknowledged, setAcknowledged] = useState(false)
const isEmpty = preview.sessionCount === 0
const impactRatio = totalSessions > 0 ? preview.sessionCount / totalSessions : 0
const highImpact = impactRatio > HIGH_IMPACT_RATIO
const highImpact = !isEmpty && impactRatio > HIGH_IMPACT_RATIO

return (
<div className={styles.backdrop} onClick={() => { if (!isApplying) onCancel() }}>
<div className={styles.dialog} onClick={e => e.stopPropagation()}>
<div className={styles.dialogTitle}>{title}</div>
<div className={styles.dialogSummary}>
<ExclusionPreviewSummary preview={preview} />
{totalSessions > 0 && (
<span>{t('storage.confirm.impactRatio', { percent: (impactRatio * 100).toFixed(1) })}</span>
)}
{isEmpty
? <span>{t('storage.confirm.emptyProjectHint')}</span>
: <>
<ExclusionPreviewSummary preview={preview} />
{totalSessions > 0 && (
<span>{t('storage.confirm.impactRatio', { percent: (impactRatio * 100).toFixed(1) })}</span>
)}
</>
}
</div>

{highImpact && (
Expand All @@ -45,7 +51,7 @@ export default function ConfirmExclusionDialog({ title, preview, totalSessions,
disabled={isApplying}
onChange={e => setAcknowledged(e.target.checked)}
/>
{t('storage.confirm.acknowledge')}
{isEmpty ? t('storage.confirm.acknowledgeExclude') : t('storage.confirm.acknowledge')}
</label>

<div className={styles.dialogActions}>
Expand All @@ -55,7 +61,9 @@ export default function ConfirmExclusionDialog({ title, preview, totalSessions,
disabled={!acknowledged || isApplying}
onClick={onConfirm}
>
{isApplying ? t('storage.confirm.deleting') : t('storage.confirm.deleteAction')}
{isApplying
? isEmpty ? t('storage.confirm.excluding') : t('storage.confirm.deleting')
: isEmpty ? t('storage.confirm.excludeAction') : t('storage.confirm.deleteAction')}
</button>
</div>
</div>
Expand Down
3 changes: 2 additions & 1 deletion src/renderer/components/Storage/StoragePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ export default function StoragePage() {
const openConfirm = useCallback(async (rule: ExclusionRuleInput, title: string) => {
try {
const preview = await window.api.previewExclusion(rule)
if (preview.sessionCount === 0) {
const isProjectOnly = !!(rule.projectId && !rule.dateFrom && !rule.dateTo)
if (preview.sessionCount === 0 && !isProjectOnly) {
return
}
setPending({ preview, title })
Expand Down
8 changes: 8 additions & 0 deletions src/renderer/i18n/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,10 @@ const zhTW = {
'storage.confirm.impactRatio': '(佔全部 {percent}%)',
'storage.confirm.warningHighImpact': '⚠️ 此操作將刪除超過一半的資料。請再次確認。',
'storage.confirm.acknowledge': '我了解此操作不可復原',
'storage.confirm.acknowledgeExclude': '我了解排除後該專案不再被索引',
'storage.confirm.emptyProjectHint': '此專案目前無任何 session。排除後,未來的 session 也不會被索引。',
'storage.confirm.excludeAction': '確認排除',
'storage.confirm.excluding': '排除中...',
'storage.confirm.deleting': '刪除中...',
'storage.confirm.deleteAction': '確認刪除',
'dashboard.title': '儀表板',
Expand Down Expand Up @@ -423,6 +427,10 @@ const en = {
'storage.confirm.impactRatio': '({percent}% of total)',
'storage.confirm.warningHighImpact': '⚠️ This will delete more than half of the data. Please confirm.',
'storage.confirm.acknowledge': 'I understand this is irreversible',
'storage.confirm.acknowledgeExclude': 'I understand this project will no longer be indexed',
'storage.confirm.emptyProjectHint': 'This project currently has no sessions. Once excluded, future sessions will not be indexed either.',
'storage.confirm.excludeAction': 'Confirm exclude',
'storage.confirm.excluding': 'Excluding...',
'storage.confirm.deleting': 'Deleting...',
'storage.confirm.deleteAction': 'Confirm delete',
'dashboard.title': 'Dashboard',
Expand Down
Loading