detailed profiles info
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
use std::collections::BTreeSet;
|
||||
use std::collections::{BTreeMap, BTreeSet};
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
@@ -49,6 +49,7 @@ pub struct ExtensionSummary {
|
||||
pub version: Option<String>,
|
||||
pub icon_data_url: Option<String>,
|
||||
pub profile_ids: Vec<String>,
|
||||
pub profiles: Vec<AssociatedProfileSummary>,
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
@@ -57,6 +58,26 @@ pub struct BookmarkSummary {
|
||||
pub url: String,
|
||||
pub title: String,
|
||||
pub profile_ids: Vec<String>,
|
||||
pub profiles: Vec<BookmarkAssociatedProfileSummary>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Clone)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct AssociatedProfileSummary {
|
||||
pub id: String,
|
||||
pub name: String,
|
||||
pub avatar_data_url: Option<String>,
|
||||
pub avatar_label: String,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Clone)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct BookmarkAssociatedProfileSummary {
|
||||
pub id: String,
|
||||
pub name: String,
|
||||
pub avatar_data_url: Option<String>,
|
||||
pub avatar_label: String,
|
||||
pub bookmark_path: String,
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
@@ -124,10 +145,12 @@ pub struct TempExtension {
|
||||
pub version: Option<String>,
|
||||
pub icon_data_url: Option<String>,
|
||||
pub profile_ids: BTreeSet<String>,
|
||||
pub profiles: BTreeMap<String, AssociatedProfileSummary>,
|
||||
}
|
||||
|
||||
pub struct TempBookmark {
|
||||
pub url: String,
|
||||
pub title: String,
|
||||
pub profile_ids: BTreeSet<String>,
|
||||
pub profiles: BTreeMap<String, BookmarkAssociatedProfileSummary>,
|
||||
}
|
||||
|
||||
@@ -10,8 +10,9 @@ use tauri::AppHandle;
|
||||
use crate::{
|
||||
config_store,
|
||||
models::{
|
||||
BookmarkSummary, BrowserConfigEntry, BrowserStats, BrowserView, ExtensionSummary,
|
||||
ProfileSummary, ScanResponse, TempBookmark, TempExtension,
|
||||
AssociatedProfileSummary, BookmarkAssociatedProfileSummary, BookmarkSummary,
|
||||
BrowserConfigEntry, BrowserStats, BrowserView, ExtensionSummary, ProfileSummary,
|
||||
ScanResponse, TempBookmark, TempExtension,
|
||||
},
|
||||
utils::{first_non_empty, load_image_as_data_url, pick_latest_subdirectory, read_json_file},
|
||||
};
|
||||
@@ -57,14 +58,15 @@ fn scan_browser(config: BrowserConfigEntry) -> Option<BrowserView> {
|
||||
}
|
||||
|
||||
let profile_info = profile_cache.and_then(|cache| cache.get(&profile_id));
|
||||
profiles.push(build_profile_summary(
|
||||
let profile_summary = build_profile_summary(
|
||||
&root,
|
||||
&profile_path,
|
||||
&profile_id,
|
||||
profile_info,
|
||||
));
|
||||
scan_extensions_for_profile(&profile_path, &profile_id, &mut extensions);
|
||||
scan_bookmarks_for_profile(&profile_path, &profile_id, &mut bookmarks);
|
||||
);
|
||||
scan_extensions_for_profile(&profile_path, &profile_summary, &mut extensions);
|
||||
scan_bookmarks_for_profile(&profile_path, &profile_summary, &mut bookmarks);
|
||||
profiles.push(profile_summary);
|
||||
}
|
||||
|
||||
let profiles = sort_profiles(profiles);
|
||||
@@ -76,6 +78,7 @@ fn scan_browser(config: BrowserConfigEntry) -> Option<BrowserView> {
|
||||
version: entry.version,
|
||||
icon_data_url: entry.icon_data_url,
|
||||
profile_ids: entry.profile_ids.into_iter().collect(),
|
||||
profiles: entry.profiles.into_values().collect(),
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
let bookmarks = bookmarks
|
||||
@@ -84,6 +87,7 @@ fn scan_browser(config: BrowserConfigEntry) -> Option<BrowserView> {
|
||||
url: entry.url,
|
||||
title: entry.title,
|
||||
profile_ids: entry.profile_ids.into_iter().collect(),
|
||||
profiles: entry.profiles.into_values().collect(),
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
@@ -188,7 +192,7 @@ fn resolve_profile_avatar(
|
||||
|
||||
fn scan_extensions_for_profile(
|
||||
profile_path: &Path,
|
||||
profile_id: &str,
|
||||
profile: &ProfileSummary,
|
||||
extensions: &mut BTreeMap<String, TempExtension>,
|
||||
) {
|
||||
let extensions_root = profile_path.join("Extensions");
|
||||
@@ -231,6 +235,7 @@ fn scan_extensions_for_profile(
|
||||
version: version.clone(),
|
||||
icon_data_url: icon_data_url.clone(),
|
||||
profile_ids: BTreeSet::new(),
|
||||
profiles: BTreeMap::new(),
|
||||
});
|
||||
|
||||
if entry.name == entry.id && name != extension_id {
|
||||
@@ -242,7 +247,16 @@ fn scan_extensions_for_profile(
|
||||
if entry.icon_data_url.is_none() {
|
||||
entry.icon_data_url = icon_data_url.clone();
|
||||
}
|
||||
entry.profile_ids.insert(profile_id.to_string());
|
||||
entry.profile_ids.insert(profile.id.clone());
|
||||
entry
|
||||
.profiles
|
||||
.entry(profile.id.clone())
|
||||
.or_insert_with(|| AssociatedProfileSummary {
|
||||
id: profile.id.clone(),
|
||||
name: profile.name.clone(),
|
||||
avatar_data_url: profile.avatar_data_url.clone(),
|
||||
avatar_label: profile.avatar_label.clone(),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -337,7 +351,7 @@ fn icon_candidates_from_object(map: &serde_json::Map<String, Value>) -> Vec<(u32
|
||||
|
||||
fn scan_bookmarks_for_profile(
|
||||
profile_path: &Path,
|
||||
profile_id: &str,
|
||||
profile: &ProfileSummary,
|
||||
bookmarks: &mut BTreeMap<String, TempBookmark>,
|
||||
) {
|
||||
let bookmarks_path = profile_path.join("Bookmarks");
|
||||
@@ -350,14 +364,15 @@ fn scan_bookmarks_for_profile(
|
||||
};
|
||||
|
||||
for root in roots.values() {
|
||||
collect_bookmarks(root, profile_id, bookmarks);
|
||||
collect_bookmarks(root, profile, bookmarks, &[]);
|
||||
}
|
||||
}
|
||||
|
||||
fn collect_bookmarks(
|
||||
node: &Value,
|
||||
profile_id: &str,
|
||||
profile: &ProfileSummary,
|
||||
bookmarks: &mut BTreeMap<String, TempBookmark>,
|
||||
ancestors: &[String],
|
||||
) {
|
||||
match node.get("type").and_then(Value::as_str) {
|
||||
Some("url") => {
|
||||
@@ -381,17 +396,44 @@ fn collect_bookmarks(
|
||||
url: url.to_string(),
|
||||
title: title.clone(),
|
||||
profile_ids: BTreeSet::new(),
|
||||
profiles: BTreeMap::new(),
|
||||
});
|
||||
|
||||
if entry.title == entry.url && title != url {
|
||||
entry.title = title;
|
||||
}
|
||||
entry.profile_ids.insert(profile_id.to_string());
|
||||
entry.profile_ids.insert(profile.id.clone());
|
||||
let bookmark_path = if ancestors.is_empty() {
|
||||
"Root".to_string()
|
||||
} else {
|
||||
ancestors.join(" > ")
|
||||
};
|
||||
entry
|
||||
.profiles
|
||||
.entry(profile.id.clone())
|
||||
.or_insert_with(|| BookmarkAssociatedProfileSummary {
|
||||
id: profile.id.clone(),
|
||||
name: profile.name.clone(),
|
||||
avatar_data_url: profile.avatar_data_url.clone(),
|
||||
avatar_label: profile.avatar_label.clone(),
|
||||
bookmark_path,
|
||||
});
|
||||
}
|
||||
Some("folder") => {
|
||||
if let Some(children) = node.get("children").and_then(Value::as_array) {
|
||||
let folder_name = node
|
||||
.get("name")
|
||||
.and_then(Value::as_str)
|
||||
.filter(|value| !value.is_empty());
|
||||
let next_ancestors = if let Some(name) = folder_name {
|
||||
let mut path = ancestors.to_vec();
|
||||
path.push(name.to_string());
|
||||
path
|
||||
} else {
|
||||
ancestors.to_vec()
|
||||
};
|
||||
for child in children {
|
||||
collect_bookmarks(child, profile_id, bookmarks);
|
||||
collect_bookmarks(child, profile, bookmarks, &next_ancestors);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
16
src/App.vue
16
src/App.vue
@@ -6,7 +6,7 @@ import { useBrowserManager } from "./composables/useBrowserManager";
|
||||
|
||||
const {
|
||||
activeSection,
|
||||
bookmarkProfilesExpanded,
|
||||
associatedProfilesModal,
|
||||
bookmarkSortKey,
|
||||
browserConfigs,
|
||||
browserMonogram,
|
||||
@@ -21,7 +21,6 @@ const {
|
||||
domainFromUrl,
|
||||
error,
|
||||
extensionMonogram,
|
||||
extensionProfilesExpanded,
|
||||
extensionSortKey,
|
||||
isDeletingConfig,
|
||||
isOpeningProfile,
|
||||
@@ -36,11 +35,12 @@ const {
|
||||
savingConfig,
|
||||
sectionCount,
|
||||
selectedBrowserId,
|
||||
showBookmarkProfilesModal,
|
||||
showExtensionProfilesModal,
|
||||
sortedBookmarks,
|
||||
sortedExtensions,
|
||||
sortedProfiles,
|
||||
toggleBookmarkProfiles,
|
||||
toggleExtensionProfiles,
|
||||
closeAssociatedProfilesModal,
|
||||
} = useBrowserManager();
|
||||
</script>
|
||||
|
||||
@@ -109,16 +109,16 @@ const {
|
||||
:section-count="sectionCount"
|
||||
:is-opening-profile="isOpeningProfile"
|
||||
:extension-monogram="extensionMonogram"
|
||||
:extension-profiles-expanded="extensionProfilesExpanded"
|
||||
:bookmark-profiles-expanded="bookmarkProfilesExpanded"
|
||||
:domain-from-url="domainFromUrl"
|
||||
:associated-profiles-modal="associatedProfilesModal"
|
||||
@update:active-section="activeSection = $event"
|
||||
@update:profile-sort-key="profileSortKey = $event"
|
||||
@update:extension-sort-key="extensionSortKey = $event"
|
||||
@update:bookmark-sort-key="bookmarkSortKey = $event"
|
||||
@open-profile="(browserId, profileId) => openBrowserProfile(browserId, profileId)"
|
||||
@toggle-extension-profiles="toggleExtensionProfiles"
|
||||
@toggle-bookmark-profiles="toggleBookmarkProfiles"
|
||||
@show-extension-profiles="showExtensionProfilesModal"
|
||||
@show-bookmark-profiles="showBookmarkProfilesModal"
|
||||
@close-associated-profiles="closeAssociatedProfilesModal"
|
||||
/>
|
||||
|
||||
<template v-else>
|
||||
|
||||
188
src/components/browser-data/AssociatedProfilesModal.vue
Normal file
188
src/components/browser-data/AssociatedProfilesModal.vue
Normal file
@@ -0,0 +1,188 @@
|
||||
<script setup lang="ts">
|
||||
import type {
|
||||
AssociatedProfileSummary,
|
||||
BookmarkAssociatedProfileSummary,
|
||||
} from "../../types/browser";
|
||||
|
||||
type ModalProfile = AssociatedProfileSummary | BookmarkAssociatedProfileSummary;
|
||||
|
||||
defineProps<{
|
||||
title: string;
|
||||
profiles: ModalProfile[];
|
||||
browserId: string;
|
||||
isBookmark: boolean;
|
||||
isOpeningProfile: (browserId: string, profileId: string) => boolean;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
close: [];
|
||||
openProfile: [browserId: string, profileId: string];
|
||||
}>();
|
||||
|
||||
function hasBookmarkPath(
|
||||
profile: ModalProfile,
|
||||
): profile is BookmarkAssociatedProfileSummary {
|
||||
return "bookmarkPath" in profile;
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="modal-backdrop" @click.self="emit('close')">
|
||||
<section class="modal-card">
|
||||
<div class="modal-header">
|
||||
<h3>{{ title }}</h3>
|
||||
<button class="secondary-button modal-close-button" type="button" @click="emit('close')">
|
||||
Close
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="modal-list">
|
||||
<article v-for="profile in profiles" :key="profile.id" class="modal-profile-card">
|
||||
<div class="modal-profile-avatar">
|
||||
<img
|
||||
v-if="profile.avatarDataUrl"
|
||||
:src="profile.avatarDataUrl"
|
||||
:alt="`${profile.name} avatar`"
|
||||
/>
|
||||
<span v-else>{{ profile.avatarLabel }}</span>
|
||||
</div>
|
||||
<div class="modal-profile-body">
|
||||
<div class="modal-profile-topline">
|
||||
<div class="modal-profile-heading">
|
||||
<h4>{{ profile.name }}</h4>
|
||||
<span class="badge neutral">{{ profile.id }}</span>
|
||||
</div>
|
||||
<button
|
||||
class="card-action-button"
|
||||
type="button"
|
||||
:disabled="isOpeningProfile(browserId, profile.id)"
|
||||
@click="emit('openProfile', browserId, profile.id)"
|
||||
>
|
||||
{{ isOpeningProfile(browserId, profile.id) ? "Opening..." : "Open" }}
|
||||
</button>
|
||||
</div>
|
||||
<p v-if="isBookmark && hasBookmarkPath(profile)" class="modal-bookmark-path">
|
||||
{{ profile.bookmarkPath }}
|
||||
</p>
|
||||
</div>
|
||||
</article>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.modal-backdrop {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
z-index: 40;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
padding: 24px;
|
||||
background: rgba(15, 23, 42, 0.26);
|
||||
backdrop-filter: blur(6px);
|
||||
-webkit-backdrop-filter: blur(6px);
|
||||
}
|
||||
|
||||
.modal-card {
|
||||
width: min(720px, 100%);
|
||||
max-height: min(78vh, 820px);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 14px;
|
||||
padding: 16px;
|
||||
border: 1px solid var(--panel-border);
|
||||
border-radius: 22px;
|
||||
background: rgba(255, 255, 255, 0.96);
|
||||
box-shadow: 0 28px 70px rgba(15, 23, 42, 0.18);
|
||||
}
|
||||
|
||||
.modal-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.modal-header h3,
|
||||
.modal-profile-heading h4 {
|
||||
margin: 0;
|
||||
font-weight: 600;
|
||||
letter-spacing: -0.03em;
|
||||
}
|
||||
|
||||
.modal-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 10px;
|
||||
min-height: 0;
|
||||
overflow: auto;
|
||||
padding-right: 4px;
|
||||
}
|
||||
|
||||
.modal-profile-card {
|
||||
display: flex;
|
||||
gap: 12px;
|
||||
padding: 12px;
|
||||
border: 1px solid rgba(148, 163, 184, 0.18);
|
||||
border-radius: 16px;
|
||||
background: var(--panel-strong);
|
||||
}
|
||||
|
||||
.modal-profile-avatar {
|
||||
display: grid;
|
||||
place-items: center;
|
||||
flex-shrink: 0;
|
||||
width: 46px;
|
||||
height: 46px;
|
||||
border-radius: 14px;
|
||||
background: linear-gradient(135deg, #dbeafe, #eff6ff);
|
||||
color: #1d4ed8;
|
||||
font-size: 1rem;
|
||||
font-weight: 700;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.modal-profile-avatar img {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
}
|
||||
|
||||
.modal-profile-body {
|
||||
min-width: 0;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.modal-profile-topline {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.modal-profile-heading {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.modal-bookmark-path {
|
||||
margin: 8px 0 0;
|
||||
color: var(--muted);
|
||||
font-size: 0.86rem;
|
||||
}
|
||||
|
||||
@media (max-width: 720px) {
|
||||
.modal-backdrop {
|
||||
padding: 12px;
|
||||
}
|
||||
|
||||
.modal-profile-card,
|
||||
.modal-profile-topline,
|
||||
.modal-profile-heading {
|
||||
flex-direction: column;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -6,12 +6,11 @@ defineProps<{
|
||||
bookmarks: BookmarkSummary[];
|
||||
sortKey: BookmarkSortKey;
|
||||
domainFromUrl: (url: string) => string;
|
||||
bookmarkProfilesExpanded: (url: string) => boolean;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
"update:sortKey": [value: BookmarkSortKey];
|
||||
toggleProfiles: [url: string];
|
||||
showProfiles: [url: string];
|
||||
}>();
|
||||
</script>
|
||||
|
||||
@@ -41,23 +40,11 @@ const emit = defineEmits<{
|
||||
<button
|
||||
class="disclosure-button"
|
||||
type="button"
|
||||
@click="emit('toggleProfiles', bookmark.url)"
|
||||
@click="emit('showProfiles', bookmark.url)"
|
||||
>
|
||||
<span>Profiles</span>
|
||||
<span>View Profiles</span>
|
||||
<span class="badge neutral">{{ bookmark.profileIds.length }}</span>
|
||||
</button>
|
||||
<div
|
||||
v-if="bookmarkProfilesExpanded(bookmark.url)"
|
||||
class="disclosure-panel"
|
||||
>
|
||||
<span
|
||||
v-for="profileId in bookmark.profileIds"
|
||||
:key="`${bookmark.url}-${profileId}`"
|
||||
class="badge"
|
||||
>
|
||||
{{ profileId }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</article>
|
||||
@@ -125,13 +112,6 @@ const emit = defineEmits<{
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.disclosure-panel {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px;
|
||||
margin-top: 8px;
|
||||
}
|
||||
|
||||
@media (max-width: 720px) {
|
||||
.bookmark-card {
|
||||
flex-direction: column;
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
<script setup lang="ts">
|
||||
import type {
|
||||
ActiveSection,
|
||||
AssociatedProfileSummary,
|
||||
BookmarkAssociatedProfileSummary,
|
||||
BookmarkSortKey,
|
||||
BrowserView,
|
||||
ExtensionSortKey,
|
||||
ProfileSortKey,
|
||||
} from "../../types/browser";
|
||||
import AssociatedProfilesModal from "./AssociatedProfilesModal.vue";
|
||||
import BookmarksList from "./BookmarksList.vue";
|
||||
import ExtensionsList from "./ExtensionsList.vue";
|
||||
import ProfilesList from "./ProfilesList.vue";
|
||||
@@ -23,9 +26,13 @@ defineProps<{
|
||||
sectionCount: (section: ActiveSection) => number;
|
||||
isOpeningProfile: (browserId: string, profileId: string) => boolean;
|
||||
extensionMonogram: (name: string) => string;
|
||||
extensionProfilesExpanded: (extensionId: string) => boolean;
|
||||
bookmarkProfilesExpanded: (url: string) => boolean;
|
||||
domainFromUrl: (url: string) => string;
|
||||
associatedProfilesModal: {
|
||||
title: string;
|
||||
browserId: string;
|
||||
profiles: (AssociatedProfileSummary | BookmarkAssociatedProfileSummary)[];
|
||||
isBookmark: boolean;
|
||||
} | null;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
@@ -34,8 +41,9 @@ const emit = defineEmits<{
|
||||
"update:extensionSortKey": [value: ExtensionSortKey];
|
||||
"update:bookmarkSortKey": [value: BookmarkSortKey];
|
||||
openProfile: [browserId: string, profileId: string];
|
||||
toggleExtensionProfiles: [extensionId: string];
|
||||
toggleBookmarkProfiles: [url: string];
|
||||
showExtensionProfiles: [extensionId: string];
|
||||
showBookmarkProfiles: [url: string];
|
||||
closeAssociatedProfiles: [];
|
||||
}>();
|
||||
</script>
|
||||
|
||||
@@ -87,9 +95,8 @@ const emit = defineEmits<{
|
||||
:extensions="sortedExtensions"
|
||||
:sort-key="extensionSortKey"
|
||||
:extension-monogram="extensionMonogram"
|
||||
:extension-profiles-expanded="extensionProfilesExpanded"
|
||||
@update:sort-key="emit('update:extensionSortKey', $event)"
|
||||
@toggle-profiles="emit('toggleExtensionProfiles', $event)"
|
||||
@show-profiles="emit('showExtensionProfiles', $event)"
|
||||
/>
|
||||
|
||||
<BookmarksList
|
||||
@@ -97,11 +104,21 @@ const emit = defineEmits<{
|
||||
:bookmarks="sortedBookmarks"
|
||||
:sort-key="bookmarkSortKey"
|
||||
:domain-from-url="domainFromUrl"
|
||||
:bookmark-profiles-expanded="bookmarkProfilesExpanded"
|
||||
@update:sort-key="emit('update:bookmarkSortKey', $event)"
|
||||
@toggle-profiles="emit('toggleBookmarkProfiles', $event)"
|
||||
@show-profiles="emit('showBookmarkProfiles', $event)"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<AssociatedProfilesModal
|
||||
v-if="associatedProfilesModal"
|
||||
:title="associatedProfilesModal.title"
|
||||
:profiles="associatedProfilesModal.profiles"
|
||||
:browser-id="associatedProfilesModal.browserId"
|
||||
:is-bookmark="associatedProfilesModal.isBookmark"
|
||||
:is-opening-profile="isOpeningProfile"
|
||||
@close="emit('closeAssociatedProfiles')"
|
||||
@open-profile="(browserId, profileId) => emit('openProfile', browserId, profileId)"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
|
||||
@@ -6,12 +6,11 @@ defineProps<{
|
||||
extensions: ExtensionSummary[];
|
||||
sortKey: ExtensionSortKey;
|
||||
extensionMonogram: (name: string) => string;
|
||||
extensionProfilesExpanded: (extensionId: string) => boolean;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
"update:sortKey": [value: ExtensionSortKey];
|
||||
toggleProfiles: [extensionId: string];
|
||||
showProfiles: [extensionId: string];
|
||||
}>();
|
||||
</script>
|
||||
|
||||
@@ -55,23 +54,11 @@ const emit = defineEmits<{
|
||||
<button
|
||||
class="disclosure-button"
|
||||
type="button"
|
||||
@click="emit('toggleProfiles', extension.id)"
|
||||
@click="emit('showProfiles', extension.id)"
|
||||
>
|
||||
<span>Profiles</span>
|
||||
<span>View Profiles</span>
|
||||
<span class="badge neutral">{{ extension.profileIds.length }}</span>
|
||||
</button>
|
||||
<div
|
||||
v-if="extensionProfilesExpanded(extension.id)"
|
||||
class="disclosure-panel"
|
||||
>
|
||||
<span
|
||||
v-for="profileId in extension.profileIds"
|
||||
:key="`${extension.id}-${profileId}`"
|
||||
class="badge"
|
||||
>
|
||||
{{ profileId }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</article>
|
||||
@@ -158,13 +145,6 @@ const emit = defineEmits<{
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.disclosure-panel {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px;
|
||||
margin-top: 8px;
|
||||
}
|
||||
|
||||
@media (max-width: 720px) {
|
||||
.extension-card {
|
||||
flex-direction: column;
|
||||
|
||||
@@ -6,6 +6,8 @@ import { sortBookmarks, sortExtensions, sortProfiles } from "../utils/sort";
|
||||
import type {
|
||||
ActiveSection,
|
||||
AppPage,
|
||||
AssociatedProfileSummary,
|
||||
BookmarkAssociatedProfileSummary,
|
||||
BookmarkSortKey,
|
||||
BrowserConfigEntry,
|
||||
BrowserConfigListResponse,
|
||||
@@ -36,8 +38,12 @@ export function useBrowserManager() {
|
||||
});
|
||||
const selectedBrowserId = ref("");
|
||||
const activeSection = ref<ActiveSection>("profiles");
|
||||
const expandedExtensionIds = ref<string[]>([]);
|
||||
const expandedBookmarkUrls = ref<string[]>([]);
|
||||
const associatedProfilesModal = ref<{
|
||||
title: string;
|
||||
browserId: string;
|
||||
profiles: (AssociatedProfileSummary | BookmarkAssociatedProfileSummary)[];
|
||||
isBookmark: boolean;
|
||||
} | null>(null);
|
||||
const profileSortKey = ref<ProfileSortKey>("name");
|
||||
const extensionSortKey = ref<ExtensionSortKey>("name");
|
||||
const bookmarkSortKey = ref<BookmarkSortKey>("title");
|
||||
@@ -80,9 +86,8 @@ export function useBrowserManager() {
|
||||
);
|
||||
|
||||
watch(selectedBrowserId, () => {
|
||||
expandedExtensionIds.value = [];
|
||||
expandedBookmarkUrls.value = [];
|
||||
openProfileError.value = "";
|
||||
associatedProfilesModal.value = null;
|
||||
});
|
||||
|
||||
async function loadBrowserConfigs() {
|
||||
@@ -272,24 +277,30 @@ export function useBrowserManager() {
|
||||
return currentBrowser.value.bookmarks.length;
|
||||
}
|
||||
|
||||
function toggleExtensionProfiles(extensionId: string) {
|
||||
expandedExtensionIds.value = expandedExtensionIds.value.includes(extensionId)
|
||||
? expandedExtensionIds.value.filter((id) => id !== extensionId)
|
||||
: [...expandedExtensionIds.value, extensionId];
|
||||
function showExtensionProfilesModal(extensionId: string) {
|
||||
const extension = currentBrowser.value?.extensions.find((item) => item.id === extensionId);
|
||||
if (!extension || !currentBrowser.value) return;
|
||||
associatedProfilesModal.value = {
|
||||
title: `${extension.name} Profiles`,
|
||||
browserId: currentBrowser.value.browserId,
|
||||
profiles: extension.profiles,
|
||||
isBookmark: false,
|
||||
};
|
||||
}
|
||||
|
||||
function toggleBookmarkProfiles(url: string) {
|
||||
expandedBookmarkUrls.value = expandedBookmarkUrls.value.includes(url)
|
||||
? expandedBookmarkUrls.value.filter((value) => value !== url)
|
||||
: [...expandedBookmarkUrls.value, url];
|
||||
function showBookmarkProfilesModal(url: string) {
|
||||
const bookmark = currentBrowser.value?.bookmarks.find((item) => item.url === url);
|
||||
if (!bookmark || !currentBrowser.value) return;
|
||||
associatedProfilesModal.value = {
|
||||
title: `${bookmark.title} Profiles`,
|
||||
browserId: currentBrowser.value.browserId,
|
||||
profiles: bookmark.profiles,
|
||||
isBookmark: true,
|
||||
};
|
||||
}
|
||||
|
||||
function extensionProfilesExpanded(extensionId: string) {
|
||||
return expandedExtensionIds.value.includes(extensionId);
|
||||
}
|
||||
|
||||
function bookmarkProfilesExpanded(url: string) {
|
||||
return expandedBookmarkUrls.value.includes(url);
|
||||
function closeAssociatedProfilesModal() {
|
||||
associatedProfilesModal.value = null;
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
@@ -298,7 +309,7 @@ export function useBrowserManager() {
|
||||
|
||||
return {
|
||||
activeSection,
|
||||
bookmarkProfilesExpanded,
|
||||
associatedProfilesModal,
|
||||
bookmarkSortKey,
|
||||
browserConfigs,
|
||||
browserMonogram,
|
||||
@@ -313,7 +324,6 @@ export function useBrowserManager() {
|
||||
domainFromUrl,
|
||||
error,
|
||||
extensionMonogram,
|
||||
extensionProfilesExpanded,
|
||||
extensionSortKey,
|
||||
isDeletingConfig,
|
||||
isOpeningProfile,
|
||||
@@ -328,10 +338,11 @@ export function useBrowserManager() {
|
||||
savingConfig,
|
||||
sectionCount,
|
||||
selectedBrowserId,
|
||||
showBookmarkProfilesModal,
|
||||
showExtensionProfilesModal,
|
||||
sortedBookmarks,
|
||||
sortedExtensions,
|
||||
sortedProfiles,
|
||||
toggleBookmarkProfiles,
|
||||
toggleExtensionProfiles,
|
||||
closeAssociatedProfilesModal,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -19,12 +19,29 @@ export type ExtensionSummary = {
|
||||
version: string | null;
|
||||
iconDataUrl: string | null;
|
||||
profileIds: string[];
|
||||
profiles: AssociatedProfileSummary[];
|
||||
};
|
||||
|
||||
export type BookmarkSummary = {
|
||||
url: string;
|
||||
title: string;
|
||||
profileIds: string[];
|
||||
profiles: BookmarkAssociatedProfileSummary[];
|
||||
};
|
||||
|
||||
export type AssociatedProfileSummary = {
|
||||
id: string;
|
||||
name: string;
|
||||
avatarDataUrl: string | null;
|
||||
avatarLabel: string;
|
||||
};
|
||||
|
||||
export type BookmarkAssociatedProfileSummary = {
|
||||
id: string;
|
||||
name: string;
|
||||
avatarDataUrl: string | null;
|
||||
avatarLabel: string;
|
||||
bookmarkPath: string;
|
||||
};
|
||||
|
||||
export type ProfileSortKey = "name" | "email" | "id";
|
||||
|
||||
Reference in New Issue
Block a user