Reset Fields widget implementation (#19283)

## Context
This PR implements the first steps for overridable entities resets.

<img width="1277" height="568" alt="Screenshot 2026-04-02 at 18 58 04"
src="https://github.com/user-attachments/assets/4c7f93b1-c453-4905-a919-cd6af11e0e16"
/>
This commit is contained in:
Weiko
2026-04-07 11:34:44 +02:00
committed by GitHub
parent 23874848a4
commit a2188cb0eb
11 changed files with 528 additions and 0 deletions
@@ -0,0 +1,45 @@
type EntityWithApplicationIdentifierAndOverrides = {
applicationUniversalIdentifier: string;
isActive: boolean;
overrides: unknown;
};
export const splitEntitiesByResetStrategy = <
T extends EntityWithApplicationIdentifierAndOverrides,
>({
entities,
workspaceCustomApplicationUniversalIdentifier,
now,
}: {
entities: T[];
workspaceCustomApplicationUniversalIdentifier: string;
now: string;
}): {
toHardDelete: T[];
toReset: (T & { isActive: true; overrides: null; updatedAt: string })[];
} => {
const toHardDelete: T[] = [];
const toReset: (T & {
isActive: true;
overrides: null;
updatedAt: string;
})[] = [];
for (const entity of entities) {
if (
entity.applicationUniversalIdentifier ===
workspaceCustomApplicationUniversalIdentifier
) {
toHardDelete.push(entity);
} else {
toReset.push({
...entity,
isActive: true as const,
overrides: null,
updatedAt: now,
});
}
}
return { toHardDelete, toReset };
};