feat: add browser profile mapping import flow
This commit is contained in:
parent
1d540d0806
commit
92cb42262c
12 changed files with 4609 additions and 258 deletions
|
|
@ -2450,6 +2450,7 @@ class TabManager: ObservableObject {
|
|||
orientation: SplitOrientation,
|
||||
insertFirst: Bool = false,
|
||||
url: URL? = nil,
|
||||
preferredProfileID: UUID? = nil,
|
||||
focus: Bool = true
|
||||
) -> UUID? {
|
||||
guard let tab = tabs.first(where: { $0.id == tabId }) else { return nil }
|
||||
|
|
@ -2458,14 +2459,24 @@ class TabManager: ObservableObject {
|
|||
orientation: orientation,
|
||||
insertFirst: insertFirst,
|
||||
url: url,
|
||||
preferredProfileID: preferredProfileID,
|
||||
focus: focus
|
||||
)?.id
|
||||
}
|
||||
|
||||
/// Create a new browser surface in a pane
|
||||
func newBrowserSurface(tabId: UUID, inPane paneId: PaneID, url: URL? = nil) -> UUID? {
|
||||
func newBrowserSurface(
|
||||
tabId: UUID,
|
||||
inPane paneId: PaneID,
|
||||
url: URL? = nil,
|
||||
preferredProfileID: UUID? = nil
|
||||
) -> UUID? {
|
||||
guard let tab = tabs.first(where: { $0.id == tabId }) else { return nil }
|
||||
return tab.newBrowserSurface(inPane: paneId, url: url)?.id
|
||||
return tab.newBrowserSurface(
|
||||
inPane: paneId,
|
||||
url: url,
|
||||
preferredProfileID: preferredProfileID
|
||||
)?.id
|
||||
}
|
||||
|
||||
/// Get a browser panel by ID
|
||||
|
|
@ -2480,6 +2491,7 @@ class TabManager: ObservableObject {
|
|||
inWorkspace tabId: UUID,
|
||||
url: URL? = nil,
|
||||
preferSplitRight: Bool = false,
|
||||
preferredProfileID: UUID? = nil,
|
||||
insertAtEnd: Bool = false
|
||||
) -> UUID? {
|
||||
guard let workspace = tabs.first(where: { $0.id == tabId }) else { return nil }
|
||||
|
|
@ -2493,7 +2505,8 @@ class TabManager: ObservableObject {
|
|||
inPane: targetPaneId,
|
||||
url: url,
|
||||
focus: true,
|
||||
insertAtEnd: insertAtEnd
|
||||
insertAtEnd: insertAtEnd,
|
||||
preferredProfileID: preferredProfileID
|
||||
) {
|
||||
rememberFocusedSurface(tabId: tabId, surfaceId: browserPanel.id)
|
||||
return browserPanel.id
|
||||
|
|
@ -2519,6 +2532,7 @@ class TabManager: ObservableObject {
|
|||
from: splitSourcePanelId,
|
||||
orientation: .horizontal,
|
||||
url: url,
|
||||
preferredProfileID: preferredProfileID,
|
||||
focus: true
|
||||
) {
|
||||
rememberFocusedSurface(tabId: tabId, surfaceId: browserPanel.id)
|
||||
|
|
@ -2531,7 +2545,8 @@ class TabManager: ObservableObject {
|
|||
inPane: paneId,
|
||||
url: url,
|
||||
focus: true,
|
||||
insertAtEnd: insertAtEnd
|
||||
insertAtEnd: insertAtEnd,
|
||||
preferredProfileID: preferredProfileID
|
||||
) else {
|
||||
return nil
|
||||
}
|
||||
|
|
@ -2541,12 +2556,17 @@ class TabManager: ObservableObject {
|
|||
|
||||
/// Open a browser in the currently focused pane (as a new surface)
|
||||
@discardableResult
|
||||
func openBrowser(url: URL? = nil, insertAtEnd: Bool = false) -> UUID? {
|
||||
func openBrowser(
|
||||
url: URL? = nil,
|
||||
preferredProfileID: UUID? = nil,
|
||||
insertAtEnd: Bool = false
|
||||
) -> UUID? {
|
||||
guard let tabId = selectedTabId else { return nil }
|
||||
return openBrowser(
|
||||
inWorkspace: tabId,
|
||||
url: url,
|
||||
preferSplitRight: false,
|
||||
preferredProfileID: preferredProfileID,
|
||||
insertAtEnd: insertAtEnd
|
||||
)
|
||||
}
|
||||
|
|
@ -2642,7 +2662,12 @@ class TabManager: ObservableObject {
|
|||
in workspace: Workspace
|
||||
) -> UUID? {
|
||||
if let originalPane = workspace.bonsplitController.allPaneIds.first(where: { $0.id == snapshot.originalPaneId }),
|
||||
let browserPanel = workspace.newBrowserSurface(inPane: originalPane, url: snapshot.url, focus: true) {
|
||||
let browserPanel = workspace.newBrowserSurface(
|
||||
inPane: originalPane,
|
||||
url: snapshot.url,
|
||||
focus: true,
|
||||
preferredProfileID: snapshot.profileID
|
||||
) {
|
||||
let tabCount = workspace.bonsplitController.tabs(inPane: originalPane).count
|
||||
let maxIndex = max(0, tabCount - 1)
|
||||
let targetIndex = min(max(snapshot.originalTabIndex, 0), maxIndex)
|
||||
|
|
@ -2659,7 +2684,8 @@ class TabManager: ObservableObject {
|
|||
from: anchorPanelId,
|
||||
orientation: orientation,
|
||||
insertFirst: snapshot.fallbackSplitInsertFirst,
|
||||
url: snapshot.url
|
||||
url: snapshot.url,
|
||||
preferredProfileID: snapshot.profileID
|
||||
)?.id {
|
||||
return browserPanelId
|
||||
}
|
||||
|
|
@ -2667,7 +2693,12 @@ class TabManager: ObservableObject {
|
|||
guard let focusedPane = workspace.bonsplitController.focusedPaneId ?? workspace.bonsplitController.allPaneIds.first else {
|
||||
return nil
|
||||
}
|
||||
return workspace.newBrowserSurface(inPane: focusedPane, url: snapshot.url, focus: true)?.id
|
||||
return workspace.newBrowserSurface(
|
||||
inPane: focusedPane,
|
||||
url: snapshot.url,
|
||||
focus: true,
|
||||
preferredProfileID: snapshot.profileID
|
||||
)?.id
|
||||
}
|
||||
|
||||
/// Flash the currently focused panel so the user can visually confirm focus.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue