Skip to content

Commit

Permalink
Added: Option to switch panel after moving active tab to another panel
Browse files Browse the repository at this point in the history
  • Loading branch information
mbnuqw committed Jun 3, 2021
1 parent ae3bac2 commit bbd9054
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 3 deletions.
1 change: 1 addition & 0 deletions addon/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ export const DEFAULT_SETTINGS = {
tabsUnreadMark: false,
tabsReloadLimit: 5,
tabsReloadLimitNotif: true,
tabsPanelSwitchActMove: true,

// New tab position
moveNewTabPin: 'start',
Expand Down
3 changes: 3 additions & 0 deletions addon/locales/en.settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,9 @@ export default {
'settings.tabs_reload_limit_notif': {
message: 'Show notification with the reloading progress',
},
'settings.tabs_panel_switch_act_move': {
message: 'Switch panel after moving active tab to another panel',
},

// --- New tab position
'settings.new_tab_position': { message: 'Position of new tab' },
Expand Down
3 changes: 3 additions & 0 deletions addon/locales/ru.settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,9 @@ export default {
'settings.tabs_reload_limit_notif': {
message: 'Показывать уведомление со статусом перезагрузки',
},
'settings.tabs_panel_switch_act_move': {
message: 'Переключать панель после перемещения активной вкладки на другую панель',
},

// --- New tab position
'settings.new_tab_position': { message: 'Позиция новых вкладок' },
Expand Down
4 changes: 4 additions & 0 deletions src/page.settings/components/settings.tabs.vue
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@ section
:inactive="!($store.state.tabsReloadLimit > 0)"
:value="$store.state.tabsReloadLimitNotif"
@input="setOpt('tabsReloadLimitNotif', $event)")
ToggleField(
label="settings.tabs_panel_switch_act_move"
:value="$store.state.tabsPanelSwitchActMove"
@input="setOpt('tabsPanelSwitchActMove', $event)")
</template>

<script>
Expand Down
8 changes: 5 additions & 3 deletions src/sidebar/actions/tabs.js
Original file line number Diff line number Diff line change
Expand Up @@ -1577,11 +1577,9 @@ async function moveTabsToPanel(tabIds, panelId) {
if (!activePanel || !activePanel.tabs) return

let tabs = []
let activeTab
for (let tabId of tabIds) {
let tab = this.state.tabsMap[tabId]
if (!tab) continue
if (tab.active) activeTab = tab
tabs.push(tab)
}
let targetPanel = this.state.panelsMap[panelId]
Expand All @@ -1594,7 +1592,6 @@ async function moveTabsToPanel(tabIds, panelId) {
if (this.state.tabsTree && activePanel.tabs.length > 0) {
this.actions.updateTabsTree(activePanel.startIndex, activePanel.endIndex + 1)
}
if (activeTab) this.state.panelIndex = targetPanel.index
this.actions.saveTabsData()
tabs.forEach(t => this.actions.saveTabData(t))
}
Expand Down Expand Up @@ -1930,9 +1927,14 @@ async function moveDroppedNodes(dropIndex, dropParent, nodes, pin, currentPanel)
}

if (differentPanel) {
let hasActiveTab = false
for (let tab of tabs) {
if (tab.active) hasActiveTab = true
tab.panelId = currentPanel.id
}
if (hasActiveTab && this.state.tabsPanelSwitchActMove) {
this.state.panelIndex = currentPanel.index
}
}
this.actions.updatePanelsTabs()

Expand Down

0 comments on commit bbd9054

Please sign in to comment.