Skip to content

Commit 32ab1c4

Browse files
authored
Merge pull request #156 from glific/feat/deactivating_profile
Contact Profiles: Added option to deactivate profile
2 parents 3bb6d03 + c094c0d commit 32ab1c4

File tree

5 files changed

+16
-15
lines changed

5 files changed

+16
-15
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "@glific/flow-editor",
33
"license": "AGPL-3.0",
44
"repository": "git://github.com/glific/floweditor.git",
5-
"version": "1.26.3-26",
5+
"version": "1.26.3-27",
66
"description": "'Standalone flow editing tool designed for use within the Glific suite of messaging tools'",
77
"browser": "umd/flow-editor.min.js",
88
"unpkg": "umd/flow-editor.min.js",

public/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@
299299
attachmentsEnabled: true,
300300
showNodeLabel: true,
301301
mutable: true,
302-
filters: ['whatsapp', 'classifier', 'ticketer', 'optins', 'groups'],
302+
filters: ['whatsapp', 'classifier', 'ticketer', 'optins', 'groups', 'profile'],
303303
skipValidation: false,
304304

305305
excludeTypes: [

src/components/flow/routers/contactprofile/ContactProfileRouter.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@ const ContactProfileRouter: React.SFC<SetContactProfile> = (
2020
Switching profile to <strong>{value}</strong>
2121
</div>
2222
);
23+
} else if (profile_type === 'Deactivate Profile') {
24+
return (
25+
<div>
26+
Deactivating profile <strong>{value}</strong>
27+
</div>
28+
);
2329
}
2430
return <div>Manage profile</div>;
2531
};

src/components/flow/routers/contactprofile/ContactProfileRouterForm.tsx

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,8 @@ export interface ContactProfileRouterFormState extends FormState {
2222

2323
export const profileOptions = {
2424
'1': { id: '1', name: 'Create Profile', type: AssetType.ContactProfile },
25-
'2': { id: '2', name: 'Switch Profile', type: AssetType.ContactProfile }
26-
};
27-
28-
export const profileOptionsWithName: any = {
29-
'Create Profile': { id: '1', name: 'Create Profile', type: AssetType.ContactProfile },
30-
'Switch Profile': { id: '2', name: 'Switch Profile', type: AssetType.ContactProfile }
25+
'2': { id: '2', name: 'Switch Profile', type: AssetType.ContactProfile },
26+
'3': { id: '3', name: 'Deactivate Profile', type: AssetType.ContactProfile }
3127
};
3228

3329
export default class ContactProfileRouterForm extends React.Component<
@@ -79,7 +75,6 @@ export default class ContactProfileRouterForm extends React.Component<
7975

8076
public renderEdit(): JSX.Element {
8177
const typeConfig = this.props.typeConfig;
82-
8378
return (
8479
<Dialog title={typeConfig.name} headerClass={typeConfig.type} buttons={this.getButtons()}>
8580
<TypeList __className="" initialType={typeConfig} onChange={this.props.onTypeChange} />

src/components/flow/routers/contactprofile/helpers.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,7 @@ import { SetContactProfile } from 'flowTypes';
66
import { RenderNode } from 'store/flowContext';
77
import { NodeEditorSettings } from 'store/nodeEditor';
88

9-
import {
10-
ContactProfileRouterFormState,
11-
profileOptions,
12-
profileOptionsWithName
13-
} from './ContactProfileRouterForm';
9+
import { ContactProfileRouterFormState, profileOptions } from './ContactProfileRouterForm';
1410

1511
export const nodeToState = (settings: NodeEditorSettings): ContactProfileRouterFormState => {
1612
let resulNode: ContactProfileRouterFormState = {
@@ -24,8 +20,12 @@ export const nodeToState = (settings: NodeEditorSettings): ContactProfileRouterF
2420
const action = settings.originalAction as SetContactProfile;
2521

2622
if (action.profile_type) {
23+
const option =
24+
Object.values(profileOptions).find(value => value.name === action.profile_type) ||
25+
profileOptions['1'];
26+
2727
resulNode.optionType = {
28-
value: profileOptionsWithName[action.profile_type]
28+
value: option
2929
};
3030

3131
if (typeof action.value === 'string') {

0 commit comments

Comments
 (0)