NOC notices that would open the NOC get no Open button (#226)

The notice list is the NOC tab, so a target of tab:noc did nothing. #232 gave the shift report a real target; the chaos monkey's arrival still pointed at the NOC, where its own card already is. logSection() now leaves the button off for that target, whatever posts it.
This commit is contained in:
Frederic Jung 2026-10-31 07:31:22 +01:00
parent d9f3cede11
commit dc89369c2a
No known key found for this signature in database
3 changed files with 14 additions and 1 deletions

View file

@ -6,6 +6,7 @@ All notable changes to this project are documented here. The project follows
## [Unreleased]
- The chaos monkey's notice in the NOC no longer has an Open button that did nothing; the monkey's own card is right above it (#226).
- Big networks freeze for less on every game day and every click: working out where traffic goes skips exits whose route is already full, so a game day takes about 40% less time (#210). Traffic goes exactly where it went before.
- Premium submarine terminals and Optical engineering can no longer be bought on a cable where they would change nothing (#198). The button now says so, and an upgrade that only helps together with the other one stays available.
- A wave size that is sold out on a route can no longer be reached by upgrading a smaller wave on it (#201). The upgrade button says how long it is sold out, just like when buying.

View file

@ -19,11 +19,12 @@ function logNote(html,kind,actions,open){S.log=S.log||[];const tmp=document.crea
const logRecent=()=>{const now=Date.now();return (S.log||[]).filter(e=>e.at&&now-e.at<LOG_MS);};
const logUnread=()=>logRecent().filter(e=>e.at>(UI.logSeen||0)).length;
const agoStr=at=>{const m=Math.floor((Date.now()-at)/60000);return m<1?tr('common.just_now'):trn('notifications.n_min_ago',m);};
// The list is the NOC tab: a notice that would open the NOC gets no Open button, since it would do nothing (#226).
function logSection(){const L=logRecent(),MAX=5,all=UI.logAll,sh=all?L:L.slice(0,MAX);
let h=`<h3 style="font-size:15px;margin:10px 0 4px">${tr('common.notifications')} <span class="meta">${tr('notifications.last_10_minutes')}</span></h3>`;
if(!L.length)return h+`<p class="empty">${tr('notifications.nothing_in_the_last_10_minutes')}</p>`;
h+=sh.map(e=>{const body=e.h&&e.t.startsWith(e.h)?e.t.slice(e.h.length).trim():e.t;
return `<div class="row note ${e.k||'info'}"><span class="ndot" aria-hidden="true"></span><div class="grow">${e.h?`<div class="nm">${esc(e.h)}${e.n>1?` <span class="tag st">×${e.n}</span>`:''}</div>`:''}${body?`<div class="meta nbody">${esc(body)}${!e.h&&e.n>1?` <span class="tag st">×${e.n}</span>`:''}</div>`:''}<div class="meta">${agoStr(e.at)} · ${dateStr(e.d)}</div></div>${e.o?btn(tr('common.open'),'logOpen',{id:e.id},'ghost sm'):''}</div>`;}).join('');
return `<div class="row note ${e.k||'info'}"><span class="ndot" aria-hidden="true"></span><div class="grow">${e.h?`<div class="nm">${esc(e.h)}${e.n>1?` <span class="tag st">×${e.n}</span>`:''}</div>`:''}${body?`<div class="meta nbody">${esc(body)}${!e.h&&e.n>1?` <span class="tag st">×${e.n}</span>`:''}</div>`:''}<div class="meta">${agoStr(e.at)} · ${dateStr(e.d)}</div></div>${e.o&&!(e.o.a==='tab'&&e.o.v==='noc')?btn(tr('common.open'),'logOpen',{id:e.id},'ghost sm'):''}</div>`;}).join('');
if(L.length>MAX)h+=`<div class="btns">${btn(all?tr('common.show_fewer'):tr('notifications.show_all_n',{n:L.length}),'logAll',{},'ghost sm')}</div>`;
return h;}
const markLayer=()=>{UI.layerAt=performance.now();};

View file

@ -107,3 +107,14 @@ test('"Met the Chaos Monkey" comes from a visit, not from an ordinary fiber cut'
assert.equal(ev("BADGES.find(b=>b.id==='backhoe').t"), 'Met the Chaos Monkey');
assert.deepEqual(errors, []);
});
test('#226 the monkey\'s notice in the NOC has no Open button that would open the NOC again', () => {
const { ev, errors } = net('oncall');
ev('mkArrive(S.day);ACT.leftTab({t:"noc"})');
const row = ev(`(()=>{const e=S.log.find(x=>x.o&&x.o.a==='tab'&&x.o.v==='noc');if(!e)return 'none';const r=[...document.querySelectorAll('#left .row.note')].find(n=>n.textContent.includes(e.t.slice(0,20)));return r?(r.querySelector('[data-act=logOpen]')?'button':'no button'):'not shown'})()`);
assert.equal(row, 'no button');
// a notice that opens something else keeps its button
ev("toast('A test notice','',[],{a:'bank'});ACT.leftTab({t:'noc'})");
assert.equal(ev(`!![...document.querySelectorAll('#left .row.note')].find(n=>n.textContent.includes('A test notice')).querySelector('[data-act=logOpen]')`), true);
assert.deepEqual(errors, []);
});