From 7f727a398109c1a9b542bc76b680a654675241d0 Mon Sep 17 00:00:00 2001 From: Tuguldur Ch Date: Mon, 2 Oct 2023 14:16:02 +0800 Subject: [PATCH 01/64] update(exm):add ability segmentation --- .../plugin-exmfeed-api/src/automations.ts | 22 +++++++ packages/plugin-exmfeed-api/src/configs.ts | 6 +- packages/plugin-exmfeed-api/src/essyncer.js | 12 ++++ packages/plugin-exmfeed-api/src/forms.ts | 59 +++++++++++++++++ packages/plugin-exmfeed-api/src/segments.ts | 64 +++++++++++++++++++ packages/plugin-imap-ui/src/configs.js | 54 ++++++++-------- packages/plugin-reactions-api/src/configs.ts | 4 +- packages/plugin-reactions-api/src/essyncer.js | 12 ++++ packages/plugin-reactions-api/src/forms.ts | 59 +++++++++++++++++ packages/plugin-reactions-api/src/segments.ts | 18 ++++++ 10 files changed, 281 insertions(+), 29 deletions(-) create mode 100644 packages/plugin-exmfeed-api/src/automations.ts create mode 100644 packages/plugin-exmfeed-api/src/essyncer.js create mode 100644 packages/plugin-exmfeed-api/src/forms.ts create mode 100644 packages/plugin-exmfeed-api/src/segments.ts create mode 100644 packages/plugin-reactions-api/src/essyncer.js create mode 100644 packages/plugin-reactions-api/src/forms.ts create mode 100644 packages/plugin-reactions-api/src/segments.ts diff --git a/packages/plugin-exmfeed-api/src/automations.ts b/packages/plugin-exmfeed-api/src/automations.ts new file mode 100644 index 0000000000..f3725629a0 --- /dev/null +++ b/packages/plugin-exmfeed-api/src/automations.ts @@ -0,0 +1,22 @@ +export default { + constants: { + triggers: [ + { + type: 'exmfeed:feeds', + img: 'automation3.svg', + icon: 'file-plus-alt', + label: 'Exm Feed', + description: + 'Start with a blank workflow that enralls and is triggered off exm feed' + }, + { + type: 'exmfeed:thanks', + img: 'automation3.svg', + icon: 'file-plus-alt', + label: 'Exm Thanks', + description: + 'Start with a blank workflow that enralls and is triggered off exm thanks' + } + ] + } +}; diff --git a/packages/plugin-exmfeed-api/src/configs.ts b/packages/plugin-exmfeed-api/src/configs.ts index f87d794599..4d58aa059f 100644 --- a/packages/plugin-exmfeed-api/src/configs.ts +++ b/packages/plugin-exmfeed-api/src/configs.ts @@ -9,6 +9,10 @@ import cronjobs, { sendCeremonyNotification } from './cronjobs'; +import automations from './automations'; +import segments from './segments'; +import forms from './forms'; + export let debug; export let graphqlPubsub; export let mainDb; @@ -55,5 +59,5 @@ export default { graphqlPubsub = options.pubsubClient; }, - meta: { cronjobs } + meta: { cronjobs, automations, segments, forms } }; diff --git a/packages/plugin-exmfeed-api/src/essyncer.js b/packages/plugin-exmfeed-api/src/essyncer.js new file mode 100644 index 0000000000..b796a20239 --- /dev/null +++ b/packages/plugin-exmfeed-api/src/essyncer.js @@ -0,0 +1,12 @@ +module.exports = [ + { + name: 'exm_feeds', + schema: '{}', + script: '' + }, + { + name: 'exm_thanks', + schema: '{}', + script: '' + } +]; diff --git a/packages/plugin-exmfeed-api/src/forms.ts b/packages/plugin-exmfeed-api/src/forms.ts new file mode 100644 index 0000000000..76164f5700 --- /dev/null +++ b/packages/plugin-exmfeed-api/src/forms.ts @@ -0,0 +1,59 @@ +import { generateFieldsFromSchema } from '@erxes/api-utils/src'; +import { generateModels } from './connectionResolver'; + +const generateFields = async ({ subdomain, data }) => { + const { type, usageType } = data; + + const models = await generateModels(subdomain); + + const { ExmFeed, ExmThanks } = models; + + let schema: any; + let fields: Array<{ + _id: number; + name: string; + group?: string; + label?: string; + type?: string; + validation?: string; + options?: string[]; + selectOptions?: Array<{ label: string; value: string }>; + }> = []; + + switch (type) { + case 'feeds': + schema = ExmFeed.schema; + break; + + case 'thanks': + schema = ExmThanks.schema; + break; + } + + fields = []; + + if (schema) { + fields = [...fields, ...(await generateFieldsFromSchema(schema, ''))]; + + for (const name of Object.keys(schema.paths)) { + const path = schema.paths[name]; + + if (path.schema) { + fields = [ + ...fields, + ...(await generateFieldsFromSchema(path.schema, `${name}.`)) + ]; + } + } + } + + return fields; +}; + +export default { + types: [ + { description: 'Exm feed', type: 'feed' }, + { description: 'Exm thanks', type: 'thanks' } + ], + fields: generateFields +}; diff --git a/packages/plugin-exmfeed-api/src/segments.ts b/packages/plugin-exmfeed-api/src/segments.ts new file mode 100644 index 0000000000..8d5b4c79c3 --- /dev/null +++ b/packages/plugin-exmfeed-api/src/segments.ts @@ -0,0 +1,64 @@ +import * as _ from 'underscore'; +import { fetchByQuery } from '@erxes/api-utils/src/elasticsearch'; +import { getEsIndexByContentType } from '@erxes/api-utils/src/segments'; + +export default { + dependentServices: [ + { name: 'contacts', twoWay: true }, + { name: 'core', twoWay: true } + ], + + contentTypes: [ + { type: 'feeds', description: 'Exm Feed', esIndex: 'exm_feeds' }, + { type: 'thanks', description: 'Exm Thanks', esIndex: 'exm_thanks' } + ], + + esTypesMap: async () => { + return { data: { typesMap: {} }, status: 'success' }; + }, + + associationFilter: async ({ + subdomain, + data: { mainType, propertyType, positiveQuery, negativeQuery } + }) => { + let ids: string[] = []; + + if (mainType.includes('core')) { + ids = await fetchByQuery({ + subdomain, + index: 'exm_feeds', + _source: 'createdBy', + positiveQuery, + negativeQuery + }); + } + + if (propertyType.includes('core')) { + const teamMemberIds = await fetchByQuery({ + subdomain, + index: await getEsIndexByContentType(propertyType), + positiveQuery, + negativeQuery + }); + + console.log({ teamMemberIds }); + + ids = await fetchByQuery({ + subdomain, + index: 'exm_feeds', + _source: '_id', + positiveQuery: { + terms: { + createdBy: teamMemberIds + } + }, + negativeQuery: undefined + }); + console.log({ ids }); + } + + ids = _.uniq(ids); + + return { data: ids, status: 'success' }; + } +}; diff --git a/packages/plugin-imap-ui/src/configs.js b/packages/plugin-imap-ui/src/configs.js index 54b2265371..46f91cc386 100644 --- a/packages/plugin-imap-ui/src/configs.js +++ b/packages/plugin-imap-ui/src/configs.js @@ -1,36 +1,36 @@ module.exports = { - name: "imap", + name: 'imap', scope: 'imap', port: 3014, exposes: { - './routes': './src/routes.tsx', - "./inboxIntegrationSettings": "./src/components/IntegrationSettings.tsx", - "./inboxIntegrationForm": "./src/components/IntegrationForm.tsx", - "./inboxConversationDetail": "./src/components/ConversationDetail.tsx", - './activityLog': './src/components/ActivityLog.tsx', - "./integrationDetailsForm": "./src/components/IntegrationEditForm.tsx", + './routes': './src/routes.tsx' + // './inboxIntegrationSettings': './src/components/IntegrationSettings.tsx', + // './inboxIntegrationForm': './src/components/IntegrationForm.tsx', + // './inboxConversationDetail': './src/components/ConversationDetail.tsx', + // './activityLog': './src/components/ActivityLog.tsx', + // './integrationDetailsForm': './src/components/IntegrationEditForm.tsx' }, routes: { url: 'http://localhost:3014/remoteEntry.js', scope: 'imap', module: './routes' - }, - inboxIntegrationSettings: './inboxIntegrationSettings', - inboxIntegrationForm: './inboxIntegrationForm', - inboxConversationDetail: './inboxConversationDetail', - inboxIntegrations: [{ - name: 'IMAP', - description: - 'Connect a company email address such as sales@mycompany.com or info@mycompany.com', - inMessenger: false, - isAvailable: true, - kind: 'imap', - logo: '/images/integrations/email.png', - createModal: 'imap', - category: - 'All integrations, For support teams, Marketing automation, Email marketing', - components: ['inboxConversationDetail'], - }], - integrationDetailsForm: './integrationDetailsForm', - activityLog: './activityLog', -}; \ No newline at end of file + } + // inboxIntegrationSettings: './inboxIntegrationSettings', + // inboxIntegrationForm: './inboxIntegrationForm', + // inboxConversationDetail: './inboxConversationDetail', + // inboxIntegrations: [{ + // name: 'IMAP', + // description: + // 'Connect a company email address such as sales@mycompany.com or info@mycompany.com', + // inMessenger: false, + // isAvailable: true, + // kind: 'imap', + // logo: '/images/integrations/email.png', + // createModal: 'imap', + // category: + // 'All integrations, For support teams, Marketing automation, Email marketing', + // components: ['inboxConversationDetail'], + // }], + // integrationDetailsForm: './integrationDetailsForm', + // activityLog: './activityLog' +}; diff --git a/packages/plugin-reactions-api/src/configs.ts b/packages/plugin-reactions-api/src/configs.ts index 0ed32f51fa..7ef3944b01 100644 --- a/packages/plugin-reactions-api/src/configs.ts +++ b/packages/plugin-reactions-api/src/configs.ts @@ -3,6 +3,8 @@ import resolvers from './graphql/resolvers'; import { generateModels } from './connectionResolver'; import { initBroker } from './messageBroker'; import { getSubdomain } from '@erxes/api-utils/src/core'; +import segments from './segments'; +import forms from './forms'; export let debug; export let graphqlPubsub; @@ -36,5 +38,5 @@ export default { debug = options.debug; graphqlPubsub = options.pubsubClient; }, - meta: {} + meta: { segments, forms } }; diff --git a/packages/plugin-reactions-api/src/essyncer.js b/packages/plugin-reactions-api/src/essyncer.js new file mode 100644 index 0000000000..0a71bcf441 --- /dev/null +++ b/packages/plugin-reactions-api/src/essyncer.js @@ -0,0 +1,12 @@ +module.exports = [ + { + name: 'emojis', + schema: '{}', + script: '' + }, + { + name: 'comments', + schema: '{}', + script: '' + } +]; diff --git a/packages/plugin-reactions-api/src/forms.ts b/packages/plugin-reactions-api/src/forms.ts new file mode 100644 index 0000000000..c1499705ab --- /dev/null +++ b/packages/plugin-reactions-api/src/forms.ts @@ -0,0 +1,59 @@ +import { generateFieldsFromSchema } from '@erxes/api-utils/src'; +import { generateModels } from './connectionResolver'; + +const generateFields = async ({ subdomain, data }) => { + const { type, usageType } = data; + + const models = await generateModels(subdomain); + + const { Comments, Emojis } = models; + + let schema: any; + let fields: Array<{ + _id: number; + name: string; + group?: string; + label?: string; + type?: string; + validation?: string; + options?: string[]; + selectOptions?: Array<{ label: string; value: string }>; + }> = []; + + switch (type) { + case 'comments': + schema = Comments.schema; + break; + + case 'emojis': + schema = Emojis.schema; + break; + } + + fields = []; + + if (schema) { + fields = [...fields, ...(await generateFieldsFromSchema(schema, ''))]; + + for (const name of Object.keys(schema.paths)) { + const path = schema.paths[name]; + + if (path.schema) { + fields = [ + ...fields, + ...(await generateFieldsFromSchema(path.schema, `${name}.`)) + ]; + } + } + } + + return fields; +}; + +export default { + types: [ + { description: 'Exm Comments', type: 'comments' }, + { description: 'Exm Emojis', type: 'emojis' } + ], + fields: generateFields +}; diff --git a/packages/plugin-reactions-api/src/segments.ts b/packages/plugin-reactions-api/src/segments.ts new file mode 100644 index 0000000000..61f60e7f55 --- /dev/null +++ b/packages/plugin-reactions-api/src/segments.ts @@ -0,0 +1,18 @@ +export default { + dependentServices: [{ name: 'exmfeed', twoWay: true }], + + contentTypes: [ + { + type: 'emojis', + description: 'Emojis', + sIndex: 'emojis', + hideInSidebar: true + }, + { + type: 'comments', + description: 'Commnents', + sIndex: 'comments', + hideInSidebar: true + } + ] +}; From c297d2a2206ff3084079afda269b584406bfe96e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=91=D0=B0=D1=8F=D0=BB=D0=B0=D0=B3?= <40917206+Baylag321@users.noreply.github.com> Date: Mon, 16 Oct 2023 15:46:46 +0800 Subject: [PATCH 02/64] updating --- .../responseTemplates/components/List.tsx | 61 ++++++++++++++----- 1 file changed, 47 insertions(+), 14 deletions(-) diff --git a/packages/plugin-inbox-ui/src/settings/responseTemplates/components/List.tsx b/packages/plugin-inbox-ui/src/settings/responseTemplates/components/List.tsx index bbeeeebb8e..9495e53200 100755 --- a/packages/plugin-inbox-ui/src/settings/responseTemplates/components/List.tsx +++ b/packages/plugin-inbox-ui/src/settings/responseTemplates/components/List.tsx @@ -22,6 +22,14 @@ import SelectBrands from '@erxes/ui/src/brands/containers/SelectBrands'; import Table from '@erxes/ui/src/components/table'; import Tip from '@erxes/ui/src/components/Tip'; import { withRouter } from 'react-router-dom'; +import { + Actions, + IframePreview, + Template, + TemplateBox, + Templates, + TemplateInfo +} from '@erxes/ui-emailtemplates/src/styles'; type Props = { renderButton: (props: IButtonMutateProps) => JSX.Element; @@ -159,19 +167,44 @@ class ResponseTemplateList extends React.Component { ); }; - renderContent = props => { - return ( - - - - - - - - - {this.renderRows(props)} -
{__('Brand')}{__('Name')}{__('Actions')}
- ); + // renderContent = (props) => { + // return ( + // + // + // + // + // + // + // + // + // {this.renderRows(props)} + //
{__("Brand")}{__("Name")}{__("Actions")}
+ // ); + // }; + + renderRow = ({ objects }) => { + return objects.map((object, index) => { + return ( +