Skip to content
Open
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
10 changes: 3 additions & 7 deletions ui/chen/components/ConsolePanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const props = defineProps<{
tab: ChenPromptConsoleTab;
contextLabel: string;
promptLabel: string;
canCopy: boolean;
}>();

const emit = defineEmits<{
Expand Down Expand Up @@ -78,11 +79,6 @@ function handleKeydown(event: KeyboardEvent) {
run();
return;
}
if (event.key === "Enter" && pendingSqlValue.value.trimEnd().endsWith(";")) {
event.preventDefault();
run();
return;
}
if (event.key === "ArrowUp" && !event.shiftKey && inputRef.value?.selectionStart === 0) {
event.preventDefault();
moveHistory(-1);
Expand Down Expand Up @@ -213,7 +209,7 @@ defineExpose({ focus: () => inputRef.value?.focus() });
<span class="font-medium text-highlighted">Result {{ resultIndex + 1 }}</span>
<span class="text-muted">{{ resultSummary(result) }}</span>
</div>
<ConsoleResultGrid :dataset="result.data" :style="{ height: gridHeight(result) }" />
<ConsoleResultGrid :dataset="result.data" :can-copy="canCopy" :style="{ height: gridHeight(result) }" />
</div>

<div
Expand Down Expand Up @@ -241,7 +237,7 @@ defineExpose({ focus: () => inputRef.value?.focus() });
class="max-h-32 min-h-7 flex-1 resize-none bg-transparent py-1 text-[var(--app-fg)] outline-none placeholder:text-[var(--app-muted)]"
:disabled="busy"
rows="1"
placeholder="Enter SQL; finish with ; or press Cmd/Ctrl+Enter"
placeholder="Enter SQL; press Cmd/Ctrl+Enter to run"
spellcheck="false"
@keydown="handleKeydown"
/>
Expand Down
19 changes: 15 additions & 4 deletions ui/chen/components/ConsoleResultGrid.client.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,15 @@ import { AgGridVue } from "ag-grid-vue3";
import "ag-grid-community/styles/ag-grid.css";
import "ag-grid-community/styles/ag-theme-balham.css";

const props = defineProps<{
dataset: ChenDataViewDataset;
}>();
const props = withDefaults(
defineProps<{
dataset: ChenDataViewDataset;
canCopy?: boolean;
}>(),
{
canCopy: false
}
);

ModuleRegistry.registerModules([AllCommunityModule]);

Expand Down Expand Up @@ -42,6 +48,10 @@ function handleGridReady(event: GridReadyEvent) {
fitColumns(event.api);
}

function handleCopy(event: ClipboardEvent) {
if (!props.canCopy) event.preventDefault();
}

watch([columnDefs, () => props.dataset.data], async () => {
const api = gridApi.value;
if (!api) return;
Expand All @@ -53,7 +63,7 @@ watch([columnDefs, () => props.dataset.data], async () => {
</script>

<template>
<div class="ag-theme-balham chen-console-grid min-h-0 w-full">
<div class="ag-theme-balham chen-console-grid min-h-0 w-full" @copy="handleCopy">
<AgGridVue
class="h-full w-full"
theme="legacy"
Expand All @@ -63,6 +73,7 @@ watch([columnDefs, () => props.dataset.data], async () => {
:row-height="28"
:header-height="32"
:animate-rows="false"
:enable-cell-text-selection="canCopy"
:suppress-cell-focus="false"
:ensure-dom-order="true"
@grid-ready="handleGridReady"
Expand Down
4 changes: 3 additions & 1 deletion ui/chen/composables/useChenQueryConsole.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,9 @@ export function useChenQueryConsole(
if (tab.kind === "console" && packet.data?.inQuery === false) {
const entry = activeConsoleEntry(tab);
if (entry) {
if (entry.status === "cancelling") entry.status = "cancelled";
const executionStatus = packet.data.executionStatus;
if (entry.status === "cancelling" || executionStatus === "cancelled") entry.status = "cancelled";
else if (executionStatus === "error") entry.status = "error";
else if (entry.status === "running") entry.status = "success";
entry.completedAt = Date.now();
tab.activeTimelineEntryId = "";
Expand Down
1 change: 1 addition & 0 deletions ui/chen/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ export type ChenSqlHints = Record<string, string[]>;
export interface ChenConsoleState {
loading?: boolean;
inQuery?: boolean;
executionStatus?: ChenConsoleExecutionStatus;
editorLoading?: boolean;
canCancel?: boolean;
currentContext?: string;
Expand Down
1 change: 1 addition & 0 deletions ui/chen/workspaces/DatabaseSessionSurface.vue
Original file line number Diff line number Diff line change
Expand Up @@ -763,6 +763,7 @@ defineExpose({ focus });
:tab="activeConsoleTab"
:context-label="currentContextLabel"
:prompt-label="consolePromptLabel"
:can-copy="auth.profile.value?.canCopy === true"
@run="runQueryTab"
@cancel="cancelQueryLikeTab"
@clear="clearConsoleTranscript"
Expand Down
Loading