Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 40 additions & 4 deletions apps/tauri/src/App.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script setup lang="ts">
import { computed, onMounted, onUnmounted } from "vue";
import { computed, onMounted, onUnmounted, ref } from "vue";
import { invoke } from "@tauri-apps/api/core";
import { open } from "@tauri-apps/plugin-dialog";
import { storeToRefs } from "pinia";
Expand All @@ -16,12 +16,14 @@ import WorkspaceEmptyHero from "./ui/WorkspaceEmptyHero.vue";
import QueryaDivider from "./ui/QueryaDivider.vue";
import ConnectionHome from "./ui/ConnectionHome.vue";
import TableObjectView from "./ui/TableObjectView.vue";
import PreferencesDialog from "./ui/PreferencesDialog.vue";

const shell = useShellStore();
const status = useShellStatusStore();
const connections = useConnectionsStore();
const nav = useShellNavStore();
const { surface } = storeToRefs(nav);
const prefsOpen = ref(false);
provideQueryaMotion();

const showEmpty = computed(() => surface.value === "empty");
Expand Down Expand Up @@ -53,6 +55,20 @@ function onNewConnection() {
});
}

function onNewConnectionFromUrl() {
status.setQueryMetrics({
message: "New connection from URL — form lands next",
busy: false,
});
}

function onNewFolder() {
status.setQueryMetrics({
message: "New folder — LocalDb folders land next",
busy: false,
});
}

function onLaunchDemo() {
connections.launchDemo();
}
Expand All @@ -61,13 +77,25 @@ function onOpenTour() {
status.setQueryMetrics({ message: "Tour stub", busy: false });
}

function onOpenPreferences() {
prefsOpen.value = true;
}

function onKeydown(e: KeyboardEvent) {
const mod = e.metaKey || e.ctrlKey;
if (!mod) return;
if (e.key.toLowerCase() === "b") {
e.preventDefault();
shell.toggleSidebar();
}
if (e.key === ",") {
e.preventDefault();
onOpenPreferences();
}
if (e.key.toLowerCase() === "n") {
e.preventDefault();
onNewConnection();
}
}

onMounted(async () => {
Expand Down Expand Up @@ -97,12 +125,19 @@ onUnmounted(() => {

<template>
<div class="app-frame" data-testid="main-screen">
<TitleBar />
<TitleBar
@new-connection="onNewConnection"
@new-connection-from-url="onNewConnectionFromUrl"
@open-sqlite="onOpenSqlite"
@open-preferences="onOpenPreferences"
@open-tour="onOpenTour"
@launch-demo="onLaunchDemo"
/>
<QueryaDivider />
<div class="body">
<ConnectionsPanel
@open-sqlite="onOpenSqlite"
@new-connection="onNewConnection"
@new-folder="onNewFolder"
/>
<main class="workspace">
<div class="workspace-body">
Expand All @@ -118,7 +153,8 @@ onUnmounted(() => {
</div>
</main>
</div>
<StatusBar />
<StatusBar @open-preferences="onOpenPreferences" />
<PreferencesDialog :open="prefsOpen" @close="prefsOpen = false" />
</div>
</template>

Expand Down
117 changes: 37 additions & 80 deletions apps/tauri/src/ui/ConnectionsPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ import { useShellNavStore } from "../stores/shellNav";
import { useObjectTreeStore } from "../stores/objectTree";
import { useQueryaMotion } from "../motion";
import SplitHandle from "./SplitHandle.vue";
import QueryaContextMenu, { type CtxItem } from "./QueryaContextMenu.vue";

const emit = defineEmits<{
openSqlite: [];
newConnection: [];
newFolder: [];
}>();

const shell = useShellStore();
Expand All @@ -24,7 +25,18 @@ const { objects, filter: objectFilter, loading, error } = storeToRefs(tree);
const motion = useQueryaMotion();
const filter = ref("");
const dragging = ref(false);
const menuOpen = ref(false);
const ctx = ref({ open: false, x: 0, y: 0 });

const ctxItems: CtxItem[] = [
{
id: "create",
label: "Create",
children: [
{ id: "new-connection", label: "New Connection" },
{ id: "new-folder", label: "New Folder" },
],
},
];

const filteredConnections = computed(() => {
const q = filter.value.trim().toLowerCase();
Expand Down Expand Up @@ -88,10 +100,17 @@ function onObjectChevron(name: string, e: MouseEvent) {
void tree.toggleColumns(name);
}

function onContextCreate(action: "connection" | "sqlite" | "folder") {
menuOpen.value = false;
if (action === "sqlite") emit("openSqlite");
else if (action === "connection") emit("newConnection");
function onPanelContext(e: MouseEvent) {
// Only empty fill / panel chrome — not rows (they get their own menus later).
const t = e.target as HTMLElement | null;
if (t?.closest(".conn-row, .node-row, .cols, input, button")) return;
e.preventDefault();
ctx.value = { open: true, x: e.clientX, y: e.clientY };
}

function onCtxSelect(id: string) {
if (id === "new-connection") emit("newConnection");
else if (id === "new-folder") emit("newFolder");
}

onUnmounted(() => {
Expand All @@ -107,7 +126,7 @@ onUnmounted(() => {
:style="panelStyle"
:aria-hidden="!shell.sidebarOpen"
>
<div class="inner" @contextmenu.prevent="menuOpen = true">
<div class="inner" @contextmenu="onPanelContext">
<div class="servers-header" data-testid="connections-servers-header">
<span class="servers-label">SERVERS</span>
<span class="count">{{ items.length }}</span>
Expand All @@ -125,10 +144,7 @@ onUnmounted(() => {

<div class="body">
<p v-if="!filteredConnections.length" class="empty-title">
{{ filter ? "No connections match" : "No connections yet" }}
</p>
<p v-if="!filteredConnections.length" class="empty-hint">
Right-click → Create, or use the empty workspace actions.
{{ filter ? `No connections match "${filter}"` : "No connections yet" }}
</p>

<ul
Expand Down Expand Up @@ -247,22 +263,16 @@ onUnmounted(() => {
</li>
</ul>
</div>

<div v-if="menuOpen" class="ctx" @click.stop>
<p class="ctx-label">Create</p>
<button type="button" @click="onContextCreate('connection')">
New Connection
</button>
<button type="button" @click="onContextCreate('sqlite')">
Open SQLite…
</button>
<button type="button" class="muted" disabled>New Folder</button>
<button type="button" class="dismiss" @click="menuOpen = false">
Close
</button>
</div>
</div>
<SplitHandle v-if="shell.sidebarOpen" @pointerdown="onResizeStart" />
<QueryaContextMenu
:open="ctx.open"
:x="ctx.x"
:y="ctx.y"
:items="ctxItems"
@close="ctx.open = false"
@select="onCtxSelect"
/>
</aside>
</template>

Expand Down Expand Up @@ -348,10 +358,10 @@ onUnmounted(() => {
.empty-title {
margin: 12px 4px 0;
font-size: 13px;
font-weight: 600;
font-weight: 500;
color: var(--q-muted-foreground);
}

.empty-hint,
.hint {
margin: 6px 4px 0;
font-size: 12px;
Expand Down Expand Up @@ -509,57 +519,4 @@ onUnmounted(() => {
font-family: var(--q-font-mono);
}

.ctx {
position: absolute;
left: 12px;
bottom: 12px;
z-index: 5;
min-width: 160px;
padding: 6px;
border-radius: var(--q-radius-control);
background: var(--q-surface);
border: 1px solid var(--q-border);
box-shadow: 0 8px 24px color-mix(in srgb, #000 35%, transparent);
display: flex;
flex-direction: column;
gap: 2px;
}

.ctx-label {
margin: 0;
padding: 4px 8px;
font-size: 10px;
font-weight: 700;
letter-spacing: 0.06em;
color: var(--q-muted-foreground);
text-transform: uppercase;
}

.ctx button {
appearance: none;
border: 0;
background: transparent;
text-align: left;
padding: 6px 8px;
border-radius: var(--q-radius-sm);
font: inherit;
font-size: 12px;
color: var(--q-foreground);
cursor: pointer;
}

.ctx button:hover:not(:disabled) {
background: var(--q-accent);
}

.ctx button:disabled,
.ctx .muted {
opacity: 0.45;
cursor: not-allowed;
}

.ctx .dismiss {
margin-top: 4px;
color: var(--q-muted-foreground);
}
</style>
Loading
Loading