@popcorn245/cornfield 0.34.2 → 0.35.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.
@@ -25,6 +25,7 @@ import { render, isNodeVisible } from './render.js';
25
25
  import { hooks, rebuildProposalMap, closeProposal } from './proposal.js';
26
26
  import { getPlayer, playScenario, stopScenario, tickScenario } from './scenario-ui.js';
27
27
  import { kindOfMark } from './proposal-model.js';
28
+ import { announce } from './keyboard.js';
28
29
  import { edgeKey } from '../core/proposal.js';
29
30
  import * as M from './whatif-model.js';
30
31
 
@@ -197,15 +198,21 @@ function doIntent(intent, where) {
197
198
 
198
199
  export function undoEdit() {
199
200
  if (!state.proposal || !M.canUndo(state.whatIf)) return false;
200
- return step(M.undo(state.whatIf));
201
+ const edit = state.whatIf.edits[state.whatIf.edits.length - 1];
202
+ return step(M.undo(state.whatIf), edit, 'Undid');
201
203
  }
202
204
  export function redoEdit() {
203
205
  if (!state.proposal || !M.canRedo(state.whatIf)) return false;
204
- return step(M.redo(state.whatIf));
206
+ const edit = state.whatIf.undone[state.whatIf.undone.length - 1];
207
+ return step(M.redo(state.whatIf), edit, 'Redid');
205
208
  }
206
- function step(whatIf) {
209
+ /** Applies an undo or a redo, and says which edit it was ("Undid: Added the service “X”"); names are read where the node exists (before for an add, after for a remove) */
210
+ function step(whatIf, edit, verb) {
207
211
  clearMessages();
212
+ const words = () => M.describeEdit(edit, { nameOf, scenarioTitle: (id) => (scenariosOf(state.effectiveProposal || state.proposal).find((s) => s.id === id) || { title: id }).title });
213
+ const before = words();
208
214
  apply({ whatIf, effective: M.evaluate(base(), state.proposal, whatIf.edits).effective });
215
+ announce(`${verb}: ${/^remove/.test(edit.op) ? words() : before}`);
209
216
  return true;
210
217
  }
211
218
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@popcorn245/cornfield",
3
- "version": "0.34.2",
3
+ "version": "0.35.0",
4
4
  "description": "A self-hostable dev dashboard with the topology map at its centre: proposals on the map, scenarios, outages and what-if edits, for any repo.",
5
5
  "license": "MIT",
6
6
  "author": "popcorn245 (https://github.com/popcorn245)",
@@ -149,7 +149,7 @@ export function errorFor(forge, status, body, rate, what) {
149
149
  if (status >= 300 && status < 400) return new ForgeError(`${forge} says ${what} has moved; check forge.repo in cornfield.config.js.`, { ...at, code: 'not-found' });
150
150
  if (status === 401) return new ForgeError(`${forge} did not accept the sign-in; sign in again.`, { ...at, code: 'unauthorized' });
151
151
  if (status === 403) return new ForgeError(`${forge} does not let this sign-in do that to ${what}.${theirs}`, { ...at, code: 'forbidden' });
152
- if (status === 404) return new ForgeError(`${forge} has no ${what}, or this sign-in cannot see it.`, { ...at, code: 'not-found' });
152
+ if (status === 404) return new ForgeError(`${forge} could not find ${what}, or this sign-in cannot see it.`, { ...at, code: 'not-found' });
153
153
  if (status === 405 || status === 409) return new ForgeError(`${forge} refused: ${what} cannot be changed that way now.${theirs}`, { ...at, code: 'conflict' });
154
154
  if (status === 400 || status === 422) return new ForgeError(`${forge} did not accept the request for ${what}.${theirs}`, { ...at, code: 'invalid' });
155
155
  return new ForgeError(`${forge} could not answer for ${what} (HTTP ${status}); try again in a minute.`, { ...at, code: 'unavailable' });
@@ -168,7 +168,7 @@ function describeProposal(slug, source, proposal, topology) {
168
168
  summary: object ? text(proposal.summary) : '',
169
169
  spec: object && typeof proposal.spec === 'string' ? proposal.spec : null,
170
170
  source,
171
- counts: summarize(proposal),
171
+ counts: summarize(proposal), // the totals, and `nodes` and `edges` apart, so the list can say what it counts
172
172
  errors: topology ? proposalProblems(topology, proposal).errors.length : null,
173
173
  };
174
174
  }