diff --git a/.changeset/35018-studio-landing-c.md b/.changeset/35018-studio-landing-c.md new file mode 100644 index 00000000000..e74f7f127f9 --- /dev/null +++ b/.changeset/35018-studio-landing-c.md @@ -0,0 +1,15 @@ +--- +'@object-ui/app-shell': patch +--- + +fix(studio): the Studio landing's own-app cards and 最近访问 entries show the app, not its package id, and 最近访问 is left out when it only repeats the cards + +Clause-②: no +Metadata-protocol: none + +Two changes on the Studio landing page (`/studio`): + +- **自己的应用 / Your own apps cards.** A card shows the app's name only. The package id line under the name (for example `app.nb57`) is gone, and so is the 可写 / "Writable" badge: every app in this section is writable, so the badge said nothing. The package id is still on the card's hover title, the way an installed app's card already carries it. +- **最近访问 / Recently viewed.** The row is left out when its entries are exactly the apps the cards above already show, for example one recent visit to the only app on the page. It is drawn whenever it adds something: an app no card shows, or a card it does not repeat. Each entry shows the app's name only; its package id line is gone and the id is on the entry's hover title, as on the cards. + +No layout or feature change: the cards, the Duplicate button, the create card and the other sections are as before. No locale keys change. diff --git a/ui/packages/app-shell/src/views/studio-design/BuilderLanding.accessibleNames-12510.test.tsx b/ui/packages/app-shell/src/views/studio-design/BuilderLanding.accessibleNames-12510.test.tsx index caa05d6ffcc..5dba179cd4b 100644 --- a/ui/packages/app-shell/src/views/studio-design/BuilderLanding.accessibleNames-12510.test.tsx +++ b/ui/packages/app-shell/src/views/studio-design/BuilderLanding.accessibleNames-12510.test.tsx @@ -94,7 +94,7 @@ describe('Studio home cards carry their visible label as their name (objectui#12 const recent = await screen.findByTestId('studio-landing-recent'); expect(within(recent).getByRole('link', { name: /HotCRM/ })).toHaveAttribute('href', '/studio/app.objectstack.hotcrm'); - // The writable card: its label leads the name; the api name follows it. + // The writable card: named by its label (its id is only its hover title, objectstack#35018). expect(screen.getByRole('button', { name: /^Acme CRM\b/ })).toBeInTheDocument(); // The installed (read-only) card: its label, and its Customize button named for it. expect(screen.getByRole('button', { name: 'HotCRM' })).toBeInTheDocument(); diff --git a/ui/packages/app-shell/src/views/studio-design/BuilderLanding.recentPackages-11863.test.tsx b/ui/packages/app-shell/src/views/studio-design/BuilderLanding.recentPackages-11863.test.tsx index 8fba6a41911..d73a85e4bf9 100644 --- a/ui/packages/app-shell/src/views/studio-design/BuilderLanding.recentPackages-11863.test.tsx +++ b/ui/packages/app-shell/src/views/studio-design/BuilderLanding.recentPackages-11863.test.tsx @@ -156,7 +156,11 @@ describe('Studio landing → recent packages (objectui#11863)', () => { it('a package renamed since the visit shows its new name: the label is read on the render, never stored', async () => { // The visit happened while the package was called something else; the // stored entry carries no text from that moment to go stale. - packages.list = [{ id: 'com.acme.crm', name: 'Acme Sales', writable: true, namespace: 'acme' }]; + // A second app the row does not repeat keeps it drawn (objectstack#35018). + packages.list = [ + { id: 'com.acme.crm', name: 'Acme Sales', writable: true, namespace: 'acme' }, + { id: 'com.acme.hr', name: 'Acme HR', writable: true, namespace: 'acmehr' }, + ]; renderLanding([visit('com.acme.crm')]); await screen.findByText('Recently viewed'); @@ -193,7 +197,10 @@ describe('Studio landing → recent packages (objectui#11863)', () => { packages.gate = new Promise((resolve) => { release = resolve; }); - packages.list = [{ id: 'com.acme.crm', name: 'Acme CRM', writable: true, namespace: 'acme' }]; + packages.list = [ + { id: 'com.acme.crm', name: 'Acme CRM', writable: true, namespace: 'acme' }, + { id: 'com.acme.hr', name: 'Acme HR', writable: true, namespace: 'acmehr' }, + ]; renderLanding([visit('com.acme.crm')]); expect(screen.getByText('Loading…')).toBeInTheDocument(); @@ -219,7 +226,10 @@ describe('Studio landing → recent packages (objectui#11863)', () => { }); it('the package cards stay beside the recent row', async () => { - packages.list = [{ id: 'com.acme.crm', name: 'Acme CRM', writable: true, namespace: 'acme' }]; + packages.list = [ + { id: 'com.acme.crm', name: 'Acme CRM', writable: true, namespace: 'acme' }, + { id: 'com.acme.hr', name: 'Acme HR', writable: true, namespace: 'acmehr' }, + ]; renderLanding([visit('com.acme.crm')]); await screen.findByText('Recently viewed'); @@ -231,7 +241,10 @@ describe('Studio landing → recent packages (objectui#11863)', () => { describe('Studio landing → a deleted package leaves "Recently viewed" (objectstack#32615)', () => { it('a package the list no longer has is not listed; CONTROL — a live one beside it is', async () => { - packages.list = [{ id: 'com.acme.crm', name: 'Acme CRM', writable: true, namespace: 'acme' }]; + packages.list = [ + { id: 'com.acme.crm', name: 'Acme CRM', writable: true, namespace: 'acme' }, + { id: 'com.acme.hr', name: 'Acme HR', writable: true, namespace: 'acmehr' }, + ]; renderLanding([visit('com.acme.gone'), visit('com.acme.crm')]); await screen.findByText('Recently viewed'); @@ -240,7 +253,8 @@ describe('Studio landing → a deleted package leaves "Recently viewed" (objects }); it('the gone entry does not take a slot of the row: the next live packages fill it', async () => { - packages.list = ['a', 'b', 'c'].map((x) => ({ + // A fourth app, never visited, keeps the row from repeating the cards (objectstack#35018). + packages.list = ['a', 'b', 'c', 'd'].map((x) => ({ id: `com.acme.${x}`, name: `Pkg ${x.toUpperCase()}`, writable: true, @@ -277,7 +291,10 @@ describe('Studio landing → a deleted package leaves "Recently viewed" (objects }); it('the stored entry is kept: filtered on the render, never dropped from the store here', async () => { - packages.list = [{ id: 'com.acme.crm', name: 'Acme CRM', writable: true, namespace: 'acme' }]; + packages.list = [ + { id: 'com.acme.crm', name: 'Acme CRM', writable: true, namespace: 'acme' }, + { id: 'com.acme.hr', name: 'Acme HR', writable: true, namespace: 'acmehr' }, + ]; renderLanding([visit('com.acme.gone'), visit('com.acme.crm')]); await screen.findByText('Recently viewed'); @@ -285,3 +302,98 @@ describe('Studio landing → a deleted package leaves "Recently viewed" (objects expect(stored.map((e) => e.id)).toEqual(['package:com.acme.gone', 'package:com.acme.crm']); }); }); + +/** The own-app section's card for `id`. */ +const ownCard = (id: string) => { + const card = screen.getByTestId('studio-landing-own').querySelector(`[data-package-id="${id}"]`); + if (!(card instanceof HTMLElement)) throw new Error(`no own-app card for ${id}`); + return card; +}; + +describe('Studio landing → an own-app card shows the app, not its package (objectstack#35018)', () => { + it('names no package id and carries no Writable badge on its face', async () => { + packages.list = [ + { id: 'com.acme.crm', name: 'Acme CRM', writable: true, namespace: 'acme' }, + { id: 'com.example.showcase', name: 'Showcase', writable: false, namespace: 'showcase' }, + ]; + renderLanding([]); + + await screen.findByText('Acme CRM'); + const card = ownCard('com.acme.crm'); + expect(within(card).getByText('Acme CRM')).toBeInTheDocument(); + expect(card.textContent).not.toContain('com.acme.crm'); + expect(within(card).queryByText('Writable')).not.toBeInTheDocument(); + // Nowhere on the page: an installed app's card carries no such badge either. + expect(screen.queryByText('Writable')).not.toBeInTheDocument(); + }); + + it('keeps the package id reachable, as the card’s hover title', async () => { + packages.list = [{ id: 'com.acme.crm', name: 'Acme CRM', writable: true, namespace: 'acme' }]; + renderLanding([]); + + await screen.findByText('Acme CRM'); + expect(within(ownCard('com.acme.crm')).getByTitle('com.acme.crm')).toBeInTheDocument(); + }); +}); + +describe('Studio landing → a "Recently viewed" entry shows the app, not its package (objectstack#35018)', () => { + it('shows the name and not the id; the id is the entry’s hover title', async () => { + packages.list = [ + { id: 'com.acme.crm', name: 'Acme CRM', writable: true, namespace: 'acme' }, + { id: 'com.acme.hr', name: 'Acme HR', writable: true, namespace: 'acmehr' }, + ]; + renderLanding([visit('com.acme.crm')]); + + await screen.findByText('Recently viewed'); + const [link] = recentLinks(); + expect(within(link).getByText('Acme CRM')).toBeInTheDocument(); + expect(link.textContent).not.toContain('com.acme.crm'); + expect(within(recentSection()).getByTitle('com.acme.crm')).toBe(link); + }); +}); + +describe('Studio landing → "Recently viewed" is left out when it only repeats the cards (objectstack#35018)', () => { + it('one recent visit to the only app: no row', async () => { + packages.list = [{ id: 'com.acme.crm', name: 'Acme CRM', writable: true, namespace: 'acme' }]; + renderLanding([visit('com.acme.crm')]); + + await screen.findByText('Acme CRM'); + expect(screen.queryByTestId('studio-landing-recent')).not.toBeInTheDocument(); + expect(screen.queryByText('Recently viewed')).not.toBeInTheDocument(); + expect(screen.getAllByText('Acme CRM')).toHaveLength(1); + }); + + it('every card visited, in any order, installed apps included: no row', async () => { + packages.list = [ + { id: 'com.acme.crm', name: 'Acme CRM', writable: true, namespace: 'acme' }, + { id: 'com.example.showcase', name: 'Showcase', writable: false, namespace: 'showcase' }, + ]; + renderLanding([visit('com.example.showcase'), visit('com.acme.crm')]); + + await screen.findByText('Acme CRM'); + expect(screen.queryByTestId('studio-landing-recent')).not.toBeInTheDocument(); + }); + + it('CONTROL — a recent app no card shows keeps the row', async () => { + packages.list = [{ id: 'com.acme.crm', name: 'Acme CRM', writable: true, namespace: 'acme' }]; + packages.hidden = ['com.objectstack.platform']; + renderLanding([visit('com.acme.crm'), visit('com.objectstack.platform')]); + + await screen.findByText('Recently viewed'); + expect(recentLinks().map((a) => a.getAttribute('href'))).toEqual([ + '/studio/com.acme.crm', + '/studio/com.objectstack.platform', + ]); + }); + + it('CONTROL — a card the row does not repeat keeps the row', async () => { + packages.list = [ + { id: 'com.acme.crm', name: 'Acme CRM', writable: true, namespace: 'acme' }, + { id: 'com.acme.hr', name: 'Acme HR', writable: true, namespace: 'acmehr' }, + ]; + renderLanding([visit('com.acme.crm')]); + + await screen.findByText('Recently viewed'); + expect(recentLinks().map((a) => a.getAttribute('href'))).toEqual(['/studio/com.acme.crm']); + }); +}); diff --git a/ui/packages/app-shell/src/views/studio-design/BuilderLanding.tsx b/ui/packages/app-shell/src/views/studio-design/BuilderLanding.tsx index b644cda20f4..a49e040b4ed 100644 --- a/ui/packages/app-shell/src/views/studio-design/BuilderLanding.tsx +++ b/ui/packages/app-shell/src/views/studio-design/BuilderLanding.tsx @@ -182,6 +182,15 @@ export function BuilderLanding(): React.ReactElement { const writable = cards.filter((p) => p.writable); const readonly = cards.filter((p) => !p.writable); + // objectstack#35018 — "Recently viewed" is drawn only when it adds something + // to the cards above it. When its entries are exactly the apps those cards + // already show (one recent visit to the only app, say), the row repeats the + // page and is left out; any entry the cards do not show, or any card it does + // not repeat, keeps the whole row. + const cardIds = new Set(cards.map((p) => p.id)); + const recentRepeatsCards = + recentPackages.length === cardIds.size && recentPackages.every((item) => cardIds.has(item.name)); + // ADR-0146 D3 — each read-only BASE's card carries "n customized, m switched // off", the server's counts (`GET /packages/:id/customizations`), one read // per card drawn. A pair (`.custom`) draws no line and is never sent: @@ -542,7 +551,10 @@ export function BuilderLanding(): React.ReactElement {
{writable.map((p) => (
-
+ {/* objectstack#35018 — the app's id is not on the card's face, only + * in its hover title, as on an installed app's card. Every app in + * this section is writable, so the card carries no badge saying so. */} +
- - {t('engine.studio.pkg.writable', locale)} - {/* ADR-0070 D4 — Duplicate clones a writable base: the copy is a new * writable package holding the base's sys_metadata rows. It is * offered here, on writable bases only; a read-only package's card @@ -642,19 +650,21 @@ export function BuilderLanding(): React.ReactElement { {/* objectui#11863 — the packages last opened here. objectstack#34715 * orders the page by the errand: installed apps first, the author's own - * apps next, then the other entries, this one among them. */} - {recentPackages.length > 0 && ( + * apps next, then the other entries, this one among them. + * objectstack#35018 — left out when it only repeats those cards. */} + {recentPackages.length > 0 && !recentRepeatsCards && ( <>

{t('engine.home.recent', locale)}

{recentPackages.map((item) => ( - + // objectstack#35018 — the app's id is only the entry's hover + // title, as on the cards above; its face shows the name. + {recentLabel(item)} - {item.name} ))}