diff --git a/.changeset/39439-record-share-object-column.md b/.changeset/39439-record-share-object-column.md new file mode 100644 index 00000000000..813c68fcb71 --- /dev/null +++ b/.changeset/39439-record-share-object-column.md @@ -0,0 +1,13 @@ +--- +'@objectstack/plugin-sharing': patch +--- + +feat(plugin-sharing): Setup → Record Shares names the object each grant is about + +Clause-②: no +Metadata-protocol: none + +Who sees it: an administrator on Setup → Record Shares (`sys_record_share`). + +- **The All view gains an Object column** right after Record, and the By Object view now opens with it. The cell draws the object's icon and label (for example 联系人 / Contact), never its API name, so a row reading a person's name says which kind of record was shared. +- `sys_record_share.object_name` declares the `object-ref` display widget, the declaration `sys_assignment_rule`, `sys_webhook` and `sys_notification` already carry on their object-name text fields. A display hint only: the stored column, the read-only data API and every other view are unchanged, and no view groups on the column. diff --git a/packages/plugins/plugin-sharing/src/objects/sys-record-share.object-column-39439.test.ts b/packages/plugins/plugin-sharing/src/objects/sys-record-share.object-column-39439.test.ts new file mode 100644 index 00000000000..5ebd787a4d6 --- /dev/null +++ b/packages/plugins/plugin-sharing/src/objects/sys-record-share.object-column-39439.test.ts @@ -0,0 +1,72 @@ +// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. + +import { describe, it, expect } from 'vitest'; +import { SysRecordShare } from './sys-record-share.object.js'; +import { SysSharingRule } from './sys-sharing-rule.object.js'; + +/** + * [#39439] Setup's share lists say which object each grant is about. + * + * A row on Setup → Record Shares read 「Nora West」 with nothing naming the + * object it belongs to. `object_name` now declares the console's `object-ref` + * face, which draws the object's icon and label in a list cell (never the + * stored API name), and two views show it: `all_shares`, the view Setup's + * `nav_record_shares` opens, right after the Record column, and `by_object` + * first, the shape `sys_sharing_rule.by_object` ships. + * + * Pinned here: + * 1. the face is declared, and it is the precedent's key on an object-name + * text column; the column keeps its stored shape; + * 2. the two views show the column where the order says, and nowhere else; + * 3. nothing else on those views moves: sorts, title, highlight strip, and + * no grouping on the column. + */ + +type FieldDef = Record; +type ViewDef = { + columns?: ReadonlyArray; + sort?: ReadonlyArray<{ field: string; order?: string }>; + grouping?: unknown; +}; + +const fields = SysRecordShare.fields as Record; +const views = SysRecordShare.listViews as Record; + +function columnsOf(view: string): string[] { + return (views[view]?.columns ?? []).map((c) => (typeof c === 'string' ? c : c.field)); +} + +describe('sys_record_share — an Object column drawn by the object-ref face (#39439)', () => { + it('object_name declares the object-ref widget and stays a required text column', () => { + expect(fields.object_name.widget).toBe('object-ref'); + expect(fields.object_name.type).toBe('text'); + expect(fields.object_name.required).toBe(true); + expect(fields.object_name.referenceVia).toBeUndefined(); + }); + + it('all_shares shows object_name right after record_id', () => { + expect(columnsOf('all_shares')).toEqual([ + 'record_id', 'object_name', 'recipient_type', 'recipient_id', 'access_level', 'source', 'created_at', + ]); + }); + + it('by_object shows object_name first, as sys_sharing_rule.by_object does', () => { + expect(columnsOf('by_object')).toEqual([ + 'object_name', 'record_id', 'recipient_id', 'access_level', 'source', 'created_at', + ]); + expect((SysSharingRule.listViews as Record).by_object.columns?.[0]).toBe('object_name'); + }); + + it('only those two views show the column', () => { + const showing = Object.keys(views).filter((v) => columnsOf(v).includes('object_name')).sort(); + expect(showing).toEqual(['all_shares', 'by_object']); + }); + + it('control: the sorts, title and highlight strip do not move, and no view groups on the column', () => { + expect(views.all_shares.sort).toEqual([{ field: 'created_at', order: 'desc' }]); + expect(views.by_object.sort).toEqual([{ field: 'object_name', order: 'asc' }, { field: 'created_at', order: 'desc' }]); + expect(SysRecordShare.nameField).toBe('recipient_id'); + expect(SysRecordShare.highlightFields).toEqual(['recipient_id', 'access_level', 'source']); + expect(Object.values(views).filter((v) => v.grouping !== undefined)).toEqual([]); + }); +}); diff --git a/packages/plugins/plugin-sharing/src/objects/sys-record-share.object.ts b/packages/plugins/plugin-sharing/src/objects/sys-record-share.object.ts index f4e8d464d82..623e034c4a4 100644 --- a/packages/plugins/plugin-sharing/src/objects/sys-record-share.object.ts +++ b/packages/plugins/plugin-sharing/src/objects/sys-record-share.object.ts @@ -63,9 +63,12 @@ export const SysRecordShare = ObjectSchema.create({ // A list names the shared record with the pointer's id half, `record_id`: // the console draws it as the target record and fetches the type half - // `object_name` for that cell without a column (objectui#13036). No list - // view shows the type half or groups on it, which would draw the stored API - // name as text or as a group header (`sharing-pointer-pairs.test.ts`). + // `object_name` for that cell without a column (objectui#13036). A view may + // also show the type half as its own Object column, because `object_name` + // declares the `object-ref` face: the cell draws the object's icon and label, + // never the stored API name, so a row says which object it is about in + // words. No view groups on the type half, since a group header draws the + // stored API name as text (`sharing-pointer-pairs.test.ts`). listViews: { // [#21972] Declared FIRST on purpose: a route that names no view opens the // first declared list view, so a caller-scoped view (`granted_to_me`, @@ -76,7 +79,7 @@ export const SysRecordShare = ObjectSchema.create({ name: 'all_shares', label: 'All', data: { provider: 'object', object: 'sys_record_share' }, - columns: ['record_id', 'recipient_type', 'recipient_id', 'access_level', 'source', 'created_at'], + columns: ['record_id', 'object_name', 'recipient_type', 'recipient_id', 'access_level', 'source', 'created_at'], sort: [{ field: 'created_at', order: 'desc' }], pagination: { pageSize: 100 }, }, @@ -110,11 +113,13 @@ export const SysRecordShare = ObjectSchema.create({ name: 'by_object', label: 'By Object', data: { provider: 'object', object: 'sys_record_share' }, - columns: ['record_id', 'recipient_id', 'access_level', 'source', 'created_at'], + columns: ['object_name', 'record_id', 'recipient_id', 'access_level', 'source', 'created_at'], // [#24611] Ordered by the shared record's object, not grouped on it: a // group header draws `object_name` as its stored API name, and no column - // holds the object's label. The sort keeps one object's grants together, - // and each Record cell draws its target with that object's icon. + // stores the object's label, so no grouping key could carry it. The + // Object column comes first and draws each object's icon and label (its + // `object-ref` face); the sort keeps one object's grants together, the + // shape `sys_sharing_rule.by_object` ships. sort: [{ field: 'object_name', order: 'asc' }, { field: 'created_at', order: 'desc' }], pagination: { pageSize: 100 }, }, @@ -154,6 +159,13 @@ export const SysRecordShare = ObjectSchema.create({ required: true, maxLength: 100, description: 'Short object name of the shared record', + // [#39439] Drawn as the object it names: the console's `object-ref` + // face draws the object's icon and label in a list cell, the declaration + // `sys_assignment_rule`, `sys_webhook` and `sys_notification` carry on + // their own object-name text fields. A display hint only: the column + // stays this text column, and no form draws the picker as an editor, + // since the object is engine-owned and its data API is read-only. + widget: 'object-ref', group: 'Target', }), diff --git a/packages/plugins/plugin-sharing/src/sharing-pointer-pairs.test.ts b/packages/plugins/plugin-sharing/src/sharing-pointer-pairs.test.ts index d749545df1f..c7f309fae99 100644 --- a/packages/plugins/plugin-sharing/src/sharing-pointer-pairs.test.ts +++ b/packages/plugins/plugin-sharing/src/sharing-pointer-pairs.test.ts @@ -82,17 +82,19 @@ describe('sys_share_link — declared pointer pair (#11386)', () => { }); /** - * [#24501] A list names the shared record with the id half alone. The console - * draws a `referenceVia` column as the target record (its object's icon and - * name) and fetches the type half for that cell without a column - * (objectui#13036); a type-half column draws the stored API name as text. + * [#24501 → #39439] A list names the shared record with the id half. The + * console draws a `referenceVia` column as the target record (its object's + * icon and name) and fetches the type half for that cell without a column + * (objectui#13036). A type half shown as a column of its own must declare the + * object-label face (`widget: 'object-ref'`), which draws the object's icon and + * label; an un-faced type-half column draws the stored API name as text. * Enumerated over every object this package ships (`objects/index.ts`), so a * view added later is judged without anyone listing it here. */ -describe('sharing list views — a pointer shows as its id half, never its type half (#24501)', () => { +describe('sharing list views — a pointer shows as its id half, and a shown type half declares the object-label face (#24501, #39439)', () => { type PointerObject = { name: string; - fields: Record; + fields: Record; listViews?: Record }>; }; @@ -115,9 +117,26 @@ describe('sharing list views — a pointer shows as its id half, never its type } const objects = Object.values(SharingObjects) as unknown as PointerObject[]; + const byName = new Map(objects.map((o) => [o.name, o])); + + it('every type half a list view shows as a column declares the object-ref face', () => { + const unfaced = pointerColumns(objects).typeHalves.filter((hit) => { + const [objectName, rest] = hit.split('.', 2) as [string, string]; + const column = rest.split(': ')[1]!; + return byName.get(objectName)?.fields[column]?.widget !== 'object-ref'; + }); + expect(unfaced).toEqual([]); + }); + + it('the rule above judges a non-empty set: the share list views that show the Object column', () => { + expect(pointerColumns(objects).typeHalves).toEqual([ + 'sys_record_share.all_shares: object_name', + 'sys_record_share.by_object: object_name', + ]); + }); - it('no list view shows a referenceVia sibling beside its id half', () => { - expect(pointerColumns(objects).typeHalves).toEqual([]); + it('control: no sys_share_link list view shows its type half', () => { + expect(pointerColumns(objects).typeHalves.filter((hit) => hit.startsWith('sys_share_link.'))).toEqual([]); }); it('the share and link lists still show the id half, so the Record column names the target', () => {