@nyaruka/temba-components 0.129.11 → 0.130.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -4
- package/demo/components/flow/example.html +5 -1
- package/demo/data/flows/sample-flow.json +144 -80
- package/dist/temba-components.js +290 -346
- package/dist/temba-components.js.map +1 -1
- package/out-tsc/src/flow/CanvasNode.js +3 -35
- package/out-tsc/src/flow/CanvasNode.js.map +1 -1
- package/out-tsc/src/flow/NodeEditor.js +44 -11
- package/out-tsc/src/flow/NodeEditor.js.map +1 -1
- package/out-tsc/src/flow/actions/add_contact_groups.js +14 -2
- package/out-tsc/src/flow/actions/add_contact_groups.js.map +1 -1
- package/out-tsc/src/flow/actions/add_contact_urn.js +1 -1
- package/out-tsc/src/flow/actions/add_contact_urn.js.map +1 -1
- package/out-tsc/src/flow/actions/add_input_labels.js +2 -1
- package/out-tsc/src/flow/actions/add_input_labels.js.map +1 -1
- package/out-tsc/src/flow/actions/remove_contact_groups.js +1 -1
- package/out-tsc/src/flow/actions/remove_contact_groups.js.map +1 -1
- package/out-tsc/src/flow/actions/send_email.js +9 -0
- package/out-tsc/src/flow/actions/send_email.js.map +1 -1
- package/out-tsc/src/flow/actions/send_msg.js +7 -8
- package/out-tsc/src/flow/actions/send_msg.js.map +1 -1
- package/out-tsc/src/flow/actions/set_contact_channel.js +25 -4
- package/out-tsc/src/flow/actions/set_contact_channel.js.map +1 -1
- package/out-tsc/src/flow/actions/set_contact_field.js +51 -1
- package/out-tsc/src/flow/actions/set_contact_field.js.map +1 -1
- package/out-tsc/src/flow/actions/set_contact_language.js +70 -2
- package/out-tsc/src/flow/actions/set_contact_language.js.map +1 -1
- package/out-tsc/src/flow/actions/set_contact_name.js +27 -2
- package/out-tsc/src/flow/actions/set_contact_name.js.map +1 -1
- package/out-tsc/src/flow/actions/set_contact_status.js +32 -2
- package/out-tsc/src/flow/actions/set_contact_status.js.map +1 -1
- package/out-tsc/src/flow/actions/set_run_result.js +13 -11
- package/out-tsc/src/flow/actions/set_run_result.js.map +1 -1
- package/out-tsc/src/flow/actions/split_by_expression_example.js +4 -4
- package/out-tsc/src/flow/actions/split_by_expression_example.js.map +1 -1
- package/out-tsc/src/flow/forms/index.js +2 -0
- package/out-tsc/src/flow/forms/index.js.map +1 -0
- package/out-tsc/src/flow/nodes/split_by_random.js +117 -0
- package/out-tsc/src/flow/nodes/split_by_random.js.map +1 -1
- package/out-tsc/src/flow/nodes/split_by_ticket.js +0 -1
- package/out-tsc/src/flow/nodes/split_by_ticket.js.map +1 -1
- package/out-tsc/src/flow/nodes/split_by_webhook.js +1 -3
- package/out-tsc/src/flow/nodes/split_by_webhook.js.map +1 -1
- package/out-tsc/src/flow/types.js.map +1 -1
- package/out-tsc/src/form/ArrayEditor.js +9 -25
- package/out-tsc/src/form/ArrayEditor.js.map +1 -1
- package/out-tsc/src/form/FieldRenderer.js +6 -64
- package/out-tsc/src/form/FieldRenderer.js.map +1 -1
- package/out-tsc/src/form/select/Select.js +35 -58
- package/out-tsc/src/form/select/Select.js.map +1 -1
- package/out-tsc/src/utils.js +3 -0
- package/out-tsc/src/utils.js.map +1 -1
- package/out-tsc/test/nodes/split_by_random.test.js +0 -6
- package/out-tsc/test/nodes/split_by_random.test.js.map +1 -1
- package/out-tsc/test/temba-field-renderer.test.js +6 -3
- package/out-tsc/test/temba-field-renderer.test.js.map +1 -1
- package/out-tsc/test/utils.test.js +18 -0
- package/out-tsc/test/utils.test.js.map +1 -1
- package/package.json +1 -1
- package/screenshots/truth/actions/add_contact_groups/editor/descriptive-group-names.png +0 -0
- package/screenshots/truth/actions/add_contact_groups/editor/long-group-names.png +0 -0
- package/screenshots/truth/actions/add_contact_groups/editor/many-groups.png +0 -0
- package/screenshots/truth/actions/add_contact_groups/editor/multiple-groups.png +0 -0
- package/screenshots/truth/actions/add_contact_groups/editor/single-group.png +0 -0
- package/screenshots/truth/actions/add_contact_groups/render/descriptive-group-names.png +0 -0
- package/screenshots/truth/actions/add_contact_groups/render/long-group-names.png +0 -0
- package/screenshots/truth/actions/add_contact_groups/render/many-groups.png +0 -0
- package/screenshots/truth/actions/add_contact_groups/render/multiple-groups.png +0 -0
- package/screenshots/truth/actions/add_contact_groups/render/single-group.png +0 -0
- package/screenshots/truth/actions/remove_contact_groups/editor/cleanup-groups.png +0 -0
- package/screenshots/truth/actions/remove_contact_groups/editor/long-descriptive-group-names.png +0 -0
- package/screenshots/truth/actions/remove_contact_groups/editor/many-groups.png +0 -0
- package/screenshots/truth/actions/remove_contact_groups/editor/multiple-groups.png +0 -0
- package/screenshots/truth/actions/remove_contact_groups/editor/remove-from-all-groups.png +0 -0
- package/screenshots/truth/actions/remove_contact_groups/editor/single-group.png +0 -0
- package/screenshots/truth/actions/remove_contact_groups/render/cleanup-groups.png +0 -0
- package/screenshots/truth/actions/remove_contact_groups/render/long-descriptive-group-names.png +0 -0
- package/screenshots/truth/actions/remove_contact_groups/render/many-groups.png +0 -0
- package/screenshots/truth/actions/remove_contact_groups/render/multiple-groups.png +0 -0
- package/screenshots/truth/actions/remove_contact_groups/render/remove-from-all-groups.png +0 -0
- package/screenshots/truth/actions/remove_contact_groups/render/single-group.png +0 -0
- package/screenshots/truth/editor/set_contact_language.png +0 -0
- package/screenshots/truth/editor/set_contact_name.png +0 -0
- package/screenshots/truth/editor/set_run_result.png +0 -0
- package/screenshots/truth/nodes/split_by_random/editor/ab-test-multiple-variants.png +0 -0
- package/screenshots/truth/nodes/split_by_random/editor/sampling-split.png +0 -0
- package/screenshots/truth/nodes/split_by_random/editor/three-way-split.png +0 -0
- package/screenshots/truth/nodes/split_by_random/editor/two-bucket-split.png +0 -0
- package/src/flow/CanvasNode.ts +2 -39
- package/src/flow/NodeEditor.ts +54 -13
- package/src/flow/actions/add_contact_groups.ts +17 -2
- package/src/flow/actions/add_contact_urn.ts +1 -1
- package/src/flow/actions/add_input_labels.ts +2 -1
- package/src/flow/actions/remove_contact_groups.ts +1 -1
- package/src/flow/actions/send_email.ts +11 -1
- package/src/flow/actions/send_msg.ts +20 -11
- package/src/flow/actions/set_contact_channel.ts +28 -5
- package/src/flow/actions/set_contact_field.ts +56 -2
- package/src/flow/actions/set_contact_language.ts +74 -3
- package/src/flow/actions/set_contact_name.ts +31 -3
- package/src/flow/actions/set_contact_status.ts +36 -3
- package/src/flow/actions/set_run_result.ts +13 -15
- package/src/flow/actions/split_by_expression_example.ts +4 -4
- package/src/flow/forms/index.ts +1 -0
- package/src/flow/nodes/split_by_random.ts +148 -0
- package/src/flow/nodes/split_by_ticket.ts +0 -1
- package/src/flow/nodes/split_by_webhook.ts +1 -3
- package/src/flow/types.ts +2 -1
- package/src/form/ArrayEditor.ts +6 -20
- package/src/form/FieldRenderer.ts +6 -65
- package/src/form/select/Select.ts +38 -66
- package/src/store/flow-definition.d.ts +6 -1
- package/src/utils.ts +4 -0
- package/static/api/fields.json +93 -1208
- package/static/api/workspace.json +23 -0
- package/test/nodes/split_by_random.test.ts +0 -7
- package/test/temba-field-renderer.test.ts +26 -13
- package/test/utils.test.ts +20 -0
- package/web-dev-server.config.mjs +2 -0
- package/web-test-runner.config.mjs +37 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.test.js","sourceRoot":"","sources":["../../test/utils.test.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAC;AAC1B,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAQjC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AACjE,OAAO,WAAW,MAAM,eAAe,CAAC;AAExC,OAAO,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC;AAa7B,MAAM,IAAI,GAAe,EAAE,CAAC;AAC5B,IAAI,KAAK,GAAe,EAAE,CAAC;AAC3B,IAAI,WAAW,CAAC;AAEhB,MAAM,CAAC,MAAM,SAAS,GAAG,KAAK,IAAI,EAAE;IAClC,MAAM,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C;QAEhB,QAAQ,EAAE,CAAC;IACb,CAAC;IAED,MAAM,IAAI,KAAK,CACb,qCAAqC,WAAW,cAC9C,WAAW,GAAG,EAChB,OAAO;QACL,YAAY,aAAa,iBAAiB,MAAM,CAAC,cAAc,CAAC,MAAM,IAAI;QAC1E,aAAa,MAAM,CAAC,QAAQ,EAAE,CACjC,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import '../temba-modules';\nimport { DateTime } from 'luxon';\ninterface Clip {\n x: number;\n y: number;\n width: number;\n height: number;\n}\n\nimport { expect, fixture, html, assert } from '@open-wc/testing';\nimport MouseHelper from './MouseHelper';\nimport { Store } from '../src/store/Store';\nimport { stub } from 'sinon';\nimport { Select, SelectOption } from '../src/form/select/Select';\nimport { Options } from '../src/display/Options';\nimport { Attachment } from '../src/interfaces';\nimport { Compose } from '../src/form/Compose';\n\nexport interface CodeMock {\n endpoint: RegExp;\n body: string;\n headers: any;\n status: string;\n}\n\nconst gets: CodeMock[] = [];\nlet posts: CodeMock[] = [];\nlet normalFetch;\n\nexport const showMouse = async () => {\n const mouse = await fixture(html`<mouse-helper />`);\n assert.instanceOf(mouse, MouseHelper);\n};\n\nexport const getAttributes = (attrs: any = {}) => {\n return `${Object.keys(attrs)\n .map((name: string) => {\n if (typeof attrs[name] === 'boolean' && attrs[name]) {\n return name;\n }\n return `${name}='${attrs[name]}'`;\n })\n .join(' ')}`;\n};\n\nexport const getComponent = async (\n tag,\n attrs: any = {},\n slot = '',\n width = 250,\n height = 0,\n style = ''\n) => {\n const spec = `<${tag} ${getAttributes(attrs)}>${slot}</${tag}>`;\n const parentNode = document.createElement('div');\n const styleAttribute = `\n ${width > 0 ? `width:${width}px;` : ``} \n ${height > 0 ? `height:${height}px;` : ``}\n ${style ? style : ``}\n `;\n parentNode.setAttribute('style', styleAttribute);\n return await fixture(spec, { parentNode });\n};\n\nconst createResponse = (mocked) => {\n const mockResponse = new window.Response(mocked.body, {\n status: mocked.status,\n headers: {\n 'Content-type': 'text/html',\n ...mocked.headers\n }\n });\n\n return Promise.resolve(mockResponse);\n};\n\nconst createJSONResponse = (mocked) => {\n const mockResponse = new window.Response(JSON.stringify(mocked.body), {\n status: mocked.status,\n headers: {\n 'Content-type': 'application/json',\n ...mocked.headers\n }\n });\n\n return Promise.resolve(mockResponse);\n};\n\nconst getResponse = (endpoint: string, options = { method: 'GET' }) => {\n // check if our path has been mocked in code\n const mocks = options.method === 'GET' ? gets : posts;\n const codeMock = mocks.find((mock) => mock.endpoint.test(endpoint));\n\n if (codeMock) {\n if (typeof codeMock.body === 'string') {\n // see if we are being mocked to a file\n if (codeMock.body.startsWith('/')) {\n endpoint = codeMock.body;\n } else {\n return createResponse(codeMock);\n }\n } else {\n return createJSONResponse(codeMock);\n }\n }\n // otherwise fetch over http\n return normalFetch(endpoint, options);\n};\n\nbefore(async () => {\n normalFetch = window.fetch;\n stub(window, 'fetch').callsFake(getResponse);\n await setViewport({ width: 1024, height: 768, deviceScaleFactor: 2 });\n});\n\nafter(() => {\n (window.fetch as any).restore();\n});\n\nconst mockMapping = {\n '/test-assets/api/users/admin1.json': [\n /\\/api\\/v2\\/users.json\\?email=admin1@nyaruka.com/\n ],\n '/test-assets/api/users/editor1.json': [\n /\\/api\\/v2\\/users.json\\?email=editor1@nyaruka.com/\n ],\n '/test-assets/api/users/agent1.json': [\n /\\/api\\/v2\\/users.json\\?email=agent1@nyaruka.com/\n ],\n '/test-assets/api/users/viewer1.json': [\n /\\/api\\/v2\\/users.json\\?email=viewer1@nyaruka.com/\n ],\n '/test-assets/contacts/contact-tickets.json': [\n /\\/api\\/v2\\/tickets.json\\?contact=24d64810-3315-4ff5-be85-48e3fe055bf9/\n ]\n};\n\nexport const mockAPI = () => {\n for (const key in mockMapping) {\n const urls = mockMapping[key];\n for (const url of urls) {\n mockGET(url, key);\n }\n }\n};\n\nexport const mockGET = (\n endpoint: RegExp,\n body: any,\n headers: any = {},\n status = '200'\n) => {\n gets.push({ endpoint, body, headers, status });\n};\n\nexport const mockPOST = (\n endpoint: RegExp,\n body: any,\n headers: any = {},\n status = '200'\n) => {\n posts.push({ endpoint, body, headers, status });\n};\n\nexport const clearMockPosts = () => {\n posts = [];\n};\n\nexport const checkTimers = (clock: any) => {\n expect(!!clock.timers).to.equal(true, 'Expected timers not found');\n expect(\n Object.keys(clock.timers).length,\n `Timers still to be run ${JSON.stringify(clock.timers)}`\n ).to.equal(0);\n};\n\nexport const delay = (millis: number) => {\n return new Promise(function (resolve) {\n window.setTimeout(resolve, millis);\n });\n};\n\n// Enhanced wait utility for more robust testing\nexport const waitForCondition = async (\n predicate: () => boolean,\n maxAttempts: number = 20,\n delayMs: number = 50\n): Promise<void> => {\n let attempts = 0;\n while (!predicate() && attempts < maxAttempts) {\n await delay(delayMs);\n attempts++;\n }\n if (!predicate()) {\n throw new Error(\n `Condition not met after ${maxAttempts} attempts (${\n maxAttempts * delayMs\n }ms)`\n );\n }\n};\n\nexport const assertScreenshot = async (filename: string, clip: Clip) => {\n // detect if we're running in copilot's environment and use adaptive threshold\n const isCopilotEnvironment = (window as any).isCopilotEnvironment;\n const threshold = isCopilotEnvironment ? 1.0 : 0.1;\n const exclude: Clip[] = [];\n\n try {\n await (window as any).matchPageSnapshot(\n `${filename}.png`,\n clip,\n exclude,\n threshold\n );\n } catch (error) {\n if (error.message) {\n throw new Error(\n `${error.message} ${\n error.expected\n ? `Expected ${error.expected} but got ${error.actual}`\n : ''\n } ${error.files ? `\\n${error.files.join('\\n')}` : ''}`\n );\n }\n throw new Error(error);\n }\n};\n\nexport const getClip = (ele: HTMLElement) => {\n let clip: any = ele.getBoundingClientRect();\n if (!clip.width || !clip.height) {\n clip = ele.shadowRoot.firstElementChild.getBoundingClientRect();\n }\n\n const padding = 10;\n const width = clip.width + padding * 2;\n const height = clip.height + padding * 2;\n const y = clip.y - padding;\n const x = clip.x - padding;\n\n const newClip = {\n x,\n y,\n width,\n height,\n bottom: y + height,\n right: x + width,\n top: y,\n left: x\n };\n\n return newClip;\n};\n\nexport const mouseClickElement = async (ele: HTMLElement | Element) => {\n const bounds = ele.getBoundingClientRect();\n await mouseClick(bounds.x + bounds.width / 2, bounds.y + bounds.height / 2);\n};\n\nexport const getHTMLAttrs = (attrs: any = {}) => {\n return Object.keys(attrs)\n .map((name: string) => `${name}='${attrs[name]}'`)\n .join(' ');\n};\n\nexport const getHTML = (tag: string, attrs: any = {}) => {\n return `<${tag} ${getHTMLAttrs(attrs)}></${tag}>`;\n};\n\nexport const loadStore = async () => {\n const store: Store = await fixture(\n `<temba-store \n completion='/test-assets/store/editor.json'\n groups='/test-assets/store/groups.json'\n languages='/test-assets/store/languages.json'\n fields='/test-assets/store/fields.json'\n users='/test-assets/store/users.json'\n workspace='/test-assets/store/workspace.json'\n />`\n );\n await store.initialHttpComplete;\n await store.initialHttpComplete;\n\n return store;\n};\n\nexport const mockNow = (isodate: string) => {\n return stub(DateTime, 'now').returns(DateTime.fromISO(isodate));\n};\n\nexport const getOptions = (select: Select<SelectOption>): Options => {\n return select.shadowRoot.querySelector('temba-options[visible]');\n};\n\nexport const clickOption = async (\n clock: any,\n select: Select<SelectOption>,\n index: number\n) => {\n const options = getOptions(select);\n if (!options) {\n throw new Error('No options element found');\n }\n\n // Wait for the specific option to be available, but only if it's not already there\n const existingOption = options.shadowRoot?.querySelector(\n `[data-option-index=\"${index}\"]`\n );\n if (!existingOption) {\n try {\n await waitForCondition(\n () => {\n const option = options.shadowRoot?.querySelector(\n `[data-option-index=\"${index}\"]`\n );\n return !!option;\n },\n 10,\n 25\n );\n } catch (e) {\n throw new Error(`Option at index ${index} not found after waiting`);\n }\n }\n\n const option = options.shadowRoot.querySelector(\n `[data-option-index=\"${index}\"]`\n ) as HTMLDivElement;\n\n await mouseClickElement(option);\n await options.updateComplete;\n await select.updateComplete;\n await clock.runAll();\n\n checkTimers(clock);\n};\nexport const openSelect = async (clock: any, select: Select<SelectOption>) => {\n const container = select.shadowRoot.querySelector('.select-container');\n container.dispatchEvent(new MouseEvent('click', { bubbles: true }));\n\n clock.runAll();\n\n // add more explicit waiting and clock ticks\n await select.updateComplete;\n clock.runAll();\n\n // reduce wait time for options to become visible\n await waitFor(25);\n clock.runAll();\n\n // For non-endpoint selects, options might be immediately available\n // For endpoint selects, we need to wait for them to load\n const hasEndpoint = select.getAttribute('endpoint');\n if (hasEndpoint) {\n try {\n // Wait for options to be properly rendered and visible (but only for endpoint selects)\n await waitForCondition(\n () => {\n const options = select.shadowRoot.querySelector(\n 'temba-options[visible]'\n );\n return options && options.isConnected;\n },\n 10,\n 25\n );\n } catch (e) {\n // If condition fails, continue - some tests might not need options to be visible immediately\n }\n }\n};\n\nexport const openAndClick = async (\n clock: any,\n select: Select<SelectOption>,\n idx: number\n) => {\n await openSelect(clock, select);\n\n // Add this line to ensure proper timing when running as part of a test suite\n await select.updateComplete;\n clock.tick(25); // Reduced from 50 to give minimum time for options to render\n\n await clickOption(clock, select, idx);\n};\n\n// valid = attachments that are uploaded sent to the server when the user clicks send\nexport const getValidAttachments = (numFiles = 2): Attachment[] => {\n const attachments = [];\n let index = 1;\n while (index <= numFiles) {\n const s = 's' + index;\n const attachment = {\n uuid: s,\n content_type: 'image/png',\n type: 'image/png',\n filename: 'name_' + s,\n url: 'url_' + s,\n size: 1024,\n error: null\n } as Attachment;\n attachments.push(attachment);\n index++;\n }\n return attachments;\n};\n\nexport const updateComponent = async (\n compose: Compose,\n text?: string,\n attachments?: Attachment[]\n): Promise<void> => {\n compose.initialText = text ? text : '';\n compose.currentAttachments = attachments ? attachments : [];\n await compose.updateComplete;\n};\nexport const getValidText = () => {\n return 'sà-wàd-dee!';\n};\n\n// Helper for waiting for select pagination to complete\nexport const waitForSelectPagination = async (\n select: Select<SelectOption>,\n clock: any,\n expectedCount: number,\n maxAttempts: number = 30\n): Promise<void> => {\n let attempts = 0;\n while (attempts < maxAttempts) {\n // Ensure we're not still fetching\n if (!select.fetching && select.visibleOptions.length >= expectedCount) {\n return;\n }\n\n await select.updateComplete;\n clock.runAll();\n\n // Give more time between attempts for slow CI environments\n await delay(75);\n\n attempts++;\n }\n\n throw new Error(\n `Pagination did not complete after ${maxAttempts} attempts (${\n maxAttempts * 75\n }ms). ` +\n `Expected ${expectedCount} options, got ${select.visibleOptions.length}. ` +\n `Fetching: ${select.fetching}`\n );\n};\n"]}
|
|
1
|
+
{"version":3,"file":"utils.test.js","sourceRoot":"","sources":["../../test/utils.test.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAC;AAC1B,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAQjC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AACjE,OAAO,WAAW,MAAM,eAAe,CAAC;AAExC,OAAO,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC;AAa7B,MAAM,IAAI,GAAe,EAAE,CAAC;AAC5B,IAAI,KAAK,GAAe,EAAE,CAAC;AAC3B,IAAI,WAAW,CAAC;AAEhB,MAAM,CAAC,MAAM,SAAS,GAAG,KAAK,IAAI,EAAE;IAClC,MAAM,KAAK,GAAG,MAAM,OAAO,CAAC,IAAI,CAAA,kBAAkB,CAAC,CAAC;IACpD,MAAM,CAAC,UAAU,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC;AACxC,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,QAAa,EAAE,EAAE,EAAE;IAC/C,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC;SACzB,GAAG,CAAC,CAAC,IAAY,EAAE,EAAE;QACpB,IAAI,OAAO,KAAK,CAAC,IAAI,CAAC,KAAK,SAAS,IAAI,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;YACpD,OAAO,IAAI,CAAC;QACd,CAAC;QACD,OAAO,GAAG,IAAI,KAAK,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC;IACpC,CAAC,CAAC;SACD,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC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a,EAAE,CAAC;YACtE,OAAO;QACT,CAAC;QAED,MAAM,MAAM,CAAC,cAAc,CAAC;QAC5B,KAAK,CAAC,MAAM,EAAE,CAAC;QAEf,2DAA2D;QAC3D,MAAM,KAAK,CAAC,EAAE,CAAC,CAAC;QAEhB,QAAQ,EAAE,CAAC;IACb,CAAC;IAED,MAAM,IAAI,KAAK,CACb,qCAAqC,WAAW,cAC9C,WAAW,GAAG,EAChB,OAAO;QACL,YAAY,aAAa,iBAAiB,MAAM,CAAC,cAAc,CAAC,MAAM,IAAI;QAC1E,aAAa,MAAM,CAAC,QAAQ,EAAE,CACjC,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import '../temba-modules';\nimport { DateTime } from 'luxon';\ninterface Clip {\n x: number;\n y: number;\n width: number;\n height: number;\n}\n\nimport { expect, fixture, html, assert } from '@open-wc/testing';\nimport MouseHelper from './MouseHelper';\nimport { Store } from '../src/store/Store';\nimport { stub } from 'sinon';\nimport { Select, SelectOption } from '../src/form/select/Select';\nimport { Options } from '../src/display/Options';\nimport { Attachment } from '../src/interfaces';\nimport { Compose } from '../src/form/Compose';\n\nexport interface CodeMock {\n endpoint: RegExp;\n body: string;\n headers: any;\n status: string;\n}\n\nconst gets: CodeMock[] = [];\nlet posts: CodeMock[] = [];\nlet normalFetch;\n\nexport const showMouse = async () => {\n const mouse = await fixture(html`<mouse-helper />`);\n assert.instanceOf(mouse, MouseHelper);\n};\n\nexport const getAttributes = (attrs: any = {}) => {\n return `${Object.keys(attrs)\n .map((name: string) => {\n if (typeof attrs[name] === 'boolean' && attrs[name]) {\n return name;\n }\n return `${name}='${attrs[name]}'`;\n })\n .join(' ')}`;\n};\n\nexport const getComponent = async (\n tag,\n attrs: any = {},\n slot = '',\n width = 250,\n height = 0,\n style = ''\n) => {\n const spec = `<${tag} ${getAttributes(attrs)}>${slot}</${tag}>`;\n const parentNode = document.createElement('div');\n const styleAttribute = `\n ${width > 0 ? `width:${width}px;` : ``} \n ${height > 0 ? `height:${height}px;` : ``}\n ${style ? style : ``}\n `;\n parentNode.setAttribute('style', styleAttribute);\n return await fixture(spec, { parentNode });\n};\n\nconst createResponse = (mocked) => {\n const mockResponse = new window.Response(mocked.body, {\n status: mocked.status,\n headers: {\n 'Content-type': 'text/html',\n ...mocked.headers\n }\n });\n\n return Promise.resolve(mockResponse);\n};\n\nconst createJSONResponse = (mocked) => {\n const mockResponse = new window.Response(JSON.stringify(mocked.body), {\n status: mocked.status,\n headers: {\n 'Content-type': 'application/json',\n ...mocked.headers\n }\n });\n\n return Promise.resolve(mockResponse);\n};\n\nconst getResponse = (endpoint: string, options = { method: 'GET' }) => {\n // check if our path has been mocked in code\n const mocks = options.method === 'GET' ? gets : posts;\n const codeMock = mocks.find((mock) => mock.endpoint.test(endpoint));\n\n if (codeMock) {\n if (typeof codeMock.body === 'string') {\n // see if we are being mocked to a file\n if (codeMock.body.startsWith('/')) {\n endpoint = codeMock.body;\n } else {\n return createResponse(codeMock);\n }\n } else {\n return createJSONResponse(codeMock);\n }\n }\n // otherwise fetch over http\n return normalFetch(endpoint, options);\n};\n\nbefore(async () => {\n normalFetch = window.fetch;\n stub(window, 'fetch').callsFake(getResponse);\n await setViewport({ width: 1024, height: 768, deviceScaleFactor: 2 });\n});\n\nafter(() => {\n (window.fetch as any).restore();\n});\n\nconst mockMapping = {\n '/test-assets/api/users/admin1.json': [\n /\\/api\\/v2\\/users.json\\?email=admin1@nyaruka.com/\n ],\n '/test-assets/api/users/editor1.json': [\n /\\/api\\/v2\\/users.json\\?email=editor1@nyaruka.com/\n ],\n '/test-assets/api/users/agent1.json': [\n /\\/api\\/v2\\/users.json\\?email=agent1@nyaruka.com/\n ],\n '/test-assets/api/users/viewer1.json': [\n /\\/api\\/v2\\/users.json\\?email=viewer1@nyaruka.com/\n ],\n '/test-assets/contacts/contact-tickets.json': [\n /\\/api\\/v2\\/tickets.json\\?contact=24d64810-3315-4ff5-be85-48e3fe055bf9/\n ]\n};\n\nexport const mockAPI = () => {\n for (const key in mockMapping) {\n const urls = mockMapping[key];\n for (const url of urls) {\n mockGET(url, key);\n }\n }\n\n // Add mock data for contact form endpoints\n mockGET(/\\/api\\/v2\\/channels\\.json/, {\n results: [\n { uuid: 'chan-1', name: 'WhatsApp Channel' },\n { uuid: 'chan-2', name: 'Telegram Channel' },\n { uuid: 'chan-3', name: 'SMS Channel' },\n { uuid: 'chan-4', name: 'Facebook Messenger' }\n ]\n });\n\n mockGET(/\\/api\\/v2\\/languages\\.json/, {\n results: [\n { iso: 'eng', name: 'English' },\n { iso: 'spa', name: 'Spanish' },\n { iso: 'fra', name: 'French' },\n { iso: 'por', name: 'Portuguese' },\n { iso: 'deu', name: 'German' }\n ]\n });\n};\n\nexport const mockGET = (\n endpoint: RegExp,\n body: any,\n headers: any = {},\n status = '200'\n) => {\n gets.push({ endpoint, body, headers, status });\n};\n\nexport const mockPOST = (\n endpoint: RegExp,\n body: any,\n headers: any = {},\n status = '200'\n) => {\n posts.push({ endpoint, body, headers, status });\n};\n\nexport const clearMockPosts = () => {\n posts = [];\n};\n\nexport const checkTimers = (clock: any) => {\n expect(!!clock.timers).to.equal(true, 'Expected timers not found');\n expect(\n Object.keys(clock.timers).length,\n `Timers still to be run ${JSON.stringify(clock.timers)}`\n ).to.equal(0);\n};\n\nexport const delay = (millis: number) => {\n return new Promise(function (resolve) {\n window.setTimeout(resolve, millis);\n });\n};\n\n// Enhanced wait utility for more robust testing\nexport const waitForCondition = async (\n predicate: () => boolean,\n maxAttempts: number = 20,\n delayMs: number = 50\n): Promise<void> => {\n let attempts = 0;\n while (!predicate() && attempts < maxAttempts) {\n await delay(delayMs);\n attempts++;\n }\n if (!predicate()) {\n throw new Error(\n `Condition not met after ${maxAttempts} attempts (${\n maxAttempts * delayMs\n }ms)`\n );\n }\n};\n\nexport const assertScreenshot = async (filename: string, clip: Clip) => {\n // detect if we're running in copilot's environment and use adaptive threshold\n const isCopilotEnvironment = (window as any).isCopilotEnvironment;\n const threshold = isCopilotEnvironment ? 1.0 : 0.1;\n const exclude: Clip[] = [];\n\n try {\n await (window as any).matchPageSnapshot(\n `${filename}.png`,\n clip,\n exclude,\n threshold\n );\n } catch (error) {\n if (error.message) {\n throw new Error(\n `${error.message} ${\n error.expected\n ? `Expected ${error.expected} but got ${error.actual}`\n : ''\n } ${error.files ? `\\n${error.files.join('\\n')}` : ''}`\n );\n }\n throw new Error(error);\n }\n};\n\nexport const getClip = (ele: HTMLElement) => {\n let clip: any = ele.getBoundingClientRect();\n if (!clip.width || !clip.height) {\n clip = ele.shadowRoot.firstElementChild.getBoundingClientRect();\n }\n\n const padding = 10;\n const width = clip.width + padding * 2;\n const height = clip.height + padding * 2;\n const y = clip.y - padding;\n const x = clip.x - padding;\n\n const newClip = {\n x,\n y,\n width,\n height,\n bottom: y + height,\n right: x + width,\n top: y,\n left: x\n };\n\n return newClip;\n};\n\nexport const mouseClickElement = async (ele: HTMLElement | Element) => {\n const bounds = ele.getBoundingClientRect();\n await mouseClick(bounds.x + bounds.width / 2, bounds.y + bounds.height / 2);\n};\n\nexport const getHTMLAttrs = (attrs: any = {}) => {\n return Object.keys(attrs)\n .map((name: string) => `${name}='${attrs[name]}'`)\n .join(' ');\n};\n\nexport const getHTML = (tag: string, attrs: any = {}) => {\n return `<${tag} ${getHTMLAttrs(attrs)}></${tag}>`;\n};\n\nexport const loadStore = async () => {\n const store: Store = await fixture(\n `<temba-store \n completion='/test-assets/store/editor.json'\n groups='/test-assets/store/groups.json'\n languages='/test-assets/store/languages.json'\n fields='/test-assets/store/fields.json'\n users='/test-assets/store/users.json'\n workspace='/test-assets/store/workspace.json'\n />`\n );\n await store.initialHttpComplete;\n await store.initialHttpComplete;\n\n return store;\n};\n\nexport const mockNow = (isodate: string) => {\n return stub(DateTime, 'now').returns(DateTime.fromISO(isodate));\n};\n\nexport const getOptions = (select: Select<SelectOption>): Options => {\n return select.shadowRoot.querySelector('temba-options[visible]');\n};\n\nexport const clickOption = async (\n clock: any,\n select: Select<SelectOption>,\n index: number\n) => {\n const options = getOptions(select);\n if (!options) {\n throw new Error('No options element found');\n }\n\n // Wait for the specific option to be available, but only if it's not already there\n const existingOption = options.shadowRoot?.querySelector(\n `[data-option-index=\"${index}\"]`\n );\n if (!existingOption) {\n try {\n await waitForCondition(\n () => {\n const option = options.shadowRoot?.querySelector(\n `[data-option-index=\"${index}\"]`\n );\n return !!option;\n },\n 10,\n 25\n );\n } catch (e) {\n throw new Error(`Option at index ${index} not found after waiting`);\n }\n }\n\n const option = options.shadowRoot.querySelector(\n `[data-option-index=\"${index}\"]`\n ) as HTMLDivElement;\n\n await mouseClickElement(option);\n await options.updateComplete;\n await select.updateComplete;\n await clock.runAll();\n\n checkTimers(clock);\n};\nexport const openSelect = async (clock: any, select: Select<SelectOption>) => {\n const container = select.shadowRoot.querySelector('.select-container');\n container.dispatchEvent(new MouseEvent('click', { bubbles: true }));\n\n clock.runAll();\n\n // add more explicit waiting and clock ticks\n await select.updateComplete;\n clock.runAll();\n\n // reduce wait time for options to become visible\n await waitFor(25);\n clock.runAll();\n\n // For non-endpoint selects, options might be immediately available\n // For endpoint selects, we need to wait for them to load\n const hasEndpoint = select.getAttribute('endpoint');\n if (hasEndpoint) {\n try {\n // Wait for options to be properly rendered and visible (but only for endpoint selects)\n await waitForCondition(\n () => {\n const options = select.shadowRoot.querySelector(\n 'temba-options[visible]'\n );\n return options && options.isConnected;\n },\n 10,\n 25\n );\n } catch (e) {\n // If condition fails, continue - some tests might not need options to be visible immediately\n }\n }\n};\n\nexport const openAndClick = async (\n clock: any,\n select: Select<SelectOption>,\n idx: number\n) => {\n await openSelect(clock, select);\n\n // Add this line to ensure proper timing when running as part of a test suite\n await select.updateComplete;\n clock.tick(25); // Reduced from 50 to give minimum time for options to render\n\n await clickOption(clock, select, idx);\n};\n\n// valid = attachments that are uploaded sent to the server when the user clicks send\nexport const getValidAttachments = (numFiles = 2): Attachment[] => {\n const attachments = [];\n let index = 1;\n while (index <= numFiles) {\n const s = 's' + index;\n const attachment = {\n uuid: s,\n content_type: 'image/png',\n type: 'image/png',\n filename: 'name_' + s,\n url: 'url_' + s,\n size: 1024,\n error: null\n } as Attachment;\n attachments.push(attachment);\n index++;\n }\n return attachments;\n};\n\nexport const updateComponent = async (\n compose: Compose,\n text?: string,\n attachments?: Attachment[]\n): Promise<void> => {\n compose.initialText = text ? text : '';\n compose.currentAttachments = attachments ? attachments : [];\n await compose.updateComplete;\n};\nexport const getValidText = () => {\n return 'sà-wàd-dee!';\n};\n\n// Helper for waiting for select pagination to complete\nexport const waitForSelectPagination = async (\n select: Select<SelectOption>,\n clock: any,\n expectedCount: number,\n maxAttempts: number = 30\n): Promise<void> => {\n let attempts = 0;\n while (attempts < maxAttempts) {\n // Ensure we're not still fetching\n if (!select.fetching && select.visibleOptions.length >= expectedCount) {\n return;\n }\n\n await select.updateComplete;\n clock.runAll();\n\n // Give more time between attempts for slow CI environments\n await delay(75);\n\n attempts++;\n }\n\n throw new Error(\n `Pagination did not complete after ${maxAttempts} attempts (${\n maxAttempts * 75\n }ms). ` +\n `Expected ${expectedCount} options, got ${select.visibleOptions.length}. ` +\n `Fetching: ${select.fetching}`\n );\n};\n"]}
|
package/package.json
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/screenshots/truth/actions/remove_contact_groups/editor/long-descriptive-group-names.png
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/screenshots/truth/actions/remove_contact_groups/render/long-descriptive-group-names.png
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/src/flow/CanvasNode.ts
CHANGED
|
@@ -873,30 +873,7 @@ export class CanvasNode extends RapidElement {
|
|
|
873
873
|
private renderRouter(router: Router, ui: NodeUI) {
|
|
874
874
|
const nodeConfig = NODE_CONFIG[ui.type];
|
|
875
875
|
if (nodeConfig) {
|
|
876
|
-
// For tests that call renderRouter directly without setting this.node
|
|
877
|
-
const hasActions = this.node ? this.node.actions.length > 0 : false;
|
|
878
|
-
const isRemoving =
|
|
879
|
-
this.node &&
|
|
880
|
-
this.node.actions.length === 0 &&
|
|
881
|
-
this.actionRemovingState.has(this.node.uuid);
|
|
882
|
-
|
|
883
876
|
return html`<div class="router" style="position: relative;">
|
|
884
|
-
${!hasActions
|
|
885
|
-
? html` <button
|
|
886
|
-
class="remove-button"
|
|
887
|
-
@click=${(e: MouseEvent) => this.handleNodeRemoveClick(e)}
|
|
888
|
-
title="Remove node"
|
|
889
|
-
>
|
|
890
|
-
✕
|
|
891
|
-
</button>
|
|
892
|
-
<div
|
|
893
|
-
@mousedown=${(e: MouseEvent) => this.handleNodeMouseDown(e)}
|
|
894
|
-
@mouseup=${(e: MouseEvent) => this.handleNodeMouseUp(e)}
|
|
895
|
-
style="cursor: pointer;"
|
|
896
|
-
>
|
|
897
|
-
${this.renderNodeTitle(nodeConfig, isRemoving)}
|
|
898
|
-
</div>`
|
|
899
|
-
: ''}
|
|
900
877
|
${router.result_name
|
|
901
878
|
? html`<div
|
|
902
879
|
class="body"
|
|
@@ -969,7 +946,7 @@ export class CanvasNode extends RapidElement {
|
|
|
969
946
|
: ''}"
|
|
970
947
|
style="left:${this.ui.position.left}px;top:${this.ui.position.top}px"
|
|
971
948
|
>
|
|
972
|
-
${nodeConfig && nodeConfig.
|
|
949
|
+
${nodeConfig && nodeConfig.type !== 'execute_actions'
|
|
973
950
|
? html`<div class="router" style="position: relative;">
|
|
974
951
|
<button
|
|
975
952
|
class="remove-button"
|
|
@@ -987,7 +964,7 @@ export class CanvasNode extends RapidElement {
|
|
|
987
964
|
nodeConfig,
|
|
988
965
|
this.actionRemovingState.has(this.node.uuid)
|
|
989
966
|
)}
|
|
990
|
-
${nodeConfig.render(this.node)}
|
|
967
|
+
${nodeConfig.render ? nodeConfig.render(this.node) : null}
|
|
991
968
|
</div>
|
|
992
969
|
</div>`
|
|
993
970
|
: this.node.actions.length > 0
|
|
@@ -1007,20 +984,6 @@ export class CanvasNode extends RapidElement {
|
|
|
1007
984
|
(action) => action.uuid,
|
|
1008
985
|
(action, index) => this.renderAction(this.node, action, index)
|
|
1009
986
|
)}`
|
|
1010
|
-
: !this.node.router && nodeConfig && nodeConfig.name
|
|
1011
|
-
? html`<div class="router" style="position: relative;">
|
|
1012
|
-
<button
|
|
1013
|
-
class="remove-button"
|
|
1014
|
-
@click=${(e: MouseEvent) => this.handleNodeRemoveClick(e)}
|
|
1015
|
-
title="Remove node"
|
|
1016
|
-
>
|
|
1017
|
-
✕
|
|
1018
|
-
</button>
|
|
1019
|
-
${this.renderNodeTitle(
|
|
1020
|
-
nodeConfig,
|
|
1021
|
-
this.actionRemovingState.has(this.node.uuid)
|
|
1022
|
-
)}
|
|
1023
|
-
</div>`
|
|
1024
987
|
: ''}
|
|
1025
988
|
${this.node.router
|
|
1026
989
|
? html` ${this.renderRouter(this.node.router, this.ui)}
|
package/src/flow/NodeEditor.ts
CHANGED
|
@@ -320,14 +320,6 @@ export class NodeEditor extends RapidElement {
|
|
|
320
320
|
this.isOpen = true;
|
|
321
321
|
}
|
|
322
322
|
|
|
323
|
-
private closeDialog(): void {
|
|
324
|
-
this.isOpen = false;
|
|
325
|
-
this.formData = {};
|
|
326
|
-
this.errors = {};
|
|
327
|
-
this.groupCollapseState = {};
|
|
328
|
-
this.groupHoverState = {};
|
|
329
|
-
}
|
|
330
|
-
|
|
331
323
|
private initializeFormData(): void {
|
|
332
324
|
const nodeConfig = this.getNodeConfig();
|
|
333
325
|
|
|
@@ -393,9 +385,51 @@ export class NodeEditor extends RapidElement {
|
|
|
393
385
|
}
|
|
394
386
|
});
|
|
395
387
|
|
|
388
|
+
// Convert select fields to array format
|
|
389
|
+
const config = this.getConfig();
|
|
390
|
+
if (config?.form) {
|
|
391
|
+
this.processSelectFields(processed, config.form);
|
|
392
|
+
}
|
|
393
|
+
|
|
396
394
|
this.formData = processed;
|
|
397
395
|
}
|
|
398
396
|
|
|
397
|
+
private processSelectFields(data: any, formConfig: any): void {
|
|
398
|
+
Object.entries(formConfig).forEach(
|
|
399
|
+
([fieldName, fieldConfig]: [string, any]) => {
|
|
400
|
+
const value = data[fieldName];
|
|
401
|
+
|
|
402
|
+
// Handle top-level select fields
|
|
403
|
+
if (fieldConfig.type === 'select' && value) {
|
|
404
|
+
data[fieldName] = this.convertToSelectArray(value);
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
// Handle select fields within array items
|
|
408
|
+
if (
|
|
409
|
+
fieldConfig.type === 'array' &&
|
|
410
|
+
Array.isArray(value) &&
|
|
411
|
+
fieldConfig.itemConfig
|
|
412
|
+
) {
|
|
413
|
+
value.forEach((item: any) => {
|
|
414
|
+
this.processSelectFields(item, fieldConfig.itemConfig);
|
|
415
|
+
});
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
);
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
private convertToSelectArray(value: any): any[] {
|
|
422
|
+
if (Array.isArray(value)) {
|
|
423
|
+
return value.map((v) =>
|
|
424
|
+
typeof v === 'string' ? { name: v, value: v } : v
|
|
425
|
+
);
|
|
426
|
+
} else if (typeof value === 'string') {
|
|
427
|
+
return [{ name: value, value: value }];
|
|
428
|
+
} else {
|
|
429
|
+
return [value];
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
|
|
399
433
|
private isKeyValueField(fieldName: string): boolean {
|
|
400
434
|
// Check if this field is configured as a key-value type
|
|
401
435
|
const config = this.getConfig();
|
|
@@ -533,6 +567,18 @@ export class NodeEditor extends RapidElement {
|
|
|
533
567
|
if (config.form) {
|
|
534
568
|
Object.entries(config.form).forEach(([fieldName, fieldConfig]) => {
|
|
535
569
|
const value = this.formData[fieldName];
|
|
570
|
+
if (fieldConfig.type === 'select' && fieldConfig.allowCreate) {
|
|
571
|
+
// check our values to see if any have arbitrary set
|
|
572
|
+
let selected = this.formData[fieldName];
|
|
573
|
+
selected = Array.isArray(selected)
|
|
574
|
+
? selected.find((v: any) => v.arbitrary)
|
|
575
|
+
: null;
|
|
576
|
+
|
|
577
|
+
if (selected && selected.arbitrary) {
|
|
578
|
+
errors[fieldName] =
|
|
579
|
+
'There was an error creating' + ' "' + selected.name + '"';
|
|
580
|
+
}
|
|
581
|
+
}
|
|
536
582
|
|
|
537
583
|
// Check required fields
|
|
538
584
|
if (
|
|
@@ -856,11 +902,6 @@ export class NodeEditor extends RapidElement {
|
|
|
856
902
|
// Handle different component types like ActionEditor does
|
|
857
903
|
if (target.tagName === 'TEMBA-CHECKBOX') {
|
|
858
904
|
value = target.checked;
|
|
859
|
-
} else if (
|
|
860
|
-
target.tagName === 'TEMBA-SELECT' &&
|
|
861
|
-
(target.multi || target.emails || target.tags)
|
|
862
|
-
) {
|
|
863
|
-
value = target.values || [];
|
|
864
905
|
} else if (target.values !== undefined) {
|
|
865
906
|
value = target.values;
|
|
866
907
|
} else {
|
|
@@ -5,7 +5,7 @@ import { renderNamedObjects } from '../utils';
|
|
|
5
5
|
|
|
6
6
|
export const add_contact_groups: ActionConfig = {
|
|
7
7
|
name: 'Add to Group',
|
|
8
|
-
color: COLORS.
|
|
8
|
+
color: COLORS.update,
|
|
9
9
|
render: (_node: Node, action: AddToGroup) => {
|
|
10
10
|
return html`<div>${renderNamedObjects(action.groups, 'group')}</div>`;
|
|
11
11
|
},
|
|
@@ -29,7 +29,22 @@ export const add_contact_groups: ActionConfig = {
|
|
|
29
29
|
endpoint: '/api/v2/groups.json',
|
|
30
30
|
valueKey: 'uuid',
|
|
31
31
|
nameKey: 'name',
|
|
32
|
-
placeholder: 'Search for groups...'
|
|
32
|
+
placeholder: 'Search for groups...',
|
|
33
|
+
allowCreate: true,
|
|
34
|
+
createArbitraryOption: (input: string, options: any[]) => {
|
|
35
|
+
// Check if a label with this name already exists
|
|
36
|
+
const existing = options.find(
|
|
37
|
+
(option) =>
|
|
38
|
+
option.name.toLowerCase().trim() === input.toLowerCase().trim()
|
|
39
|
+
);
|
|
40
|
+
if (!existing && input.trim()) {
|
|
41
|
+
return {
|
|
42
|
+
name: input.trim(),
|
|
43
|
+
arbitrary: true
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
33
48
|
}
|
|
34
49
|
},
|
|
35
50
|
fromFormData: (formData: any): AddToGroup => {
|
|
@@ -4,7 +4,7 @@ import { Node, AddContactUrn } from '../../store/flow-definition';
|
|
|
4
4
|
import { urnSchemeMap } from '../utils';
|
|
5
5
|
|
|
6
6
|
export const add_contact_urn: ActionConfig = {
|
|
7
|
-
name: 'Add
|
|
7
|
+
name: 'Add URN',
|
|
8
8
|
color: COLORS.update,
|
|
9
9
|
render: (_node: Node, action: AddContactUrn) => {
|
|
10
10
|
const friendlyScheme = urnSchemeMap[action.scheme] || action.scheme;
|
|
@@ -5,7 +5,7 @@ import { renderNamedObjects } from '../utils';
|
|
|
5
5
|
|
|
6
6
|
export const add_input_labels: ActionConfig = {
|
|
7
7
|
name: 'Add Input Labels',
|
|
8
|
-
color: COLORS.
|
|
8
|
+
color: COLORS.save,
|
|
9
9
|
render: (_node: Node, action: AddInputLabels) => {
|
|
10
10
|
return html`<div>${renderNamedObjects(action.labels, 'label')}</div>`;
|
|
11
11
|
},
|
|
@@ -31,6 +31,7 @@ export const add_input_labels: ActionConfig = {
|
|
|
31
31
|
valueKey: 'uuid',
|
|
32
32
|
nameKey: 'name',
|
|
33
33
|
placeholder: 'Search for labels or type to create new ones...',
|
|
34
|
+
allowCreate: true,
|
|
34
35
|
createArbitraryOption: (input: string, options: any[]) => {
|
|
35
36
|
// Check if a label with this name already exists
|
|
36
37
|
const existing = options.find(
|
|
@@ -5,7 +5,7 @@ import { renderNamedObjects } from '../utils';
|
|
|
5
5
|
|
|
6
6
|
export const remove_contact_groups: ActionConfig = {
|
|
7
7
|
name: 'Remove from Group',
|
|
8
|
-
color: COLORS.
|
|
8
|
+
color: COLORS.update,
|
|
9
9
|
render: (_node: Node, action: RemoveFromGroup) => {
|
|
10
10
|
if (action.all_groups) {
|
|
11
11
|
return html`<div>Remove from all groups</div>`;
|
|
@@ -19,7 +19,6 @@ export const send_email: ActionConfig = {
|
|
|
19
19
|
</div>
|
|
20
20
|
</div>`;
|
|
21
21
|
},
|
|
22
|
-
|
|
23
22
|
form: {
|
|
24
23
|
addresses: {
|
|
25
24
|
type: 'select',
|
|
@@ -44,6 +43,17 @@ export const send_email: ActionConfig = {
|
|
|
44
43
|
minHeight: 175
|
|
45
44
|
}
|
|
46
45
|
},
|
|
46
|
+
fromFormData: (formData: any): SendEmail => {
|
|
47
|
+
return {
|
|
48
|
+
uuid: formData.uuid,
|
|
49
|
+
type: 'send_email',
|
|
50
|
+
addresses: formData.addresses.map(
|
|
51
|
+
(addr: { name: string; value: string }) => addr.value
|
|
52
|
+
),
|
|
53
|
+
subject: formData.subject,
|
|
54
|
+
body: formData.body
|
|
55
|
+
};
|
|
56
|
+
},
|
|
47
57
|
validate: (action: SendEmail): ValidationResult => {
|
|
48
58
|
const errors: { [key: string]: string } = {};
|
|
49
59
|
|
|
@@ -2,6 +2,7 @@ import { html } from 'lit-html';
|
|
|
2
2
|
import { unsafeHTML } from 'lit-html/directives/unsafe-html.js';
|
|
3
3
|
import { ActionConfig, COLORS, ValidationResult } from '../types';
|
|
4
4
|
import { Node, SendMsg } from '../../store/flow-definition';
|
|
5
|
+
import { titleCase } from '../../utils';
|
|
5
6
|
|
|
6
7
|
export const send_msg: ActionConfig = {
|
|
7
8
|
name: 'Send Message',
|
|
@@ -65,10 +66,10 @@ export const send_msg: ActionConfig = {
|
|
|
65
66
|
type: {
|
|
66
67
|
type: 'select',
|
|
67
68
|
options: [
|
|
68
|
-
{ value: 'image',
|
|
69
|
-
{ value: 'audio',
|
|
70
|
-
{ value: 'video',
|
|
71
|
-
{ value: 'document',
|
|
69
|
+
{ value: 'image', name: 'Image' },
|
|
70
|
+
{ value: 'audio', name: 'Audio' },
|
|
71
|
+
{ value: 'video', name: 'Video' },
|
|
72
|
+
{ value: 'document', name: 'Document' }
|
|
72
73
|
],
|
|
73
74
|
required: true,
|
|
74
75
|
searchable: false
|
|
@@ -116,7 +117,10 @@ export const send_msg: ActionConfig = {
|
|
|
116
117
|
],
|
|
117
118
|
toFormData: (action: SendMsg) => {
|
|
118
119
|
// Extract runtime attachments from the text field attachments
|
|
119
|
-
const runtimeAttachments: {
|
|
120
|
+
const runtimeAttachments: {
|
|
121
|
+
type: { name: string; value: string };
|
|
122
|
+
expression: string;
|
|
123
|
+
}[] = [];
|
|
120
124
|
const staticAttachments: string[] = [];
|
|
121
125
|
|
|
122
126
|
if (action.attachments && Array.isArray(action.attachments)) {
|
|
@@ -127,13 +131,11 @@ export const send_msg: ActionConfig = {
|
|
|
127
131
|
const value = attachment.substring(colonIndex + 1);
|
|
128
132
|
|
|
129
133
|
if (!contentType.includes('/')) {
|
|
130
|
-
// This is a runtime attachment
|
|
131
134
|
runtimeAttachments.push({
|
|
132
|
-
type: contentType,
|
|
135
|
+
type: { name: titleCase(contentType), value: contentType },
|
|
133
136
|
expression: value
|
|
134
137
|
});
|
|
135
138
|
} else {
|
|
136
|
-
// This is a static attachment
|
|
137
139
|
staticAttachments.push(attachment);
|
|
138
140
|
}
|
|
139
141
|
}
|
|
@@ -165,10 +167,17 @@ export const send_msg: ActionConfig = {
|
|
|
165
167
|
// Combine static attachments from text field with runtime attachments
|
|
166
168
|
const staticAttachments = data.attachments || [];
|
|
167
169
|
const runtimeAttachments = (data.runtime_attachments || [])
|
|
168
|
-
.filter(
|
|
170
|
+
.filter(
|
|
171
|
+
(item: {
|
|
172
|
+
type: [{ name: string; value: string }];
|
|
173
|
+
expression: string;
|
|
174
|
+
}) => item && item.type && item.expression
|
|
175
|
+
) // Filter out invalid items
|
|
169
176
|
.map(
|
|
170
|
-
(item: {
|
|
171
|
-
|
|
177
|
+
(item: {
|
|
178
|
+
type: [{ name: string; value: string }];
|
|
179
|
+
expression: string;
|
|
180
|
+
}) => `${item.type[0].value}:${item.expression}`
|
|
172
181
|
);
|
|
173
182
|
|
|
174
183
|
result.attachments = [...staticAttachments, ...runtimeAttachments];
|
|
@@ -1,13 +1,36 @@
|
|
|
1
1
|
import { html } from 'lit-html';
|
|
2
|
-
import { ActionConfig, COLORS } from '../types';
|
|
2
|
+
import { ActionConfig, COLORS, ValidationResult } from '../types';
|
|
3
3
|
import { Node, SetContactChannel } from '../../store/flow-definition';
|
|
4
4
|
|
|
5
5
|
export const set_contact_channel: ActionConfig = {
|
|
6
|
-
name: 'Update
|
|
6
|
+
name: 'Update Channel',
|
|
7
7
|
color: COLORS.update,
|
|
8
8
|
render: (_node: Node, action: SetContactChannel) => {
|
|
9
|
-
return html`<div>
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
return html`<div>Set to <b>${action.channel.name}</b></div>`;
|
|
10
|
+
},
|
|
11
|
+
form: {
|
|
12
|
+
channel: {
|
|
13
|
+
type: 'select',
|
|
14
|
+
label: 'Channel',
|
|
15
|
+
required: true,
|
|
16
|
+
searchable: true,
|
|
17
|
+
clearable: false,
|
|
18
|
+
endpoint: '/api/v2/channels.json',
|
|
19
|
+
valueKey: 'uuid',
|
|
20
|
+
nameKey: 'name',
|
|
21
|
+
helpText: 'Select the channel to set for the contact'
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
validate: (formData: SetContactChannel): ValidationResult => {
|
|
25
|
+
const errors: { [key: string]: string } = {};
|
|
26
|
+
|
|
27
|
+
if (!formData.channel) {
|
|
28
|
+
errors.channel = 'Channel is required';
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return {
|
|
32
|
+
valid: Object.keys(errors).length === 0,
|
|
33
|
+
errors
|
|
34
|
+
};
|
|
12
35
|
}
|
|
13
36
|
};
|