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
22 changes: 13 additions & 9 deletions admin-js/src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ function createInputs(resource, name, perm_type, permissions) {
return components;
}

function createBulkUpdates(resource, name, permissions) {
function createBulkUpdates(resource, name, permissions, refresh) {
let buttons = [];
for (const [label, data] of Object.entries(resource["bulk_update"])) {
let allowed = true;
Expand All @@ -277,7 +277,8 @@ function createBulkUpdates(resource, name, permissions) {
}
}
if (allowed)
buttons.push(<BulkUpdateButton mutationMode="pessimistic" key={label} label={label} data={data} />);
buttons.push(<BulkUpdateButton mutationMode="pessimistic" key={label} label={label} data={data}
mutationOptions={{onSettled: refresh}} />);
}
return buttons;
}
Expand All @@ -294,13 +295,16 @@ const AiohttpList = (resource, name, permissions) => {
<ExportButton />
</TopToolbar>
);
const BulkActionButtons = () => (
<>
{hasPermission(`${name}.edit`, permissions) && createBulkUpdates(resource, name, permissions)}
<BulkExportButton />
{hasPermission(`${name}.delete`, permissions) && <BulkDeleteButton mutationMode="pessimistic" />}
</>
);
const BulkActionButtons = () => {
const refresh = useRefresh();
return (
<>
{hasPermission(`${name}.edit`, permissions) && createBulkUpdates(resource, name, permissions, refresh)}
<BulkExportButton />
{hasPermission(`${name}.delete`, permissions) && <BulkDeleteButton mutationMode="pessimistic" />}
</>
);
};
const filters = createInputs(resource, name, "view", permissions);
// Remove inputs with duplicate sources.
const filterSources = filters.map(c => c["props"]["source"]);
Expand Down
1 change: 0 additions & 1 deletion admin-js/tests/permissions.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ describe("admin", () => {
await userEvent.click(await screen.findByRole("button", {"name": "Set to 7"}));
expect(await screen.findByText("Update 6 simples")).toBeInTheDocument();
await userEvent.click(screen.getByRole("button", {"name": "Confirm"}));
return; // Broken now
await waitFor(() => screen.getAllByText("7"));

const table = await screen.findByRole("table");
Expand Down
3 changes: 0 additions & 3 deletions admin-js/tests/simple.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ test("filters work", async () => {
const table = await within(main).findByRole("table");
let rows = within(table).getAllByRole("row");
expect(rows.length).toBeGreaterThan(2);
return; // Broken now
await userEvent.type(within(quickSearch).getByRole("spinbutton", {"name": "Id"}), "1");

await waitFor(() => within(main).getByRole("button", {"name": "Add filter"}));
Expand All @@ -90,7 +89,6 @@ test("enum filter works", async () => {
expect(within(table).getAllByRole("row").length).toBe(2);
const record = within(table).getAllByRole("row")[1];
await userEvent.click(currencySelect);
return; // Broken now
await userEvent.click(await screen.findByRole("option", {"name": "GBP"}));

expect(await within(main).findByText("No results found")).toBeInTheDocument();
Expand Down Expand Up @@ -154,7 +152,6 @@ test("reference input filter", async () => {
const optionsInitial = within(resultsInitial).getAllByRole("option");
expect(optionsInitial.map(e => e.textContent)).toEqual(["first", "with child"]);

return; // Broken now
await userEvent.click(within(resultsInitial).getByRole("option", {"name": "first"}));
await waitFor(() => expect(screen.queryByText("USD")).not.toBeInTheDocument());
expect(await within(main).findByText("No results found")).toBeInTheDocument();
Expand Down
Loading