Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .changeset/35978-key-fields-no-strip-preview.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
'@object-ui/app-shell': patch
'@object-ui/console': patch
'@object-ui/i18n': patch
---

fix(studio): the key-fields editor no longer previews a record-page strip

Clause-②: no
Metadata-protocol: none

The default record page draws no key-field strip, so Studio's object settings
stop drawing a "Highlight strip preview" under the `highlightFields` list. The
ordered rows stay: order still decides which fields each surface takes. The
`engine.studio.settings.highlightPreview` catalogue key leaves the studio
namespace (English and Chinese).
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,21 @@
/**
* The object's `highlightFields` (ADR-0085) as an ORDERED pick list.
*
* Order is the whole meaning of the key: the spec says "first entry wins where
* only one fits", and the record page's highlight strip draws the fields in
* this order. So the editor is a list, not a chip cloud:
* Order is the whole meaning of the key. The spec: "Ordered most-important
* fields; first entry wins where only one fits. Drives default list and
* related-list columns, cards, hover cards, previews and the record picker;
* the default record page draws no strip from it." Each of those surfaces
* takes the fields in this order, as many as it has room for. So the editor
* is a list, not a chip cloud:
*
* - each row can be dragged to a new place, or moved with the up / down
* buttons (the keyboard path; the drag has no keyboard equivalent) — the
* rows are the shared `OrderedRowList`, which `RelatedListsEditor` uses too;
* - fields are added at the end, from the object's visible fields not already
* picked, up to {@link HIGHLIGHT_FIELDS_MAX};
* - a preview below draws the strip in the picked order, so the order is seen
* as the record page will show it.
* picked, up to {@link HIGHLIGHT_FIELDS_MAX}.
*
* The row order is the one rendering of the list here: no surface preview is
* drawn, since no single surface shows the list the way every other does.
*
* Removing the last field removes the key: an empty list and an absent key
* would both read "not declared" here, and only the absent key says it.
Expand All @@ -32,8 +36,9 @@ import { OrderedRowList } from './OrderedRowList.js';
import { t, tFormat, type SupportedLocale } from '../metadata-admin/i18n.js';

/**
* How many highlight fields the editor offers. The record-page strip shows a
* handful of facts at a glance; six is the ruled ceiling for authoring here.
* How many highlight fields the editor offers. The surfaces that read the key
* show a handful of facts at a glance, each taking as many as fit; six is the
* ruled ceiling for authoring here.
* A stored list that is already longer is shown whole and never truncated.
*/
export const HIGHLIGHT_FIELDS_MAX = 6;
Expand All @@ -53,7 +58,7 @@ export function HighlightFieldsEditor({
}: {
/** The stored list, in order. */
value: string[];
/** The object's fields (labels for the rows and the preview). */
/** The object's fields (labels for the rows). */
fields: readonly FieldEntry[];
/** The next list; `undefined` removes the key. */
onChange: (next: string[] | undefined) => void;
Expand Down Expand Up @@ -93,22 +98,6 @@ export function HighlightFieldsEditor({
<span className="text-[11px] text-muted-foreground">{t('engine.studio.settings.undeclared', locale)}</span>
)}
</div>
{value.length > 0 && (
<div className="space-y-1">
<span className="block text-[10px] text-muted-foreground">{t('engine.studio.settings.highlightPreview', locale)}</span>
<div
data-testid="highlight-preview"
className="flex gap-5 overflow-x-auto rounded-md border bg-muted/20 px-3 py-2"
>
{value.map((name) => (
<div key={name} className="min-w-0 shrink-0" data-testid="highlight-preview-cell">
<div className="text-[10px] text-muted-foreground">{labelOf(fields, name)}</div>
<div className="text-[13px] text-muted-foreground/70">—</div>
</div>
))}
</div>
</div>
)}
</div>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
* one fits"), and the object settings panel authors it as one.
*
* The real panel, inside a host that feeds every patch back into the draft:
* - the stored order is the row order and the strip preview's order;
* - the stored order is the row order, and no strip preview is drawn: the
* default record page draws no strip from the key, so the rows are the one
* rendering of the list;
* - up / down and a drag move a field, and the written list keeps every other
* field in place;
* - a picked field is appended at the end;
Expand Down Expand Up @@ -59,15 +61,16 @@ function Host({ initial, writes }: { initial: Row; writes: Row[] }) {

const rowOrder = () =>
screen.getAllByTestId(/^highlight-row-/).map((el) => el.getAttribute('data-testid')!.replace('highlight-row-', ''));
const previewOrder = () =>
within(screen.getByTestId('highlight-preview')).getAllByTestId('highlight-preview-cell').map((c) => c.firstChild!.textContent);
const lastHighlights = (writes: Row[]) => writes.at(-1)!.highlightFields;

describe('ObjectSettingsPanel — highlightFields is an ordered pick list with a strip preview', () => {
it('shows the stored order in the rows and in the strip preview', () => {
describe('ObjectSettingsPanel — highlightFields is an ordered pick list', () => {
it('shows the stored order in the rows, and draws no strip preview', () => {
render(<Host initial={{ fields: FIELDS, highlightFields: ['status', 'amount', 'name'] }} writes={[]} />);
expect(rowOrder()).toEqual(['status', 'amount', 'name']);
expect(previewOrder()).toEqual(['Status', 'Amount', 'Name']);
// The editor itself is drawn (the control), with no preview beside its rows.
expect(screen.getByTestId('highlight-fields-editor')).toBeInTheDocument();
expect(screen.queryByTestId('highlight-preview')).toBeNull();
expect(screen.queryAllByTestId('highlight-preview-cell')).toHaveLength(0);
});

it('moves a field with the up / down buttons, keeping every other field in place', () => {
Expand All @@ -76,7 +79,7 @@ describe('ObjectSettingsPanel — highlightFields is an ordered pick list with a
const amountRow = screen.getByTestId('highlight-row-amount');
fireEvent.click(within(amountRow).getByRole('button', { name: 'Move up' }));
expect(lastHighlights(writes)).toEqual(['amount', 'status', 'name']);
expect(previewOrder()).toEqual(['Amount', 'Status', 'Name']);
expect(rowOrder()).toEqual(['amount', 'status', 'name']);
fireEvent.click(within(screen.getByTestId('highlight-row-amount')).getByRole('button', { name: 'Move down' }));
expect(lastHighlights(writes)).toEqual(['status', 'amount', 'name']);
});
Expand Down Expand Up @@ -130,7 +133,7 @@ describe('ObjectSettingsPanel — highlightFields is an ordered pick list with a
render(<Host initial={{ fields: FIELDS, highlightFields: ['status'] }} writes={writes} />);
fireEvent.click(screen.getByRole('button', { name: 'Remove status' }));
expect(writes.at(-1)!.highlightFields).toBeUndefined();
expect(screen.queryByTestId('highlight-preview')).toBeNull();
expect(screen.queryAllByTestId(/^highlight-row-/)).toHaveLength(0);
expect(screen.getByText(t('engine.studio.settings.undeclared', 'en-US'))).toBeInTheDocument();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@
* first (`7a90afdf9`).
* 3. Semantic roles (ADR-0085) — the cross-surface presentation roles:
* `nameField`, `stageField` (string | false | unset), `highlightFields`
* (an ordered list with a strip preview — `HighlightFieldsEditor`), and
* (an ordered list — `HighlightFieldsEditor`), and
* `relatedLists` (objectstack#27069), the business order of the record
* page's related lists, over the object's inbound relationships
* (`RelatedListsEditor`).
* These are the ONLY presentation knobs the protocol carries, so the
* builder must make them directly editable — otherwise designers fall
* back to guessing which heuristic picked their title/stepper/columns.
* back to guessing which heuristic picked their title/stage/columns.
* 4. Capabilities (framework#2707/#2727) — the `enable.*` record-surface
* switches. Only LIVE flags are exposed (every toggle is enforced at
* runtime — writer gates, 403s, or UI surfaces): trackHistory & files
Expand Down
1 change: 0 additions & 1 deletion ui/packages/i18n/src/namespaces/studio/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2350,7 +2350,6 @@ const STUDIO_EN: Record<string, string> = {
'engine.studio.settings.addFieldOption': '+ Add field…',
'engine.studio.settings.undeclared': '(not declared — surfaces pick heuristically)',
'engine.studio.settings.highlightMax': 'Up to {max} highlight fields — remove one to add another.',
'engine.studio.settings.highlightPreview': 'Highlight strip preview',
'engine.studio.settings.relatedLists': 'Related list order (relatedLists) — the order of the lists of child records on this object\'s record page, most important first; it orders only, and showing or hiding a list stays on its relationship field',
'engine.studio.settings.relatedListsAdd': '+ Add relationship…',
'engine.studio.settings.relatedListsTail': 'Not listed — shown after these, in the default order',
Expand Down
1 change: 0 additions & 1 deletion ui/packages/i18n/src/namespaces/studio/zh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2136,7 +2136,6 @@ const STUDIO_ZH: Record<string, string> = {
'engine.studio.settings.addFieldOption': '+ 添加字段…',
'engine.studio.settings.undeclared': '(未声明 —— 各处按启发式自动挑选)',
'engine.studio.settings.highlightMax': '最多 {max} 个重点字段——移除一个才能再添加。',
'engine.studio.settings.highlightPreview': '要点条预览',
'engine.studio.settings.relatedLists': '关联列表顺序(relatedLists)—— 本对象记录页上各子记录列表的顺序,最重要的在前;只管排序,显示与否仍在关系字段上设置',
'engine.studio.settings.relatedListsAdd': '+ 添加关系…',
'engine.studio.settings.relatedListsTail': '未列出 —— 排在以上之后,按默认顺序',
Expand Down
Loading