Skip to content

Commit 65a8b19

Browse files
committed
fix(app-shell): the cross-package leg's ask pre-selects nothing
The leg fell through to the heuristic pick, so the ask opened with a package checked. Pin it with the heuristic fixture, and say where the datasource import door lands an object as the page's comment does. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L9qibzywxH36FPH6ayWMUe
1 parent 75fbb8d commit 65a8b19

3 files changed

Lines changed: 38 additions & 3 deletions

File tree

‎.changeset/38149-create-asks-for-package.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ The console no longer saves a new item naming no package. Where a create's packa
1616
- The item editor at a create address naming no package (a deep link to `/new`): Save asks first; the item is saved as a draft in the chosen package and published at once, and the editor opens it under that package. A position or a permission set takes this path too, instead of the live package-less create.
1717
- A new view or report in an app: saved into the app's writable package or its customization package, as before; where neither can be had the person is asked. In a system app the create is refused with the reason (a view: save it to My views or add it in a business app; a report: create it in a business app). Where the customization package's door refuses the caller (`403`), the create is refused with the door's reason. The "saved outside this app" notice no longer runs.
1818
- The console's create-app route asks for the package, then saves the wizard's app as a draft there and publishes it. `CreateAppPage` (plugin-designer) takes an optional `saveApp(name, app)` that replaces its own save; answering `false` keeps the wizard open with nothing done.
19-
- Datasource Sync lands each object through the server's import door (`POST /api/v1/datasources/:name/external/tables/:remote/import`), which places it in the datasource's package, instead of a client save naming none.
19+
- Datasource Sync lands each object through the server's import door (`POST /api/v1/datasources/:name/external/tables/:remote/import`), which lands it in the datasource's own package, its read-only base's `.custom` pair, or no package for a datasource that has none, instead of a client save naming none.
2020
- Setup → Access control → Positions and permissions reads its own sub-path at the address the shell serves Setup at (`/apps/com.objectstack.setup/...`) as well as at the `setup` alias, so New on a position or a permission set opens the editor in Studio instead of a blank page, and a list gets the environment scope on both addresses (objectstack#38206).
2121
- New `studio` catalogue keys `engine.packageAsk.*` (English and Chinese).
2222

‎ui/packages/app-shell/src/views/metadata-admin/ResourceListPage.createAsk-38149.test.tsx‎

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,39 @@ describe('Setup catalog: a new permission set opens in the environment scope (ob
201201
describe("Studio's cross-package leg: New asks for its package (objectstack#38149)", () => {
202202
const ALL: MetadataAreaHost = { packageId: null, readOnly: false, basePath: '/studio/~all/metadata' };
203203

204+
it('the ask opens with nothing pre-selected, though the heuristic would pick a package, and Continue is disabled', async () => {
205+
// The fixture's heuristic picks Bravo (it owns the rows); Setup's list
206+
// pre-selects it (above). The case waits until the list holds the packages, so
207+
// the pick exists when New is pressed.
208+
let packagesRead = false;
209+
const served = packageList;
210+
packageList = async () => {
211+
const list = await served();
212+
packagesRead = true;
213+
return list;
214+
};
215+
render(
216+
<MetadataAreaHostContext.Provider value={ALL}>
217+
<MemoryRouter initialEntries={[`/studio/~all/metadata/${TYPE}`]}>
218+
<Routes>
219+
<Route path="/studio/~all/metadata/:type" element={<MetadataResourceListPage type={TYPE} />} />
220+
<Route path="/studio/~all/metadata/:type/new" element={<CreateProbe />} />
221+
</Routes>
222+
</MemoryRouter>
223+
</MetadataAreaHostContext.Provider>,
224+
);
225+
await waitFor(() => expect(packagesRead).toBe(true));
226+
await waitFor(() => expect(screen.getByText('bravo_set')).toBeInTheDocument());
227+
await new Promise((r) => setTimeout(r, 50));
228+
fireEvent.click(await newButton());
229+
const dialog = await ask();
230+
const bravo = await within(dialog).findByTestId(`package-create-ask-option-${PKG_B}`);
231+
expect(bravo).toHaveAttribute('data-state', 'unchecked');
232+
expect(within(dialog).getByTestId(`package-create-ask-option-${PKG_A}`)).toHaveAttribute('data-state', 'unchecked');
233+
expect(within(dialog).getByTestId('package-create-ask-continue')).toBeDisabled();
234+
expect(screen.queryByTestId('create-opened')).toBeNull();
235+
});
236+
204237
it('New asks, and the create opens in the leg under the chosen package', async () => {
205238
render(
206239
<MetadataAreaHostContext.Provider value={ALL}>

‎ui/packages/app-shell/src/views/metadata-admin/ResourceListPage.tsx‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -542,9 +542,11 @@ function DefaultMetadataList({ type, appName }: { type: string; appName?: string
542542
navigate(`./new?package=${encodeURIComponent(activePackage)}`);
543543
return;
544544
}
545-
// The cross-package leg, and a Setup list on a heuristic pick: ask.
545+
// The cross-package leg, and a Setup list on a heuristic pick: ask. The
546+
// leg lists across packages, so nothing is pre-selected there; a Setup
547+
// list offers its heuristic pick.
546548
const chosen = await askPackage({
547-
preselect: pickedPackage,
549+
preselect: allLeg ? null : pickedPackage,
548550
typeLabel: translateMetadataType(type, locale, entry?.label ?? type),
549551
});
550552
if (!chosen) return;

0 commit comments

Comments
 (0)