mirror of
https://github.com/kevinmcaleer/obsidian-dashboards.git
synced 2026-07-22 06:06:04 +00:00
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:
parent
d82eb89437
commit
068c7091b1
4 changed files with 13 additions and 9 deletions
|
|
@ -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,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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];
|
||||
|
|
|
|||
|
|
@ -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; });
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue