mirror of
https://github.com/gristlabs/grist-core.git
synced 2026-03-02 04:09:24 +00:00
(core) tolerate table renames when displaying differences
Summary: This makes data diff rendering robust to changes in the names of tables. It does not yet show information about those changes, but at least it won't fail to show table content changes. Added a missing case to ActionSummary concatenation that came up in testing. Test Plan: added test, updated test Reviewers: dsagal Reviewed By: dsagal Differential Revision: https://phab.getgrist.com/D2661
This commit is contained in:
@@ -233,3 +233,25 @@ export function getAffectedTables(summary: ActionSummary): string[] {
|
||||
...Object.keys(summary.tableDeltas)
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Given a tableId from after the specified renames, figure out what the tableId was before
|
||||
* the renames. Returns null if table didn't exist.
|
||||
*/
|
||||
export function getTableIdBefore(renames: LabelDelta[], tableIdAfter: string|null): string|null {
|
||||
if (tableIdAfter === null) { return tableIdAfter; }
|
||||
const rename = renames.find(rename => rename[1] === tableIdAfter);
|
||||
return rename ? rename[0] : tableIdAfter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Given a tableId from before the specified renames, figure out what the tableId is after
|
||||
* the renames. Returns null if there is no valid tableId to return.
|
||||
*/
|
||||
export function getTableIdAfter(renames: LabelDelta[], tableIdBefore: string|null): string|null {
|
||||
if (tableIdBefore === null) { return tableIdBefore; }
|
||||
const rename = renames.find(rename => rename[0] === tableIdBefore);
|
||||
const tableIdAfter = rename ? rename[1] : tableIdBefore;
|
||||
if (tableIdAfter?.startsWith('-')) { return null; }
|
||||
return tableIdAfter;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user