feat(sidebar): show column nullability
This commit is contained in:
11 files changed
+197
-5
No files matched your search
@@ -7,7 +7,7 @@ import { useQueryStore } from "@/stores/queryStore";
|
||||
import { useSavedSqlStore } from "@/stores/savedSqlStore";
|
||||
import { useSettingsStore } from "@/stores/settingsStore";
|
||||
import { useToast } from "@/composables/useToast";
|
||||
import type { ObjectSourceKind, QueryTab, TableInfo, TableNameFilter, TreeNode, TreeNodeType } from "@/types/database";
|
||||
import type { ColumnInfo, ObjectSourceKind, QueryTab, TableInfo, TableNameFilter, TreeNode, TreeNodeType } from "@/types/database";
|
||||
import type { ElasticsearchIndexMetadataKind } from "@/lib/backend/tauri";
|
||||
import {
|
||||
filterLocallySearchedTables,
|
||||
@@ -94,7 +94,7 @@ import { createSidebarLayoutMonitor, type SidebarExpandedConnectionInfo } from "
|
||||
import { disconnectSidebarConnections } from "@/lib/sidebar/sidebarConnectionDisconnect";
|
||||
import { compileSearchRegex } from "@/lib/common/searchPattern";
|
||||
|
||||
const { t } = useI18n();
|
||||
const { t, locale } = useI18n();
|
||||
const store = useConnectionStore();
|
||||
const queryStore = useQueryStore();
|
||||
const savedSqlStore = useSavedSqlStore();
|
||||
@@ -884,6 +884,10 @@ function measureSidebarCommentLabelWidths() {
|
||||
const context = document.createElement("canvas").getContext("2d");
|
||||
if (!context) return;
|
||||
const style = window.getComputedStyle(rootRef.value);
|
||||
context.font = `${style.fontWeight} 10px ${style.fontFamily}`;
|
||||
const badgePaddingAndGapWidth = 16;
|
||||
const nullableBadgeWidth = context.measureText(t("structureEditor.nullable")).width + badgePaddingAndGapWidth;
|
||||
const notNullBadgeWidth = context.measureText(t("structureEditor.notNull")).width + badgePaddingAndGapWidth;
|
||||
context.font = style.font || `${style.fontWeight} ${style.fontSize} ${style.fontFamily}`;
|
||||
sidebarCommentLabelWidths.value = alignedSidebarCommentLabelWidths(
|
||||
flatNodes.value.map(({ id, depth, node }) => ({
|
||||
@@ -891,7 +895,7 @@ function measureSidebarCommentLabelWidths() {
|
||||
depth,
|
||||
alignable: isSidebarCommentAlignableNode(node),
|
||||
hasComment: !!sidebarTreeNodeComment(node, settingsStore.editorSettings.sidebarShowConnectionNotes),
|
||||
labelWidth: context.measureText(sidebarCommentLabel(node)).width,
|
||||
labelWidth: context.measureText(sidebarCommentLabel(node)).width + (node.type === "column" && node.meta ? ((node.meta as ColumnInfo).is_nullable ? nullableBadgeWidth : notNullBadgeWidth) : 0),
|
||||
})),
|
||||
);
|
||||
}
|
||||
@@ -947,6 +951,7 @@ function scheduleSidebarTreeContentWidthMeasure() {
|
||||
watch(
|
||||
[
|
||||
flatNodes,
|
||||
locale,
|
||||
() => settingsStore.editorSettings.sidebarObjectInfoMode,
|
||||
() => settingsStore.editorSettings.sidebarShowConnectionNotes,
|
||||
() => settingsStore.editorSettings.sidebarHiddenTablePrefixes,
|
||||
|
||||
Reference in new issue
Block a user