fix(adwright): distinguish null vs [] in cycles/audience/connections empty-states
Some checks failed
plugin-tests / test (push) Failing after 6s
Some checks failed
plugin-tests / test (push) Failing after 6s
Empty-state messages now differentiate "never fetched" (null) from "fetched but empty" ([]), so the panel reads correctly after a refresh returns zero rows. Affected renderers: _renderCycles, _renderAudience, _renderConnections. Targeting unchanged (its gate is "both lists needed", not single-list empty). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
ef6a123c06
commit
db1d4e0cdb
@ -337,17 +337,20 @@
|
||||
function _renderCycles() {
|
||||
const pane = _pane("cycles");
|
||||
if (!pane) return;
|
||||
const cycles = NS.state.data.cycles || [];
|
||||
const cycles = NS.state.data.cycles; // null = never fetched, [] = fetched empty
|
||||
const emptyMsg = cycles === null
|
||||
? 'No cycles loaded. Click Refresh cycles.'
|
||||
: '0 cycles in Adwright. Create a cycle via CMO chat to dispatch ads.';
|
||||
pane.innerHTML =
|
||||
'<div class="svrnty-aw-tab-header">' +
|
||||
'<div class="svrnty-aw-tab-title">Cycles</div>' +
|
||||
'<button class="svrnty-aw-btn" data-svrnty-aw-action="refresh-cycles" data-svrnty-aw-needs-cmo>Refresh cycles</button>' +
|
||||
'</div>' +
|
||||
(cycles.length
|
||||
((cycles && cycles.length)
|
||||
? ('<div class="svrnty-aw-list">' +
|
||||
cycles.map((c) => _cycleRow(c)).join("") +
|
||||
'</div>')
|
||||
: '<div class="svrnty-aw-empty">No cycles loaded. Click Refresh cycles.</div>');
|
||||
: '<div class="svrnty-aw-empty">' + emptyMsg + '</div>');
|
||||
_rewireActions(pane);
|
||||
pane.querySelectorAll("[data-svrnty-aw-cycle]").forEach((row) => {
|
||||
row.addEventListener("click", () => {
|
||||
@ -404,15 +407,19 @@
|
||||
function _renderAudience() {
|
||||
const pane = _pane("audience");
|
||||
if (!pane) return;
|
||||
const segs = NS.state.data.segments || [];
|
||||
const segs = NS.state.data.segments; // null = never fetched, [] = fetched empty
|
||||
const segList = segs || [];
|
||||
const emptyMsg = segs === null
|
||||
? 'No segments loaded. Click Refresh.'
|
||||
: '0 segments in Adwright. Define segments via CMO chat (e.g., "add segment vegan-31-50").';
|
||||
pane.innerHTML =
|
||||
'<div class="svrnty-aw-tab-header">' +
|
||||
'<div class="svrnty-aw-tab-title">Audience segments</div>' +
|
||||
'<button class="svrnty-aw-btn" data-svrnty-aw-action="list-segments" data-svrnty-aw-needs-cmo>Refresh</button>' +
|
||||
'</div>' +
|
||||
(segs.length
|
||||
(segList.length
|
||||
? '<div class="svrnty-aw-list">' +
|
||||
segs.map((s) =>
|
||||
segList.map((s) =>
|
||||
'<div class="svrnty-aw-row">' +
|
||||
'<div class="svrnty-aw-row-main">' +
|
||||
'<div class="svrnty-aw-row-title">' + _esc(s.name || s.id) + '</div>' +
|
||||
@ -422,7 +429,7 @@
|
||||
'</div>'
|
||||
).join("") +
|
||||
'</div>'
|
||||
: '<div class="svrnty-aw-empty">No segments loaded. Click Refresh.</div>');
|
||||
: '<div class="svrnty-aw-empty">' + emptyMsg + '</div>');
|
||||
_rewireActions(pane);
|
||||
_refreshDisabledState();
|
||||
}
|
||||
@ -468,15 +475,19 @@
|
||||
function _renderConnections() {
|
||||
const pane = _pane("connections");
|
||||
if (!pane) return;
|
||||
const conns = NS.state.data.connections || [];
|
||||
const conns = NS.state.data.connections; // null = never fetched, [] = fetched empty
|
||||
const connList = conns || [];
|
||||
const emptyConnMsg = conns === null
|
||||
? 'No status loaded. Click Re-check.'
|
||||
: '0 connections configured. Provision Meta + Woo credentials below.';
|
||||
pane.innerHTML =
|
||||
'<div class="svrnty-aw-tab-header">' +
|
||||
'<div class="svrnty-aw-tab-title">Connections</div>' +
|
||||
'<button class="svrnty-aw-btn" data-svrnty-aw-action="connections-status" data-svrnty-aw-needs-cmo>Re-check</button>' +
|
||||
'</div>' +
|
||||
'<div class="svrnty-aw-conn-list">' +
|
||||
(conns.length ? conns.map(_connRow).join("") :
|
||||
'<div class="svrnty-aw-empty">No status loaded. Click Re-check.</div>') +
|
||||
(connList.length ? connList.map(_connRow).join("") :
|
||||
'<div class="svrnty-aw-empty">' + emptyConnMsg + '</div>') +
|
||||
'</div>' +
|
||||
'<button class="svrnty-aw-btn svrnty-aw-btn-primary" data-svrnty-aw-action="open-cred-form">Fix credentials</button>' +
|
||||
'<form class="svrnty-aw-form" id="svrntyAwCredForm">' +
|
||||
|
||||
Loading…
Reference in New Issue
Block a user