fix(databases): align database header with table row list in sidebar tree
This commit is contained in:
@@ -28,25 +28,17 @@ type Selection = {
|
|||||||
|
|
||||||
export default function DataTablesPage() {
|
export default function DataTablesPage() {
|
||||||
const params = useParams();
|
const params = useParams();
|
||||||
const searchParams = useSearchParams();
|
|
||||||
const projectId = params.projectId as string;
|
const projectId = params.projectId as string;
|
||||||
const targetDbId = searchParams.get("db");
|
|
||||||
|
|
||||||
const { anatomy, loading, error } = useAnatomy(projectId);
|
const { anatomy, loading, error } = useAnatomy(projectId);
|
||||||
|
|
||||||
const databases = anatomy?.infrastructure?.databases ?? [];
|
const databases = anatomy?.infrastructure?.databases ?? [];
|
||||||
|
|
||||||
// If targetDbId is in the URL, only show that database.
|
|
||||||
// Otherwise, default to the first database in the list if available.
|
|
||||||
const activeDbId =
|
|
||||||
targetDbId || (databases.length > 0 ? databases[0].uuid : null);
|
|
||||||
const activeDatabases = databases.filter((db) => db.uuid === activeDbId);
|
|
||||||
|
|
||||||
const [selection, setSelection] = useState<Selection>(null);
|
const [selection, setSelection] = useState<Selection>(null);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setSelection(null);
|
setSelection(null);
|
||||||
}, [projectId, targetDbId]);
|
}, [projectId]);
|
||||||
|
|
||||||
const showLoading = loading && !anatomy;
|
const showLoading = loading && !anatomy;
|
||||||
|
|
||||||
@@ -130,7 +122,7 @@ export default function DataTablesPage() {
|
|||||||
display: "flex",
|
display: "flex",
|
||||||
alignItems: "center",
|
alignItems: "center",
|
||||||
justifyContent: "space-between",
|
justifyContent: "space-between",
|
||||||
padding: "20px 20px 12px 20px",
|
padding: "10px 20px",
|
||||||
position: "sticky",
|
position: "sticky",
|
||||||
top: 0,
|
top: 0,
|
||||||
background: THEME.cardBg,
|
background: THEME.cardBg,
|
||||||
@@ -159,7 +151,7 @@ export default function DataTablesPage() {
|
|||||||
padding: "0 20px 20px 20px",
|
padding: "0 20px 20px 20px",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{activeDatabases.length === 0 && (
|
{databases.length === 0 && (
|
||||||
<div
|
<div
|
||||||
style={{
|
style={{
|
||||||
padding: "10px 12px",
|
padding: "10px 12px",
|
||||||
@@ -187,7 +179,7 @@ export default function DataTablesPage() {
|
|||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
{activeDatabases.map((db) => {
|
{databases.map((db) => {
|
||||||
return (
|
return (
|
||||||
<article
|
<article
|
||||||
key={db.uuid}
|
key={db.uuid}
|
||||||
@@ -203,7 +195,7 @@ export default function DataTablesPage() {
|
|||||||
alignItems: "center",
|
alignItems: "center",
|
||||||
gap: 8,
|
gap: 8,
|
||||||
width: "100%",
|
width: "100%",
|
||||||
padding: "16px 20px 8px",
|
padding: "16px 14px 12px",
|
||||||
background: "transparent",
|
background: "transparent",
|
||||||
border: "none",
|
border: "none",
|
||||||
font: "inherit",
|
font: "inherit",
|
||||||
@@ -225,7 +217,7 @@ export default function DataTablesPage() {
|
|||||||
/>
|
/>
|
||||||
</span>
|
</span>
|
||||||
<Database
|
<Database
|
||||||
size={13}
|
size={16}
|
||||||
style={{ color: THEME.mid, flexShrink: 0 }}
|
style={{ color: THEME.mid, flexShrink: 0 }}
|
||||||
/>
|
/>
|
||||||
<div
|
<div
|
||||||
|
|||||||
@@ -250,9 +250,9 @@ const list: React.CSSProperties = {
|
|||||||
const row: React.CSSProperties = {
|
const row: React.CSSProperties = {
|
||||||
display: "flex",
|
display: "flex",
|
||||||
alignItems: "center",
|
alignItems: "center",
|
||||||
gap: 6,
|
gap: 8,
|
||||||
width: "fit-content",
|
width: "fit-content",
|
||||||
padding: "4px 8px 4px 0",
|
padding: "4px 8px 4px 6px",
|
||||||
border: "1px solid transparent",
|
border: "1px solid transparent",
|
||||||
borderRadius: THEME.radiusSm,
|
borderRadius: THEME.radiusSm,
|
||||||
cursor: "pointer",
|
cursor: "pointer",
|
||||||
|
|||||||
Reference in New Issue
Block a user