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
15 changes: 15 additions & 0 deletions .changeset/35018-studio-landing-c.md
Original file line number Diff line number Diff line change
@@ -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.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -193,7 +197,10 @@ describe('Studio landing → recent packages (objectui#11863)', () => {
packages.gate = new Promise<void>((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();
Expand All @@ -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');
Expand All @@ -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');
Expand All @@ -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,
Expand Down Expand Up @@ -277,11 +291,109 @@ 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');
const stored = JSON.parse(localStorage.getItem(STORAGE_KEY) ?? '[]') as Array<{ id: string }>;
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']);
});
});
28 changes: 19 additions & 9 deletions ui/packages/app-shell/src/views/studio-design/BuilderLanding.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (`<base>.custom`) draws no line and is never sent:
Expand Down Expand Up @@ -542,7 +551,10 @@ export function BuilderLanding(): React.ReactElement {
<div data-testid="studio-landing-own" className="mb-6 grid grid-cols-1 gap-2.5 sm:grid-cols-2 lg:grid-cols-3">
{writable.map((p) => (
<div key={p.id} data-package-id={p.id} className="rounded-lg border bg-background">
<div className="flex items-center gap-2.5 px-3 py-2.5">
{/* 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. */}
<div title={p.id} className="flex items-center gap-2.5 px-3 py-2.5">
<button
type="button"
onClick={() => open(p.id)}
Expand All @@ -553,12 +565,8 @@ export function BuilderLanding(): React.ReactElement {
</span>
<span className="min-w-0 flex-1">
<span className="block truncate text-[13px] font-medium">{p.name}</span>
<span className="block truncate font-mono text-[10px] text-muted-foreground">{p.id}</span>
</span>
</button>
<span className="rounded bg-emerald-400/15 px-1.5 py-0.5 text-[10px] text-emerald-600 dark:text-emerald-300">
{t('engine.studio.pkg.writable', locale)}
</span>
{/* 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
Expand Down Expand Up @@ -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 && (
<>
<h2 className={headingClass}>{t('engine.home.recent', locale)}</h2>
<div data-testid="studio-landing-recent" className="mb-6 grid grid-cols-1 gap-2.5 sm:grid-cols-2 lg:grid-cols-3">
{recentPackages.map((item) => (
<Link key={item.id} to={item.href} className={entryCardClass}>
// objectstack#35018 — the app's id is only the entry's hover
// title, as on the cards above; its face shows the name.
<Link key={item.id} to={item.href} title={item.name} className={entryCardClass}>
<span className={entryIconClass}>
<Clock className="h-4 w-4" />
</span>
<span className="min-w-0 flex-1">
<span className="block truncate text-[13px] font-medium">{recentLabel(item)}</span>
<span className="block truncate font-mono text-[10px] text-muted-foreground">{item.name}</span>
</span>
</Link>
))}
Expand Down
Loading