@floless/app 0.166.0 → 0.167.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -31,6 +31,8 @@
31
31
  if (!$pill || !$modal) return;
32
32
  var $dialog = $modal.querySelector('.tool-updates-dialog');
33
33
  var $title = document.getElementById('tool-updates-title');
34
+ var $sub = document.getElementById('tool-updates-sub');
35
+ var TOOLS_SUB = $sub ? $sub.textContent : '';
34
36
  var $body = document.getElementById('tool-updates-body');
35
37
  var $live = document.getElementById('tool-updates-live');
36
38
  var $progress = document.getElementById('tool-updates-progress');
@@ -44,6 +46,7 @@
44
46
  var view = null;
45
47
  var templateUpdates = [];
46
48
  var templateTicket = 0;
49
+ var toolsOpen = false; // the collapsed Tools section under workflow updates, as the person last left it
47
50
  var results = null;
48
51
  var compileSelection = null; // immutable review shown before the person's separate confirmation
49
52
  var compileExcluded = [];
@@ -316,9 +319,12 @@
316
319
  }
317
320
  var text;
318
321
  var state = 'offer';
322
+ var more = '';
319
323
  if (templateUpdates.length) {
320
- text = plural(templateUpdates.length, 'workflow file update', 'workflow file updates');
321
- if (offers.length || needCount || cleanup.length) text += ' · ' + (offers.length + needCount + cleanup.length) + ' also need you';
324
+ // One-click update (owner ruling 2026-11-02): the pill counts workflows with an update the person can apply, and only
325
+ // those. Tool approvals and cleanup are a dot here and a section in the dialog.
326
+ text = plural(templateUpdates.length, 'workflow update', 'workflow updates');
327
+ if (offers.length || needCount || cleanup.length) more = 'Tool updates also wait for you in this list.';
322
328
  } else if (offers.length) {
323
329
  text = plural(offers.length, 'workflow update', 'workflow updates');
324
330
  if (urgent) {
@@ -348,8 +354,11 @@
348
354
  else if (checking && state !== 'checking') text += ' · checking…';
349
355
  $pill.textContent = text;
350
356
  $pill.setAttribute('data-state', state);
351
- $pill.setAttribute('data-tip', firstCheck ? 'The first workflow check is still running. The total is not known yet.' : !checking ? PILL_TIP : state === 'checking'
352
- ? 'Still checking for tool updates. Open to watch it.' : PILL_TIP + '. A check is also running.');
357
+ if (more) $pill.setAttribute('data-more', ''); else $pill.removeAttribute('data-more');
358
+ var tip = templateUpdates.length ? 'Newer versions of your workflows from FloLess. Open to update them in one click.' : PILL_TIP;
359
+ if (more) tip += ' ' + more;
360
+ $pill.setAttribute('data-tip', firstCheck ? 'The first workflow check is still running. The total is not known yet.' : !checking ? tip : state === 'checking'
361
+ ? 'Still checking for tool updates. Open to watch it.' : tip + (/\.$/.test(tip) ? ' ' : '. ') + 'A check is also running.');
353
362
  $pill.hidden = false;
354
363
  if (isOpen() && !approving && !results) paint();
355
364
  }
@@ -615,7 +624,8 @@
615
624
  }
616
625
 
617
626
  /** The workflows' rows, laid out by group. An older server's view has no groups: its flat rows are listed as they come. */
618
- function paintNeeds(needs, cleanup) {
627
+ function paintNeeds(needs, cleanup, host) {
628
+ host = host || $body;
619
629
  var groups = view && Array.isArray(view.needsGroups) ? view.needsGroups : null;
620
630
  var rowsOf = function (id) { return needs.filter(function (n) { return n.group === id; }); };
621
631
  var loose = groups ? needs.filter(function (n) { return !groups.some(function (g) { return g.id === n.group; }); }) : needs;
@@ -627,13 +637,13 @@
627
637
  acting.forEach(function (g) { needsSection.appendChild(actionGroup(g, rowsOf(g.id))); });
628
638
  loose.forEach(function (n) { needsSection.appendChild(needsRow(n, false)); });
629
639
  cleanup.forEach(function (n) { needsSection.appendChild(cleanupRow(n)); });
630
- $body.appendChild(needsSection);
640
+ host.appendChild(needsSection);
631
641
  }
632
642
  if (quiet.length) {
633
643
  var total = quiet.reduce(function (n, g) { return n + rowsOf(g.id).length; }, 0);
634
644
  var quietSection = section('Nothing to do', total);
635
645
  quiet.forEach(function (g) { quietSection.appendChild(quietGroup(g, rowsOf(g.id))); });
636
- $body.appendChild(quietSection);
646
+ host.appendChild(quietSection);
637
647
  }
638
648
  return count;
639
649
  }
@@ -736,6 +746,7 @@
736
746
  function paintNow() {
737
747
  $body.textContent = '';
738
748
  $foot.textContent = '';
749
+ if ($sub) $sub.textContent = TOOLS_SUB;
739
750
  $cancel.setAttribute('data-command-id', compileSelection ? 'shell.tool-updates-back' : CANCEL_COMMAND);
740
751
  $title.textContent = compileSelection ? 'Compile and approve workflows' : 'Approve updated workflows';
741
752
  if (compileSelection) {
@@ -775,22 +786,53 @@
775
786
  }
776
787
  var offers = (view && view.offers) || [];
777
788
  var needs = (view && view.needsYou) || [];
778
- if (templateUpdates.length) {
779
- var bundled = section('Workflow files supplied by FloLess', templateUpdates.length);
780
- templateUpdates.forEach(function (item) { bundled.appendChild(templateUpdateRow(item)); });
789
+ var bridge = window.flolessBridge;
790
+ var rows = typeof bridge?.workflowUpdateRows === 'function' ? bridge.workflowUpdateRows() : templateUpdates;
791
+ var toolsHost = $body;
792
+ if (rows.length) {
793
+ $title.textContent = 'Workflow updates';
794
+ if ($sub) $sub.textContent = 'Newer versions of your workflows from FloLess. Each one updates when you click it.';
795
+ var bundled = el('div', 'tool-updates-section wf-upd-section');
796
+ var head = el('div', 'wf-upd-head');
797
+ head.appendChild(el('div', 'tool-updates-section-head', 'Each update keeps your data and saves a backup first'));
798
+ // The count is exactly what the click updates (an offer being worked on, or one the person changed, is not counted).
799
+ var plain = typeof bridge?.updateAllCount === 'function' ? bridge.updateAllCount() : templateUpdates.filter(function (u) { return !u.hasChanges; }).length;
800
+ if (plain >= 2 && typeof bridge?.updateAllWorkflows === 'function') {
801
+ var all = el('button', 'tool-updates-open wf-upd-primary', 'Update all (' + plain + ')');
802
+ all.type = 'button';
803
+ all.setAttribute('data-command-id', 'shell.workflow-update-all');
804
+ all.setAttribute('data-tip', 'Updates every workflow you have not changed. Ones you changed wait for your choice below.');
805
+ all.addEventListener('click', function () { void bridge.updateAllWorkflows(); });
806
+ head.appendChild(all);
807
+ }
808
+ bundled.appendChild(head);
809
+ rows.forEach(function (item) {
810
+ bundled.appendChild(typeof bridge?.workflowUpdateRow === 'function' ? bridge.workflowUpdateRow(item) : templateUpdateRow(item));
811
+ });
781
812
  $body.appendChild(bundled);
813
+ if (offers.length || needs.length || cleanupNeeds().length || results) {
814
+ var tools = el('details', 'tool-updates-section wf-upd-tools');
815
+ var waiting = offers.length + ((view && typeof view.needsCount === 'number') ? view.needsCount : needs.length) + cleanupNeeds().length;
816
+ var toolsHead = el('summary', 'tool-updates-section-head', 'Tools' + (waiting ? ' · ' + plural(waiting, 'item needs you', 'items need you') : ''));
817
+ toolsHead.setAttribute('data-command-id', 'shell.tool-updates-tools');
818
+ tools.appendChild(toolsHead);
819
+ if (results || toolsOpen) tools.open = true;
820
+ tools.addEventListener('toggle', function () { toolsOpen = tools.open; });
821
+ $body.appendChild(tools);
822
+ toolsHost = tools;
823
+ }
782
824
  }
783
825
  if (view && !view.supported) {
784
- $body.appendChild(el('div', 'tool-updates-summary', view.sentence || 'Tool updates are not available on this computer.'));
826
+ toolsHost.appendChild(el('div', 'tool-updates-summary', view.sentence || 'Tool updates are not available on this computer.'));
785
827
  } else if (view && view.sentence) {
786
- $body.appendChild(el('div', 'tool-updates-summary', view.sentence));
828
+ toolsHost.appendChild(el('div', 'tool-updates-summary', view.sentence));
787
829
  }
788
830
  if (results) {
789
831
  var done = section('Results', results.length);
790
832
  done.querySelector('.tool-updates-section-head').id = 'tool-updates-results-head';
791
833
  done.querySelector('.tool-updates-section-head').tabIndex = -1;
792
834
  results.forEach(function (r) { done.appendChild(resultRow(r)); });
793
- $body.appendChild(done);
835
+ toolsHost.appendChild(done);
794
836
  } else {
795
837
  var urgent = offers.filter(function (o) { return !!o.advisory; });
796
838
  if (urgent.length) {
@@ -799,25 +841,26 @@
799
841
  banner.appendChild(el('div', 'tool-updates-urgent-head', 'AWARE marked ' + (urgent.length === 1 ? 'this update' : 'these updates') + ' urgent'));
800
842
  urgent.forEach(function (o) { banner.appendChild(el('div', 'tool-updates-urgent-text', o.workflowName + ': ' + o.advisory)); });
801
843
  banner.appendChild(el('div', 'tool-updates-urgent-note', 'Approving is still your decision.'));
802
- $body.appendChild(banner);
844
+ toolsHost.appendChild(banner);
803
845
  }
804
846
  if (offers.length) {
805
847
  var ready = section('Ready to approve', offers.length);
806
848
  offers.forEach(function (o) { ready.appendChild(offerCard(o)); });
807
- $body.appendChild(ready);
849
+ toolsHost.appendChild(ready);
808
850
  }
809
851
  }
810
852
  var cleanup = cleanupNeeds();
811
- var needsYou = paintNeeds(needs, cleanup);
853
+ var needsYou = paintNeeds(needs, cleanup, toolsHost);
812
854
  // Nothing to approve and nothing the person can act on: say so first, above any quiet "Nothing to do" rows, and do
813
855
  // not title the dialog as if something were waiting for approval.
814
- var allClear = !results && !offers.length && !templateUpdates.length && !needsYou && view && view.supported && !view.sentence;
856
+ var allClear = !results && !offers.length && !rows.length && !needsYou && view && view.supported && !view.sentence;
815
857
  if (allClear) {
816
858
  $body.insertBefore(el('div', 'tool-updates-summary', view.checking
817
859
  ? 'Checking which workflows a tool update affects…'
818
860
  : 'Nothing to do. All your workflows are on the tool versions you approved.'), $body.firstChild);
819
861
  }
820
- if (!offers.length && !results) $title.textContent = 'Tool updates';
862
+ if (!offers.length && !results && !rows.length) $title.textContent = 'Tool updates';
863
+ else if (!rows.length && !results) $title.textContent = 'Approve tool updates';
821
864
  var dl = downloadsLine();
822
865
  if (dl) $foot.appendChild(el('div', 'tool-updates-downloads' + (view.downloads && view.downloads.error ? ' tool-updates-downloads-problem' : ''), dl));
823
866
  // Tools AWARE left as they are because they are the person's own copy: said apart from a failure.
@@ -833,7 +876,8 @@
833
876
  if (canApprove) $approve.textContent = 'Approve ' + plural(offers.length, 'workflow', 'workflows');
834
877
  $check.hidden = !!results || !(view && view.supported);
835
878
  // "Not now" would read as cancelling the check, which closing the dialog does not do.
836
- $cancel.textContent = results ? 'Done' : checkInFlight() ? 'Close' : 'Not now';
879
+ var anyDone = rows.some(function (u) { var r = document.querySelector('[data-template-update="' + u.id + '"]'); return r && r.getAttribute('data-state') !== 'idle'; });
880
+ $cancel.textContent = results || anyDone ? 'Done' : checkInFlight() ? 'Close' : 'Not now';
837
881
  }
838
882
 
839
883
  /** A control that cannot be used right now says why (Instructor reads data-blocked-reason only while it is disabled). */
@@ -1119,8 +1163,9 @@
1119
1163
 
1120
1164
  window.addEventListener('floless:tool-updates-changed', function () { void refresh(); });
1121
1165
  window.addEventListener('floless:workflow-updates-changed', function () { void refresh(); });
1166
+ window.addEventListener('floless:workflow-update-rows', function () { if (isOpen() && !approving) paint(); });
1122
1167
  window.addEventListener('floless:apps-changed', function () { void refresh(); });
1123
1168
  window.addEventListener('floless:workflows-listed', giveAwaitingOpenButtons);
1124
- window.flolessToolUpdates = { refresh: refresh, open: open };
1169
+ window.flolessToolUpdates = { refresh: refresh, open: open, close: close };
1125
1170
  void refresh();
1126
1171
  })();