feat(web): show DBX brand logo in toolbar on web
This commit is contained in:
1 parent
e08eda972b
commit
ce57e8d9c0
2 files changed
+175
No files matched your search
@@ -10,6 +10,7 @@ import WindowControls from "@/components/layout/WindowControls.vue";
|
|||||||
import ExportProgressPopover from "@/components/export/ExportProgressPopover.vue";
|
import ExportProgressPopover from "@/components/export/ExportProgressPopover.vue";
|
||||||
import ToolbarUpdateIcon from "@/components/layout/ToolbarUpdateIcon.vue";
|
import ToolbarUpdateIcon from "@/components/layout/ToolbarUpdateIcon.vue";
|
||||||
import PluginShortcutToolbar from "@/components/plugins/PluginShortcutToolbar.vue";
|
import PluginShortcutToolbar from "@/components/plugins/PluginShortcutToolbar.vue";
|
||||||
|
import AppLogo from "@/components/icons/AppLogo.vue";
|
||||||
import { MAC_TRAFFIC_LIGHT_X, macTrafficLightInsetPaddingForScale, shouldReserveMacTrafficLightInset, useWindowControls } from "@/composables/useWindowControls";
|
import { MAC_TRAFFIC_LIGHT_X, macTrafficLightInsetPaddingForScale, shouldReserveMacTrafficLightInset, useWindowControls } from "@/composables/useWindowControls";
|
||||||
import { useToast } from "@/composables/useToast";
|
import { useToast } from "@/composables/useToast";
|
||||||
import { useSettingsStore } from "@/stores/settingsStore";
|
import { useSettingsStore } from "@/stores/settingsStore";
|
||||||
@@ -553,6 +554,18 @@ const toolbarStyle = computed(() => {
|
|||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div ref="toolbarEl" class="app-toolbar h-10 flex items-center gap-1 px-2 border-b bg-muted/30 shrink-0 overflow-hidden" :style="toolbarStyle" data-tauri-drag-region @dblclick="onToolbarDblClick">
|
<div ref="toolbarEl" class="app-toolbar h-10 flex items-center gap-1 px-2 border-b bg-muted/30 shrink-0 overflow-hidden" :style="toolbarStyle" data-tauri-drag-region @dblclick="onToolbarDblClick">
|
||||||
|
<a
|
||||||
|
v-if="!isDesktop"
|
||||||
|
href="https://dbxio.com"
|
||||||
|
target="_blank"
|
||||||
|
rel="noopener noreferrer"
|
||||||
|
class="flex items-center gap-1.5 h-8 px-2 rounded-md hover:bg-muted/60 transition-colors shrink-0 select-none mr-0.5 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring"
|
||||||
|
title="DBX"
|
||||||
|
data-testid="web-brand-logo"
|
||||||
|
>
|
||||||
|
<AppLogo class="h-5 w-5 rounded shrink-0 pointer-events-none" />
|
||||||
|
<span class="font-bold text-xs tracking-tight text-foreground/90 translate-y-px">DBX</span>
|
||||||
|
</a>
|
||||||
<Tooltip v-if="showSidebarExpand">
|
<Tooltip v-if="showSidebarExpand">
|
||||||
<TooltipTrigger as-child>
|
<TooltipTrigger as-child>
|
||||||
<Button variant="ghost" size="icon" class="toolbar-action-button h-8 w-8 shrink-0" :aria-label="t('sidebar.expand')" @click="emit('expand-sidebar')">
|
<Button variant="ghost" size="icon" class="toolbar-action-button h-8 w-8 shrink-0" :aria-label="t('sidebar.expand')" @click="emit('expand-sidebar')">
|
||||||
|
|||||||
@@ -0,0 +1,162 @@
|
|||||||
|
// @vitest-environment happy-dom
|
||||||
|
import { createApp, nextTick } from "vue";
|
||||||
|
import { createPinia, setActivePinia } from "pinia";
|
||||||
|
import { createI18n } from "vue-i18n";
|
||||||
|
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
||||||
|
|
||||||
|
let mockIsTauriRuntime = false;
|
||||||
|
|
||||||
|
vi.mock("@/lib/backend/tauriRuntime", () => ({
|
||||||
|
isTauriRuntime: () => mockIsTauriRuntime,
|
||||||
|
}));
|
||||||
|
vi.mock("@tauri-apps/api/core", () => ({ invoke: vi.fn(async () => undefined) }));
|
||||||
|
vi.mock("@tauri-apps/api/event", () => ({
|
||||||
|
listen: vi.fn(async () => () => {}),
|
||||||
|
emit: vi.fn(async () => undefined),
|
||||||
|
}));
|
||||||
|
vi.mock("@tauri-apps/api/webviewWindow", () => ({
|
||||||
|
getAllWebviewWindows: vi.fn(async () => []),
|
||||||
|
WebviewWindow: { getByLabel: vi.fn(async () => null) },
|
||||||
|
}));
|
||||||
|
vi.mock("@tauri-apps/api/window", () => ({
|
||||||
|
getCurrentWindow: () => ({
|
||||||
|
label: "main",
|
||||||
|
isMaximized: async () => false,
|
||||||
|
isFullscreen: async () => false,
|
||||||
|
isAlwaysOnTop: async () => false,
|
||||||
|
setAlwaysOnTop: async () => {},
|
||||||
|
onResized: async () => () => {},
|
||||||
|
onFocusChanged: async () => () => {},
|
||||||
|
minimize: async () => {},
|
||||||
|
toggleMaximize: async () => {},
|
||||||
|
}),
|
||||||
|
}));
|
||||||
|
|
||||||
|
vi.mock("@/components/ui/button", () => ({
|
||||||
|
Button: { name: "ButtonStub", props: ["ariaLabel"], template: `<button :aria-label="ariaLabel"><slot /></button>` },
|
||||||
|
}));
|
||||||
|
vi.mock("@/components/ui/tooltip", () => ({
|
||||||
|
Tooltip: { name: "TooltipStub", template: `<span><slot /></span>` },
|
||||||
|
TooltipTrigger: { name: "TooltipTriggerStub", template: `<span><slot /></span>` },
|
||||||
|
TooltipContent: { name: "TooltipContentStub", template: `<span><slot /></span>` },
|
||||||
|
}));
|
||||||
|
vi.mock("@/components/ui/LightDropdown.vue", () => ({
|
||||||
|
default: { name: "LightDropdownStub", template: `<div />` },
|
||||||
|
}));
|
||||||
|
vi.mock("@/components/layout/WindowControls.vue", () => ({
|
||||||
|
default: { name: "WindowControlsStub", template: `<div />` },
|
||||||
|
}));
|
||||||
|
vi.mock("@/components/export/ExportProgressPopover.vue", () => ({
|
||||||
|
default: { name: "ExportProgressPopoverStub", template: `<div />` },
|
||||||
|
}));
|
||||||
|
vi.mock("@/components/layout/ToolbarUpdateIcon.vue", () => ({
|
||||||
|
default: { name: "ToolbarUpdateIconStub", template: `<span />` },
|
||||||
|
}));
|
||||||
|
|
||||||
|
import AppToolbar from "../AppToolbar.vue";
|
||||||
|
|
||||||
|
const defaultToolbarProps = {
|
||||||
|
isDark: false,
|
||||||
|
themeMode: "light" as const,
|
||||||
|
showSidebarExpand: false,
|
||||||
|
showAiPanel: false,
|
||||||
|
activeAiRunCount: 0,
|
||||||
|
awaitingAiRunCount: 0,
|
||||||
|
showHistory: false,
|
||||||
|
showSqlLibrary: false,
|
||||||
|
sqlLibrarySaveFeedbackId: 0,
|
||||||
|
showSqlFilePanel: false,
|
||||||
|
showDriverStore: false,
|
||||||
|
showPluginCenter: false,
|
||||||
|
showSettingsPage: false,
|
||||||
|
checkingUpdates: false,
|
||||||
|
hasUpdateAvailable: false,
|
||||||
|
isDownloadingUpdate: false,
|
||||||
|
downloadProgress: null,
|
||||||
|
updateReadyToInstall: false,
|
||||||
|
updateReady: false,
|
||||||
|
agentDriverUpdateCount: 0,
|
||||||
|
hasMcpUpdateAvailable: false,
|
||||||
|
hasConnections: false,
|
||||||
|
canNewQuery: false,
|
||||||
|
hasSqlFileConnections: false,
|
||||||
|
};
|
||||||
|
|
||||||
|
let pinia: ReturnType<typeof createPinia>;
|
||||||
|
|
||||||
|
function mount(props: Record<string, unknown> = {}) {
|
||||||
|
const host = document.createElement("div");
|
||||||
|
document.body.appendChild(host);
|
||||||
|
const app = createApp(AppToolbar, {
|
||||||
|
...defaultToolbarProps,
|
||||||
|
...props,
|
||||||
|
});
|
||||||
|
app.use(pinia);
|
||||||
|
app.use(
|
||||||
|
createI18n({
|
||||||
|
legacy: false,
|
||||||
|
locale: "en",
|
||||||
|
missingWarn: false,
|
||||||
|
fallbackWarn: false,
|
||||||
|
messages: {
|
||||||
|
en: {
|
||||||
|
toolbar: {
|
||||||
|
newConnection: "New Connection",
|
||||||
|
newQuery: "New Query",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
app.mount(host);
|
||||||
|
return {
|
||||||
|
host,
|
||||||
|
unmount: () => {
|
||||||
|
app.unmount();
|
||||||
|
host.remove();
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
describe("AppToolbar web branding (#8703)", () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
document.body.innerHTML = "";
|
||||||
|
mockIsTauriRuntime = false;
|
||||||
|
pinia = createPinia();
|
||||||
|
setActivePinia(pinia);
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
document.body.innerHTML = "";
|
||||||
|
});
|
||||||
|
|
||||||
|
it("renders the DBX brand logo and title on web mode", async () => {
|
||||||
|
mockIsTauriRuntime = false;
|
||||||
|
const { host, unmount } = mount();
|
||||||
|
await nextTick();
|
||||||
|
|
||||||
|
const brandEl = host.querySelector('[data-testid="web-brand-logo"]');
|
||||||
|
expect(brandEl).not.toBeNull();
|
||||||
|
expect(brandEl?.getAttribute("href")).toBe("https://dbxio.com");
|
||||||
|
expect(brandEl?.getAttribute("target")).toBe("_blank");
|
||||||
|
expect(brandEl?.getAttribute("rel")).toBe("noopener noreferrer");
|
||||||
|
expect(brandEl?.textContent).toContain("DBX");
|
||||||
|
|
||||||
|
const logoImg = brandEl?.querySelector("img");
|
||||||
|
expect(logoImg).not.toBeNull();
|
||||||
|
expect(logoImg?.getAttribute("alt")).toBe("DBX");
|
||||||
|
|
||||||
|
unmount();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("does not render the web DBX brand logo in desktop mode", async () => {
|
||||||
|
mockIsTauriRuntime = true;
|
||||||
|
const { host, unmount } = mount();
|
||||||
|
await nextTick();
|
||||||
|
|
||||||
|
const brandEl = host.querySelector('[data-testid="web-brand-logo"]');
|
||||||
|
expect(brandEl).toBeNull();
|
||||||
|
|
||||||
|
unmount();
|
||||||
|
});
|
||||||
|
});
|
||||||
Reference in new issue
Block a user