@integry/sdk 4.5.2 → 4.5.4

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.
Files changed (279) hide show
  1. package/.vscode/launch.json +2 -2
  2. package/THIRD_PARTY_LICENSES +0 -37
  3. package/dist/esm/index.csm.d.ts +12 -2
  4. package/dist/esm/index.csm.js +7262 -1
  5. package/dist/umd/index.umd.d.ts +9 -1
  6. package/dist/umd/index.umd.js +7262 -1
  7. package/jest.config.cjs +10 -0
  8. package/package.json +10 -4
  9. package/src/components/AddTagButton/index.ts +23 -0
  10. package/src/components/BasicSelect/index.ts +114 -0
  11. package/src/components/BasicSelect/styles.module.scss +44 -0
  12. package/src/components/Button/index.ts +94 -0
  13. package/src/components/Button/styles.module.scss +152 -0
  14. package/src/components/CheckboxGroup/Checkbox.ts +104 -0
  15. package/src/components/CheckboxGroup/index.ts +190 -0
  16. package/src/components/CheckboxGroup/styles.module.scss +63 -0
  17. package/src/components/CollapsedMenu/index.ts +101 -0
  18. package/src/components/CollapsedMenu/styles.module.scss +46 -0
  19. package/src/components/ConfigureFieldWrapper/index.ts +85 -0
  20. package/src/components/ConfigureFieldWrapper/styles.module.scss +57 -0
  21. package/src/components/EditableText/index.ts +121 -0
  22. package/src/components/EditableText/styles.module.scss +38 -0
  23. package/src/components/EditableTextArea/index.ts +143 -0
  24. package/src/components/EditableTextArea/styles.module.scss +91 -0
  25. package/src/components/ErrorMessage/index.ts +16 -0
  26. package/src/components/ErrorMessage/styles.module.scss +19 -0
  27. package/src/components/ErrorPage/index.ts +42 -0
  28. package/src/components/ErrorPage/styles.module.scss +26 -0
  29. package/src/components/Footer/index.ts +41 -0
  30. package/src/components/Footer/styles.module.scss +40 -0
  31. package/src/components/HTMLContent/index.tsx +275 -0
  32. package/src/components/HTMLContent/styles.module.scss +3 -0
  33. package/src/components/InfoBox/index.ts +48 -0
  34. package/src/components/InfoBox/styles.module.scss +21 -0
  35. package/src/components/Input/BaseInput/index.ts +170 -0
  36. package/src/components/Input/BaseInput/styles.module.scss +94 -0
  37. package/src/components/Input/DateInput/index.ts +103 -0
  38. package/src/components/Input/DateInput/styles.module.scss +50 -0
  39. package/src/components/Input/Input/index.ts +206 -0
  40. package/src/components/Input/Input/styles.module.scss +14 -0
  41. package/src/components/Input/PasswordInput/index.ts +164 -0
  42. package/src/components/Input/PasswordInput/styles.module.scss +37 -0
  43. package/src/components/Input/index.ts +7 -0
  44. package/src/components/Label/index.ts +61 -0
  45. package/src/components/Label/styles.module.scss +41 -0
  46. package/src/components/LargeLoader/index.ts +25 -0
  47. package/src/components/LargeLoader/styles.module.scss +16 -0
  48. package/src/components/Listbox/ListBoxItem.ts +57 -0
  49. package/src/components/Listbox/index.ts +479 -0
  50. package/src/components/Listbox/styles.module.scss +197 -0
  51. package/src/components/Loader/index.ts +25 -0
  52. package/src/components/Loader/styles.module.scss +16 -0
  53. package/src/components/MediaGallery/MediaGalleryModal.ts +82 -0
  54. package/src/components/MediaGallery/MediaSlider.ts +76 -0
  55. package/src/components/MediaGallery/index.ts +92 -0
  56. package/src/components/MediaGallery/styles.module.scss +156 -0
  57. package/src/components/MediaUpload/index.ts +233 -0
  58. package/src/components/MediaUpload/styles.module.scss +118 -0
  59. package/src/components/Modal/index.ts +87 -0
  60. package/src/components/Modal/styles.module.scss +441 -0
  61. package/src/components/MultipurposeField/Dropdown/ListBoxItem.tsx +58 -0
  62. package/src/components/MultipurposeField/Dropdown/index.tsx +981 -0
  63. package/src/components/MultipurposeField/Dropdown/styles.module.scss +208 -0
  64. package/src/components/MultipurposeField/TagMenu/index.ts +384 -0
  65. package/src/components/MultipurposeField/TagMenu/styles.module.scss +136 -0
  66. package/src/components/MultipurposeField/TagOptions/index.tsx +83 -0
  67. package/src/components/MultipurposeField/TagOptions/styles.module.scss +95 -0
  68. package/src/components/MultipurposeField/index.tsx +687 -0
  69. package/src/components/MultipurposeField/styles.module.scss +56 -0
  70. package/src/components/NewModal/index.ts +69 -0
  71. package/src/components/NewModal/styles.module.scss +70 -0
  72. package/src/components/OverflowTooltip/index.tsx +59 -0
  73. package/src/components/PopUp/ConfirmationPopUp/index.ts +58 -0
  74. package/src/components/PopUp/ConfirmationPopUp/styles.module.scss +49 -0
  75. package/src/components/PopUp/SuccessPopUp/index.ts +62 -0
  76. package/src/components/PopUp/SuccessPopUp/styles.module.scss +38 -0
  77. package/src/components/RadioGroup/Radio.ts +129 -0
  78. package/src/components/RadioGroup/index.ts +169 -0
  79. package/src/components/RadioGroup/styles.module.scss +81 -0
  80. package/src/components/Search/index.ts +69 -0
  81. package/src/components/Search/styles.module.scss +149 -0
  82. package/src/components/TabBar/Tab.ts +33 -0
  83. package/src/components/TabBar/index.ts +64 -0
  84. package/src/components/TabBar/styles.module.scss +43 -0
  85. package/src/components/Tag/index.ts +29 -0
  86. package/src/components/Tag/styles.module.scss +57 -0
  87. package/src/components/TextArea/index.ts +172 -0
  88. package/src/components/TextArea/styles.module.scss +70 -0
  89. package/src/components/TextContent/index.tsx +128 -0
  90. package/src/components/TextContent/styles.module.scss +6 -0
  91. package/src/components/ThreeDotLoader/index.ts +39 -0
  92. package/src/components/ThreeDotLoader/styles.module.scss +41 -0
  93. package/src/components/TimeInput/index.ts +129 -0
  94. package/src/components/TimeInput/styles.module.scss +16 -0
  95. package/src/components/Toggle/index.ts +34 -0
  96. package/src/components/Toggle/styles.module.scss +56 -0
  97. package/src/components/Toggle-v2/index.ts +40 -0
  98. package/src/components/Toggle-v2/styles.module.scss +86 -0
  99. package/src/components/Tooltip/index.ts +271 -0
  100. package/src/components/Tooltip/styles.module.scss +105 -0
  101. package/src/components/form/ObjectField/index.ts +364 -0
  102. package/src/components/form/ObjectField/styles.module.scss +103 -0
  103. package/src/components/form/index.ts +3 -0
  104. package/src/contexts/AppContext.ts +12 -0
  105. package/src/declaration.d.ts +7 -0
  106. package/src/extensions/HMAC.ts +25 -0
  107. package/src/extensions/IntegryAPIError.ts +19 -0
  108. package/src/features/common/AccountDropdown/index.ts +291 -0
  109. package/src/features/common/AccountDropdown/styles.module.scss +19 -0
  110. package/src/features/common/ActionForm/index.ts +1818 -0
  111. package/src/features/common/ActionForm/styles.module.scss +23 -0
  112. package/src/features/common/AppCard/index.ts +207 -0
  113. package/src/features/common/AppCard/styles.module.scss +117 -0
  114. package/src/features/common/AppCardCompact/index.ts +189 -0
  115. package/src/features/common/AppCardCompact/styles.module.scss +141 -0
  116. package/src/features/common/AuthSelector/index.ts +537 -0
  117. package/src/features/common/AuthSelector/styles.module.scss +161 -0
  118. package/src/features/common/AuthSelectorCompact/index.ts +706 -0
  119. package/src/features/common/AuthSelectorCompact/styles.module.scss +219 -0
  120. package/src/features/common/AuthSelectorDropdown/index.ts +704 -0
  121. package/src/features/common/AuthSelectorDropdown/styles.module.scss +361 -0
  122. package/src/features/common/DynamicField/index.ts +229 -0
  123. package/src/features/common/DynamicField/styles.module.scss +67 -0
  124. package/src/features/common/DynamicTypedField/index.ts +217 -0
  125. package/src/features/common/DynamicTypedField/styles.module.scss +67 -0
  126. package/src/features/common/FunctionForm/index.ts +862 -0
  127. package/src/features/common/FunctionForm/styles.module.scss +163 -0
  128. package/src/features/common/MappingUI/index.ts +649 -0
  129. package/src/features/common/MappingUI/styles.module.scss +121 -0
  130. package/src/features/common/MarketplaceAppCard/index.ts +279 -0
  131. package/src/features/common/MarketplaceAppCard/styles.module.scss +231 -0
  132. package/src/features/common/MarketplaceAppCardCompact/index.ts +283 -0
  133. package/src/features/common/MarketplaceAppCardCompact/styles.module.scss +255 -0
  134. package/src/features/common/NewMappingUI/index.ts +515 -0
  135. package/src/features/common/NewMappingUI/styles.module.scss +113 -0
  136. package/src/features/common/RequestAppWidget/RequestAppModal/index.ts +67 -0
  137. package/src/features/common/RequestAppWidget/RequestAppModal/styles.module.scss +23 -0
  138. package/src/features/common/RequestAppWidget/index.ts +48 -0
  139. package/src/features/common/RequestAppWidget/request-app-form.ts +89 -0
  140. package/src/features/common/RequestAppWidget/styles.module.scss +43 -0
  141. package/src/features/common/SectionField/index.ts +272 -0
  142. package/src/features/common/SectionField/styles.module.scss +67 -0
  143. package/src/features/common/Step/index.ts +827 -0
  144. package/src/features/common/Step/styles.module.scss +12 -0
  145. package/src/features/common/StepNavigation/CollapsedSteps.ts +125 -0
  146. package/src/features/common/StepNavigation/NavItem.ts +111 -0
  147. package/src/features/common/StepNavigation/index.ts +257 -0
  148. package/src/features/common/StepNavigation/styles.module.scss +117 -0
  149. package/src/features/common/Steps/index.ts +1139 -0
  150. package/src/features/common/Steps/styles.module.scss +314 -0
  151. package/src/features/containers/AppFlowContainer/AppFlowListing/compactStyles.module.scss +383 -0
  152. package/src/features/containers/AppFlowContainer/AppFlowListing/flow-instance.tsx +367 -0
  153. package/src/features/containers/AppFlowContainer/AppFlowListing/flowCard.tsx +194 -0
  154. package/src/features/containers/AppFlowContainer/AppFlowListing/flowCardCompact.tsx +389 -0
  155. package/src/features/containers/AppFlowContainer/AppFlowListing/flowInstanceCompact.tsx +577 -0
  156. package/src/features/containers/AppFlowContainer/AppFlowListing/index.tsx +83 -0
  157. package/src/features/containers/AppFlowContainer/AppFlowListing/styles.module.scss +212 -0
  158. package/src/features/containers/AppFlowContainer/AppFlowWrap/app-page-loader.tsx +45 -0
  159. package/src/features/containers/AppFlowContainer/AppFlowWrap/index.tsx +1081 -0
  160. package/src/features/containers/AppFlowContainer/AppFlowWrap/styles.module.scss +452 -0
  161. package/src/features/containers/AppFlowContainer/Authentication/index.ts +610 -0
  162. package/src/features/containers/AppFlowContainer/Authentication/styles.module.scss +468 -0
  163. package/src/features/containers/AppFlowContainer/index.ts +114 -0
  164. package/src/features/containers/AppPageContainer/AppPage/index.tsx +262 -0
  165. package/src/features/containers/AppPageContainer/AppPage/styles.module.scss +120 -0
  166. package/src/features/containers/AppPageContainer/IntegrationCard/index.ts +165 -0
  167. package/src/features/containers/AppPageContainer/IntegrationCard/styles.module.scss +81 -0
  168. package/src/features/containers/AppPageContainer/index.tsx +93 -0
  169. package/src/features/containers/AppPageContainer/styles.module.scss +0 -0
  170. package/src/features/containers/AppsForFlows/index.ts +161 -0
  171. package/src/features/containers/AppsForFlows/styles.module.scss +280 -0
  172. package/src/features/containers/AppsForFlowsCompact/index.ts +161 -0
  173. package/src/features/containers/AppsForFlowsCompact/styles.module.scss +279 -0
  174. package/src/features/containers/AuthSetupContainer/AppSelection.ts +73 -0
  175. package/src/features/containers/AuthSetupContainer/AuthTypeSelection.ts +67 -0
  176. package/src/features/containers/AuthSetupContainer/Footer.ts +32 -0
  177. package/src/features/containers/AuthSetupContainer/Header.ts +39 -0
  178. package/src/features/containers/AuthSetupContainer/PostAdditionPopup.ts +27 -0
  179. package/src/features/containers/AuthSetupContainer/index.ts +349 -0
  180. package/src/features/containers/AuthSetupContainer/styles.module.scss +229 -0
  181. package/src/features/containers/FlowSetupContainer/index.ts +390 -0
  182. package/src/features/containers/FlowSetupContainer/styles.module.scss +18 -0
  183. package/src/features/containers/MarkeplaceApps/index.ts +574 -0
  184. package/src/features/containers/MarkeplaceApps/styles.module.scss +559 -0
  185. package/src/features/containers/MarketplaceAppsCompact/index.ts +576 -0
  186. package/src/features/containers/MarketplaceAppsCompact/styles.module.scss +546 -0
  187. package/src/features/containers/MarketplaceAppsContainer/index.ts +83 -0
  188. package/src/features/containers/MarketplaceContainer/AppCard/index.ts +91 -0
  189. package/src/features/containers/MarketplaceContainer/AppCard/styles.module.scss +66 -0
  190. package/src/features/containers/MarketplaceContainer/AppListing/index.ts +34 -0
  191. package/src/features/containers/MarketplaceContainer/AppListing/styles.module.scss +10 -0
  192. package/src/features/containers/MarketplaceContainer/MarketplaceContentWrap/index.ts +132 -0
  193. package/src/features/containers/MarketplaceContainer/MarketplaceContentWrap/styles.module.scss +117 -0
  194. package/src/features/containers/MarketplaceContainer/index.ts +242 -0
  195. package/src/features/containers/MarketplaceContainer/styles.module.scss +84 -0
  196. package/src/features/containers/SDKContainer/index.ts +817 -0
  197. package/src/features/containers/SDKContainer/styles.module.scss +266 -0
  198. package/src/features/containers/SDKDebugContainer/index.ts +137 -0
  199. package/src/features/containers/SDKDebugContainer/styles.module.scss +37 -0
  200. package/src/features/containers/SDKFailedContainer/index.ts +117 -0
  201. package/src/features/containers/SDKFailedContainer/styles.module.scss +57 -0
  202. package/src/features/integrations/IntegrationRow/Icons.ts +77 -0
  203. package/src/features/integrations/IntegrationRow/index.ts +129 -0
  204. package/src/features/integrations/IntegrationRow/styles.module.scss +62 -0
  205. package/src/features/integrations/IntegrationsHeader/index.ts +34 -0
  206. package/src/features/integrations/IntegrationsHeader/styles.module.scss +47 -0
  207. package/src/features/integrations/IntegrationsList/index.ts +252 -0
  208. package/src/features/integrations/IntegrationsList/styles.module.scss +67 -0
  209. package/src/features/templates/Template/index.ts +295 -0
  210. package/src/features/templates/Template/styles.module.scss +226 -0
  211. package/src/features/templates/TemplatesView/index.ts +368 -0
  212. package/src/features/templates/TemplatesView/styles.module.scss +71 -0
  213. package/src/features/templates/TemplatesViewCompact/index.ts +364 -0
  214. package/src/features/templates/TemplatesViewCompact/styles.module.scss +141 -0
  215. package/src/hooks/useAutosizeTextArea.ts +22 -0
  216. package/src/hooks/useCustomRef.ts +13 -0
  217. package/src/hooks/useDebounce.ts +17 -0
  218. package/src/hooks/useElementResize.ts +40 -0
  219. package/src/hooks/useEventListener.ts +44 -0
  220. package/src/hooks/useHover.ts +40 -0
  221. package/src/hooks/useOnClickOutside.ts +32 -0
  222. package/src/index.ts +2051 -0
  223. package/src/index.umd.ts +13 -0
  224. package/src/interfaces/index.ts +924 -0
  225. package/src/modules/api/index.ts +1315 -0
  226. package/src/modules/api/responseHandler.ts +38 -0
  227. package/src/modules/event-emitter/index.ts +72 -0
  228. package/src/modules/event-emitter/runners/abstract.ts +21 -0
  229. package/src/modules/event-emitter/runners/default.ts +11 -0
  230. package/src/modules/event-emitter/runners/ntimes.ts +28 -0
  231. package/src/modules/event-emitter/types.ts +34 -0
  232. package/src/store/actionFunctions.ts +1573 -0
  233. package/src/store/index.ts +17 -0
  234. package/src/store/initialState.ts +58 -0
  235. package/src/stories/Button.stories.tsx +83 -0
  236. package/src/stories/Checkbox/Checkbox.stories.tsx +41 -0
  237. package/src/stories/Checkbox/CheckboxGroup.stories.tsx +46 -0
  238. package/src/stories/EditableText.stories.tsx +35 -0
  239. package/src/stories/Input/BaseInput.stories.tsx +48 -0
  240. package/src/stories/Input/DateInput.stories.tsx +28 -0
  241. package/src/stories/Input/Input.stories.tsx +24 -0
  242. package/src/stories/Input/PasswordInput.stories.tsx +26 -0
  243. package/src/stories/Introduction.stories.mdx +211 -0
  244. package/src/stories/Label.stories.tsx +27 -0
  245. package/src/stories/Listbox.stories.tsx +122 -0
  246. package/src/stories/Radio/Radio.stories.tsx +39 -0
  247. package/src/stories/Radio/RadioGroup.stories.tsx +46 -0
  248. package/src/stories/StepNavigation/NavItem.stories.tsx +31 -0
  249. package/src/stories/StepNavigation/StepNavigation.stories.tsx +50 -0
  250. package/src/stories/TabBar.stories.tsx +31 -0
  251. package/src/stories/TextArea.stories.tsx +23 -0
  252. package/src/stories/TimeInput.stories.tsx +37 -0
  253. package/src/stories/Toggle.stories.tsx +33 -0
  254. package/src/stories/assets/code-brackets.svg +1 -0
  255. package/src/stories/assets/colors.svg +1 -0
  256. package/src/stories/assets/comments.svg +1 -0
  257. package/src/stories/assets/direction.svg +1 -0
  258. package/src/stories/assets/flow.svg +1 -0
  259. package/src/stories/assets/plugin.svg +1 -0
  260. package/src/stories/assets/repo.svg +1 -0
  261. package/src/stories/assets/stackalt.svg +1 -0
  262. package/src/types/index.ts +293 -0
  263. package/src/types/store.ts +366 -0
  264. package/src/types/utils.ts +19 -0
  265. package/src/utils/ActivityOutputUtils.ts +163 -0
  266. package/src/utils/common.ts +20 -0
  267. package/src/utils/copyToClipboard.ts +24 -0
  268. package/src/utils/datetime.ts +101 -0
  269. package/src/utils/getUrlParam.ts +11 -0
  270. package/src/utils/isAuthMessage.ts +16 -0
  271. package/src/utils/isBrowser.ts +1 -0
  272. package/src/utils/jsonEncodeDecode.ts +15 -0
  273. package/src/utils/objectUtils.ts +116 -0
  274. package/src/utils/popup.ts +30 -0
  275. package/src/utils/searchJson.ts +51 -0
  276. package/src/utils/stepUtils.ts +45 -0
  277. package/src/utils/truncate.ts +6 -0
  278. package/test/setup.ts +1 -0
  279. package/vitest.config.ts +10 -0
@@ -0,0 +1,577 @@
1
+ /* eslint-disable import/no-cycle */
2
+ /* eslint-disable @typescript-eslint/quotes */
3
+ import { html } from 'htm/preact';
4
+ import AppContext from '@/contexts/AppContext';
5
+ import { useEffect, useContext, useState } from 'preact/hooks';
6
+ import { Hint } from '@/components/Tooltip';
7
+ import { Loader } from '@/components/Loader';
8
+
9
+ import { Instance } from '@/interfaces';
10
+ import { CollapsedMenu } from '@/components/CollapsedMenu';
11
+ import { EditableText } from '@/components/EditableText';
12
+ import { Toggle } from '@/components/Toggle-v2';
13
+ import { Tag } from '@/components/Tag';
14
+
15
+ import { convertDateToStandard } from '@/utils/datetime';
16
+
17
+ import styles from './compactStyles.module.scss';
18
+
19
+ interface FlowInstanceRowProps {
20
+ instance: Instance;
21
+ onEditInstance?: (instance: Instance) => void;
22
+ onDelete?: (instance: Instance) => void;
23
+ isCompact?: boolean;
24
+ hideLastRunTime?: boolean;
25
+ hideInfoIcon?: boolean;
26
+ hideContextMenu?: boolean;
27
+ hideIntegrationToggle?: boolean;
28
+ }
29
+ interface FlowInstanceProps {
30
+ instances: Instance[];
31
+ onEditInstance: FlowInstanceRowProps['onEditInstance'];
32
+ onDelete: FlowInstanceRowProps['onDelete'];
33
+ updateInstanceName: (instanceId: number, name: string) => void;
34
+ isCompact?: boolean;
35
+ }
36
+
37
+ export const MenuIcon = () =>
38
+ html`<svg
39
+ width="20"
40
+ height="20"
41
+ viewBox="0 0 20 20"
42
+ fill="none"
43
+ xmlns="http://www.w3.org/2000/svg"
44
+ >
45
+ <path
46
+ fill-rule="evenodd"
47
+ clip-rule="evenodd"
48
+ d="M4.5 11C5.32843 11 6 10.3284 6 9.5C6 8.67157 5.32843 8 4.5 8C3.67157 8 3 8.67157 3 9.5C3 10.3284 3.67157 11 4.5 11Z"
49
+ fill="#999999"
50
+ />
51
+ <path
52
+ fill-rule="evenodd"
53
+ clip-rule="evenodd"
54
+ d="M9.5 11C10.3284 11 11 10.3284 11 9.5C11 8.67157 10.3284 8 9.5 8C8.67157 8 8 8.67157 8 9.5C8 10.3284 8.67157 11 9.5 11Z"
55
+ fill="#999999"
56
+ />
57
+ <path
58
+ fill-rule="evenodd"
59
+ clip-rule="evenodd"
60
+ d="M14.5 11C15.3284 11 16 10.3284 16 9.5C16 8.67157 15.3284 8 14.5 8C13.6716 8 13 8.67157 13 9.5C13 10.3284 13.6716 11 14.5 11Z"
61
+ fill="#999999"
62
+ />
63
+ </svg>`;
64
+
65
+ export const InstanceBlockedInfo = (props: { instance: Instance }) => {
66
+ const {
67
+ error_app_name,
68
+ first_error_received_at,
69
+ status,
70
+ usage_limit_reached_at,
71
+ error_code,
72
+ } = props.instance;
73
+
74
+ const convertedTime = first_error_received_at
75
+ ? convertDateToStandard(first_error_received_at)
76
+ : '';
77
+
78
+ const getBlockedReason = () => {
79
+ switch (status) {
80
+ case 'AUTH_MISSING':
81
+ // return `Authentication failed. Try to re-authenticate your account and enable the instance.`;
82
+ return `Integration has been blocked because\nof failed authentication. User needs to\nre-authenticate their account and enable\nthe integration.`;
83
+ case 'BLOCKED':
84
+ if (usage_limit_reached_at) {
85
+ return `Integration has been blocked because\nthe user limit has been reached`;
86
+ return `User limit is reached`;
87
+ }
88
+ if (error_code >= 500 && error_code <= 599) {
89
+ return `Integration has been blocked because\nof too many server errors`;
90
+ return error_app_name && convertedTime
91
+ ? `Too many server errors from ${error_app_name} since ${convertedTime}. \nYou can try enabling the instance.`
92
+ : `Too many server errors. You can try enabling the instance.`;
93
+ }
94
+ if (error_code >= 400 && error_code <= 499) {
95
+ return `Integration has been blocked because of too many data errors`;
96
+ return error_app_name && convertedTime
97
+ ? `Too many errors from ${error_app_name} since ${convertedTime} \ndue to a configuration issue. Try creating a new instance.`
98
+ : `Too many errors due to a configuration issue. Try create a new instance.`;
99
+ }
100
+ return '';
101
+ default:
102
+ return '';
103
+ }
104
+ };
105
+ const blockedReason = getBlockedReason();
106
+ return blockedReason
107
+ ? html`<${Hint}
108
+ dismissOnClick=${false}
109
+ deltaY=${12}
110
+ position="fixed"
111
+ style="display: flex; flex-direction: row; align-items: center; justify-content: center;margin-right:6px;"
112
+ template=${(content: string) => html`<div>${blockedReason}</div>`}
113
+ >
114
+ <svg
115
+ width="16"
116
+ height="16"
117
+ viewBox="0 0 24 24"
118
+ fill="none"
119
+ xmlns="http://www.w3.org/2000/svg"
120
+ >
121
+ <path
122
+ data-hint="${blockedReason}"
123
+ d="M0 12C0 18.6268 5.37184 24 12 24C18.6268 24 24 18.6268 24 12C24 5.37322 18.6282 3.05176e-05 12 3.05176e-05C5.37319 3.05176e-05 0 5.37187 0 12Z"
124
+ fill="#F05C42"
125
+ />
126
+ <path
127
+ d="M13.185 16.9089C13.185 15.3294 10.8164 15.3294 10.8164 16.9089C10.8164 18.4884 13.185 18.4884 13.185 16.9089Z"
128
+ fill="white"
129
+ />
130
+ <path
131
+ d="M11.1582 13.2688C11.1582 13.7326 11.5342 14.1087 11.9981 14.1087V14.1087C12.462 14.1087 12.838 13.7326 12.838 13.2688V6.74489C12.838 6.28101 12.462 5.90497 11.9981 5.90497V5.90497C11.5342 5.90497 11.1582 6.28102 11.1582 6.74489V13.2688Z"
132
+ fill="white"
133
+ />
134
+ </svg>
135
+ <//>`
136
+ : '';
137
+ };
138
+
139
+ export const InstanceStatusPill = (props: {
140
+ instance: Instance;
141
+ flowType: 'ON_DEMAND' | 'AUTOMATIC';
142
+ executionBehaviour: 'SAVE_ONLY' | 'SAVE_AND_EXECUTE';
143
+ }) => {
144
+ const {
145
+ instance,
146
+ flowType = 'AUTOMATIC',
147
+ executionBehaviour = 'SAVE_AND_EXECUTE',
148
+ } = props;
149
+ const {
150
+ last_run_status = null,
151
+ last_run_start_time = null,
152
+ status,
153
+ } = instance;
154
+ const getTagData = () => {
155
+ if (!last_run_status && !last_run_start_time && status === 'ACTIVE') {
156
+ return {
157
+ type: 'grey',
158
+ label:
159
+ flowType === 'ON_DEMAND' && executionBehaviour === 'SAVE_AND_EXECUTE'
160
+ ? 'Queued'
161
+ : // : "Hasn't Run",
162
+ // : "No runs as yet",
163
+ '',
164
+ };
165
+ }
166
+ switch (last_run_status) {
167
+ case 'failed':
168
+ return {
169
+ type: 'fail',
170
+ // label: 'Failed',
171
+ label: 'Blocked',
172
+ };
173
+ case 'running...':
174
+ return {
175
+ type: 'info',
176
+ label: 'Running...',
177
+ };
178
+ case 'running':
179
+ return {
180
+ type: 'info',
181
+ label: 'Running...',
182
+ };
183
+ case 'ok':
184
+ return {
185
+ type: 'success',
186
+ label: 'Completed',
187
+ };
188
+ default:
189
+ return null;
190
+ }
191
+ };
192
+
193
+ const tagData = getTagData();
194
+ return tagData && (tagData.label || '') !== ''
195
+ ? html`<${Tag}
196
+ type="${tagData.type}"
197
+ label="${tagData.label}"
198
+ className="flow-instance"
199
+ />`
200
+ : '';
201
+ };
202
+
203
+ const lastRunTooltip: any = {
204
+ failed: 'Last run was aborted',
205
+ 'running...': 'The integration is running',
206
+ running: 'The integration is running',
207
+ ok: 'Last run was completed',
208
+ };
209
+
210
+ export const InstanceStatusCompactPill = (props: {
211
+ instance: Instance;
212
+ flowType: 'ON_DEMAND' | 'AUTOMATIC';
213
+ executionBehaviour: 'SAVE_ONLY' | 'SAVE_AND_EXECUTE';
214
+ }) => {
215
+ const {
216
+ instance,
217
+ flowType = 'AUTOMATIC',
218
+ executionBehaviour = 'SAVE_AND_EXECUTE',
219
+ } = props;
220
+ const {
221
+ last_run_status = null,
222
+ last_run_start_time = null,
223
+ status,
224
+ } = instance;
225
+ const getTagData = () => {
226
+ if (!last_run_status && !last_run_start_time && status === 'ACTIVE') {
227
+ return {
228
+ type: 'grey',
229
+ label:
230
+ flowType === 'ON_DEMAND' && executionBehaviour === 'SAVE_AND_EXECUTE'
231
+ ? 'Queued'
232
+ : // : "Hasn't Run",
233
+ // : "No runs as yet",
234
+ '',
235
+ };
236
+ }
237
+ switch (last_run_status) {
238
+ case 'failed':
239
+ return {
240
+ type: 'fail',
241
+ // label: 'Failed',
242
+ label: 'Aborted',
243
+ icon: html`
244
+ <svg
245
+ width="12"
246
+ height="12"
247
+ viewBox="0 0 24 24"
248
+ fill="none"
249
+ xmlns="http://www.w3.org/2000/svg"
250
+ >
251
+ <circle
252
+ data-hint="${lastRunTooltip[last_run_status]}"
253
+ cx="12"
254
+ cy="12"
255
+ r="12"
256
+ fill="#FDEFEC"
257
+ />
258
+ <path
259
+ d="M16 8L8 16"
260
+ stroke="#F05C42"
261
+ stroke-width="2"
262
+ stroke-linecap="round"
263
+ stroke-linejoin="round"
264
+ />
265
+ <path
266
+ d="M8 8L16 16"
267
+ stroke="#F05C42"
268
+ stroke-width="2"
269
+ stroke-linecap="round"
270
+ stroke-linejoin="round"
271
+ />
272
+ </svg>
273
+ `,
274
+ tooltip: `Last run was aborted`,
275
+ };
276
+ case 'running...':
277
+ return {
278
+ type: 'info',
279
+ label: 'Running...',
280
+ icon: html`
281
+ <svg
282
+ width="12"
283
+ height="12"
284
+ viewBox="0 0 24 24"
285
+ fill="none"
286
+ xmlns="http://www.w3.org/2000/svg"
287
+ >
288
+ <circle
289
+ data-hint="${lastRunTooltip[last_run_status]}"
290
+ cx="12"
291
+ cy="12"
292
+ r="12"
293
+ fill="#CAE1FC"
294
+ />
295
+ <circle cx="6" cy="12" r="2" fill="#509CF6" />
296
+ <circle opacity="0.5" cx="12" cy="12" r="2" fill="#509CF6" />
297
+ <circle opacity="0.3" cx="18" cy="12" r="2" fill="#509CF6" />
298
+ </svg>
299
+ `,
300
+ tooltip: `The integration is running`,
301
+ };
302
+ case 'running':
303
+ return {
304
+ type: 'info',
305
+ label: 'Running...',
306
+ icon: html`
307
+ <svg
308
+ width="12"
309
+ height="12"
310
+ viewBox="0 0 24 24"
311
+ fill="none"
312
+ xmlns="http://www.w3.org/2000/svg"
313
+ >
314
+ <circle
315
+ data-hint="${lastRunTooltip[last_run_status]}"
316
+ cx="12"
317
+ cy="12"
318
+ r="12"
319
+ fill="#CAE1FC"
320
+ />
321
+ <circle cx="6" cy="12" r="2" fill="#509CF6" />
322
+ <circle opacity="0.5" cx="12" cy="12" r="2" fill="#509CF6" />
323
+ <circle opacity="0.3" cx="18" cy="12" r="2" fill="#509CF6" />
324
+ </svg>
325
+ `,
326
+ tooltip: `The integration is running`,
327
+ };
328
+ case 'ok':
329
+ return {
330
+ type: 'success',
331
+ label: 'Completed',
332
+ icon: html`
333
+ <svg
334
+ width="12"
335
+ height="12"
336
+ viewBox="0 0 24 24"
337
+ fill="none"
338
+ xmlns="http://www.w3.org/2000/svg"
339
+ >
340
+ <circle
341
+ data-hint="${lastRunTooltip[last_run_status]}"
342
+ cx="12"
343
+ cy="12"
344
+ r="12"
345
+ fill="#C4E9D2"
346
+ />
347
+ <path
348
+ d="M17 8L10.441 15.5L7 11.5653"
349
+ stroke="#3BB568"
350
+ stroke-width="2"
351
+ stroke-linecap="round"
352
+ />
353
+ </svg>
354
+ `,
355
+ tooltip: `Last run was completed`,
356
+ };
357
+ default:
358
+ return null;
359
+ }
360
+ };
361
+
362
+ const tagData = getTagData();
363
+ return tagData && (tagData.label || '') !== ''
364
+ ? // ? html`<${Hint} deltaY=${12} position="fixed" style="display: flex; flex-direction: row; align-items: center; justify-content: flex-start;" disabled=${!tagData.tooltip}>${tagData.icon}<//>`
365
+ html`${tagData.icon}`
366
+ : '';
367
+ };
368
+
369
+ export const FlowInstanceRow = (props: FlowInstanceRowProps) => {
370
+ const {
371
+ instance,
372
+ onEditInstance,
373
+ onDelete,
374
+ isCompact = false,
375
+ hideLastRunTime = false,
376
+ hideInfoIcon = false,
377
+ hideContextMenu = false,
378
+ hideIntegrationToggle = false,
379
+ } = props;
380
+ const context = useContext(AppContext);
381
+ const [instanceStatus, setInstanceStatus] = useState<Instance['status']>(
382
+ instance.status,
383
+ );
384
+ const [isDeleting, setIsDeleting] = useState(false);
385
+
386
+ useEffect(() => {
387
+ setInstanceStatus(instance.status);
388
+ }, [instance.status]);
389
+
390
+ const toggleIntegration = (instanceId: number, value: boolean) => {
391
+ setInstanceStatus(value ? 'ACTIVE' : 'INACTIVE'); // optimistic update
392
+ context?.apiHandler
393
+ .toggleIntegration(instanceId, value)
394
+ .catch((err: unknown) => {
395
+ console.error(err);
396
+ setInstanceStatus(instance.status);
397
+ });
398
+ };
399
+ const handleOptionSelect = (
400
+ option: { id: string; label: string },
401
+ selectedInstance: Instance,
402
+ ) => {
403
+ switch (option.id) {
404
+ case 'edit':
405
+ if (onEditInstance) {
406
+ onEditInstance(selectedInstance);
407
+ }
408
+ break;
409
+ case 'delete':
410
+ setIsDeleting(true);
411
+ if (onDelete) onDelete(selectedInstance);
412
+ break;
413
+ default:
414
+ break;
415
+ }
416
+ };
417
+
418
+ return html`
419
+ ${!hideLastRunTime &&
420
+ html` <${Hint} style="" position="fixed" deltaY=${14}>
421
+ <div
422
+ data-hint="${lastRunTooltip[instance.last_run_status]}"
423
+ class="${styles.flowInstanceColumn} ${styles.instanceRunTime}"
424
+ style="${isCompact
425
+ ? 'display:flex;flex-direction:row;align-items:center;justify-content:flex-start;gap:4px;'
426
+ : 'flex: 1;'}"
427
+ >
428
+ ${instance.last_run_start_time
429
+ ? convertDateToStandard(instance.last_run_start_time)
430
+ : `No runs as yet`}
431
+ ${isCompact &&
432
+ html`<${InstanceStatusCompactPill} instance=${instance} />`}
433
+ </div>
434
+ <//>`}
435
+ ${!isCompact &&
436
+ html` <div
437
+ class="${styles.flowInstanceColumn}"
438
+ style="margin-right: 8px;display:flex;flex-direction:row;align-items:center;justify-content:center;"
439
+ >
440
+ ${html`<${isCompact ? InstanceStatusCompactPill : InstanceStatusPill}
441
+ instance=${instance}
442
+ />`}
443
+ </div>`}
444
+ <div
445
+ onClick=${(e: any) => {
446
+ e.stopPropagation();
447
+ }}
448
+ class="${styles.flowInstanceColumn} ${styles.instanceStatus}"
449
+ style="${'display: flex; flex-direction: row; align-items: center; justify-content: flex-end; gap: 0px; margin-top: -16.5px;'}"
450
+ >
451
+ ${!hideInfoIcon &&
452
+ instanceStatus === 'BLOCKED' &&
453
+ html`<${InstanceBlockedInfo} instance=${instance} />`}
454
+ ${!hideIntegrationToggle &&
455
+ html`<${Toggle}
456
+ id=${instance.id}
457
+ value=${isDeleting ? false : instanceStatus === 'ACTIVE'}
458
+ disabled=${isDeleting}
459
+ onChange=${(value: boolean) => {
460
+ if (!isDeleting) {
461
+ toggleIntegration(instance.id, value);
462
+ }
463
+ }}
464
+ size=${isCompact ? 'sm' : 'lg'}
465
+ />`}
466
+ ${isDeleting
467
+ ? html`<div style="margin: 0 6px; margin-bottom: -3px;">
468
+ <${Loader} size="sm" />
469
+ </div>`
470
+ : !hideContextMenu &&
471
+ html` <${CollapsedMenu}
472
+ verticalIcon=${true}
473
+ className="instanceMenu"
474
+ options=${[
475
+ ...(onEditInstance
476
+ ? [
477
+ {
478
+ id: 'edit',
479
+ label: 'Edit',
480
+ },
481
+ ]
482
+ : []),
483
+ ...(onDelete
484
+ ? [
485
+ {
486
+ id: 'delete',
487
+ label: 'Delete',
488
+ },
489
+ ]
490
+ : []),
491
+ ]}
492
+ onOptionSelect=${(option: { id: string; label: string }) =>
493
+ handleOptionSelect(option, instance)}
494
+ />`}
495
+ </div>
496
+ <!--<div class="${styles.flowInstanceColumn}" style="display: flex; flex-direction: row; align-items: center; justify-content: flex-start;${isDeleting
497
+ ? 'margin: 0 6px;'
498
+ : ''}">
499
+ </div>-->
500
+ `;
501
+ };
502
+
503
+ const FlowInstance = (props: FlowInstanceProps) => {
504
+ const {
505
+ instances,
506
+ onEditInstance,
507
+ updateInstanceName,
508
+ onDelete,
509
+ isCompact = false,
510
+ } = props;
511
+ const context = useContext(AppContext);
512
+
513
+ const onUpdateName = (instanceId: number, name: string) => {
514
+ const oldName =
515
+ instances.find((instance) => instance.id === instanceId)?.name || '';
516
+ updateInstanceName(instanceId, name);
517
+ context?.apiHandler
518
+ .renameIntegration(`${instanceId}`, name)
519
+ .then((integrationData) => {
520
+ if (!integrationData) {
521
+ updateInstanceName(instanceId, oldName);
522
+ throw new Error('Could not update integration name');
523
+ }
524
+ })
525
+ .catch((err) => {
526
+ console.error(err);
527
+ updateInstanceName(instanceId, oldName);
528
+ });
529
+ };
530
+ return html`
531
+ <div class="${styles.flowInstanceContainer}">
532
+ ${instances.map(
533
+ (instance) => html`
534
+ <div class="${styles.flowInstancesContainer}">
535
+ <svg
536
+ xmlns="http://www.w3.org/2000/svg"
537
+ width="13"
538
+ height="15"
539
+ viewBox="0 0 13 15"
540
+ fill="none"
541
+ >
542
+ <path
543
+ d="M12.677 11.5703C12.8723 11.375 12.8723 11.0584 12.677 10.8632L9.49501 7.68121C9.29975 7.48595 8.98316 7.48595 8.7879 7.68121C8.59264 7.87647 8.59264 8.19306 8.7879 8.38832L11.6163 11.2167L8.78791 14.0452C8.59264 14.2404 8.59264 14.557 8.78791 14.7523C8.98317 14.9475 9.29975 14.9475 9.49501 14.7523L12.677 11.5703ZM1.00571 11.2167L0.505714 11.2167L0.505697 11.7168L1.00571 11.7167L1.00571 11.2167ZM0.506052 1.30357C0.506043 1.57971 0.729893 1.80358 1.00604 1.80358C1.28218 1.80359 1.50604 1.57974 1.50605 1.3036L0.506052 1.30357ZM1.50599 3.106C1.506 2.82985 1.28215 2.60599 1.00601 2.60598C0.729866 2.60597 0.506 2.82982 0.50599 3.10596L1.50599 3.106ZM0.505929 4.90836C0.505919 5.1845 0.729769 5.40836 1.00591 5.40837C1.28205 5.40838 1.50592 5.18453 1.50593 4.90839L0.505929 4.90836ZM1.50587 6.71078C1.50588 6.43464 1.28203 6.21077 1.00588 6.21077C0.729742 6.21076 0.505877 6.43461 0.505868 6.71075L1.50587 6.71078ZM0.505806 8.51314C0.505797 8.78928 0.729647 9.01315 1.00579 9.01316C1.28193 9.01317 1.5058 8.78932 1.50581 8.51318L0.505806 8.51314ZM1.50574 10.3156C1.50575 10.0394 1.2819 9.81556 1.00576 9.81555C0.72962 9.81554 0.505754 10.0394 0.505745 10.3155L1.50574 10.3156ZM1.94886 11.7167C2.225 11.7167 2.44886 11.4929 2.44886 11.2167C2.44886 10.9406 2.225 10.7167 1.94886 10.7167L1.94886 11.7167ZM3.83514 10.7167C3.559 10.7167 3.33514 10.9406 3.33514 11.2167C3.33515 11.4929 3.559 11.7167 3.83515 11.7167L3.83514 10.7167ZM5.72143 11.7167C5.99757 11.7167 6.22143 11.4929 6.22143 11.2167C6.22143 10.9406 5.99757 10.7167 5.72143 10.7167L5.72143 11.7167ZM7.60772 10.7167C7.33158 10.7167 7.10772 10.9406 7.10772 11.2167C7.10772 11.4929 7.33158 11.7167 7.60772 11.7167L7.60772 10.7167ZM9.49401 11.7167C9.77015 11.7167 9.99401 11.4929 9.99401 11.2167C9.99401 10.9406 9.77015 10.7167 9.49401 10.7167L9.49401 11.7167ZM11.3803 10.7167C11.1042 10.7167 10.8803 10.9406 10.8803 11.2167C10.8803 11.4929 11.1042 11.7167 11.3803 11.7167L11.3803 10.7167ZM0.506083 0.402371L0.506052 1.30357L1.50605 1.3036L1.50608 0.402405L0.506083 0.402371ZM0.50599 3.10596L0.505929 4.90836L1.50593 4.90839L1.50599 3.106L0.50599 3.10596ZM0.505868 6.71075L0.505806 8.51314L1.50581 8.51318L1.50587 6.71078L0.505868 6.71075ZM0.505745 10.3155L0.505714 11.2167L1.50571 11.2168L1.50574 10.3156L0.505745 10.3155ZM1.00571 11.7167L1.94886 11.7167L1.94886 10.7167L1.00571 10.7167L1.00571 11.7167ZM3.83515 11.7167L5.72143 11.7167L5.72143 10.7167L3.83514 10.7167L3.83515 11.7167ZM7.60772 11.7167L9.49401 11.7167L9.49401 10.7167L7.60772 10.7167L7.60772 11.7167ZM11.3803 11.7167L12.3234 11.7167L12.3234 10.7167L11.3803 10.7167L11.3803 11.7167Z"
544
+ fill="#D6D6D6"
545
+ />
546
+ </svg>
547
+ <div
548
+ class="${styles.flowInstanceRow} ${styles.flowInstanceMultipleRow}"
549
+ key=${`instance-id-flow-row-${instance.id}`}
550
+ >
551
+ <${EditableText}
552
+ value=${instance.name}
553
+ handleChange=${(name: string) =>
554
+ onUpdateName(instance.id, name)}
555
+ wrapperClassName=${styles.editableTextWrapper}
556
+ customStyles=${{
557
+ wrapperClassName: styles.editableTextWrapper,
558
+ inputClassName: styles.inlineEditInput,
559
+ }}
560
+ />
561
+ <div class=${styles.flowInstanceRowMeta}>
562
+ <${FlowInstanceRow}
563
+ instance=${instance}
564
+ onEditInstance=${onEditInstance}
565
+ onDelete=${onDelete}
566
+ isCompact=${isCompact}
567
+ />
568
+ </div>
569
+ </div>
570
+ </div>
571
+ `,
572
+ )}
573
+ </div>
574
+ `;
575
+ };
576
+
577
+ export default FlowInstance;
@@ -0,0 +1,83 @@
1
+ import { Flow, Instance, UserConfig } from '@/interfaces';
2
+ import { actionFunctions } from '@/store';
3
+ import { MarketplaceRenderModes, ViewStyles } from '@/types';
4
+ import { StoreType } from '@/types/store';
5
+ import { html } from 'htm/preact';
6
+ import { useEffect } from 'preact/hooks';
7
+ import { connect } from 'unistore/preact';
8
+ import FlowCard from './flowCard';
9
+ import FlowCardCompact from './flowCardCompact';
10
+
11
+ import styles from './styles.module.scss';
12
+
13
+ interface WraperrProps extends StoreType {
14
+ marketplaceId: string;
15
+ userConfig?: UserConfig;
16
+ accountVerified: boolean;
17
+ renderMode: MarketplaceRenderModes;
18
+ onFlowSelect: (flowId: Flow, instance?: Instance) => void;
19
+ updateInstanceName: (
20
+ flowId: number,
21
+ instanceId: number,
22
+ name: string,
23
+ ) => void;
24
+ appFlows: Flow[];
25
+ onDeleteInstance?: (instance: any) => void;
26
+ appData?: any;
27
+ }
28
+
29
+ const AppFlowListing = (props: WraperrProps) => {
30
+ const {
31
+ onFlowSelect,
32
+ updateInstanceName,
33
+ appFlows,
34
+ accountVerified,
35
+ renderMode,
36
+ onDeleteInstance,
37
+ genericData,
38
+ appData,
39
+ } = props;
40
+
41
+ useEffect(() => {
42
+ props.resetTemplateFields();
43
+ }, []);
44
+
45
+ return html`
46
+ <div
47
+ id="${`embed--flowCardContainer__${renderMode}`}"
48
+ class="${styles.flowCardContainer} ${styles.integryScrollbar} ${renderMode ===
49
+ MarketplaceRenderModes.INLINE
50
+ ? styles.inlineFlowContainer
51
+ : ''}"
52
+ >
53
+ ${appFlows.map(
54
+ (template: any) => html`
55
+ <${genericData.viewStyle === ViewStyles.COMPACT ? FlowCardCompact : FlowCard}
56
+ flow=${template}
57
+ flowIcon=${appData ? appData.icon_url : ""}
58
+ accountVerified=${accountVerified}
59
+ onFlowSelect=${onFlowSelect}
60
+ updateInstanceName=${updateInstanceName}
61
+ onDeleteInstance=${(instance: any) => {
62
+ if (onDeleteInstance) {
63
+ onDeleteInstance({...instance, template_detail: template});
64
+ }
65
+ }}
66
+ customStyle=${`max-width: 364px; width: 100%;`}
67
+ />
68
+ `,
69
+ )}
70
+ </div>
71
+ `;
72
+ };
73
+
74
+ export default connect<WraperrProps, unknown, StoreType, unknown>(
75
+ [
76
+ 'userConfig',
77
+ 'genericData',
78
+ 'showMarketplaceModal',
79
+ 'showMarketplaceAppPageId',
80
+ 'IUAccountsData',
81
+ ],
82
+ actionFunctions,
83
+ )(AppFlowListing);