Address Obsidian review bot feedback

Fix issues flagged by the Obsidian plugin review bot on PR #12037:

- configSerializer: guard stat widget value against object stringification
- UI strings: apply sentence case to button labels and descriptions; use
  canonical SQL casing
- dashboardRenderer: drop redundant HTMLElement|null assertion on
  parentElement
- linkWidget: mark openLinkText promise as intentionally unawaited
This commit is contained in:
Kevin McAleer 2026-04-18 00:26:14 +01:00
parent d82eb89437
commit 068c7091b1
4 changed files with 13 additions and 9 deletions

View file

@ -81,7 +81,11 @@ function parseWidget(raw: unknown): Widget | null {
return {
type: 'stat',
label: typeof w.label === 'string' ? w.label : '',
value: typeof w.value === 'string' ? w.value : String(w.value ?? ''),
value: typeof w.value === 'string'
? w.value
: (typeof w.value === 'number' || typeof w.value === 'boolean')
? String(w.value)
: '',
trend: typeof w.trend === 'string' ? w.trend : undefined,
icon: typeof w.icon === 'string' ? w.icon : undefined,
};

View file

@ -63,7 +63,7 @@ export function renderDashboard(
const rowsContainer = root.createDiv({ cls: 'dashboard-rows' });
// Add row button (only visible in edit mode via CSS)
const addRowBtn = root.createEl('button', { cls: 'dashboard-add-row', text: '+ Add row' });
const addRowBtn = root.createEl('button', { cls: 'dashboard-add-row', text: '+ add row' });
addRowBtn.addEventListener('click', () => {
state.config.rows.push({ columns: [{}] }); // auto-width column (becomes 12)
emit(state, onChanged);
@ -146,7 +146,7 @@ function renderRow(
emit();
});
const addColBtn = toolbar.createEl('button', { cls: 'dashboard-btn', text: '+ Column' });
const addColBtn = toolbar.createEl('button', { cls: 'dashboard-btn', text: '+ column' });
addColBtn.addEventListener('click', () => {
row.columns.push({}); // auto-width so existing columns redistribute
emit();
@ -258,7 +258,7 @@ function renderColumn(
} else {
const empty = body.createDiv({ cls: 'dashboard-column-empty' });
if (state.editMode) {
const addBtn = empty.createEl('button', { cls: 'dashboard-add-widget-btn', text: '+ Add widget' });
const addBtn = empty.createEl('button', { cls: 'dashboard-add-widget-btn', text: '+ add widget' });
addBtn.addEventListener('click', () => {
new WidgetEditorModal(app, undefined, (widget: Widget) => {
col.widget = widget;
@ -292,7 +292,7 @@ function addResizeHandle(colEl: HTMLElement, row: Row, colIdx: number, emit: ()
handle.addEventListener('pointerdown', (e: PointerEvent) => {
e.preventDefault();
const rightColEl = colEl.nextElementSibling as HTMLElement | null;
const grid = colEl.parentElement as HTMLElement | null;
const grid = colEl.parentElement;
if (!rightColEl || !grid) return;
const rightCol = row.columns[colIdx + 1];

View file

@ -121,7 +121,7 @@ export class WidgetEditorModal extends Modal {
if (w.chart) {
new Setting(this.body)
.setName('Chart YAML')
.setDesc('Bases-chart config: type, sql, title, colors, etc.')
.setDesc('Bases-chart config: type, SQL, title, colors, etc.')
.addTextArea((ta) => {
ta.setValue(stringifyYaml(w.chart).trimEnd()).onChange((val) => {
try {
@ -151,7 +151,7 @@ export class WidgetEditorModal extends Modal {
const w = this.widget;
new Setting(this.body)
.setName('Target')
.setDesc('Wikilink to the note or section to transclude, e.g. "[[Weekly summary]]"')
.setDesc('Wikilink to the note or section to transclude, e.g. "[[weekly summary]]"')
.addText((t) => {
t.setValue(w.target).onChange((val) => { w.target = val; });
t.inputEl.addClass('dashboard-widget-editor-input');
@ -170,7 +170,7 @@ export class WidgetEditorModal extends Modal {
new Setting(this.body).setName('Trend').setDesc('Optional, e.g. "+3" or "-5%"').addText((t) => {
t.setValue(w.trend || '').onChange((val) => { w.trend = val || undefined; });
});
new Setting(this.body).setName('Icon').setDesc('Optional Lucide icon name').addText((t) => {
new Setting(this.body).setName('Icon').setDesc('Optional icon name').addText((t) => {
t.setValue(w.icon || '').onChange((val) => { w.icon = val || undefined; });
});
}

View file

@ -25,6 +25,6 @@ export function renderLinkWidget(container: HTMLElement, widget: LinkWidget, app
card.addEventListener('click', (e) => {
e.preventDefault();
app.workspace.openLinkText(target, '', false);
void app.workspace.openLinkText(target, '', false);
});
}