Skip to content

Commit

Permalink
Merge pull request #62 from glific/feature/remove-name-field
Browse files Browse the repository at this point in the history
Remove name option from update contacts
  • Loading branch information
mdshamoon authored Dec 27, 2021
2 parents d86ff7b + 65107ee commit b708058
Show file tree
Hide file tree
Showing 45 changed files with 1,140 additions and 300 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,7 @@ scratch.tsx
stats.json
report.html
lambda-build
lib
lib
build
fabric
fabfile.py
49 changes: 48 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,38 @@ All notable changes to this project will be documented in this file. Dates are d

Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).

#### [v1.15.0](https://github.com/nyaruka/floweditor/compare/v1.14.3...v1.15.0)

> 5 November 2021
- Update validation for various router types [`#1018`](https://github.com/nyaruka/floweditor/pull/1018)
- Only show location router tests if locations feature flag set [`#1016`](https://github.com/nyaruka/floweditor/pull/1016)
- Update to latest temba-components [`89f1fee`](https://github.com/nyaruka/floweditor/commit/89f1fee971a2d06afc9d7b32d00b0fff487baf49)

#### [v1.14.3](https://github.com/nyaruka/floweditor/compare/v1.14.2...v1.14.3)

> 20 September 2021
- Let components control how new objects are created [`#1013`](https://github.com/nyaruka/floweditor/pull/1013)

#### [v1.14.2](https://github.com/nyaruka/floweditor/compare/v1.14.1...v1.14.2)

> 16 September 2021
- Use topic rather than subject for open ticket events in simulator [`#1012`](https://github.com/nyaruka/floweditor/pull/1012)
- Bump axios from 0.21.1 to 0.21.2 [`#1011`](https://github.com/nyaruka/floweditor/pull/1011)
- Change topic to be an object rather than string [`521994f`](https://github.com/nyaruka/floweditor/commit/521994f536a45618c7adf7cfd2b5cc6adeed2d9e)

#### [v1.14.1](https://github.com/nyaruka/floweditor/compare/v1.14.0...v1.14.1)

> 15 September 2021
- Topic and assignee [`#1010`](https://github.com/nyaruka/floweditor/pull/1010)
- Include latest translations from transifex [`#1006`](https://github.com/nyaruka/floweditor/pull/1006)
- Add topic and assignee to open ticket action [`f3f6274`](https://github.com/nyaruka/floweditor/commit/f3f6274e0169de45d81e302be899b7010b289f5e)
- Update snapshots [`07a9bef`](https://github.com/nyaruka/floweditor/commit/07a9befef7699da7d41f235ddee31e44bb475899)
- Update snapshots [`95de60a`](https://github.com/nyaruka/floweditor/commit/95de60a6b89860baf573858a5e02995d4e3c2230)

#### [v1.14.0](https://github.com/nyaruka/floweditor/compare/v1.13.19...v1.14.0)

> 14 July 2021
Expand Down Expand Up @@ -32,15 +64,30 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
- Update i18n [`433d561`](https://github.com/nyaruka/floweditor/commit/433d561617365c762db02217545d7966341d307b)
- Fix i18n for field placeholder [`ee7763d`](https://github.com/nyaruka/floweditor/commit/ee7763d66160f9078e1f8abba1361455528cb359)

#### [v1.13.16](https://github.com/nyaruka/floweditor/compare/v1.13.9...v1.13.16)
#### [v1.13.16](https://github.com/nyaruka/floweditor/compare/v1.13.15...v1.13.16)

> 3 June 2021
- Remove old completion [`#999`](https://github.com/nyaruka/floweditor/pull/999)
- Update snapshots [`74b2d6a`](https://github.com/nyaruka/floweditor/commit/74b2d6a941f20e1b01a593b40bb288fc08abb976)
- merge [`d250bdc`](https://github.com/nyaruka/floweditor/commit/d250bdcd3d7fc8f81fdc2753b623c50d75b06983)

#### [v1.13.15](https://github.com/nyaruka/floweditor/compare/v1.13.14...v1.13.15)

> 20 May 2021
- Make sass a dev dependency only [`5f8e6fe`](https://github.com/nyaruka/floweditor/commit/5f8e6fe6e3c7d463908e24fa3b646981ff6d5c6d)

#### [v1.13.14](https://github.com/nyaruka/floweditor/compare/v1.13.13...v1.13.14)

> 20 May 2021
#### [v1.13.13](https://github.com/nyaruka/floweditor/compare/v1.13.9...v1.13.13)

> 20 May 2021
- Update to latest temba-components [`be2723b`](https://github.com/nyaruka/floweditor/commit/be2723bd2e3ccae82f232a7282817bf6de88584c)

#### [v1.13.9](https://github.com/nyaruka/floweditor/compare/v1.13.8...v1.13.9)

> 7 May 2021
Expand Down
29 changes: 29 additions & 0 deletions lambda/topics.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { v4 as generateUUID } from 'uuid';

import { respond } from './utils/index.js';
const topics = {
next: null,
previous: null,
results: [
{
uuid: '6f38eba0-d673-4a35-82df-21bae2b6d466',
name: 'General',
created_on: '2021-09-01T01:06:39.178493Z'
}
]
};

exports.handler = (request, context, callback) => {
if (request.httpMethod === 'POST') {
const body = JSON.parse(request.body);
respond(callback, {
uuid: generateUUID(),
name: body.name,
query: null,
status: 'ready',
count: 0
});
} else {
respond(callback, topics);
}
};
45 changes: 45 additions & 0 deletions lambda/users.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { v4 as generateUUID } from 'uuid';

import { respond } from './utils/index.js';
const users = {
next: null,
previous: null,
results: [
{
email: '[email protected]',
first_name: 'Agent',
last_name: 'User',
role: 'agent',
created_on: '2021-06-10T21:44:30.971221Z'
},
{
email: '[email protected]',
first_name: 'Viewer',
last_name: 'User',
role: 'viewer',
created_on: '2020-11-09T23:02:10.095493Z'
},
{
email: '[email protected]',
first_name: 'Admin',
last_name: 'User',
role: 'administrator',
created_on: '2020-08-18T19:07:08.984182Z'
}
]
};

exports.handler = (request, context, callback) => {
if (request.httpMethod === 'POST') {
const body = JSON.parse(request.body);
respond(callback, {
uuid: generateUUID(),
name: body.name,
query: null,
status: 'ready',
count: 0
});
} else {
respond(callback, users);
}
};
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@glific/flow-editor",
"license": "AGPL-3.0",
"repository": "git://github.com/glific/floweditor.git",
"version": "1.14.0-4",
"version": "1.15.0-1",
"description": "'Standalone flow editing tool designed for use within the Glific suite of messaging tools'",
"browser": "umd/flow-editor.min.js",
"unpkg": "umd/flow-editor.min.js",
Expand Down Expand Up @@ -71,7 +71,7 @@
"@babel/core": "^7.4.4",
"@babel/preset-env": "^7.4.4",
"@babel/preset-react": "7.0.0",
"@nyaruka/temba-components": "0.11.13",
"@nyaruka/temba-components": "0.18.1",
"@testing-library/jest-dom": "4.0.0",
"@testing-library/react": "8.0.1",
"@types/common-tags": "^1.8.0",
Expand All @@ -97,7 +97,7 @@
"array-move": "2.1.0",
"auto-bind": "2.1.0",
"auto-changelog": "1.13.0",
"axios": "0.21.1",
"axios": "0.21.2",
"camelcase": "^5.3.1",
"classnames": "2.2.6",
"common-tags": "1.8.0",
Expand Down
2 changes: 2 additions & 0 deletions src/components/__snapshots__/index.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ Array [
"simulateStart": "",
"templates": "/assets/templates.json",
"ticketers": "/assets/ticketers.json",
"topics": "/assets/topics.json",
"users": "/assets/users.json",
},
"a4f64f1b-85bc-477e-b706-de313a022979",
undefined,
Expand Down
4 changes: 2 additions & 2 deletions src/components/flow/actions/openticket/OpenTicket.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ import { OpenTicket } from 'flowTypes';
import { fakePropType } from 'config/ConfigProvider';

const OpenTicketComp: React.SFC<OpenTicket> = (
{ ticketer, subject },
{ ticketer, subject, topic },
context: any
): JSX.Element => {
const showTicketer = ticketer.name.indexOf(context.config.brand) === -1;
return (
<div>
<div>{subject}</div>
<div>{subject ? subject : topic ? topic.name : null}</div>
{showTicketer ? (
<div style={{ fontSize: '80%' }}>
Using <span style={{ fontWeight: 400 }}>{ticketer.name}</span>
Expand Down
2 changes: 1 addition & 1 deletion src/components/flow/actions/updatecontact/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export const initializeForm = (
channel: { value: null },
language: { value: null },
status: { value: CONTACT_STATUS_ACTIVE },
field: { value: NAME_PROPERTY },
field: { value: LANGUAGE_PROPERTY },
fieldValue: { value: '' }
};

Expand Down
19 changes: 7 additions & 12 deletions src/components/flow/routers/classify/ClassifyRouterForm.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { react as bindCallbacks } from 'auto-bind';
import Dialog, { ButtonSet, Tab } from 'components/dialog/Dialog';
import { hasErrors, renderIssues } from 'components/flow/actions/helpers';
import { renderIssues } from 'components/flow/actions/helpers';
import { RouterFormProps } from 'components/flow/props';
import { nodeToState, stateToNode } from './helpers';
import { createResultNameInput } from 'components/flow/routers/widgets';
Expand Down Expand Up @@ -71,7 +71,10 @@ export default class ClassifyRouterForm extends React.Component<

if (keys.hasOwnProperty('resultName')) {
updates.resultName = validate(i18n.t('forms.result_name', 'Result Name'), keys.resultName, [
shouldRequireIf(submitting)
shouldRequireIf(submitting),
Required,
Alphanumeric,
StartIsNonNumeric
]);
}

Expand All @@ -93,16 +96,8 @@ export default class ClassifyRouterForm extends React.Component<
this.setState({ cases, valid: !invalidCase });
}

private handleUpdateResultName(value: string): void {
const resultName = validate(i18n.t('forms.result_name', 'Result Name'), value, [
Required,
Alphanumeric,
StartIsNonNumeric
]);
this.setState({
resultName,
valid: this.state.valid && !hasErrors(resultName)
});
private handleUpdateResultName(value: string): boolean {
return this.handleUpdate({ resultName: value });
}

private handleSave(): void {
Expand Down
65 changes: 49 additions & 16 deletions src/components/flow/routers/expression/ExpressionRouterForm.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { react as bindCallbacks } from 'auto-bind';
import * as React from 'react';
import Dialog, { ButtonSet } from 'components/dialog/Dialog';
import { hasErrors, renderIssues } from 'components/flow/actions/helpers';
import { renderIssues } from 'components/flow/actions/helpers';
import { RouterFormProps } from 'components/flow/props';
import CaseList, { CaseProps } from 'components/flow/routers/caselist/CaseList';
import { nodeToState, stateToNode } from 'components/flow/routers/expression/helpers';
import { createResultNameInput } from 'components/flow/routers/widgets';
import TextInputElement from 'components/form/textinput/TextInputElement';
import TypeList from 'components/nodeeditor/TypeList';
import { FormState, StringEntry } from 'store/nodeEditor';
import { FormState, mergeForm, StringEntry } from 'store/nodeEditor';
import { LowerCaseAlphaNumeric, Required, StartIsNonNumeric, validate } from 'store/validators';
import i18n from 'config/i18n';

Expand Down Expand Up @@ -43,28 +43,61 @@ export default class ExpressionRouterForm extends React.Component<
});
}

private handleUpdateResultName(value: string): void {
const resultName = validate(i18n.t('forms.result_name', 'Result Name'), value, [
LowerCaseAlphaNumeric,
StartIsNonNumeric
]);
this.setState({
resultName
});
private handleUpdate(keys: {
resultName?: string;
operand?: string;
cases?: CaseProps[];
}): boolean {
const updates: Partial<ExpressionRouterFormState> = {};

if (keys.hasOwnProperty('operand')) {
updates.operand = validate(i18n.t('forms.operand', 'Operand'), keys.operand, [Required]);
}

if (keys.hasOwnProperty('cases')) {
updates.cases = keys.cases;
}

if (keys.hasOwnProperty('resultName')) {
updates.resultName = validate(i18n.t('forms.result_name', 'Result Name'), keys.resultName, [
LowerCaseAlphaNumeric,
StartIsNonNumeric
]);
}

const updated = mergeForm(this.state, updates);

// update our form
this.setState(updated);
return updated.valid;
}

private handleOperandUpdated(value: string): void {
this.setState({
operand: validate(i18n.t('forms.operand', 'Operand'), value, [Required])
});
private handleUpdateResultName(resultName: string): void {
this.handleUpdate({ resultName });
}

private handleOperandUpdated(operand: string): void {
this.handleUpdate({ operand });
}

private handleCasesUpdated(cases: CaseProps[]): void {
this.setState({ cases });
this.handleUpdate({ cases });
}

private handleSave(): void {
if (this.state.valid && !hasErrors(this.state.resultName)) {
// if we still have invalid cases, don't move forward
const invalidCase = this.state.cases.find((caseProps: CaseProps) => !caseProps.valid);
if (invalidCase) {
return;
}

// validate our result name in case they haven't interacted
const valid = this.handleUpdate({
resultName: this.state.resultName.value,
operand: this.state.operand.value
});

if (valid) {
this.props.updateRouter(stateToNode(this.props.nodeSettings, this.state));
this.props.onClose(false);
}
Expand Down
Loading

0 comments on commit b708058

Please sign in to comment.