Skip to content

Commit b707b75

Browse files
authored
Merge pull request #54 from delegateas/patches/querystrings
Query params are back, for easy sharing via links
2 parents 0c447eb + 3868cdf commit b707b75

14 files changed

Lines changed: 75 additions & 14 deletions

Website/components/datamodelview/Attributes.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { useState } from "react"
77
import { ArrowUpDown, ArrowUp, ArrowDown, EyeOff, Eye, Search, X } from "lucide-react"
88
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "./../ui/select"
99
import { Input } from "../ui/input"
10-
import { AttributeDetails } from "./../entity/AttributeDetails"
10+
import { AttributeDetails } from "./entity/AttributeDetails"
1111
import BooleanAttribute from "./../attributes/BooleanAttribute"
1212
import ChoiceAttribute from "./../attributes/ChoiceAttribute"
1313
import DateTimeAttribute from "./../attributes/DateTimeAttribute"

Website/components/datamodelview/DatamodelView.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import { List } from "./List";
1010
import { TimeSlicedSearch } from "./TimeSlicedSearch";
1111
import React, { useState, useEffect, useRef, useCallback } from "react";
1212
import { useDatamodelData, useDatamodelDataDispatch } from "@/contexts/DatamodelDataContext";
13+
import { updateURL } from "@/lib/url-utils";
14+
import { useSearchParams } from "next/navigation";
1315

1416
export function DatamodelView() {
1517
const dispatch = useSidebarDispatch();
@@ -38,6 +40,7 @@ function DatamodelViewContent() {
3840

3941
// Calculate total search results
4042
const totalResults = filtered.length > 0 ? filtered.filter(item => item.type === 'entity').length : 0;
43+
const initialLocalValue = useSearchParams().get('globalsearch') || "";
4144

4245
// Isolated search handlers - these don't depend on component state
4346
const handleSearch = useCallback((searchValue: string) => {
@@ -49,6 +52,7 @@ function DatamodelViewContent() {
4952
datamodelDataDispatch({ type: "SET_FILTERED", payload: [] });
5053
}
5154
}
55+
updateURL({ query: { globalsearch: searchValue.length >= 3 ? searchValue : "" } })
5256
datamodelDataDispatch({ type: "SET_SEARCH", payload: searchValue.length >= 3 ? searchValue : "" });
5357
setCurrentSearchIndex(searchValue.length >= 3 ? 1 : 0); // Reset to first result when searching, 0 when cleared
5458
}, [groups, datamodelDataDispatch]);
@@ -207,6 +211,7 @@ function DatamodelViewContent() {
207211
onLoadingChange={handleLoadingChange}
208212
onNavigateNext={handleNavigateNext}
209213
onNavigatePrevious={handleNavigatePrevious}
214+
initialLocalValue={initialLocalValue}
210215
currentIndex={currentSearchIndex}
211216
totalResults={totalResults}
212217
/>

Website/components/datamodelview/List.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { useVirtualizer } from '@tanstack/react-virtual';
55
import { Section } from "./Section";
66
import { useDatamodelData } from "@/contexts/DatamodelDataContext";
77
import { AttributeType, EntityType, GroupType } from "@/lib/Types";
8+
import { updateURL } from "@/lib/url-utils";
89

910
interface IListProps {
1011
}
@@ -84,7 +85,7 @@ export const List = ({ }: IListProps) => {
8485
return item.type === 'group' ? 92 : 300;
8586
},
8687
// Override scroll behavior to prevent jumping during tab switches
87-
scrollToFn: (offset, options) => {
88+
scrollToFn: (offset) => {
8889
// When switching tabs during search, don't change scroll position
8990
if (isTabSwitching.current && !isIntentionalScroll.current) {
9091
return;
@@ -98,7 +99,6 @@ export const List = ({ }: IListProps) => {
9899
// Default scroll behavior for other cases
99100
const scrollElement = parentRef.current;
100101
if (scrollElement) {
101-
console.log("setting scroll to: " + offset + " - " + options.adjustments)
102102
scrollElement.scrollTop = offset;
103103
}
104104
},
@@ -235,6 +235,7 @@ export const List = ({ }: IListProps) => {
235235
const item = flatItems[firstVisibleItem.index];
236236
if (item?.type === 'entity') {
237237
if (item.entity.SchemaName !== datamodelView.currentSection) {
238+
updateURL({ query: { group: item.group.Name, section: item.entity.SchemaName } });
238239
dispatch({ type: "SET_CURRENT_GROUP", payload: item.group.Name });
239240
dispatch({ type: "SET_CURRENT_SECTION", payload: item.entity.SchemaName });
240241
}

Website/components/datamodelview/Relationships.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import { EntityType } from "@/lib/Types"
44
import { TableHeader, TableRow, TableHead, TableBody, TableCell, Table } from "../ui/table"
55
import { Button } from "../ui/button"
6-
import { CascadeConfiguration } from "../entity/CascadeConfiguration"
6+
import { CascadeConfiguration } from "./entity/CascadeConfiguration"
77
import { useState } from "react"
88
import { ArrowUpDown, ArrowUp, ArrowDown, Search, X } from "lucide-react"
99
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "../ui/select"

Website/components/datamodelview/Section.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
import { EntityType, GroupType } from "@/lib/Types"
44
import { Tabs, TabsList, TabsTrigger, TabsContent } from "../ui/tabs"
5-
import { EntityHeader } from "../entity/EntityHeader"
6-
import { SecurityRoles } from "../entity/SecurityRoles"
5+
import { EntityHeader } from "./entity/EntityHeader"
6+
import { SecurityRoles } from "./entity/SecurityRoles"
77
import Keys from "./Keys"
88
import { KeyRound, Tags, Unplug } from "lucide-react"
99
import { Attributes } from "./Attributes"
@@ -28,7 +28,7 @@ export const Section = React.memo(
2828
// Handle tab changes to notify parent component
2929
const handleTabChange = React.useCallback((value: string) => {
3030
if (onTabChange) {
31-
onTabChange(true); // Signal that tab switching is starting
31+
onTabChange(true);
3232
}
3333
setTab(value);
3434
}, [onTabChange]);

Website/components/datamodelview/TimeSlicedSearch.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ interface TimeSlicedSearchProps {
1212
onLoadingChange: (loading: boolean) => void;
1313
onNavigateNext?: () => void;
1414
onNavigatePrevious?: () => void;
15+
initialLocalValue: string;
1516
currentIndex?: number;
1617
totalResults?: number;
1718
placeholder?: string;
@@ -23,11 +24,12 @@ export const TimeSlicedSearch = ({
2324
onLoadingChange,
2425
onNavigateNext,
2526
onNavigatePrevious,
27+
initialLocalValue,
2628
currentIndex = 0,
2729
totalResults = 0,
2830
placeholder = "Search attributes...",
2931
}: TimeSlicedSearchProps) => {
30-
const [localValue, setLocalValue] = useState('');
32+
const [localValue, setLocalValue] = useState(initialLocalValue);
3133
const [isTyping, setIsTyping] = useState(false);
3234
const [portalRoot, setPortalRoot] = useState<HTMLElement | null>(null);
3335
const [lastValidSearch, setLastValidSearch] = useState('');

Website/components/entity/AttributeDetails.tsx renamed to Website/components/datamodelview/entity/AttributeDetails.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import { AttributeType, CalculationMethods, RequiredLevel } from "@/lib/Types";
44
import { Calculator, CircleAlert, CirclePlus, Eye, Lock, Sigma, Zap } from "lucide-react";
5-
import { HybridTooltip, HybridTooltipContent, HybridTooltipTrigger } from "../ui/hybridtooltop";
5+
import { HybridTooltip, HybridTooltipContent, HybridTooltipTrigger } from "../../ui/hybridtooltop";
66

77
export function AttributeDetails({ attribute }: { attribute: AttributeType }) {
88
const details = [];

Website/components/entity/CascadeConfiguration.tsx renamed to Website/components/datamodelview/entity/CascadeConfiguration.tsx

File renamed without changes.

Website/components/entity/EntityDetails.tsx renamed to Website/components/datamodelview/entity/EntityDetails.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import { EntityType, OwnershipType } from "@/lib/Types";
44
import { Eye, ClipboardList, Paperclip, Building, Users } from "lucide-react";
5-
import { HybridTooltip, HybridTooltipContent, HybridTooltipTrigger } from "../ui/hybridtooltop";
5+
import { HybridTooltip, HybridTooltipContent, HybridTooltipTrigger } from "../../ui/hybridtooltop";
66

77
type EntityDetailType = {
88
icon: JSX.Element;
File renamed without changes.

0 commit comments

Comments
 (0)