Skip to content

Commit fd0baf4

Browse files
committed
wip
1 parent fbd1e35 commit fd0baf4

File tree

11 files changed

+141
-83
lines changed

11 files changed

+141
-83
lines changed

actionHandling/handler/DefaultAddUrlToTabsetHandler.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export class DefaultAddUrlToTabsetHandler implements AddUrlToTabsetHandler {
4242
}
4343
return tabsetsCount > 0 ? 'positive' : ''
4444
}
45-
return 'black'
45+
return ''
4646
})
4747
.onClicked(this.clicked)
4848
}

actionHandling/handler/RapidApiAddUrlToTabsetHandler.ts

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { DialogChainObject, QVueGlobals, uid } from 'quasar'
22
import { TabReference, TabReferenceType } from 'src/content/models/TabReference'
3+
import { useContentStore } from 'src/content/stores/contentStore'
34
import { ExecutionResult } from 'src/core/domain/ExecutionResult'
45
import { useCommandExecutor } from 'src/core/services/CommandExecutor'
56
import { RestParam, RestTab } from 'src/rest/models/RestTab'
@@ -9,11 +10,13 @@ import {
910
AddUrlToTabsetHandlerAdditionalData,
1011
ClickedHandler,
1112
} from 'src/tabsets/actionHandling/AddUrlToTabsetHandler'
13+
import { DefaultActions } from 'src/tabsets/actionHandling/handler/DefaultActions'
1214
import { ActionContext } from 'src/tabsets/actionHandling/model/ActionContext'
1315
import { AddTabToTabsetCommand } from 'src/tabsets/commands/AddTabToTabsetCommand'
1416
import { CreateFolderCommand } from 'src/tabsets/commands/CreateFolderCommand'
1517
import { Tab } from 'src/tabsets/models/Tab'
1618
import { Tabset } from 'src/tabsets/models/Tabset'
19+
import { useTabsetService } from 'src/tabsets/services/TabsetService2'
1720
import { useTabsetsStore } from 'src/tabsets/stores/tabsetsStore'
1821
import { useTabsStore2 } from 'src/tabsets/stores/tabsStore2'
1922
import { Component } from 'vue'
@@ -35,9 +38,25 @@ export class RapidApiAddUrlToTabsetHandler implements AddUrlToTabsetHandler {
3538
.onOk(this.onOk)
3639
}
3740

38-
actions(): Component[] {
39-
// new ActionContext('Add Rapid API', ButtonActions.Save)
40-
return []
41+
actions(currentTabsetId: string | undefined): Component[] {
42+
const url = useContentStore().getCurrentTabUrl
43+
const currentTabset = useTabsetsStore().getCurrentTabset
44+
45+
const actions = DefaultActions.getDefaultActions(currentTabset)
46+
47+
if (url) {
48+
// TODO folders?
49+
const tabsetIds = useTabsetService()
50+
.tabsetsFor(url)
51+
.filter((tsId: string) => tsId !== currentTabsetId)
52+
53+
if (tabsetIds.length > 0) {
54+
tabsetIds.forEach((tabsetId: string) => {
55+
//actions.push(new ActionContext('Open', undefined, undefined, { tabsetId }).onClicked(this.clicked))
56+
})
57+
}
58+
}
59+
return actions
4160
}
4261

4362
async clicked(

commands/AddTabToTabsetCommand.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ export class AddTabToTabsetCommand implements Command<any> {
3636
public tab: Tab,
3737
public tabset: Tabset | undefined = undefined,
3838
public activeFolder: string | undefined = undefined,
39-
public allowDuplicates: boolean = false,
40-
public ignoreDuplicates: boolean = false,
39+
public allowDuplicates: boolean = false, // used eg at Excalidraw Handler
40+
public ignoreDuplicates: boolean = false, // used eg. at RssFolderHandler
4141
) {
4242
if (!tabset) {
4343
this.tabset = useTabsetsStore().getCurrentTabset

commands/CreateFolderCommand.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ export class CreateFolderCommand implements Command<Tabset> {
6868
Analytics.fireEvent('tabset_subfolder_created', {})
6969
return Promise.resolve(new ExecutionResult<Tabset>(newFolder, 'Subfolder created'))
7070
}
71+
console.log(`missed subfolder for tabset '${tabset.name}', #${tabset.id}`)
7172
return Promise.reject('could not find subfolder')
7273
} catch (err) {
7374
return Promise.reject(err)

commands/OpenTabCommand.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,6 @@ export class OpenTabCommand implements Command<string> {
5252
if (this.tab.httpStatus === 0) {
5353
this.tab.httpStatus = 200 // ok "for now"
5454
}
55-
// if (useTabsStore2().browserTabs.length > 7 && !useFeaturesStore().hasFeature(FeatureIdent.OPEN_TABS)) {
56-
// useSuggestionsStore().addSuggestion(Suggestion.getStaticSuggestion('TRY_OPENTABS_FEATURE'))
57-
// }
5855
Analytics.fireEvent('tabset_tab_opened', {})
5956
return Promise.resolve(new ExecutionResult('', 'opened'))
6057
} catch (err: any) {

layouts/SidePanelPageTabList.vue

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@
1313
:group="{ name: 'tabs', pull: 'clone' }"
1414
@change="(event: any) => handleDragAndDrop(event, column)">
1515
<SidePanelTabListHelper
16-
v-for="tab in tabs"
16+
v-for="(tab, index) in tabs"
17+
:key="index"
18+
v-once
1719
:tab="tab.tab as Tab"
1820
:index="tab.index"
1921
:type="props.type"
@@ -29,14 +31,17 @@
2931
all your collections.
3032
</div>
3133
<div v-else-if="props.tabset?.folders.length === 0" class="q-ma-md text-caption text-center">
32-
Empty Collection
34+
Empty Tabset<br />
35+
check the action menu<br />
3336
</div>
3437
</template>
3538

3639
<!-- no drag & drop on mobile -->
3740
<template v-else>
3841
<SidePanelTabListHelper
39-
v-for="tab in tabs"
42+
v-for="(tab, index) in tabs"
43+
:key="index"
44+
v-once
4045
:tab="tab.tab as Tab"
4146
:index="0"
4247
:type="props.type"
@@ -79,20 +84,23 @@ const props = defineProps({
7984
filter: { type: String, required: false },
8085
})
8186
87+
const emits = defineEmits(['tabs-found'])
88+
8289
const tabs = ref<IndexedTab[]>([])
8390
8491
watch(
8592
() => props.filter,
8693
(a: string | undefined, b: string | undefined) => {
8794
tabs.value = tabsForColumn()
95+
emits('tabs-found', tabs.value.length)
8896
},
8997
)
9098
9199
watch(
92100
() => props.tabset?.tabs || [],
93101
(a: Tab[], b: Tab[]) => {
94-
console.log('--------', a)
95102
tabs.value = tabsForColumn()
103+
emits('tabs-found', tabs.value.length)
96104
},
97105
)
98106

layouts/SidePanelTabListHelper.vue

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<q-item
55
clickable
66
v-ripple
7-
class="q-mt-xs q-mx-xs q-mb-none q-pr-none q-pl-sm q-pb-none q-pt-none darkColors lightColors"
7+
class="q-mt-xs q-mx-xs q-mb-none q-pr-none q-pl-none q-pb-none q-pt-none darkColors lightColors"
88
:style="itemStyle()"
99
@dragstart="startDrag($event, tab)"
1010
:key="'paneltablist_' + tab.id">
@@ -72,4 +72,8 @@ const itemStyle = () => {
7272
background-color: $grey-2;
7373
border: 1px solid $grey-3;
7474
}
75+
76+
.q-item {
77+
min-height: 30px;
78+
}
7579
</style>

services/TabsetService2.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -447,12 +447,13 @@ export function useTabsetService() {
447447
* @param ts
448448
* @param tab
449449
* @param useIndex
450+
* @param allowDuplicates
450451
*/
451452
const addToTabset = async (
452453
ts: Tabset,
453454
tab: Tab,
454455
useIndex: number | undefined = undefined,
455-
allowDuplicates = false,
456+
allowDuplicates = false, // used eg at Excalidraw Handler
456457
): Promise<Tabset> => {
457458
if (tab.url) {
458459
const exceedInfo = useAuthStore().limitExceeded('TABS', useTabsetsStore().allTabsCount)

views/sidepanel/SidePanelFoldersView.vue

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
<q-list>
2424
<q-item
2525
v-if="props.tabset"
26-
v-for="folder in calcFolders(props.tabset)"
26+
v-for="folder in folders"
2727
clickable
2828
v-ripple
2929
class="q-ma-none q-pa-sm"
@@ -70,7 +70,7 @@
7070

7171
<script lang="ts" setup>
7272
import { Tabset, TabsetType } from 'src/tabsets/models/Tabset'
73-
import { ref, watchEffect } from 'vue'
73+
import { onMounted, ref, watchEffect } from 'vue'
7474
import '@he-tree/vue/style/default.css'
7575
import '@he-tree/vue/style/material-design.css'
7676
import { QVueGlobals } from 'quasar'
@@ -84,10 +84,22 @@ import Highlight from 'src/tabsets/widgets/Highlight.vue'
8484
import { useUiStore } from 'src/ui/stores/uiStore'
8585
import { useWindowsStore } from 'src/windows/stores/windowsStore'
8686
87-
const props = defineProps<{ tabset: Tabset; filter: string }>()
87+
type Props = {
88+
tabset: Tabset
89+
filter?: string
90+
}
91+
92+
const props = defineProps<Props>()
93+
94+
const emits = defineEmits(['folders-found', 'folder-selected'])
8895
8996
const currentChromeTab = ref<chrome.tabs.Tab | undefined>(undefined)
9097
const hoveredTabset = ref<string | undefined>(undefined)
98+
const folders = ref<Tabset[]>([])
99+
100+
onMounted(() => {
101+
folders.value = calcFolders(props.tabset)
102+
})
91103
92104
watchEffect(() => {
93105
const windowId = useWindowsStore().currentBrowserWindow?.id || 0
@@ -108,6 +120,13 @@ const calcFolders = (tabset: Tabset): Tabset[] => {
108120
)
109121
}
110122
123+
watchEffect(() => {
124+
if (props.filter || props.tabset.folderActive) {
125+
folders.value = calcFolders(props.tabset)
126+
emits('folders-found', folders.value.length)
127+
}
128+
})
129+
111130
const startDrag = (evt: any, folder: Tabset) => {
112131
console.log('start dragging', evt, folder)
113132
if (evt.dataTransfer) {
@@ -154,9 +173,9 @@ const dropAtBreadcrumb = (evt: any, f?: any) => {
154173
const selectFolder = (tabset: Tabset, folder?: Tabset) => {
155174
console.log(`selecting folder '${folder?.id}' (${folder?.name}) in tabset ${tabset.id} (${tabset.name})`)
156175
tabset.folderActive = folder ? (tabset.id === folder.id ? undefined : folder.id) : undefined
157-
158176
useTabsetService().saveTabset(tabset)
159177
useTabsetService().handleHeadRequests(tabset, folder?.id)
178+
emits('folder-selected')
160179
}
161180
162181
const folderCaption = (folder: Tabset): string => {

0 commit comments

Comments
 (0)