/** * What an undo did, in one line: how many changes went back, how many were * left because someone edited the field after the automation wrote it, and * how many were on pages deleted since. * * @param {number} reverted - Changes put back. * @param {number} skipped - Changes left, edited since. * @param {number} gone - Changes on pages, terms or users deleted since. * @returns {string} */ export const revertMessage = ( reverted: number, skipped = 0, gone = 0 ): string => { const lines = [ reverted === 1 ? 'One change put back.' : `${reverted} changes put back.`, ]; if (skipped > 0) { lines.push( skipped === 1 ? 'One field was edited after the automation wrote it and keeps that edit.' : `${skipped} fields were edited after the automation wrote them and keep those edits.` ); } if (gone > 0) { lines.push( gone === 1 ? 'One change was on a page deleted since, so there is nothing to put back.' : `${gone} changes were on pages deleted since, so there is nothing to put back.` ); } return lines.join(' '); };