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: Dynamic fields disappearing on saving again #134

Merged
merged 2 commits into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
7 changes: 4 additions & 3 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@
attachmentsEnabled: true,
showNodeLabel: true,
mutable: true,
filters: ['whatsapp', 'classifier', 'ticketer', 'optins', 'groups'],
filters: ['whatsapp', 'classifier', 'ticketer', 'optins'],

excludeTypes: [
'add_contact_urn',
Expand Down Expand Up @@ -350,8 +350,9 @@
endpoints: {
globals: base + 'globals',
groups: base + 'groups',
fields: base + 'fields?scope=contact',
waGroupFields: base + 'fields?scope=group',
fields: base + 'fields',
// fields: base + 'fields?scope=contact',
// waGroupFields: base + 'fields?scope=group',
labels: base + 'labels',
optins: base + 'optins',
channels: base + 'channels',
Expand Down
1 change: 0 additions & 1 deletion src/components/__snapshots__/index.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ Array [
"topics": "/assets/topics.json",
"users": "/assets/users.json",
"validateMedia": "",
"waGroupFields": "/assets/fields.json",
},
"a4f64f1b-85bc-477e-b706-de313a022979",
undefined,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,23 +64,30 @@ export default class SendMsgForm extends React.Component<
private handleInteractivesChanged(selected: any[]): void {
const { endpoint, type } = this.props.assetStore.interactives;
const interactiveMsg = selected ? selected[0] : null;
if (interactiveMsg.name === 'Expression') {
this.setState({
expression: { value: '' },
interactives: {
value: { name: 'Expression' }
}
});
} else {
if (interactiveMsg) {
if (interactiveMsg) {
if (interactiveMsg.name === 'Expression') {
this.setState({
expression: { value: '' },
interactives: {
value: { name: 'Expression' }
}
});
} else {
getAsset(endpoint, type, interactiveMsg.id).then(response => {
this.setState({
let state: any = {
expression: null,
interactives: {
value: response
},
isChecked: false
});
}
};

if (interactiveMsg.id !== this.state.interactives.value.id) {
state.isChecked = false;
state.listValuesCount = '';
state.listValues = Array(10).fill({ value: { id: '', label: '' } });
}

this.setState(state);
});
}
}
Expand All @@ -100,7 +107,6 @@ export default class SendMsgForm extends React.Component<
]);
}
const updated = mergeForm(this.state, updates) as SendInteractiveMsgFormState;

this.setState(updated);
return updated.valid;
}
Expand Down Expand Up @@ -246,7 +252,6 @@ export default class SendMsgForm extends React.Component<
);

const values = listValues.map((value, index) => renderListOption(value, index));

return (
<div>
<div className={styles.list_container}>
Expand Down Expand Up @@ -335,6 +340,7 @@ export default class SendMsgForm extends React.Component<
const message = currentMessage.interactive_content;
body = getMsgBody(message);
}

return (
<Dialog
title={typeConfig.name}
Expand Down Expand Up @@ -374,7 +380,7 @@ export default class SendMsgForm extends React.Component<
<CheckboxElement
name={i18n.t('forms.timeout', 'Timeout')}
checked={this.state.isChecked}
description={'Use dynamic fields'}
title={'Use dynamic fields'}
onChange={value => {
this.setState({ isChecked: value });
}}
Expand Down
12 changes: 6 additions & 6 deletions src/external/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -306,12 +306,12 @@ export const createAssetStore = (endpoints: Endpoints): Promise<AssetStore> => {
id: 'key',
items: {}
},
waGroupFields: {
endpoint: getURL(endpoints.waGroupFields),
type: AssetType.Field,
id: 'key',
items: {}
},
// waGroupFields: {
// endpoint: getURL(endpoints.waGroupFields),
// type: AssetType.Field,
// id: 'key',
// items: {}
// },
globals: {
endpoint: getURL(endpoints.globals),
type: AssetType.Global,
Expand Down
2 changes: 1 addition & 1 deletion src/flowTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export interface Endpoints {
resthooks: string;
recents: string;
fields: string;
waGroupFields: string;
// waGroupFields: string;
globals: string;
groups: string;
recipients: string;
Expand Down
2 changes: 1 addition & 1 deletion src/test/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const config: FlowEditorConfig = {
globals: '/assets/globals.json',
groups: '/assets/groups.json',
fields: '/assets/fields.json',
waGroupFields: '/assets/fields.json',
// waGroupFields: '/assets/fields.json',
recipients: '/assets/recipients.json',
contacts: '/assets/recipients.json',
labels: '/assets/labels.json',
Expand Down
2 changes: 1 addition & 1 deletion src/test/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export const TEST_DEFINITION: FlowDefinition = {
export const EMPTY_TEST_ASSETS = {
channels: { items: {}, type: AssetType.Channel },
fields: { items: {}, type: AssetType.Field },
waGroupFields: { items: {}, type: AssetType.Field },
// waGroupFields: { items: {}, type: AssetType.Field },
languages: { items: {}, type: AssetType.Language },
labels: { items: {}, type: AssetType.Label },
results: { items: {}, type: AssetType.Result },
Expand Down
2 changes: 1 addition & 1 deletion src/testUtils/assetCreators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ export const getActionFormProps = (action: AnyAction): ActionFormProps => ({
assetStore: {
channels: { items: {}, type: AssetType.Channel },
fields: { items: {}, type: AssetType.Field },
waGroupFields: { items: {}, type: AssetType.Field },
// waGroupFields: { items: {}, type: AssetType.Field },
languages: { items: {}, type: AssetType.Language },
labels: { items: {}, type: AssetType.Label },
results: { items: {}, type: AssetType.Result },
Expand Down
Loading