Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(CE): form-data loss on navigation #443

Open
wants to merge 49 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
fd585ab
fix(CE): form-data loss on navigation
xyfer17 Oct 26, 2024
dcf1c3b
chore(CE): add audit logs serializer and audit log permission (#426)
github-actions[bot] Oct 24, 2024
ef1c394
fix(CE): add exception to tracker (#436)
subintp Oct 24, 2024
9f7f06c
chore(CE): added audit logs to catalogs_controller (#439)
github-actions[bot] Oct 25, 2024
e7fd2c7
chore(CE): added audit logs to schedule_sync_controller (#440)
github-actions[bot] Oct 25, 2024
23b9de3
chore(CE): add data app session model (#438)
github-actions[bot] Oct 25, 2024
45ee172
chore(CE): added audit log to workspace (#442)
github-actions[bot] Oct 28, 2024
d234817
chore(CE): add audit logs to factory and roles (#441)
github-actions[bot] Oct 28, 2024
98b0477
Multiwoven release v0.24.0 (#427)
RafaelOAiSquared Oct 28, 2024
ca5b2b5
Multiwoven release v0.25.0 (#428)
RafaelOAiSquared Oct 28, 2024
383365c
Multiwoven release v0.27.0 (#430)
RafaelOAiSquared Oct 28, 2024
818cba7
Multiwoven release v0.28.0 (#431)
RafaelOAiSquared Oct 28, 2024
c10c637
Multiwoven release v0.29.0 (#432)
RafaelOAiSquared Oct 28, 2024
c109963
Multiwoven release v0.30.0 (#433)
RafaelOAiSquared Oct 28, 2024
9b3634b
chore(CE): add audit logs to report controller (#446)
github-actions[bot] Oct 29, 2024
00aab20
chore(CE): data app report model changes (#445)
github-actions[bot] Oct 29, 2024
73a1987
chore(CE): add audit logs to users controller (#449)
github-actions[bot] Oct 30, 2024
3723e23
chore(CE): add audit to sync records controller (#448)
github-actions[bot] Oct 30, 2024
0395e5c
chore(CE): add audit logs to sync runs controller (#450)
github-actions[bot] Oct 30, 2024
fdb0d24
Multiwoven release v0.31.0 (#447)
RafaelOAiSquared Oct 30, 2024
9a46d87
Multiwoven release v0.32.0 (#453)
RafaelOAiSquared Nov 5, 2024
924daa7
chore(CE): add additional_remarks in feedback model (#454)
github-actions[bot] Nov 8, 2024
b0a18be
feat(CE): Added Mailchimp Destination Connector (#437)
xyfer17 Nov 11, 2024
6ecba38
fix(CE): data app deletion error fix
github-actions[bot] Nov 12, 2024
ba6d8df
fix(CE): mailchimp dependency build issue
afthabvp Nov 12, 2024
a70219e
Multiwoven release v0.33.0 (#459)
RafaelOAiSquared Nov 12, 2024
61edf7c
chore(CE): add icons for ais data store and http model (#460)
afthabvp Nov 12, 2024
b276d1c
chore(CE): add timeout to http client (#458)
github-actions[bot] Nov 13, 2024
2fd27d0
feat(CE): Add HTTP Model Source Connector (#466)
github-actions[bot] Nov 13, 2024
9626b58
chore(CE): Dynamic sql model type added (#465)
github-actions[bot] Nov 13, 2024
8afc338
fix(CE): http model config (#464)
github-actions[bot] Nov 13, 2024
47c2af9
feat(CE): AIS Data store destination connector (#462)
github-actions[bot] Nov 13, 2024
8d57a24
fix(CE): ais data store icon (#467)
afthabvp Nov 13, 2024
ad08480
chore(CE): update integration gem version (#457)
github-actions[bot] Nov 14, 2024
f7dbfda
fix(CE): Dockerfile update free tds (#470)
afthabvp Nov 14, 2024
5ebfcc8
feat(CE): added dynamic_sql type to model (#576)
bvb007 Nov 13, 2024
26eef75
chore(CE): Change http model name (#469)
github-actions[bot] Nov 14, 2024
435ff50
feat(CE): Fetch json_schema from model (#581)
bvb007 Nov 14, 2024
234c1d8
chore(CE): Update HTTP Model spec (#583) (#474)
github-actions[bot] Nov 15, 2024
ebfdd35
Resolve conflict in cherry-pick of d10fecacbae9908b9ef7e8d08bb1fd3bde…
github-actions[bot] Nov 15, 2024
17b34d6
chore(CE): Server Gem Update 0.15.3 (#589) (#471)
github-actions[bot] Nov 15, 2024
a7cb638
feat(CE): fetch data for dsql models (#596) (#476)
github-actions[bot] Nov 18, 2024
d5e43d8
chore(CE): Add session id to filter parameter (#591) (#475)
github-actions[bot] Nov 18, 2024
c797034
chore(CE): Change title of AIS Data Store (#585) (#477)
github-actions[bot] Nov 18, 2024
cf716da
feat(CE): on_failure report error to AppSignal (#478)
RafaelOAiSquared Nov 18, 2024
d3ce365
Multiwoven release v0.34.0 (#480)
RafaelOAiSquared Nov 19, 2024
c584c38
fix(CE): fixed build error
macintushar Nov 19, 2024
17cd11d
fix(CE): removed reference to build_and_push job
RafaelOAiSquared Nov 19, 2024
cd1abb9
Merge branch 'main' into bugfix/connector-formData-persistence
xyfer17 Nov 20, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion ui/src/components/ExitModal/ExitModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,18 @@ import {
} from '@chakra-ui/react';
import { useNavigate } from 'react-router-dom';
import ExitWarningImage from '@/assets/images/ExitWarning.png';
import useConnectorFormStore from '@/stores/useConnectorFormStore';

const ExitModal = (): JSX.Element => {
const { isOpen, onOpen, onClose } = useDisclosure();
const { resetAllFormData } = useConnectorFormStore();
const navigate = useNavigate();

const handleSetupExit = () => {
resetAllFormData();
navigate('*');
};

return (
<>
<Button
Expand Down Expand Up @@ -74,7 +81,7 @@ const ExitModal = (): JSX.Element => {
variant='solid'
color='white'
rounded='lg'
onClick={() => navigate('*')}
onClick={handleSetupExit}
letterSpacing='-0.14px'
>
Exit
Expand Down
37 changes: 34 additions & 3 deletions ui/src/components/JSONSchemaForm/JSONSchemaForm.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { useEffect } from 'react';
import Form from '@rjsf/chakra-ui';
import { RJSFSchema } from '@rjsf/utils';
import validator from '@rjsf/validator-ajv8';
Expand All @@ -9,6 +10,7 @@ import BaseInputTemplate from '@/components/JSONSchemaForm/rjsf/BaseInputTemplat
import DescriptionFieldTemplate from '@/components/JSONSchemaForm/rjsf/DescriptionFieldTemplate';
import { FormProps } from '@rjsf/core';
import WrapIfAdditionalTemplate from './rjsf/WrapIfAdditionalTemplate';
import useConnectorFormStore from '@/stores/useConnectorFormStore';

type JSONSchemaFormProps = {
schema: RJSFSchema;
Expand All @@ -17,6 +19,8 @@ type JSONSchemaFormProps = {
onChange?: (formData: FormData) => void;
children?: JSX.Element;
formData?: unknown;
connectorId?: string;
connectorType: string;
};

const JSONSchemaForm = ({
Expand All @@ -26,7 +30,13 @@ const JSONSchemaForm = ({
onChange,
children,
formData,
connectorId,
connectorType,
}: JSONSchemaFormProps): JSX.Element => {
const { getConnectorFormData, setConnectorFormData, resetConnectorFormData } =
useConnectorFormStore();
const currentFormData = connectorId ? getConnectorFormData(connectorType, connectorId) : formData;

const templateOverrides: FormProps<any, RJSFSchema, any>['templates'] = {
ObjectFieldTemplate: ObjectFieldTemplate,
TitleFieldTemplate: TitleFieldTemplate,
Expand All @@ -35,15 +45,36 @@ const JSONSchemaForm = ({
DescriptionFieldTemplate: DescriptionFieldTemplate,
WrapIfAdditionalTemplate: WrapIfAdditionalTemplate,
};

const handleFormChange = (data: any) => {
const updatedFormData = data.formData;
connectorId && setConnectorFormData(connectorType, connectorId, updatedFormData);
onChange?.(updatedFormData);
};

useEffect(() => {
const handleBeforeUnload = () => {
connectorId && resetConnectorFormData(connectorType, connectorId);
};
window.addEventListener('beforeunload', handleBeforeUnload);

return () => {
window.removeEventListener('beforeunload', handleBeforeUnload);
};
}, [connectorType, connectorId, resetConnectorFormData]);

return (
<Form
uiSchema={uiSchema}
schema={schema}
validator={validator}
templates={templateOverrides}
formData={formData}
onSubmit={({ formData }) => onSubmit(formData)}
onChange={({ formData }) => onChange?.(formData)}
formData={currentFormData}
onSubmit={({ formData }) => {
onSubmit(formData);
connectorId && resetConnectorFormData(connectorType, connectorId);
}}
onChange={handleFormChange}
>
{children}
</Form>
Expand Down
61 changes: 61 additions & 0 deletions ui/src/stores/useConnectorFormStore.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import { create } from 'zustand';

type ConnectorType = string;
type ConnectorId = string;
interface FormData {
[key: string]: unknown;
}

interface ConnectorFormState {
formsData: {
[connectorType: string]: {
[connectorId: string]: FormData;
};
};
setConnectorFormData: (
connectorType: ConnectorType,
connectorId: ConnectorId,
data: FormData,
) => void;
getConnectorFormData: (connectorType: ConnectorType, connectorId: ConnectorId) => FormData | null;
resetConnectorFormData: (connectorType: ConnectorType, connectorId: ConnectorId) => void;
resetAllFormData: () => void;
}

const useConnectorFormStore = create<ConnectorFormState>((set, get) => ({
formsData: {},

setConnectorFormData: (connectorType, connectorId, data) =>
set((state) => ({
formsData: {
...state.formsData,
[connectorType]: {
...state.formsData[connectorType],
[connectorId]: data,
},
},
})),

getConnectorFormData: (connectorType, connectorId) => {
const state = get();
return state.formsData[connectorType]?.[connectorId] ?? null;
},

resetConnectorFormData: (connectorType, connectorId) =>
set((state) => {
if (!state.formsData[connectorType]) return state;
const remainingConnectorData = Object.fromEntries(
Object.entries(state.formsData[connectorType] || {}).filter(([key]) => key !== connectorId),
);
return {
formsData: {
...state.formsData,
[connectorType]: remainingConnectorData,
},
};
}),

resetAllFormData: () => set(() => ({ formsData: {} })),
}));

export default useConnectorFormStore;
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ const ConnectorConfigForm = ({ connectorType }: { connectorType: string }): JSX.
schema={connectorSchema}
uiSchema={generatedSchema}
onSubmit={(formData: FormData) => handleFormSubmit(formData)}
connectorId={connector}
connectorType={connectorType}
>
<FormFooter
ctaName='Continue'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ const EditDestination = (): JSX.Element => {
formData={formData}
onSubmit={(formData: FormData) => handleOnTestClick(formData)}
onChange={(formData: FormData) => setFormData(formData)}
connectorType='destination'
>
<FormFooter
ctaName='Save Changes'
Expand Down
1 change: 1 addition & 0 deletions ui/src/views/Connectors/Sources/EditSource/EditSource.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ const EditSource = (): JSX.Element => {
formData={formData}
onSubmit={(formData: FormData) => handleOnTestClick(formData)}
onChange={(formData: FormData) => setFormData(formData)}
connectorType='source'
>
<FormFooter
ctaName='Save Changes'
Expand Down
Loading