(core) Fix widget loading spinner title

Summary:
The loading spinner would always display
'Building Table widget' when creating or changing
a widget. This fixes the title to reflect the selected
widget type.

Test Plan:
Updated existing browser tests to verify the loading spinner
title includes the correct widget type.

Reviewers: dsagal, paulfitz

Reviewed By: dsagal

Differential Revision: https://phab.getgrist.com/D2863
pull/9/head
George Gevoian 3 years ago
parent 3af6dd46ea
commit f613b68a9e

@ -158,8 +158,9 @@ export function buildPageWidgetPicker(
// calls onSave and closes the popup. Failure must be handled by the caller.
async function onSaveCB() {
ctl.close();
const type = value.type.get();
const savePromise = onSave({
type: value.type.get(),
type,
table: value.table.get(),
summarize: value.summarize.get(),
columns: sortedAs(value.columns.get(), columns.get().map((col) => col.id.peek())),
@ -169,7 +170,7 @@ export function buildPageWidgetPicker(
// If savePromise throws an error, before or after timeout, we let the error propagate as it
// should be handle by the caller.
if (await isLongerThan(savePromise, DELAY_BEFORE_SPINNER_MS)) {
const label = getWidgetTypes(value.type.get()).label;
const label = getWidgetTypes(type).label;
await spinnerModal(`Building ${label} widget`, savePromise);
}
}

@ -212,7 +212,10 @@ export async function spinnerModal<T>(
return [
cssModalSpinner.cls(''),
cssModalTitle(title),
cssModalTitle(
title,
testId('modal-spinner-title'),
),
cssSpinner(loadingSpinner()),
testId('modal-spinner'),
];

Loading…
Cancel
Save