mirror of
https://github.com/t8y2/dbx.git
synced 2026-10-28 08:08:02 +00:00
fix(grid): keep save actions visible
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { strict as assert } from "node:assert";
|
||||
import test from "node:test";
|
||||
import { dataGridSaveActionMode } from "../../apps/desktop/src/lib/dataGridSaveUi.ts";
|
||||
import { dataGridSaveActionMode, dataGridSaveToolbarState } from "../../apps/desktop/src/lib/dataGridSaveUi.ts";
|
||||
|
||||
test("uses concise save and commit labels for the primary grid save action", () => {
|
||||
assert.deepEqual(dataGridSaveActionMode({ pendingChangeCount: 3, useTransaction: true }), {
|
||||
@@ -15,3 +15,59 @@ test("uses concise save and commit labels for the primary grid save action", ()
|
||||
secondaryActionKey: "grid.discard",
|
||||
});
|
||||
});
|
||||
|
||||
test("keeps grid save actions visible for editable grids even without pending changes", () => {
|
||||
assert.deepEqual(
|
||||
dataGridSaveToolbarState({
|
||||
editable: true,
|
||||
hasSaveTarget: true,
|
||||
hasPendingChanges: false,
|
||||
isSaving: false,
|
||||
}),
|
||||
{
|
||||
showActions: true,
|
||||
actionsDisabled: true,
|
||||
},
|
||||
);
|
||||
|
||||
assert.deepEqual(
|
||||
dataGridSaveToolbarState({
|
||||
editable: true,
|
||||
hasSaveTarget: true,
|
||||
hasPendingChanges: true,
|
||||
isSaving: false,
|
||||
}),
|
||||
{
|
||||
showActions: true,
|
||||
actionsDisabled: false,
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
test("hides grid save actions when a grid cannot save edits", () => {
|
||||
assert.deepEqual(
|
||||
dataGridSaveToolbarState({
|
||||
editable: false,
|
||||
hasSaveTarget: true,
|
||||
hasPendingChanges: false,
|
||||
isSaving: false,
|
||||
}),
|
||||
{
|
||||
showActions: false,
|
||||
actionsDisabled: true,
|
||||
},
|
||||
);
|
||||
|
||||
assert.deepEqual(
|
||||
dataGridSaveToolbarState({
|
||||
editable: true,
|
||||
hasSaveTarget: false,
|
||||
hasPendingChanges: true,
|
||||
isSaving: false,
|
||||
}),
|
||||
{
|
||||
showActions: false,
|
||||
actionsDisabled: true,
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user