Skip to content

Commit

Permalink
fix(config): move config to app store. close #663
Browse files Browse the repository at this point in the history
  • Loading branch information
Anu-Ujin authored and ganzorig committed Aug 14, 2019
1 parent 813acf6 commit d02a742
Show file tree
Hide file tree
Showing 17 changed files with 189 additions and 222 deletions.
1 change: 1 addition & 0 deletions public/images/integrations/aws-ses.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
140 changes: 0 additions & 140 deletions src/modules/settings/engages/components/Settings.tsx

This file was deleted.

4 changes: 0 additions & 4 deletions src/modules/settings/engages/graphql/index.ts

This file was deleted.

13 changes: 0 additions & 13 deletions src/modules/settings/engages/graphql/mutations.ts

This file was deleted.

13 changes: 0 additions & 13 deletions src/modules/settings/engages/graphql/queries.ts

This file was deleted.

11 changes: 0 additions & 11 deletions src/modules/settings/engages/routes.tsx

This file was deleted.

26 changes: 0 additions & 26 deletions src/modules/settings/engages/types.ts

This file was deleted.

102 changes: 102 additions & 0 deletions src/modules/settings/integrations/components/engages/Settings.tsx
@@ -0,0 +1,102 @@
import Button from 'modules/common/components/Button';
import { FormControl } from 'modules/common/components/form';
import Form from 'modules/common/components/form/Form';
import FormGroup from 'modules/common/components/form/Group';
import ControlLabel from 'modules/common/components/form/Label';
import { ModalFooter } from 'modules/common/styles/main';
import { IButtonMutateProps, IFormProps } from 'modules/common/types';
import React from 'react';
import { IEngageConfig } from '../../types';

type Props = {
engagesConfigDetail: IEngageConfig;
renderButton: (props: IButtonMutateProps) => JSX.Element;
closeModal: () => void;
};

type State = {
secretAccessKey?: string;
accessKeyId?: string;
region?: string;
};

class List extends React.Component<Props, State> {
constructor(props: Props) {
super(props);

const { engagesConfigDetail } = props;

this.state = {
secretAccessKey: engagesConfigDetail.secretAccessKey || '',
accessKeyId: engagesConfigDetail.accessKeyId || '',
region: engagesConfigDetail.region || ''
};
}

generateDoc = values => {
return values;
};

renderContent = (formProps: IFormProps) => {
const { engagesConfigDetail, renderButton, closeModal } = this.props;
const { values, isSubmitted } = formProps;

return (
<>
<FormGroup>
<ControlLabel>AWS-SES Access key ID</ControlLabel>
<FormControl
{...formProps}
max={140}
name="accessKeyId"
defaultValue={engagesConfigDetail.accessKeyId}
/>
</FormGroup>

<FormGroup>
<ControlLabel>AWS-SES Secret access key</ControlLabel>
<FormControl
{...formProps}
max={140}
name="secretAccessKey"
defaultValue={engagesConfigDetail.secretAccessKey}
/>
</FormGroup>

<FormGroup>
<ControlLabel>AWS-SES Region</ControlLabel>
<FormControl
{...formProps}
max={140}
name="region"
defaultValue={engagesConfigDetail.region}
/>
</FormGroup>

<ModalFooter>
<Button
btnStyle="simple"
type="button"
onClick={closeModal}
icon="cancel-1"
>
Cancel
</Button>

{renderButton({
name: 'engagesConfigDetail',
values: this.generateDoc(values),
isSubmitted,
object: this.props.engagesConfigDetail
})}
</ModalFooter>
</>
);
};

render() {
return <Form renderContent={this.renderContent} />;
}
}

export default List;
15 changes: 15 additions & 0 deletions src/modules/settings/integrations/components/store/Entry.tsx
Expand Up @@ -5,6 +5,7 @@ import Facebook from 'modules/settings/integrations/containers/facebook/Form';
import Gmail from 'modules/settings/integrations/containers/google/Gmail';
import React from 'react';
import { Link } from 'react-router-dom';
import Settings from '../../containers/engages/Settings';
import KnowledgeBase from '../../containers/knowledgebase/Form';
import Lead from '../../containers/lead/Form';
import { Box, IntegrationItem, Type } from './styles';
Expand Down Expand Up @@ -71,6 +72,20 @@ class Entry extends React.Component<Props> {
);
}

if (createModal === 'sesconfig') {
const trigger = <a href="#add">+ {__('Add')}</a>;

const content = props => <Settings {...props} />;

return (
<ModalTrigger
title="Add engage config"
trigger={trigger}
content={content}
/>
);
}

if (createModal === 'knowledgeBase') {
const trigger = <a href="#add">+ {__('Add')}</a>;

Expand Down
2 changes: 1 addition & 1 deletion src/modules/settings/integrations/components/store/Row.tsx
Expand Up @@ -50,7 +50,7 @@ class Row extends React.Component<Props, State> {
};

toggleBox = selectedKind => {
if (!selectedKind) {
if (!selectedKind || selectedKind === 'amazon-ses') {
return false;
}

Expand Down
9 changes: 9 additions & 0 deletions src/modules/settings/integrations/constants.ts
Expand Up @@ -136,6 +136,15 @@ export const INTEGRATIONS = [
logo: '/images/integrations/knowledge-base.png',
createModal: 'knowledgeBase',
createUrl: '/settings/integrations/knowledgeBase'
},
{
name: 'Engage config',
description:
'Set up your custome amazon simple email service account here',
inMessenger: false,
kind: 'amazon-ses',
logo: '/images/integrations/aws-ses.svg',
createModal: 'sesconfig'
}
]
},
Expand Down

0 comments on commit d02a742

Please sign in to comment.