Skip to content

Commit 57b96f7

Browse files
feat(schema): URL reflects the selected instance so entry views are shareable
Old behaviour: selectInstance(dbId) mutated component state only -- the URL stayed on /content/schema/:className so an entry view couldn't be linked, bookmarked, or recovered via browser back. Add a nested route /content/schema/:className/instance/:dbId pointing at the same SchemaComponent. The single route.params subscription now keeps both selectedClass and selectedInstanceId in sync; a dbId in the URL forces the Entries tab so deep links render the instance browser instead of the Properties view. selectInstance / clearSelectedInstance / onInstanceLinkClick all router.navigate now so the URL is the single source of truth. Note: clicking a link inside an instance to another object can land us on a URL whose :className segment doesn't match the loaded instance's actual schema class. We don't fix the className up after-the-fact yet -- the per-instance "Referrals" section that needs the same load-then- recompute work is blocked on a new ContentService endpoint (filed separately).
1 parent c09373d commit 57b96f7

2 files changed

Lines changed: 36 additions & 4 deletions

File tree

projects/website-angular/src/app/app.routes.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,14 @@ export const routes: Routes = [
169169
),
170170
pathMatch: 'full',
171171
},
172+
{
173+
path: 'content/schema/:className/instance/:dbId',
174+
loadComponent: () =>
175+
import('./content/schema/schema.component').then(
176+
(m) => m.SchemaComponent
177+
),
178+
pathMatch: 'full',
179+
},
172180

173181
//Detail Pages
174182
{

projects/website-angular/src/app/content/schema/schema.component.ts

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,25 @@ export class SchemaComponent implements OnInit, OnDestroy {
8484
this.rebuildFlatTree();
8585
this.loading = false;
8686

87-
// Listen for route changes
87+
// Listen for route changes. The path can be either
88+
// /content/schema/:className
89+
// or
90+
// /content/schema/:className/instance/:dbId
91+
// so a single subscription has to keep both selectedClass and
92+
// selectedInstanceId in sync with the URL.
8893
this.route.params.pipe(takeUntil(this.destroy$)).subscribe((params) => {
8994
const className = params['className'] || 'DatabaseObject';
9095
if (className !== this.selectedClass) {
9196
this.selectClass(className);
9297
}
98+
const dbIdParam = params['dbId'];
99+
const dbId = dbIdParam != null ? Number(dbIdParam) : null;
100+
if (dbId !== this.selectedInstanceId) {
101+
this.selectedInstanceId = dbId;
102+
// If we deep-linked into an instance, make sure we're on the
103+
// Entries tab so the <app-instance-browser> renders.
104+
if (dbId != null) this.activeTab = 'entries';
105+
}
93106
});
94107
},
95108
error: () => {
@@ -364,14 +377,25 @@ export class SchemaComponent implements OnInit, OnDestroy {
364377
}
365378

366379
selectInstance(dbId: number) {
367-
this.selectedInstanceId = dbId;
380+
this.router.navigate(
381+
['/content/schema', this.selectedClass, 'instance', dbId],
382+
{ queryParams: { tab: 'entries' }, queryParamsHandling: 'merge' },
383+
);
368384
}
369385

370386
clearSelectedInstance() {
371-
this.selectedInstanceId = null;
387+
this.router.navigate(['/content/schema', this.selectedClass], {
388+
queryParams: { tab: 'entries' },
389+
});
372390
}
373391

374392
onInstanceLinkClick(dbId: number) {
375-
this.selectedInstanceId = dbId;
393+
// Followed-from links inside the instance browser may point to objects
394+
// of a different schema class; we'll fix the className segment after
395+
// the instance loads and reveals its real class.
396+
this.router.navigate(
397+
['/content/schema', this.selectedClass, 'instance', dbId],
398+
{ queryParams: { tab: 'entries' }, queryParamsHandling: 'merge' },
399+
);
376400
}
377401
}

0 commit comments

Comments
 (0)