detailed profiles info

This commit is contained in:
Julian Freeman
2026-04-16 17:50:33 -04:00
parent 33f43aac56
commit 65b9401726
9 changed files with 356 additions and 98 deletions

View File

@@ -1,4 +1,4 @@
use std::collections::BTreeSet; use std::collections::{BTreeMap, BTreeSet};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
@@ -49,6 +49,7 @@ pub struct ExtensionSummary {
pub version: Option<String>, pub version: Option<String>,
pub icon_data_url: Option<String>, pub icon_data_url: Option<String>,
pub profile_ids: Vec<String>, pub profile_ids: Vec<String>,
pub profiles: Vec<AssociatedProfileSummary>,
} }
#[derive(Serialize)] #[derive(Serialize)]
@@ -57,6 +58,26 @@ pub struct BookmarkSummary {
pub url: String, pub url: String,
pub title: String, pub title: String,
pub profile_ids: Vec<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)] #[derive(Serialize)]
@@ -124,10 +145,12 @@ pub struct TempExtension {
pub version: Option<String>, pub version: Option<String>,
pub icon_data_url: Option<String>, pub icon_data_url: Option<String>,
pub profile_ids: BTreeSet<String>, pub profile_ids: BTreeSet<String>,
pub profiles: BTreeMap<String, AssociatedProfileSummary>,
} }
pub struct TempBookmark { pub struct TempBookmark {
pub url: String, pub url: String,
pub title: String, pub title: String,
pub profile_ids: BTreeSet<String>, pub profile_ids: BTreeSet<String>,
pub profiles: BTreeMap<String, BookmarkAssociatedProfileSummary>,
} }

View File

@@ -10,8 +10,9 @@ use tauri::AppHandle;
use crate::{ use crate::{
config_store, config_store,
models::{ models::{
BookmarkSummary, BrowserConfigEntry, BrowserStats, BrowserView, ExtensionSummary, AssociatedProfileSummary, BookmarkAssociatedProfileSummary, BookmarkSummary,
ProfileSummary, ScanResponse, TempBookmark, TempExtension, BrowserConfigEntry, BrowserStats, BrowserView, ExtensionSummary, ProfileSummary,
ScanResponse, TempBookmark, TempExtension,
}, },
utils::{first_non_empty, load_image_as_data_url, pick_latest_subdirectory, read_json_file}, 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)); let profile_info = profile_cache.and_then(|cache| cache.get(&profile_id));
profiles.push(build_profile_summary( let profile_summary = build_profile_summary(
&root, &root,
&profile_path, &profile_path,
&profile_id, &profile_id,
profile_info, profile_info,
)); );
scan_extensions_for_profile(&profile_path, &profile_id, &mut extensions); scan_extensions_for_profile(&profile_path, &profile_summary, &mut extensions);
scan_bookmarks_for_profile(&profile_path, &profile_id, &mut bookmarks); scan_bookmarks_for_profile(&profile_path, &profile_summary, &mut bookmarks);
profiles.push(profile_summary);
} }
let profiles = sort_profiles(profiles); let profiles = sort_profiles(profiles);
@@ -76,6 +78,7 @@ fn scan_browser(config: BrowserConfigEntry) -> Option<BrowserView> {
version: entry.version, version: entry.version,
icon_data_url: entry.icon_data_url, icon_data_url: entry.icon_data_url,
profile_ids: entry.profile_ids.into_iter().collect(), profile_ids: entry.profile_ids.into_iter().collect(),
profiles: entry.profiles.into_values().collect(),
}) })
.collect::<Vec<_>>(); .collect::<Vec<_>>();
let bookmarks = bookmarks let bookmarks = bookmarks
@@ -84,6 +87,7 @@ fn scan_browser(config: BrowserConfigEntry) -> Option<BrowserView> {
url: entry.url, url: entry.url,
title: entry.title, title: entry.title,
profile_ids: entry.profile_ids.into_iter().collect(), profile_ids: entry.profile_ids.into_iter().collect(),
profiles: entry.profiles.into_values().collect(),
}) })
.collect::<Vec<_>>(); .collect::<Vec<_>>();
@@ -188,7 +192,7 @@ fn resolve_profile_avatar(
fn scan_extensions_for_profile( fn scan_extensions_for_profile(
profile_path: &Path, profile_path: &Path,
profile_id: &str, profile: &ProfileSummary,
extensions: &mut BTreeMap<String, TempExtension>, extensions: &mut BTreeMap<String, TempExtension>,
) { ) {
let extensions_root = profile_path.join("Extensions"); let extensions_root = profile_path.join("Extensions");
@@ -231,6 +235,7 @@ fn scan_extensions_for_profile(
version: version.clone(), version: version.clone(),
icon_data_url: icon_data_url.clone(), icon_data_url: icon_data_url.clone(),
profile_ids: BTreeSet::new(), profile_ids: BTreeSet::new(),
profiles: BTreeMap::new(),
}); });
if entry.name == entry.id && name != extension_id { if entry.name == entry.id && name != extension_id {
@@ -242,7 +247,16 @@ fn scan_extensions_for_profile(
if entry.icon_data_url.is_none() { if entry.icon_data_url.is_none() {
entry.icon_data_url = icon_data_url.clone(); 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( fn scan_bookmarks_for_profile(
profile_path: &Path, profile_path: &Path,
profile_id: &str, profile: &ProfileSummary,
bookmarks: &mut BTreeMap<String, TempBookmark>, bookmarks: &mut BTreeMap<String, TempBookmark>,
) { ) {
let bookmarks_path = profile_path.join("Bookmarks"); let bookmarks_path = profile_path.join("Bookmarks");
@@ -350,14 +364,15 @@ fn scan_bookmarks_for_profile(
}; };
for root in roots.values() { for root in roots.values() {
collect_bookmarks(root, profile_id, bookmarks); collect_bookmarks(root, profile, bookmarks, &[]);
} }
} }
fn collect_bookmarks( fn collect_bookmarks(
node: &Value, node: &Value,
profile_id: &str, profile: &ProfileSummary,
bookmarks: &mut BTreeMap<String, TempBookmark>, bookmarks: &mut BTreeMap<String, TempBookmark>,
ancestors: &[String],
) { ) {
match node.get("type").and_then(Value::as_str) { match node.get("type").and_then(Value::as_str) {
Some("url") => { Some("url") => {
@@ -381,17 +396,44 @@ fn collect_bookmarks(
url: url.to_string(), url: url.to_string(),
title: title.clone(), title: title.clone(),
profile_ids: BTreeSet::new(), profile_ids: BTreeSet::new(),
profiles: BTreeMap::new(),
}); });
if entry.title == entry.url && title != url { if entry.title == entry.url && title != url {
entry.title = title; 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") => { Some("folder") => {
if let Some(children) = node.get("children").and_then(Value::as_array) { 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 { for child in children {
collect_bookmarks(child, profile_id, bookmarks); collect_bookmarks(child, profile, bookmarks, &next_ancestors);
} }
} }
} }

View File

@@ -6,7 +6,7 @@ import { useBrowserManager } from "./composables/useBrowserManager";
const { const {
activeSection, activeSection,
bookmarkProfilesExpanded, associatedProfilesModal,
bookmarkSortKey, bookmarkSortKey,
browserConfigs, browserConfigs,
browserMonogram, browserMonogram,
@@ -21,7 +21,6 @@ const {
domainFromUrl, domainFromUrl,
error, error,
extensionMonogram, extensionMonogram,
extensionProfilesExpanded,
extensionSortKey, extensionSortKey,
isDeletingConfig, isDeletingConfig,
isOpeningProfile, isOpeningProfile,
@@ -36,11 +35,12 @@ const {
savingConfig, savingConfig,
sectionCount, sectionCount,
selectedBrowserId, selectedBrowserId,
showBookmarkProfilesModal,
showExtensionProfilesModal,
sortedBookmarks, sortedBookmarks,
sortedExtensions, sortedExtensions,
sortedProfiles, sortedProfiles,
toggleBookmarkProfiles, closeAssociatedProfilesModal,
toggleExtensionProfiles,
} = useBrowserManager(); } = useBrowserManager();
</script> </script>
@@ -109,16 +109,16 @@ const {
:section-count="sectionCount" :section-count="sectionCount"
:is-opening-profile="isOpeningProfile" :is-opening-profile="isOpeningProfile"
:extension-monogram="extensionMonogram" :extension-monogram="extensionMonogram"
:extension-profiles-expanded="extensionProfilesExpanded"
:bookmark-profiles-expanded="bookmarkProfilesExpanded"
:domain-from-url="domainFromUrl" :domain-from-url="domainFromUrl"
:associated-profiles-modal="associatedProfilesModal"
@update:active-section="activeSection = $event" @update:active-section="activeSection = $event"
@update:profile-sort-key="profileSortKey = $event" @update:profile-sort-key="profileSortKey = $event"
@update:extension-sort-key="extensionSortKey = $event" @update:extension-sort-key="extensionSortKey = $event"
@update:bookmark-sort-key="bookmarkSortKey = $event" @update:bookmark-sort-key="bookmarkSortKey = $event"
@open-profile="(browserId, profileId) => openBrowserProfile(browserId, profileId)" @open-profile="(browserId, profileId) => openBrowserProfile(browserId, profileId)"
@toggle-extension-profiles="toggleExtensionProfiles" @show-extension-profiles="showExtensionProfilesModal"
@toggle-bookmark-profiles="toggleBookmarkProfiles" @show-bookmark-profiles="showBookmarkProfilesModal"
@close-associated-profiles="closeAssociatedProfilesModal"
/> />
<template v-else> <template v-else>

View 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>

View File

@@ -6,12 +6,11 @@ defineProps<{
bookmarks: BookmarkSummary[]; bookmarks: BookmarkSummary[];
sortKey: BookmarkSortKey; sortKey: BookmarkSortKey;
domainFromUrl: (url: string) => string; domainFromUrl: (url: string) => string;
bookmarkProfilesExpanded: (url: string) => boolean;
}>(); }>();
const emit = defineEmits<{ const emit = defineEmits<{
"update:sortKey": [value: BookmarkSortKey]; "update:sortKey": [value: BookmarkSortKey];
toggleProfiles: [url: string]; showProfiles: [url: string];
}>(); }>();
</script> </script>
@@ -41,23 +40,11 @@ const emit = defineEmits<{
<button <button
class="disclosure-button" class="disclosure-button"
type="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> <span class="badge neutral">{{ bookmark.profileIds.length }}</span>
</button> </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>
</div> </div>
</article> </article>
@@ -125,13 +112,6 @@ const emit = defineEmits<{
cursor: pointer; cursor: pointer;
} }
.disclosure-panel {
display: flex;
flex-wrap: wrap;
gap: 8px;
margin-top: 8px;
}
@media (max-width: 720px) { @media (max-width: 720px) {
.bookmark-card { .bookmark-card {
flex-direction: column; flex-direction: column;

View File

@@ -1,11 +1,14 @@
<script setup lang="ts"> <script setup lang="ts">
import type { import type {
ActiveSection, ActiveSection,
AssociatedProfileSummary,
BookmarkAssociatedProfileSummary,
BookmarkSortKey, BookmarkSortKey,
BrowserView, BrowserView,
ExtensionSortKey, ExtensionSortKey,
ProfileSortKey, ProfileSortKey,
} from "../../types/browser"; } from "../../types/browser";
import AssociatedProfilesModal from "./AssociatedProfilesModal.vue";
import BookmarksList from "./BookmarksList.vue"; import BookmarksList from "./BookmarksList.vue";
import ExtensionsList from "./ExtensionsList.vue"; import ExtensionsList from "./ExtensionsList.vue";
import ProfilesList from "./ProfilesList.vue"; import ProfilesList from "./ProfilesList.vue";
@@ -23,9 +26,13 @@ defineProps<{
sectionCount: (section: ActiveSection) => number; sectionCount: (section: ActiveSection) => number;
isOpeningProfile: (browserId: string, profileId: string) => boolean; isOpeningProfile: (browserId: string, profileId: string) => boolean;
extensionMonogram: (name: string) => string; extensionMonogram: (name: string) => string;
extensionProfilesExpanded: (extensionId: string) => boolean;
bookmarkProfilesExpanded: (url: string) => boolean;
domainFromUrl: (url: string) => string; domainFromUrl: (url: string) => string;
associatedProfilesModal: {
title: string;
browserId: string;
profiles: (AssociatedProfileSummary | BookmarkAssociatedProfileSummary)[];
isBookmark: boolean;
} | null;
}>(); }>();
const emit = defineEmits<{ const emit = defineEmits<{
@@ -34,8 +41,9 @@ const emit = defineEmits<{
"update:extensionSortKey": [value: ExtensionSortKey]; "update:extensionSortKey": [value: ExtensionSortKey];
"update:bookmarkSortKey": [value: BookmarkSortKey]; "update:bookmarkSortKey": [value: BookmarkSortKey];
openProfile: [browserId: string, profileId: string]; openProfile: [browserId: string, profileId: string];
toggleExtensionProfiles: [extensionId: string]; showExtensionProfiles: [extensionId: string];
toggleBookmarkProfiles: [url: string]; showBookmarkProfiles: [url: string];
closeAssociatedProfiles: [];
}>(); }>();
</script> </script>
@@ -87,9 +95,8 @@ const emit = defineEmits<{
:extensions="sortedExtensions" :extensions="sortedExtensions"
:sort-key="extensionSortKey" :sort-key="extensionSortKey"
:extension-monogram="extensionMonogram" :extension-monogram="extensionMonogram"
:extension-profiles-expanded="extensionProfilesExpanded"
@update:sort-key="emit('update:extensionSortKey', $event)" @update:sort-key="emit('update:extensionSortKey', $event)"
@toggle-profiles="emit('toggleExtensionProfiles', $event)" @show-profiles="emit('showExtensionProfiles', $event)"
/> />
<BookmarksList <BookmarksList
@@ -97,11 +104,21 @@ const emit = defineEmits<{
:bookmarks="sortedBookmarks" :bookmarks="sortedBookmarks"
:sort-key="bookmarkSortKey" :sort-key="bookmarkSortKey"
:domain-from-url="domainFromUrl" :domain-from-url="domainFromUrl"
:bookmark-profiles-expanded="bookmarkProfilesExpanded"
@update:sort-key="emit('update:bookmarkSortKey', $event)" @update:sort-key="emit('update:bookmarkSortKey', $event)"
@toggle-profiles="emit('toggleBookmarkProfiles', $event)" @show-profiles="emit('showBookmarkProfiles', $event)"
/> />
</div> </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> </template>
<style scoped> <style scoped>

View File

@@ -6,12 +6,11 @@ defineProps<{
extensions: ExtensionSummary[]; extensions: ExtensionSummary[];
sortKey: ExtensionSortKey; sortKey: ExtensionSortKey;
extensionMonogram: (name: string) => string; extensionMonogram: (name: string) => string;
extensionProfilesExpanded: (extensionId: string) => boolean;
}>(); }>();
const emit = defineEmits<{ const emit = defineEmits<{
"update:sortKey": [value: ExtensionSortKey]; "update:sortKey": [value: ExtensionSortKey];
toggleProfiles: [extensionId: string]; showProfiles: [extensionId: string];
}>(); }>();
</script> </script>
@@ -55,23 +54,11 @@ const emit = defineEmits<{
<button <button
class="disclosure-button" class="disclosure-button"
type="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> <span class="badge neutral">{{ extension.profileIds.length }}</span>
</button> </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>
</div> </div>
</article> </article>
@@ -158,13 +145,6 @@ const emit = defineEmits<{
cursor: pointer; cursor: pointer;
} }
.disclosure-panel {
display: flex;
flex-wrap: wrap;
gap: 8px;
margin-top: 8px;
}
@media (max-width: 720px) { @media (max-width: 720px) {
.extension-card { .extension-card {
flex-direction: column; flex-direction: column;

View File

@@ -6,6 +6,8 @@ import { sortBookmarks, sortExtensions, sortProfiles } from "../utils/sort";
import type { import type {
ActiveSection, ActiveSection,
AppPage, AppPage,
AssociatedProfileSummary,
BookmarkAssociatedProfileSummary,
BookmarkSortKey, BookmarkSortKey,
BrowserConfigEntry, BrowserConfigEntry,
BrowserConfigListResponse, BrowserConfigListResponse,
@@ -36,8 +38,12 @@ export function useBrowserManager() {
}); });
const selectedBrowserId = ref(""); const selectedBrowserId = ref("");
const activeSection = ref<ActiveSection>("profiles"); const activeSection = ref<ActiveSection>("profiles");
const expandedExtensionIds = ref<string[]>([]); const associatedProfilesModal = ref<{
const expandedBookmarkUrls = ref<string[]>([]); title: string;
browserId: string;
profiles: (AssociatedProfileSummary | BookmarkAssociatedProfileSummary)[];
isBookmark: boolean;
} | null>(null);
const profileSortKey = ref<ProfileSortKey>("name"); const profileSortKey = ref<ProfileSortKey>("name");
const extensionSortKey = ref<ExtensionSortKey>("name"); const extensionSortKey = ref<ExtensionSortKey>("name");
const bookmarkSortKey = ref<BookmarkSortKey>("title"); const bookmarkSortKey = ref<BookmarkSortKey>("title");
@@ -80,9 +86,8 @@ export function useBrowserManager() {
); );
watch(selectedBrowserId, () => { watch(selectedBrowserId, () => {
expandedExtensionIds.value = [];
expandedBookmarkUrls.value = [];
openProfileError.value = ""; openProfileError.value = "";
associatedProfilesModal.value = null;
}); });
async function loadBrowserConfigs() { async function loadBrowserConfigs() {
@@ -272,24 +277,30 @@ export function useBrowserManager() {
return currentBrowser.value.bookmarks.length; return currentBrowser.value.bookmarks.length;
} }
function toggleExtensionProfiles(extensionId: string) { function showExtensionProfilesModal(extensionId: string) {
expandedExtensionIds.value = expandedExtensionIds.value.includes(extensionId) const extension = currentBrowser.value?.extensions.find((item) => item.id === extensionId);
? expandedExtensionIds.value.filter((id) => id !== extensionId) if (!extension || !currentBrowser.value) return;
: [...expandedExtensionIds.value, extensionId]; associatedProfilesModal.value = {
title: `${extension.name} Profiles`,
browserId: currentBrowser.value.browserId,
profiles: extension.profiles,
isBookmark: false,
};
} }
function toggleBookmarkProfiles(url: string) { function showBookmarkProfilesModal(url: string) {
expandedBookmarkUrls.value = expandedBookmarkUrls.value.includes(url) const bookmark = currentBrowser.value?.bookmarks.find((item) => item.url === url);
? expandedBookmarkUrls.value.filter((value) => value !== url) if (!bookmark || !currentBrowser.value) return;
: [...expandedBookmarkUrls.value, url]; associatedProfilesModal.value = {
title: `${bookmark.title} Profiles`,
browserId: currentBrowser.value.browserId,
profiles: bookmark.profiles,
isBookmark: true,
};
} }
function extensionProfilesExpanded(extensionId: string) { function closeAssociatedProfilesModal() {
return expandedExtensionIds.value.includes(extensionId); associatedProfilesModal.value = null;
}
function bookmarkProfilesExpanded(url: string) {
return expandedBookmarkUrls.value.includes(url);
} }
onMounted(() => { onMounted(() => {
@@ -298,7 +309,7 @@ export function useBrowserManager() {
return { return {
activeSection, activeSection,
bookmarkProfilesExpanded, associatedProfilesModal,
bookmarkSortKey, bookmarkSortKey,
browserConfigs, browserConfigs,
browserMonogram, browserMonogram,
@@ -313,7 +324,6 @@ export function useBrowserManager() {
domainFromUrl, domainFromUrl,
error, error,
extensionMonogram, extensionMonogram,
extensionProfilesExpanded,
extensionSortKey, extensionSortKey,
isDeletingConfig, isDeletingConfig,
isOpeningProfile, isOpeningProfile,
@@ -328,10 +338,11 @@ export function useBrowserManager() {
savingConfig, savingConfig,
sectionCount, sectionCount,
selectedBrowserId, selectedBrowserId,
showBookmarkProfilesModal,
showExtensionProfilesModal,
sortedBookmarks, sortedBookmarks,
sortedExtensions, sortedExtensions,
sortedProfiles, sortedProfiles,
toggleBookmarkProfiles, closeAssociatedProfilesModal,
toggleExtensionProfiles,
}; };
} }

View File

@@ -19,12 +19,29 @@ export type ExtensionSummary = {
version: string | null; version: string | null;
iconDataUrl: string | null; iconDataUrl: string | null;
profileIds: string[]; profileIds: string[];
profiles: AssociatedProfileSummary[];
}; };
export type BookmarkSummary = { export type BookmarkSummary = {
url: string; url: string;
title: string; title: string;
profileIds: 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"; export type ProfileSortKey = "name" | "email" | "id";