change history to clean
This commit is contained in:
391
src/components/browser-data/HistoryCleanupList.vue
Normal file
391
src/components/browser-data/HistoryCleanupList.vue
Normal file
@@ -0,0 +1,391 @@
|
||||
<script setup lang="ts">
|
||||
import { computed } from "vue";
|
||||
import type {
|
||||
CleanupHistoryResult,
|
||||
CleanupFileStatus,
|
||||
ProfileSummary,
|
||||
} from "../../types/browser";
|
||||
import { profileAvatarSrc } from "../../utils/icons";
|
||||
|
||||
const props = defineProps<{
|
||||
browserId: string;
|
||||
browserFamilyId: string | null;
|
||||
profiles: ProfileSummary[];
|
||||
selectedProfileIds: string[];
|
||||
cleanupBusy: boolean;
|
||||
cleanupError: string;
|
||||
cleanupResults: CleanupHistoryResult[];
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
toggleProfile: [profileId: string];
|
||||
toggleAllProfiles: [];
|
||||
cleanupSelected: [];
|
||||
cleanupProfile: [profileId: string];
|
||||
}>();
|
||||
|
||||
const selectableProfiles = computed(() =>
|
||||
props.profiles.filter((profile) =>
|
||||
hasAnyHistoryFile([
|
||||
profile.historyCleanup.history,
|
||||
profile.historyCleanup.topSites,
|
||||
profile.historyCleanup.visitedLinks,
|
||||
]),
|
||||
),
|
||||
);
|
||||
|
||||
const allSelected = computed(
|
||||
() =>
|
||||
selectableProfiles.value.length > 0 &&
|
||||
selectableProfiles.value.every((profile) =>
|
||||
props.selectedProfileIds.includes(profile.id),
|
||||
),
|
||||
);
|
||||
|
||||
function statusLabel(status: CleanupFileStatus) {
|
||||
return status === "found" ? "Found" : "Missing";
|
||||
}
|
||||
|
||||
function statusClass(status: CleanupFileStatus) {
|
||||
return status === "found" ? "found" : "missing";
|
||||
}
|
||||
|
||||
function isSelected(profileId: string) {
|
||||
return props.selectedProfileIds.includes(profileId);
|
||||
}
|
||||
|
||||
function isSelectable(profile: ProfileSummary) {
|
||||
return hasAnyHistoryFile([
|
||||
profile.historyCleanup.history,
|
||||
profile.historyCleanup.topSites,
|
||||
profile.historyCleanup.visitedLinks,
|
||||
]);
|
||||
}
|
||||
|
||||
function hasAnyHistoryFile(statuses: CleanupFileStatus[]) {
|
||||
return statuses.some((status) => status === "found");
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section class="table-section">
|
||||
<div v-if="cleanupError" class="inline-error">
|
||||
{{ cleanupError }}
|
||||
</div>
|
||||
|
||||
<div v-if="cleanupResults.length" class="result-strip">
|
||||
<article
|
||||
v-for="result in cleanupResults"
|
||||
:key="result.profileId"
|
||||
class="result-chip"
|
||||
:class="{ error: result.error }"
|
||||
>
|
||||
<strong>{{ result.profileId }}</strong>
|
||||
<span v-if="result.error">{{ result.error }}</span>
|
||||
<span v-else-if="result.deletedFiles.length">
|
||||
Deleted {{ result.deletedFiles.join(", ") }}
|
||||
</span>
|
||||
<span v-else>
|
||||
Nothing to delete
|
||||
</span>
|
||||
</article>
|
||||
</div>
|
||||
|
||||
<div class="history-toolbar">
|
||||
<label class="toolbar-checkbox" :class="{ disabled: !selectableProfiles.length }">
|
||||
<input
|
||||
type="checkbox"
|
||||
:checked="allSelected"
|
||||
:disabled="!selectableProfiles.length || cleanupBusy"
|
||||
@change="emit('toggleAllProfiles')"
|
||||
/>
|
||||
<span>Select All</span>
|
||||
</label>
|
||||
<button
|
||||
class="danger-button"
|
||||
type="button"
|
||||
:disabled="!selectedProfileIds.length || cleanupBusy"
|
||||
@click="emit('cleanupSelected')"
|
||||
>
|
||||
{{ cleanupBusy ? "Cleaning..." : `Clean Selected (${selectedProfileIds.length})` }}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div v-if="profiles.length" class="data-table">
|
||||
<div class="data-table-header history-grid">
|
||||
<div class="header-cell checkbox-cell">Pick</div>
|
||||
<div class="header-cell icon-cell">Avatar</div>
|
||||
<div class="header-cell">Profile</div>
|
||||
<div class="header-cell">History</div>
|
||||
<div class="header-cell">Top Sites</div>
|
||||
<div class="header-cell">Visited Links</div>
|
||||
<div class="header-cell actions-cell">Action</div>
|
||||
</div>
|
||||
<div class="data-table-body styled-scrollbar">
|
||||
<article v-for="profile in profiles" :key="profile.id" class="data-table-row history-grid">
|
||||
<div class="row-cell checkbox-cell">
|
||||
<input
|
||||
type="checkbox"
|
||||
:checked="isSelected(profile.id)"
|
||||
:disabled="!isSelectable(profile) || cleanupBusy"
|
||||
@change="emit('toggleProfile', profile.id)"
|
||||
/>
|
||||
</div>
|
||||
<div class="profile-avatar table-avatar">
|
||||
<img
|
||||
v-if="profileAvatarSrc(profile, browserFamilyId)"
|
||||
:src="profileAvatarSrc(profile, browserFamilyId) ?? undefined"
|
||||
:alt="`${profile.name} avatar`"
|
||||
/>
|
||||
<span v-else>{{ profile.avatarLabel }}</span>
|
||||
</div>
|
||||
<div class="row-cell primary-cell">
|
||||
<strong>{{ profile.name }}</strong>
|
||||
<span class="subtle-line">{{ profile.id }}</span>
|
||||
</div>
|
||||
<div class="row-cell">
|
||||
<span class="status-pill" :class="statusClass(profile.historyCleanup.history)">
|
||||
{{ statusLabel(profile.historyCleanup.history) }}
|
||||
</span>
|
||||
</div>
|
||||
<div class="row-cell">
|
||||
<span class="status-pill" :class="statusClass(profile.historyCleanup.topSites)">
|
||||
{{ statusLabel(profile.historyCleanup.topSites) }}
|
||||
</span>
|
||||
</div>
|
||||
<div class="row-cell">
|
||||
<span class="status-pill" :class="statusClass(profile.historyCleanup.visitedLinks)">
|
||||
{{ statusLabel(profile.historyCleanup.visitedLinks) }}
|
||||
</span>
|
||||
</div>
|
||||
<div class="row-cell actions-cell">
|
||||
<button
|
||||
class="danger-button action-button"
|
||||
type="button"
|
||||
:disabled="!isSelectable(profile) || cleanupBusy"
|
||||
@click="emit('cleanupProfile', profile.id)"
|
||||
>
|
||||
Clean
|
||||
</button>
|
||||
</div>
|
||||
</article>
|
||||
</div>
|
||||
</div>
|
||||
<div v-else class="empty-card">
|
||||
<p>No profile directories were found for this browser.</p>
|
||||
</div>
|
||||
</section>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.table-section {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 10px;
|
||||
padding: 0;
|
||||
height: 100%;
|
||||
min-height: 0;
|
||||
}
|
||||
|
||||
.history-toolbar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.toolbar-checkbox {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
color: var(--text);
|
||||
font-size: 0.88rem;
|
||||
}
|
||||
|
||||
.toolbar-checkbox.disabled {
|
||||
opacity: 0.55;
|
||||
}
|
||||
|
||||
.result-strip {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
overflow: auto;
|
||||
padding-bottom: 2px;
|
||||
}
|
||||
|
||||
.result-chip {
|
||||
display: grid;
|
||||
gap: 4px;
|
||||
min-width: 220px;
|
||||
padding: 10px 12px;
|
||||
border: 1px solid rgba(16, 185, 129, 0.2);
|
||||
border-radius: 14px;
|
||||
background: rgba(236, 253, 245, 0.92);
|
||||
color: #065f46;
|
||||
font-size: 0.82rem;
|
||||
}
|
||||
|
||||
.result-chip.error {
|
||||
border-color: rgba(239, 68, 68, 0.18);
|
||||
background: rgba(254, 242, 242, 0.96);
|
||||
color: #b42318;
|
||||
}
|
||||
|
||||
.data-table {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: 100%;
|
||||
min-height: 0;
|
||||
border: 1px solid rgba(148, 163, 184, 0.18);
|
||||
border-radius: 22px;
|
||||
background: var(--panel);
|
||||
box-shadow: var(--shadow);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.data-table-body {
|
||||
min-height: 0;
|
||||
overflow: auto;
|
||||
scrollbar-gutter: stable;
|
||||
}
|
||||
|
||||
.history-grid {
|
||||
display: grid;
|
||||
grid-template-columns: 52px 56px minmax(170px, 1fr) 118px 118px 128px 108px;
|
||||
gap: 12px;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.data-table-header {
|
||||
position: sticky;
|
||||
top: 0;
|
||||
z-index: 2;
|
||||
padding: 10px 24px 10px 14px;
|
||||
border-bottom: 1px solid rgba(148, 163, 184, 0.14);
|
||||
background: rgba(248, 250, 252, 0.94);
|
||||
backdrop-filter: blur(12px);
|
||||
-webkit-backdrop-filter: blur(12px);
|
||||
}
|
||||
|
||||
.data-table-row {
|
||||
padding: 12px 14px;
|
||||
border-bottom: 1px solid rgba(148, 163, 184, 0.12);
|
||||
}
|
||||
|
||||
.data-table-row:last-child {
|
||||
border-bottom: 0;
|
||||
}
|
||||
|
||||
.data-table-row:hover {
|
||||
background: rgba(248, 250, 252, 0.65);
|
||||
}
|
||||
|
||||
.header-cell {
|
||||
color: var(--muted);
|
||||
font-size: 0.81rem;
|
||||
font-weight: 700;
|
||||
letter-spacing: 0.02em;
|
||||
}
|
||||
|
||||
.checkbox-cell {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.icon-cell {
|
||||
padding-left: 4px;
|
||||
}
|
||||
|
||||
.row-cell {
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.profile-avatar {
|
||||
display: grid;
|
||||
place-items: center;
|
||||
flex-shrink: 0;
|
||||
background: linear-gradient(135deg, #dbeafe, #eff6ff);
|
||||
color: #1d4ed8;
|
||||
font-size: 0.96rem;
|
||||
font-weight: 700;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.table-avatar {
|
||||
width: 36px;
|
||||
height: 36px;
|
||||
border-radius: 999px;
|
||||
}
|
||||
|
||||
.profile-avatar img {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
}
|
||||
|
||||
.primary-cell strong {
|
||||
display: block;
|
||||
font-size: 0.93rem;
|
||||
line-height: 1.3;
|
||||
}
|
||||
|
||||
.subtle-line {
|
||||
display: block;
|
||||
margin-top: 3px;
|
||||
color: var(--muted-soft);
|
||||
font-size: 0.8rem;
|
||||
}
|
||||
|
||||
.status-pill {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
min-width: 78px;
|
||||
padding: 6px 10px;
|
||||
border-radius: 999px;
|
||||
font-size: 0.79rem;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.status-pill.found {
|
||||
background: rgba(37, 99, 235, 0.12);
|
||||
color: #1d4ed8;
|
||||
}
|
||||
|
||||
.status-pill.missing {
|
||||
background: rgba(226, 232, 240, 0.7);
|
||||
color: var(--badge-text);
|
||||
}
|
||||
|
||||
.actions-cell {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
.action-button {
|
||||
padding-inline: 12px;
|
||||
}
|
||||
|
||||
@media (max-width: 900px) {
|
||||
.history-grid {
|
||||
grid-template-columns: 52px 56px minmax(160px, 1fr) 110px 110px 118px 100px;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 720px) {
|
||||
.history-toolbar {
|
||||
flex-direction: column;
|
||||
align-items: stretch;
|
||||
}
|
||||
|
||||
.history-grid {
|
||||
grid-template-columns: 52px 56px minmax(0, 1fr) 108px;
|
||||
}
|
||||
|
||||
.history-grid > :nth-child(5),
|
||||
.history-grid > :nth-child(6),
|
||||
.history-grid > :nth-child(7) {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user