Skip to content

Commit

Permalink
test fix
Browse files Browse the repository at this point in the history
  • Loading branch information
evandor committed Mar 16, 2024
1 parent 10e8833 commit be48352
Show file tree
Hide file tree
Showing 12 changed files with 126 additions and 53 deletions.
3 changes: 3 additions & 0 deletions src/components/widgets/PanelTabListElementWidget.vue
Original file line number Diff line number Diff line change
Expand Up @@ -515,9 +515,11 @@ watchEffect(() => {
watchEffect(() => {
if (props.tab) {
const t = props.tab
//console.log("placeholders", t.placeholders)
if (t.placeholders && t.placeholders.type === PlaceholdersType.URL_SUBSTITUTION) {
const subs = t.placeholders.config
Object.entries(subs).forEach(e => {
console.log("got e", e)
const name = e[0]
const val = e[1]
val.split(",").forEach((v: string) => {
Expand All @@ -535,6 +537,7 @@ watchEffect(() => {
})
}
}
//console.log("===>", placeholders.value)
})
watchEffect(async () => {
Expand Down
74 changes: 56 additions & 18 deletions src/components/widgets/helper/PanelTabListContextMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@
<q-item :clickable="props.tab?.placeholders === undefined || props.tab?.monitor !== undefined"
v-close-popup @click.stop="monitoringDialog(props['tab' as keyof object])">
<q-item-section style="padding-right:0;min-width:25px;max-width: 25px;">
<q-icon size="xs" name="o_change_circle" :color="props.tab?.placeholders !== undefined && props.tab?.monitor === undefined? 'grey' : 'info'"/>
<q-icon size="xs" name="o_change_circle"
:color="props.tab?.placeholders !== undefined && props.tab?.monitor === undefined? 'grey' : 'info'"/>
</q-item-section>
<q-item-section v-if="props.tab?.monitor">
Monitoring Changes...
Expand All @@ -49,15 +50,15 @@
</q-item>
</template>

<!-- <q-separator inset/>-->
<!-- <q-item clickable v-close-popup @click.stop="copyToClipboard(props['tab' as keyof object])">-->
<!-- <q-item-section style="padding-right:0;min-width:25px;max-width: 25px;">-->
<!-- <q-icon size="xs" name="o_link" color="accent"/>-->
<!-- </q-item-section>-->
<!-- <q-item-section>-->
<!-- Copy URL to Clipboard-->
<!-- </q-item-section>-->
<!-- </q-item>-->
<!-- <q-separator inset/>-->
<!-- <q-item clickable v-close-popup @click.stop="copyToClipboard(props['tab' as keyof object])">-->
<!-- <q-item-section style="padding-right:0;min-width:25px;max-width: 25px;">-->
<!-- <q-icon size="xs" name="o_link" color="accent"/>-->
<!-- </q-item-section>-->
<!-- <q-item-section>-->
<!-- Copy URL to Clipboard-->
<!-- </q-item-section>-->
<!-- </q-item>-->

<template v-if="usePermissionsStore().hasFeature(FeatureIdent.ADVANCED_TAB_MANAGEMENT)">
<q-separator inset/>
Expand Down Expand Up @@ -85,6 +86,18 @@
</q-item>
</template>

<template v-if="useAuthStore().isAuthenticated()">
<q-separator inset/>
<q-item clickable v-close-popup @click.stop="openSimilar()">
<q-item-section style="padding-right:0;min-width:25px;max-width: 25px;">
<q-icon size="xs" name="o_equal"/>
</q-item-section>
<q-item-section>
Open similar websites
</q-item-section>
</q-item>
</template>

<q-separator inset/>
<q-item clickable v-close-popup @click.stop="deleteTab()">
<q-item-section style="padding-right:0;min-width:25px;max-width: 25px;">
Expand All @@ -108,7 +121,6 @@ import {Tab} from "src/models/Tab";
import {DeleteTabCommand} from "src/domain/tabs/DeleteTabCommand";
import {useRouter} from "vue-router";
import {useSettingsStore} from "stores/settingsStore";
import {CopyToClipboardCommand} from "src/domain/commands/CopyToClipboard";
import NavigationService from "src/services/NavigationService";
import {Tabset, TabsetType} from "src/models/Tabset";
import {usePermissionsStore} from "stores/permissionsStore";
Expand All @@ -121,6 +133,13 @@ import ColorSelector from "components/dialogues/helper/ColorSelector.vue";
import {UpdateTabColorCommand} from "src/domain/tabs/UpdateTabColor";
import MonitoringDialog from "components/dialogues/MonitoringDialog.vue";
import CommentDialog from "components/dialogues/CommentDialog.vue";
import {api} from "boot/axios";
import _ from "lodash"
import {useAuthStore} from "stores/authStore";
import {NotificationType, useNotificationHandler} from "src/services/ErrorHandler";
import {ExecutionResult} from "src/domain/ExecutionResult";
const {handleSuccess, handleError} = useNotificationHandler()
const props = defineProps({
tab: {type: Object as PropType<Tab>, required: true},
Expand All @@ -146,6 +165,25 @@ async function tabToUse(tab: Tab) {
return useTab;
}
const openSimilar = async () => {
console.log("finding similar websites for", props.tab.url)
try {
const url = new URL(props.tab.url || '')
const hostname = url.hostname
const res = await api.post("https://us-central1-tabsets-dev.cloudfunctions.net/app/ra/similar", {"domain": hostname})
const data = res.data
console.log("res", res, data['similar_sites'])
if (data['similar_sites']) {
const urls = _.map(data['similar_sites'], u => "https://" + u)
NavigationService.openOrCreateTab(urls)
handleSuccess(new ExecutionResult("done", "opening " + urls.length + " similar page(s)"))
}
} catch (err) {
console.log("got error", err)
handleError("not able to find similar pages", NotificationType.TOAST)
}
}
const deleteTab = async () => {
const useTab = await tabToUse(props.tab)
useCommandExecutor().executeFromUi(new DeleteTabCommand(useTab, props.tabset))
Expand All @@ -157,8 +195,8 @@ const deleteTab = async () => {
title: res.length === 1 ? 'Found Bookmark with same URL' : 'Found Bookmarks with same URL',
cancel: true,
message: res.length === 1 ?
'Do you want to delete this bookmark as well?' :
'Do you want to delete these ' + res.length + ' bookmarks as well?'
'Do you want to delete this bookmark as well?' :
'Do you want to delete these ' + res.length + ' bookmarks as well?'
}).onOk(() => {
res.forEach(bm => {
chrome.bookmarks.remove(bm.id)
Expand Down Expand Up @@ -192,14 +230,14 @@ const showTabDetails = async (tab: Tab) => {
}
const showTabDetailsMenuEntry = (tab: Tab) =>
useSettingsStore().isEnabled('dev')
useSettingsStore().isEnabled('dev')
//&& !(tab.placeholders?.type === PlaceholdersType.URL_SUBSTITUTION)
const deleteTabLabel = (tab: Tab) =>
(tab.placeholders && tab.placeholders.type === PlaceholdersType.URL_SUBSTITUTION) ?
'Delete all'
:
'Delete Tab'
(tab.placeholders && tab.placeholders.type === PlaceholdersType.URL_SUBSTITUTION) ?
'Delete all'
:
'Delete Tab'
const editURL = async (tab: Tab) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ import {useSearchStore} from "stores/searchStore";
import {uid, useQuasar} from "quasar";
import {useGroupsStore} from "stores/groupsStore";
import PlaceholderUtils from "src/utils/PlaceholderUtils";
import {useAuthStore} from "stores/authStore";
import {collection, deleteDoc, doc, getDoc, getDocs, setDoc, updateDoc} from "firebase/firestore";
import FirebaseServices from "src/services/firebase/FirebaseServices";

const {saveTabset} = useTabsetService()
const {sendMsg} = useUtils()
Expand Down Expand Up @@ -54,6 +57,12 @@ export class AddTabToTabsetCommand implements Command<any> {

const tabset: Tabset = await useTabsetService().addToTabset(tabsetOrFolder, this.tab, 0)

// Analysis
if (useAuthStore().isAuthenticated() && this.tab.url?.startsWith("https://")) {
const userId = useAuthStore().user.uid
setDoc(doc(FirebaseServices.getFirestore(), "users", userId, "queue", uid()),{"event": "new-tab", "url": this.tab.url})
}

// Sharing
if (tabset.sharedId && tabset.sharing === TabsetSharing.PUBLIC_LINK && !this.activeFolder) {
tabset.sharing = TabsetSharing.PUBLIC_LINK_OUTDATED
Expand Down
36 changes: 24 additions & 12 deletions src/pages/SidePanelPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -175,17 +175,29 @@
@mouseover="hoveredTabset = tabset.id"
@mouseleave="hoveredTabset = undefined">
<q-item-label>
<q-icon
id="foo"
v-if="showAddTabButton(tabset as Tabset, currentChromeTab)"
@click.stop="saveInTabset(tabset.id, tabset.folderActive)"
class="q-mr-none"
name="o_bookmark_add"
:class="alreadyInTabset() ? '':'cursor-pointer'"
:color="alreadyInTabset() ? 'grey-5': tsBadges.length > 0 ? 'accent':'warning'"
size="xs"
data-testid="saveInTabsetBtn">
</q-icon>
<!-- <q-icon-->
<!-- id="foo"-->
<!-- v-if="showAddTabButton(tabset as Tabset, currentChromeTab)"-->
<!-- @click.stop="saveInTabset(tabset.id, tabset.folderActive)"-->
<!-- class="q-mr-none"-->
<!-- name="o_bookmark_add"-->
<!-- :class="alreadyInTabset() ? '':'cursor-pointer'"-->
<!-- :color="alreadyInTabset() ? 'grey-5': tsBadges.length > 0 ? 'accent':'warning'"-->
<!-- size="xs"-->
<!-- data-testid="saveInTabsetBtn">-->
<!-- </q-icon>-->
<q-btn outline
v-if="showAddTabButton(tabset as Tabset, currentChromeTab)"
@click.stop="saveInTabset(tabset.id, tabset.folderActive)"
class="q-ma-none q-px-sm q-py-none"
name="o_bookmark_add"
:class="alreadyInTabset() ? '':'cursor-pointer'"
:color="alreadyInTabset() ? 'grey-5': tsBadges.length > 0 ? 'accent':'warning'"
size="xs"
data-testid="saveInTabsetBtn">
<div>Add Tab</div>
<!-- <q-icon right class="q-ma-none q-pa-none" size="2em" name="o_south" />-->
</q-btn>
<span
v-if="!alreadyInTabset() && showAddTabButton(tabset as Tabset, currentChromeTab) && tsBadges.length > 0"
style="color: grey;font-size: 7px;position: relative;top:-2px;left:-11px;">{{
Expand Down Expand Up @@ -367,7 +379,7 @@ import {useDB} from "src/services/usePersistenceService";
import {useBookmarksStore} from "stores/bookmarksStore";
import {useSuggestionsStore} from "stores/suggestionsStore";
import SidePanelPageTabList from "components/layouts/SidePanelPageTabList.vue";
import {AddTabToTabsetCommand} from "src/domain/tabs/AddTabToTabset";
import {AddTabToTabsetCommand} from "src/domain/tabs/AddTabToTabsetCommand"
import {CopyToClipboardCommand} from "src/domain/commands/CopyToClipboard";
import ShareTabsetPubliclyDialog from "components/dialogues/ShareTabsetPubliclyDialog.vue";
import {FirebaseCall} from "src/services/firebase/FirebaseCall";
Expand Down
2 changes: 1 addition & 1 deletion src/pages/SidePanelTabsetPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ import {uid, useQuasar} from "quasar";
import SidePanelPageTabList from "components/layouts/SidePanelPageTabList.vue";
import {useTabsetService} from "src/services/TabsetService2";
import {useCommandExecutor} from "src/services/CommandExecutor";
import {AddTabToTabsetCommand} from "src/domain/tabs/AddTabToTabset";
import {AddTabToTabsetCommand} from "src/domain/tabs/AddTabToTabsetCommand"
import {usePermissionsStore} from "stores/permissionsStore";
import {FeatureIdent} from "src/models/AppFeature";
import ContextMenuItem from "pages/sidepanel/helper/ContextMenuItem.vue";
Expand Down
2 changes: 1 addition & 1 deletion src/pages/contentscript/ContentScriptPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import {onMounted, ref, watchEffect} from "vue";
import {useTabsStore} from "stores/tabsStore";
import {useTabsetService} from "src/services/TabsetService2";
import {useCommandExecutor} from "src/services/CommandExecutor";
import {AddTabToTabsetCommand} from "src/domain/tabs/AddTabToTabset";
import {AddTabToTabsetCommand} from "src/domain/tabs/AddTabToTabsetCommand"
import {Tab} from "src/models/Tab";
import {uid} from "quasar";
import {Tabset} from "src/models/Tabset";
Expand Down
11 changes: 6 additions & 5 deletions src/pages/mainpanel/MainPanelSpacesPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,7 @@ import {useSpacesStore} from "src/stores/spacesStore";
import {onMounted, ref, watchEffect} from "vue"
import _ from "lodash"
import {Space} from "src/models/Space"
import {Tabset} from "src/models/Tabset";
import {useRouter} from "vue-router";
import {Tabset, TabsetStatus} from "src/models/Tabset";
import {useTabsetService} from "src/services/TabsetService2";
import Analytics from "src/utils/google-analytics";
import {useUtils} from "src/services/Utils";
Expand Down Expand Up @@ -134,9 +133,11 @@ watchEffect(() => {
console.log("watching effect tabsets")
rows.value = []
_.forEach(sortedTabsets.value as Tabset[], (ts: Tabset) => {
rows.value.push({
tabset: ts.name,
})
if (ts.status !== TabsetStatus.DELETED) {
rows.value.push({
tabset: ts.name,
})
}
})
})
Expand Down
26 changes: 18 additions & 8 deletions src/pages/sidepanel/helper/FirstToolbarHelper.vue
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,24 @@
size="10px"
class="q-ml-sm"/>

<SidePanelToolbarButton
icon="o_add_circle"
:tooltip="newTabsetTooltip()"
color="warning"
class="q-ml-sm"
:class="{ shake: annimateNewTabsetButton }"
data-testid="addTabsetBtn"
@click="openNewTabsetDialog()"/>
<!-- <SidePanelToolbarButton-->
<!-- icon="o_add_circle"-->
<!-- :tooltip="newTabsetTooltip()"-->
<!-- color="warning"-->
<!-- class="q-ml-sm"-->
<!-- :class="{ shake: annimateNewTabsetButton }"-->
<!-- data-testid="addTabsetBtn"-->
<!-- @click="openNewTabsetDialog()"/>-->

<q-btn outline
label="New Tabset"
color="primary"
size="sm"
:class="{ shake: annimateNewTabsetButton }"
data-testid="addTabsetBtn"
@click="openNewTabsetDialog()"
class="q-ma-none q-px-sm q-py-none"
name="o_bookmark_add" />

</slot>
</div>
Expand Down
11 changes: 6 additions & 5 deletions src/services/ErrorHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@ export function useNotificationHandler() {

const {info, error} = useLogger()

const handleError = (error: any, type: NotificationType = NotificationType.TOAST) => {
console.log("showing error message: ", error ? error.toString() : 'unknown error')
const handleError = (err: any, type: NotificationType = NotificationType.TOAST) => {
const errorMsg = err ? err.toString() : 'unknown error'
console.log("showing error message: ", errorMsg)
console.trace()

//logtail.error(error ? error.toString() : 'unknown error', error)
error(error ? error.toString() : 'unknown error', error)
error(errorMsg /** todo pass actual error */)

switch (type) {
case NotificationType.NOTIFY:
Expand All @@ -26,11 +27,11 @@ export function useNotificationHandler() {
color: 'red-5',
textColor: 'white',
icon: 'error',
message: error ? error.toString() : 'unknown error'
message: errorMsg
})
break;
default:
useUiStore().createErrorToast(error ? error.toString() : 'unknown error')
useUiStore().createErrorToast(errorMsg)
}

}
Expand Down
2 changes: 1 addition & 1 deletion test/vitest/__tests__/domain/tabs/AddTabToTabset.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {afterEach, beforeEach, describe, expect, it, vi} from 'vitest';
import {createPinia, setActivePinia} from "pinia";
import ChromeApi from "src/services/ChromeApi";
import IndexedDbPersistenceService from "src/services/IndexedDbPersistenceService";
import {AddTabToTabsetCommand} from "src/domain/tabs/AddTabToTabset";
import {AddTabToTabsetCommand} from "src/domain/tabs/AddTabToTabsetCommand"
import {Tab} from "src/models/Tab";
import {CreateTabsetCommand} from "src/domain/tabsets/CreateTabset";
import {useTabsetService} from "src/services/TabsetService2";
Expand Down
2 changes: 1 addition & 1 deletion test/vitest/__tests__/domain/tabs/UpdateTabUrl.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {afterEach, beforeEach, describe, expect, it, vi} from 'vitest';
import {createPinia, setActivePinia} from "pinia";
import ChromeApi from "src/services/ChromeApi";
import IndexedDbPersistenceService from "src/services/IndexedDbPersistenceService";
import {AddTabToTabsetCommand} from "src/domain/tabs/AddTabToTabset";
import {AddTabToTabsetCommand} from "src/domain/tabs/AddTabToTabsetCommand"
import {Tab} from "src/models/Tab";
import {CreateTabsetCommand} from "src/domain/tabsets/CreateTabset";
import {useTabsetService} from "src/services/TabsetService2";
Expand Down
1 change: 0 additions & 1 deletion test/vitest/__tests__/domain/tabsets/CreateTabset.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import {installQuasarPlugin} from '@quasar/quasar-app-extension-testing-unit-vit
import {afterEach, beforeEach, describe, expect, it, vi} from 'vitest';
import {createPinia, setActivePinia} from "pinia";
import IndexedDbPersistenceService from "src/services/IndexedDbPersistenceService";
import {AddTabToTabsetCommand} from "src/domain/tabs/AddTabToTabset";
import {CreateTabsetCommand} from "src/domain/tabsets/CreateTabset";
import {useDB} from "src/services/usePersistenceService";
import {useTabsStore} from "stores/tabsStore";
Expand Down

0 comments on commit be48352

Please sign in to comment.