Skip to content

Free, simple, and intuitive online database diagram editor and SQL generator.

Show comments in the sidebar as well (#1159)

1ilitee550b4117a6
diff --git a/src/components/EditorSidePanel/TablesTab/TablesTab.jsx b/src/components/EditorSidePanel/TablesTab/TablesTab.jsx
index b1b2fa15..06e3e172 100644
--- a/src/components/EditorSidePanel/TablesTab/TablesTab.jsx
+++ b/src/components/EditorSidePanel/TablesTab/TablesTab.jsx
@@ -7,6 +7,7 @@ import {
useSaveState,
useLayout,
useUndoRedo,
+ useSettings,
} from "../../../hooks";
import { Action, ObjectType, State } from "../../../data/constants";
import { useTranslation } from "react-i18next";
@@ -76,6 +77,7 @@ function TableListItem({ table }) {
const { layout } = useLayout();
const { updateTable } = useDiagram();
const { setUndoStack, setRedoStack } = useUndoRedo();
+ const { settings } = useSettings();
const { t } = useTranslation();
const toggleTableVisibility = (e) => {
@@ -105,11 +107,19 @@ function TableListItem({ table }) {
className="relative"
header={
<div className="flex items-center justify-between w-full">
- <div className="flex items-center gap-2 flex-1">
+ <div className="flex items-center gap-2 flex-1 min-w-0">
<DragHandle readOnly={layout.readOnly} id={table.id} />
- <div className="overflow-hidden text-ellipsis whitespace-nowrap">
+ <div className="overflow-hidden text-ellipsis whitespace-nowrap shrink-0 max-w-[60%]">
{table.name}
</div>
+ {settings.showComments && table.comment && (
+ <div
+ className="overflow-hidden text-ellipsis whitespace-nowrap min-w-0 flex-1 text-xs font-normal opacity-60"
+ title={table.comment}
+ >
+ {table.comment}
+ </div>
+ )}
</div>
<Button
size="small"
diff --git a/src/components/EditorSidePanel/ViewsTab/ViewsTab.jsx b/src/components/EditorSidePanel/ViewsTab/ViewsTab.jsx
index 0699eb01..9814ae5a 100644
--- a/src/components/EditorSidePanel/ViewsTab/ViewsTab.jsx
+++ b/src/components/EditorSidePanel/ViewsTab/ViewsTab.jsx
@@ -1,6 +1,12 @@
import { Collapse, Button } from "@douyinfe/semi-ui";
import { IconPlus, IconEyeOpened, IconEyeClosed } from "@douyinfe/semi-icons";
-import { useLayout, useSelect, useUndoRedo, useViews } from "../../../hooks";
+import {
+ useLayout,
+ useSelect,
+ useSettings,
+ useUndoRedo,
+ useViews,
+} from "../../../hooks";
import { Action, ObjectType } from "../../../data/constants";
import { useTranslation } from "react-i18next";
import SearchBar from "./SearchBar";
@@ -61,6 +67,7 @@ export default function ViewsTab() {
function ViewListItem({ view }) {
const { updateView } = useViews();
const { setUndoStack, setRedoStack } = useUndoRedo();
+ const { settings } = useSettings();
const { t } = useTranslation();
const toggleViewVisibility = (e) => {
@@ -88,9 +95,17 @@ function ViewListItem({ view }) {
header={
<div className="flex items-center justify-between w-full">
<div className="flex items-center gap-2 flex-1 min-w-0">
- <div className="overflow-hidden text-ellipsis whitespace-nowrap">
+ <div className="overflow-hidden text-ellipsis whitespace-nowrap shrink-0 max-w-[60%]">
{view.name}
</div>
+ {settings.showComments && view.comment && (
+ <div
+ className="overflow-hidden text-ellipsis whitespace-nowrap min-w-0 flex-1 text-xs font-normal opacity-60"
+ title={view.comment}
+ >
+ {view.comment}
+ </div>
+ )}
</div>
<Button
size="small"