From 0be8c6c2e8386f9ee48f62346c75417c22a10cdd Mon Sep 17 00:00:00 2001
From: Nick Zelei <2420177+nickzelei@users.noreply.github.com>
Date: Wed, 20 Nov 2024 16:24:54 -0800
Subject: [PATCH] NEOS-1628: Optimizes Bulk Set and Apply Default (#2968)
---
.../components/DataGenConnectionCard.tsx | 33 ++++++++++-----
.../components/DataSyncConnectionCard.tsx | 37 ++++++++++------
.../components/useOnApplyDefaultClick.tsx | 14 +++----
.../useOnTransformerBulkUpdateClick.tsx | 42 +++++++++++++++++++
.../new/job/generate/single/schema/page.tsx | 33 ++++++++++-----
.../(mgmt)/[account]/new/job/schema/page.tsx | 37 ++++++++++------
.../ApplyDefaultTransformersButton.tsx | 2 +-
7 files changed, 142 insertions(+), 56 deletions(-)
create mode 100644 frontend/apps/web/app/(mgmt)/[account]/jobs/[id]/source/components/useOnTransformerBulkUpdateClick.tsx
diff --git a/frontend/apps/web/app/(mgmt)/[account]/jobs/[id]/source/components/DataGenConnectionCard.tsx b/frontend/apps/web/app/(mgmt)/[account]/jobs/[id]/source/components/DataGenConnectionCard.tsx
index 5da58a8417..ece66a947a 100644
--- a/frontend/apps/web/app/(mgmt)/[account]/jobs/[id]/source/components/DataGenConnectionCard.tsx
+++ b/frontend/apps/web/app/(mgmt)/[account]/jobs/[id]/source/components/DataGenConnectionCard.tsx
@@ -70,6 +70,7 @@ import {
import SchemaPageSkeleton from './SchemaPageSkeleton';
import { useOnApplyDefaultClick } from './useOnApplyDefaultClick';
import { useOnImportMappings } from './useOnImportMappings';
+import { useOnTransformerBulkUpdateClick } from './useOnTransformerBulkUpdateClick';
import {
getFilteredTransformersForBulkSet,
getOnSelectedTableToggle,
@@ -290,24 +291,34 @@ export default function DataGenConnectionCard({ jobId }: Props): ReactElement {
getMappings() {
return form.getValues('mappings');
},
- setTransformer: onTransformerUpdate,
+ setMappings(mappings) {
+ form.setValue('mappings', mappings, {
+ shouldDirty: true,
+ shouldTouch: true,
+ shouldValidate: false,
+ });
+ },
constraintHandler: schemaConstraintHandler,
triggerUpdate() {
form.trigger('mappings');
},
});
- function onTransformerBulkUpdate(
- indices: number[],
- config: JobMappingTransformerForm
- ): void {
- indices.forEach((idx) => {
- onTransformerUpdate(idx, config);
- });
- setTimeout(() => {
+ const { onClick: onTransformerBulkUpdate } = useOnTransformerBulkUpdateClick({
+ getMappings() {
+ return form.getValues('mappings');
+ },
+ setMappings(mappings) {
+ form.setValue('mappings', mappings, {
+ shouldDirty: true,
+ shouldTouch: true,
+ shouldValidate: false,
+ });
+ },
+ triggerUpdate() {
form.trigger('mappings');
- }, 0);
- }
+ },
+ });
if (isJobLoading || isSchemaDataMapLoading || isGetTransformersLoading) {
return