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:
+45
@@ -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 };
|
||||
};
|
||||
Reference in New Issue
Block a user