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
11 changes: 11 additions & 0 deletions .changeset/30039-view-panel-zh-filter-prompt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
'@object-ui/app-shell': patch
---

fix(app-shell): on a zh-CN console the view properties panel's empty filter button reads 「+ 添加筛选…」 and the description row's hint reads in Chinese

Clause-②: no
Metadata-protocol: none

- The `filter-builder` widget's empty trigger was an English literal (`+ Add filter…`); it now reads the Studio string the dataset scope filter already uses, so it follows the designer locale.
- The zh-CN view form overlay gains the `description` row's help text, which showed the schema's English description.
Original file line number Diff line number Diff line change
Expand Up @@ -202,13 +202,17 @@ describe('every form type Studio renders reads in zh-CN (objectstack#30039)', ()
expect(sections(zh).find((s) => s.label === '基础信息')?.description).toBe('标识与主显示形态');
expect(fieldByName(zh, 'searchableFields')?.label).toBe('可搜索字段');
expect(fieldByName(zh, 'description')?.label).toBe('描述');
// The description row's hint: without the overlay leaf it showed the
// schema's English `.describe()` text.
expect(fieldByName(zh, 'description')?.helpText).toBe('视图说明,用于文档与悬停提示');
});

it('an English console reads the spec English, the same object every time — the control', () => {
const en = getViewForm('en');
expect(en).toBe(getViewForm('en'));
expect(sections(en).map((s) => s.label)).toContain('Basics');
expect(fieldByName(en, 'searchableFields')?.label).toBeUndefined();
expect(fieldByName(en, 'description')?.helpText).toBeUndefined();
});

it('the page and report panels read in Chinese too', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
* these forms with), so a form reads the same words whether the server
* localized it or this console did. A leaf the platform has not translated
* (still the English source) is left out: the overlay then returns the spec's
* own English for it, as it does for every type it does not name.
* own English for it, as it does for every type it does not name. The one
* exception is a leaf a curated inspector SHOWS that the platform has no zh
* for; it is hand-worded here and marked so at its row.
*
* ## Two depths, by who renders the form
*
Expand Down Expand Up @@ -375,7 +377,9 @@ export const ZH_CN_SPEC_FORMS: NonNullable<TranslationData['metadataForms']> = {
fields: {
name: { label: '名称', helpText: 'snake_case,环境内唯一' },
label: { label: '显示名称' },
description: { label: '描述' },
// Hand-worded: the platform bundle has no zh leaf for this help, and the
// view inspector shows it (the schema's own `.describe()` text).
description: { label: '描述', helpText: '视图说明,用于文档与悬停提示' },
type: { label: '类型', helpText: '主要的视图形态' },
data: { label: '数据', helpText: '数据源——如:{"provider":"object","object":"task"}' },
columns: { label: '列', helpText: '要展示的列(来自所选对象的字段名)' },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,14 @@ import '@testing-library/jest-dom/vitest';
import * as React from 'react';
import { afterEach, describe, expect, it, vi } from 'vitest';
import { cleanup, fireEvent, render, screen } from '@testing-library/react';
import { I18nProvider } from '@object-ui/i18n';
import { loadStudioCatalogue } from '@object-ui/i18n/namespaces/studio';
import { WIDGETS } from './widgets';
import { loaded } from './loadState';

// The studio namespace fetches zh on demand; load it before any zh render.
await loadStudioCatalogue('zh');

// The builder lives inside a Radix popover, which does not open in jsdom.
// Rendering the popover parts inline is this directory's existing way of
// reaching it (`WidgetContext.catalogUnion.test.tsx`); the rest of the barrel
Expand Down Expand Up @@ -147,3 +152,24 @@ describe('the filter-builder widget holds a row until it is complete (objectstac
expect(writes).toEqual([]);
});
});

describe('the empty filter trigger reads in the designer locale (objectstack#30039)', () => {
const renderIn = (lang: 'en' | 'zh') =>
render(
<I18nProvider config={{ defaultLanguage: lang, detectBrowserLanguage: false }}>
<Host initial={{ type: 'grid' }} writes={[]} />
</I18nProvider>,
);

it('a zh-CN console reads the Chinese prompt, not the English literal', () => {
renderIn('zh');
const trigger = screen.getByTestId('filter-builder-trigger');
expect(trigger).toHaveTextContent('+ 添加筛选…');
expect(trigger).not.toHaveTextContent('Add filter');
});

it('CONTROL: an English console keeps the English prompt', () => {
renderIn('en');
expect(screen.getByTestId('filter-builder-trigger')).toHaveTextContent('+ Add filter…');
});
});
2 changes: 1 addition & 1 deletion ui/packages/app-shell/src/views/metadata-admin/widgets.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2875,7 +2875,7 @@ export function FilterBuilderField({ value, onChange, fields, readOnly, id, aria
<Button {...controlNaming({ id, ariaLabelledBy })} variant="outline" size="sm" disabled={readOnly || notEditable}
title={notEditable ? tr('console.objectView.filterOrGroupNotEditable') : undefined}
className="h-8 w-full justify-between text-xs font-normal" data-testid="filter-builder-trigger">
<span className="truncate text-left">{summary || <span className="text-muted-foreground">+ Add filter…</span>}</span>
<span className="truncate text-left">{summary || <span className="text-muted-foreground">{t('engine.inspector.dataset.addFilter', locale)}</span>}</span>
<ChevronDown className="h-3.5 w-3.5 opacity-60 shrink-0" />
</Button>
</PopoverTrigger>
Expand Down
Loading