@eohjsc/react-native-smart-city 0.7.3 → 0.7.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 (274) hide show
  1. package/assets/images/Automation-fill.svg +85 -0
  2. package/assets/images/Map/LocationPin.svg +10 -0
  3. package/assets/images/Scenario-filled.svg +22 -0
  4. package/assets/images/schedule-fill.svg +48 -0
  5. package/package.json +20 -17
  6. package/src/commons/Action/ItemQuickAction.js +1 -1
  7. package/src/commons/Action/__test__/ItemQuickAction.test.js +6 -6
  8. package/src/commons/ActionGroup/NumberUpDownActionTemplate.js +3 -3
  9. package/src/commons/ActionGroup/OnOffSmartLock/AutoLock/ButtonWrapper.js +3 -3
  10. package/src/commons/ActionGroup/OnOffSmartLock/PasscodeList/__test__/index.test.js +5 -5
  11. package/src/commons/ActionGroup/OnOffSmartLock/PasscodeList/index.js +3 -3
  12. package/src/commons/ActionGroup/OnOffSmartLock/SetupGeneratePasscode/ButtonWrapper.js +2 -2
  13. package/src/commons/ActionGroup/OnOffTemplate/OnOffSimpleTemplate.js +2 -2
  14. package/src/commons/ActionGroup/OptionsDropdownActionTemplate.js +2 -2
  15. package/src/commons/ActionGroup/SliderRangeTemplate.js +7 -7
  16. package/src/commons/ActionGroup/SmartTiviActionTemplate/SmartTiviActionTemplate.js +2 -2
  17. package/src/commons/ActionGroup/SmartTiviActionTemplate/component/CircleButton.js +5 -5
  18. package/src/commons/ActionGroup/SmartTiviActionTemplate/component/ControlPlay.js +5 -5
  19. package/src/commons/ActionGroup/TerminalBoxTemplate.js +2 -2
  20. package/src/commons/ActionGroup/TextBoxTemplate.js +2 -2
  21. package/src/commons/ActionGroup/ThreeButtonTemplate/__test__/ThreeButtonCircle.test.js +2 -2
  22. package/src/commons/ActionGroup/ThreeButtonTemplate/__test__/ThreeButtonDefault.test.js +2 -2
  23. package/src/commons/ActionGroup/TimerActionTemplate.js +6 -3
  24. package/src/commons/ActionGroup/TwoButtonTemplate/index.js +2 -2
  25. package/src/commons/ActionGroup/__test__/ColorPickerTemplate.test.js +9 -10
  26. package/src/commons/ActionGroup/__test__/OnOffSmartLock.test.js +5 -5
  27. package/src/commons/ActionGroup/__test__/OnOffTemplate.test.js +5 -5
  28. package/src/commons/ActionGroup/__test__/OptionsDropdownTemplate.test.js +8 -8
  29. package/src/commons/ActionGroup/__test__/StatesGridActionTemplate.test.js +3 -3
  30. package/src/commons/ActionGroup/__test__/TimerActionTemplate.test.js +6 -6
  31. package/src/commons/ActionGroup/__test__/TwoButtonTemplate.test.js +1 -1
  32. package/src/commons/ActionGroup/__test__/index.test.js +6 -6
  33. package/src/commons/ActionGroup/index.js +2 -2
  34. package/src/commons/ActionTemplate/__test__/index.test.js +4 -4
  35. package/src/commons/Automate/ItemAutomate.js +9 -41
  36. package/src/commons/Automate/ItemConditionScriptDetail.js +109 -0
  37. package/src/commons/Automate/ItemConditionScriptDetailStyles.js +46 -0
  38. package/src/commons/Automate/__test__/ItemAutomate.test.js +0 -21
  39. package/src/commons/BackDefault/index.js +2 -2
  40. package/src/commons/BottomButtonView/index.js +1 -0
  41. package/src/commons/ButtonPopup/index.js +3 -2
  42. package/src/commons/ChartAggregationOption/__test__/FourButtonFilterHistory.test.js +2 -2
  43. package/src/commons/Dashboard/MyPinnedSharedUnit/__test__/MyPinnedSharedUnit.test.js +8 -9
  44. package/src/commons/Dashboard/MyUnit/__test__/MyUnit.test.js +7 -7
  45. package/src/commons/DateTimeRangeChange/DateTimeButton.js +3 -3
  46. package/src/commons/DateTimeRangeChange/index.js +1 -1
  47. package/src/commons/Device/ConnectedViewHeader.js +2 -2
  48. package/src/commons/Device/Emergency/EmergencyDetail.js +3 -3
  49. package/src/commons/Device/Emergency/__test__/EmergencyButton.test.js +1 -1
  50. package/src/commons/Device/FlatListItems.js +20 -19
  51. package/src/commons/Device/Hanet/ItemHanetDevice.js +3 -3
  52. package/src/commons/Device/Hanet/ItemHanetDevice.test.js +3 -3
  53. package/src/commons/Device/HorizontalBarChart.js +54 -34
  54. package/src/commons/Device/ItemAddNew/index.js +2 -2
  55. package/src/commons/Device/ItemDevice.js +5 -21
  56. package/src/commons/Device/SonosSpeaker/index.js +3 -3
  57. package/src/commons/Device/WaterPurifierStatus/AlertStatusMachine.js +2 -2
  58. package/src/commons/Device/WaterQualitySensor/QualityIndicatorsItem.js +6 -2
  59. package/src/commons/DisplayChecking/index.js +2 -2
  60. package/src/commons/EmergencyButton/AlertSendConfirm.js +2 -2
  61. package/src/commons/FieldTemplate/ChooseUserField/index.js +2 -2
  62. package/src/commons/FieldTemplate/PasscodeField/__test__/index.test.js +3 -3
  63. package/src/commons/FieldTemplate/ScheduleField/__test__/index.test.js +6 -6
  64. package/src/commons/FlatListDnD/__test__/index.test.js +4 -4
  65. package/src/commons/FlatListDnD/index.js +12 -9
  66. package/src/commons/Grid/GridItem.js +10 -2
  67. package/src/commons/GroupCheckBox/__test__/GroupCheckBox.test.js +3 -3
  68. package/src/commons/Header/HeaderCustom.js +2 -2
  69. package/src/commons/Header/__test__/HeaderCT.test.js +3 -3
  70. package/src/commons/HeaderAni/index.js +2 -2
  71. package/src/commons/IconComponent/index.js +3 -3
  72. package/src/commons/ImagePicker/__test__/ImagePicker.test.js +5 -5
  73. package/src/commons/MediaPlayerDetail/__test__/MediaPlayerDetail.test.js +6 -4
  74. package/src/commons/MenuActionMore/MenuActionMoreStyles.js +2 -1
  75. package/src/commons/MenuActionMore/index.js +1 -1
  76. package/src/commons/NavBar/NavBarStyles.js +1 -1
  77. package/src/commons/NavBar/index.js +2 -2
  78. package/src/commons/OneTapTemplate/NumberUpDownActionTemplate.js +3 -3
  79. package/src/commons/OneTapTemplate/__test__/StatesGridActionTemplate.test.js +1 -1
  80. package/src/commons/Popover/__test__/index.test.js +3 -3
  81. package/src/commons/Processing/__test__/Connecting.test.js +4 -4
  82. package/src/commons/SearchLocation/index.js +3 -3
  83. package/src/commons/SelectActionCard/index.js +2 -2
  84. package/src/commons/SelectSubUnit/index.js +6 -2
  85. package/src/commons/SelectUnit/__test__/SelectUnit.test.js +5 -5
  86. package/src/commons/Sharing/BtnRemoveMember.js +2 -2
  87. package/src/commons/Sharing/StationDevicePermissions.js +2 -2
  88. package/src/commons/SubUnit/DeviceTemplate/ConfigAndEvaluation/ConfigAndEvaluation.js +2 -2
  89. package/src/commons/SubUnit/DeviceTemplate/ConfigValue/ConfigValue.js +2 -2
  90. package/src/commons/SubUnit/DeviceTemplate/EvaluationOverConfig/EvaluationOverConfig.js +2 -2
  91. package/src/commons/SubUnit/OneTap/ItemOneTap.js +6 -7
  92. package/src/commons/SubUnit/OneTap/__test__/SubUnitAutomate.test.js +0 -2
  93. package/src/commons/SubUnit/OneTap/index.js +9 -8
  94. package/src/commons/SubUnit/__test__/ShortDetail.test.js +8 -8
  95. package/src/commons/Unit/HeaderUnit/index.js +30 -22
  96. package/src/commons/Unit/SharedUnit.js +7 -7
  97. package/src/commons/Widgets/IFrame/__tests__/IFrame.test.js +9 -13
  98. package/src/commons/Widgets/IFrameWithConfig/IFrameWithConfig.js +34 -2
  99. package/src/commons/Widgets/IFrameWithConfig/__tests__/IFrameWithConfig.test.js +88 -8
  100. package/src/commons/WrapParallaxScrollView/index.js +9 -10
  101. package/src/configs/API.js +1 -1
  102. package/src/configs/AccessibilityLabel.js +1 -0
  103. package/src/configs/Constants.js +3 -3
  104. package/src/configs/Theme.js +1 -1
  105. package/src/hooks/Common/__test__/useAndroidTranslucentStatusBar.test.js +5 -5
  106. package/src/hooks/IoT/__test__/useHomeAssistantConnection.test.js +12 -12
  107. package/src/hooks/IoT/__test__/useRemoteControl.test.js +14 -7
  108. package/src/hooks/IoT/__test__/useWatchConfigs.test.js +3 -3
  109. package/src/hooks/IoT/useRemoteControl.js +24 -13
  110. package/src/hooks/useMqtt.js +2 -2
  111. package/src/iot/RemoteControl/Bluetooth.js +19 -22
  112. package/src/iot/RemoteControl/Internet.js +13 -5
  113. package/src/iot/RemoteControl/__test__/Internet.test.js +7 -7
  114. package/src/navigations/EmergencyContactsStack.js +4 -3
  115. package/src/navigations/SharedStack.js +2 -0
  116. package/src/navigations/UnitStack.js +56 -57
  117. package/src/screens/AQIGuide/index.js +0 -2
  118. package/src/screens/ActivityLog/index.js +2 -2
  119. package/src/screens/AddLocationMaps/__test__/index.test.js +12 -12
  120. package/src/screens/AddLocationMaps/index.js +16 -19
  121. package/src/screens/AddLocationMaps/indexStyle.js +1 -0
  122. package/src/screens/AddNewGateway/RenameNewDevices.js +2 -2
  123. package/src/screens/AddNewGateway/SelectDeviceType.js +1 -1
  124. package/src/screens/AddNewGateway/ShareWifiPassword.js +16 -15
  125. package/src/screens/AddNewGateway/__test__/AddNewGateway.test.js +7 -7
  126. package/src/screens/AddNewGateway/__test__/ConnectingWifiDevice.test.js +8 -8
  127. package/src/screens/AddNewGateway/__test__/ConnectingZigbeeDevice.test.js +7 -7
  128. package/src/screens/AddNewGateway/__test__/RenameNewDevices.test.js +8 -8
  129. package/src/screens/AddNewGateway/__test__/ScanGatewayQR.test.js +5 -5
  130. package/src/screens/AddNewGateway/__test__/SelectDeviceUnit.test.js +4 -4
  131. package/src/screens/AddNewGateway/__test__/SelectModbusGateway.test.js +6 -6
  132. package/src/screens/AddNewGateway/__test__/SelectZigbeeGateway.test.js +6 -6
  133. package/src/screens/AddNewGateway/__test__/ShareWifiPassword.test.js +0 -4
  134. package/src/screens/AddNewGateway/hooks/__Tests__/useWifiManage.test.js +2 -2
  135. package/src/screens/AllGateway/DetailConfigActionModbus/__test__/index.test.js +6 -6
  136. package/src/screens/AllGateway/DeviceInternalDetail/__test__/index.test.js +19 -17
  137. package/src/screens/AllGateway/DeviceModbusDetail/__test__/index.test.js +19 -17
  138. package/src/screens/AllGateway/DeviceZigbeeDetail/__test__/index.test.js +18 -16
  139. package/src/screens/AllGateway/GatewayDetail/__test__/index.test.js +43 -35
  140. package/src/screens/AllGateway/GatewayInfo/__test__/index.test.js +38 -22
  141. package/src/screens/AllGateway/__test__/index.test.js +6 -6
  142. package/src/screens/AllGateway/components/Detail/__test__/index.test.js +3 -5
  143. package/src/screens/AllGateway/components/GatewayItem/__test__/index.test.js +3 -3
  144. package/src/screens/AllGateway/components/TabPaneCT/__test__/index.test.js +6 -6
  145. package/src/screens/AllGateway/hooks/__test__/index.test.js +2 -2
  146. package/src/screens/AllGateway/test-utils.js +3 -4
  147. package/src/screens/Automate/AddNewAction/ChooseAction.js +17 -3
  148. package/src/screens/Automate/AddNewAction/ChooseConfig.js +7 -6
  149. package/src/screens/Automate/AddNewAction/NewActionWrapper.js +8 -8
  150. package/src/screens/Automate/AddNewAction/SelectControlDevices.js +30 -20
  151. package/src/screens/Automate/AddNewAction/SelectMonitorDevices.js +17 -10
  152. package/src/screens/Automate/AddNewAction/SetupConfigCondition.js +58 -44
  153. package/src/screens/Automate/AddNewAction/SetupScriptDelay.js +1 -1
  154. package/src/screens/Automate/AddNewAction/SetupScriptNotify.js +3 -3
  155. package/src/screens/Automate/AddNewAction/Styles/SetupSensorStyles.js +20 -4
  156. package/src/screens/Automate/AddNewAction/__test__/ChooseAction.test.js +12 -12
  157. package/src/screens/Automate/AddNewAction/__test__/SelectControlDevices.test.js +14 -8
  158. package/src/screens/Automate/AddNewAction/__test__/SelectMonitorDevices.test.js +13 -7
  159. package/src/screens/Automate/AddNewAction/__test__/SetupConfigCondition.test.js +54 -15
  160. package/src/screens/Automate/AddNewAction/__test__/SetupScriptDelay.test.js +9 -9
  161. package/src/screens/Automate/AddNewAction/__test__/SetupScriptNotify.test.js +39 -10
  162. package/src/screens/Automate/AddNewAutoSmart/AddTypeSmart.js +10 -10
  163. package/src/screens/Automate/AddNewAutoSmart/__test__/AddNewAutoSmart.test.js +13 -8
  164. package/src/screens/Automate/Components/InputName.js +10 -7
  165. package/src/screens/Automate/EditActionsList/__tests__/UpdateActionScript.test.js +8 -8
  166. package/src/screens/Automate/EditActionsList/__tests__/UpdateDelayScript.test.js +6 -6
  167. package/src/screens/Automate/EditActionsList/__tests__/UpdateNotifyScript.test.js +7 -7
  168. package/src/screens/Automate/EditActionsList/index.js +19 -17
  169. package/src/screens/Automate/MultiUnits.js +19 -22
  170. package/src/screens/Automate/OneTap/__test__/AddNewOneTap.test.js +18 -8
  171. package/src/screens/Automate/Scenario/__test__/AddNewOneTap.test.js +15 -7
  172. package/src/screens/Automate/ScriptDetail/Components/AddActionScript.js +14 -6
  173. package/src/screens/Automate/ScriptDetail/Components/RenameScript.js +4 -7
  174. package/src/screens/Automate/ScriptDetail/__test__/index.test.js +42 -17
  175. package/src/screens/Automate/ScriptDetail/__test__/useStarredScript.test.js +6 -6
  176. package/src/screens/Automate/ScriptDetail/index.js +51 -40
  177. package/src/screens/Automate/SetSchedule/__test__/SelectWeekday.test.js +4 -4
  178. package/src/screens/Automate/SetSchedule/__test__/index.test.js +29 -18
  179. package/src/screens/Automate/SetSchedule/components/RowItem.js +5 -5
  180. package/src/screens/Automate/SetSchedule/index.js +8 -7
  181. package/src/screens/Automate/Styles/indexStyles.js +1 -1
  182. package/src/screens/Automate/__test__/MultiUnits.test.js +1 -4
  183. package/src/screens/Automate/__test__/index.test.js +0 -1
  184. package/src/screens/Automate/index.js +36 -34
  185. package/src/screens/ChangePosition/__test__/index.test.js +6 -6
  186. package/src/screens/ChangePosition/index.js +2 -1
  187. package/src/screens/Device/EditDevice/__test__/EditDevice.test.js +13 -13
  188. package/src/screens/Device/EditDevice/index.js +4 -4
  189. package/src/screens/Device/__test__/BluetoothDevice.test.js +300 -0
  190. package/src/screens/Device/__test__/detail.test.js +14 -14
  191. package/src/screens/Device/__test__/mqttDetail.test.js +9 -9
  192. package/src/screens/Device/components/BluetoothDevice.js +135 -0
  193. package/src/screens/Device/components/SensorDisplayItem.js +9 -8
  194. package/src/screens/Device/detail.js +70 -62
  195. package/src/screens/Device/hooks/useEvaluateValue.js +1 -1
  196. package/src/screens/Drawer/Drawer.test.js +2 -2
  197. package/src/screens/Drawer/index.js +3 -3
  198. package/src/screens/EmergencyContacts/EmergencyContactsList.js +8 -4
  199. package/src/screens/EmergencyContacts/EmergencyContactsSelectContacts.js +3 -3
  200. package/src/screens/EmergencyContacts/__test__/EmergencyContactsSelectContacts.test.js +7 -7
  201. package/src/screens/EmergencySetting/components/DropDownItem.js +2 -2
  202. package/src/screens/EnterPassword/__test__/EnterPassword.test.js +8 -8
  203. package/src/screens/GuestInfo/components/RowGuestInfo.js +2 -2
  204. package/src/screens/GuestInfo/components/__test__/AccessScheduleSheet.test.js +3 -3
  205. package/src/screens/GuestInfo/index.js +2 -2
  206. package/src/screens/HanetCamera/ManageAccess.js +3 -3
  207. package/src/screens/HanetCamera/MemberInfo.js +2 -2
  208. package/src/screens/HanetCamera/__test__/Detail.test.js +9 -9
  209. package/src/screens/HanetCamera/__test__/MemberInfo.test.js +10 -10
  210. package/src/screens/HanetCamera/components/RequestFaceIDPopup.js +2 -2
  211. package/src/screens/ManageAccess/index.js +3 -3
  212. package/src/screens/MoveToAnotherSubUnit/__test__/index.test.js +9 -9
  213. package/src/screens/Notification/__test__/Notification.test.js +9 -9
  214. package/src/screens/Notification/components/NotificationItem.js +3 -4
  215. package/src/screens/Notification/index.js +3 -3
  216. package/src/screens/Notification/styles/NotificationItemStyles.js +0 -1
  217. package/src/screens/PlayBackCamera/__test__/index.test.js +1 -1
  218. package/src/screens/ScanChipQR/components/QRScan/__test__/QRScan.test.js +1 -1
  219. package/src/screens/ScanChipQR/components/QRScan/index.js +3 -3
  220. package/src/screens/SelectUnit/__test__/index.test.js +8 -8
  221. package/src/screens/SelectUnit/index.js +4 -4
  222. package/src/screens/SharedUnit/TabHeader.js +2 -2
  223. package/src/screens/Sharing/Components/EndDevice.js +3 -3
  224. package/src/screens/Sharing/UnitMemberList.js +2 -2
  225. package/src/screens/Sharing/__test__/UpdateShareDevice.test.js +7 -7
  226. package/src/screens/SideMenuDetail/__test__/index.test.js +8 -8
  227. package/src/screens/SmartAccount/Connecting/index.js +5 -5
  228. package/src/screens/SmartAccount/ListDevice/__test__/ListDevice.test.js +8 -8
  229. package/src/screens/SmartAccount/SuccessfullyConnected/__test__/SuccessfullyConnected.test.js +7 -7
  230. package/src/screens/SmartAccount/SuccessfullyConnected/index.js +2 -2
  231. package/src/screens/SmartAccount/__test__/Connecting.test.js +6 -6
  232. package/src/screens/SmartAccount/__test__/SmartAccount.test.js +10 -10
  233. package/src/screens/SmartIr/__test__/GroupButtonByType.test.js +3 -2
  234. package/src/screens/SmartIr/components/GroupButtonByType/GroupButtonByType.js +2 -2
  235. package/src/screens/SmartIr/components/SelectBrand.js +2 -2
  236. package/src/screens/SubUnit/AddSubUnit.js +28 -26
  237. package/src/screens/SubUnit/AddSubUnitStyles.js +10 -4
  238. package/src/screens/SubUnit/EditSubUnit.js +12 -11
  239. package/src/screens/SubUnit/ManageSubUnit.js +3 -3
  240. package/src/screens/SubUnit/__test__/AddSubUnit.test.js +13 -13
  241. package/src/screens/SubUnit/__test__/EditSubUnit.test.js +3 -3
  242. package/src/screens/Template/EditTemplate.js +6 -4
  243. package/src/screens/Template/__test__/EditTemplate.test.js +7 -7
  244. package/src/screens/Template/__test__/detail.test.js +4 -4
  245. package/src/screens/Template/__test__/index.test.js +1 -1
  246. package/src/screens/UVIndexGuide/index.js +2 -4
  247. package/src/screens/Unit/Detail.js +1 -5
  248. package/src/screens/Unit/MoreMenu.js +6 -5
  249. package/src/screens/Unit/SelectAddToFavorites.js +2 -2
  250. package/src/screens/Unit/SelectAddress.js +16 -12
  251. package/src/screens/Unit/Station/__test__/index.test.js +1 -1
  252. package/src/screens/Unit/__test__/MoreMenu.test.js +5 -1
  253. package/src/screens/Unit/__test__/SelectAddToFavorites.test.js +9 -9
  254. package/src/screens/Unit/__test__/SelectAddress.test.js +11 -17
  255. package/src/screens/Unit/__test__/Summaries.test.js +7 -7
  256. package/src/screens/Unit/components/AutomateScript/index.js +5 -5
  257. package/src/screens/Unit/components/ButtonWrapper/index.js +3 -3
  258. package/src/screens/Unit/components/Header/index.js +2 -2
  259. package/src/screens/Unit/components/SharedUnit/index.js +5 -5
  260. package/src/screens/Unit/components/__test__/AutomateScript.test.js +3 -3
  261. package/src/screens/Unit/components/__test__/SharedUnit.test.js +8 -8
  262. package/src/screens/Unit/hook/__test__/useUnitConnectRemoteDevices.test.js +2 -2
  263. package/src/screens/UnitSummary/components/AirQuality/index.js +6 -11
  264. package/src/screens/UnitSummary/components/WaterQuality/Item/index.js +5 -5
  265. package/src/screens/UnitSummary/index.js +6 -2
  266. package/src/utils/Apis/axios.js +5 -5
  267. package/src/utils/Functions/ShortEmail.js +1 -0
  268. package/src/utils/I18n/translations/en.js +6 -3
  269. package/src/utils/I18n/translations/vi.js +8 -4
  270. package/src/utils/__test__/Utils.test.js +16 -16
  271. package/src/utils/bluetooth.js +3 -0
  272. package/assets/images/OneTap.svg +0 -14
  273. package/assets/images/Schedule.svg +0 -39
  274. package/assets/images/ValueChange.svg +0 -49
@@ -1,6 +1,6 @@
1
1
  import React, { useState, useCallback } from 'react';
2
2
  import { View, StyleSheet, TouchableOpacity } from 'react-native';
3
- import AntDesign from 'react-native-vector-icons/AntDesign';
3
+ import { IconOutline } from '@ant-design/icons-react-native';
4
4
  import { useTranslations } from '../../hooks/Common/useTranslations';
5
5
  import { Colors } from '../../configs';
6
6
  import Text from '../../commons/Text';
@@ -86,7 +86,7 @@ const StationDevicePermissions = ({ dataStation, onselectSensor }) => {
86
86
  <View style={styles.infoContainer}>
87
87
  <Text style={styles.text}>{sensor.name}</Text>
88
88
  <View style={styles.rightImage}>
89
- <AntDesign
89
+ <IconOutline
90
90
  name={expandedIndex === index ? 'up' : 'down'}
91
91
  size={20}
92
92
  color={Colors.Gray6}
@@ -5,7 +5,7 @@ import Text from '../../../Text';
5
5
  import LastUpdatedText from '../../../Device/LastUpdatedText';
6
6
  import { EvaluationConfigWrapper } from '../EvaluationOverConfig/EvaluationOverConfig';
7
7
  import IconComponent from '../../../IconComponent';
8
- import AntDesign from 'react-native-vector-icons/AntDesign';
8
+ import { IconOutline } from '@ant-design/icons-react-native';
9
9
 
10
10
  const ConfigAndEvaluationDisplay = memo(
11
11
  ({ device, valueEvaluation, stationItem, configValue }) => {
@@ -44,7 +44,7 @@ const ConfigAndEvaluationDisplay = memo(
44
44
  lastUpdated={configValue?.last_updated}
45
45
  format={'DDMMYYYY'}
46
46
  />
47
- <AntDesign style={styles.marginTop10} name="right" size={12} />
47
+ <IconOutline style={styles.marginTop10} name="right" size={12} />
48
48
  </View>
49
49
  )}
50
50
  </>
@@ -5,7 +5,7 @@ import Text from '../../../Text';
5
5
  import { useConfigGlobalState } from '../../../../iot/states';
6
6
  import LastUpdatedText from '../../../Device/LastUpdatedText';
7
7
  import IconComponent from '../../../IconComponent';
8
- import AntDesign from 'react-native-vector-icons/AntDesign';
8
+ import { IconOutline } from '@ant-design/icons-react-native';
9
9
 
10
10
  const ConfigValue = ({ device, stationItem }) => {
11
11
  const [configValues] = useConfigGlobalState('configValues');
@@ -40,7 +40,7 @@ const ConfigValue = ({ device, stationItem }) => {
40
40
  lastUpdated={configValue?.last_updated}
41
41
  format={'DDMMYYYY'}
42
42
  />
43
- <AntDesign style={styles.marginTop10} name="right" size={12} />
43
+ <IconOutline style={styles.marginTop10} name="right" size={12} />
44
44
  </View>
45
45
  )}
46
46
  </View>
@@ -9,7 +9,7 @@ import {
9
9
  } from '../../../../screens/Device/hooks/useEvaluateValue';
10
10
  import LastUpdatedText from '../../../Device/LastUpdatedText';
11
11
  import IconComponent from '../../../IconComponent';
12
- import AntDesign from 'react-native-vector-icons/AntDesign';
12
+ import { IconOutline } from '@ant-design/icons-react-native';
13
13
 
14
14
  export const EvaluationConfigWrapper = memo(
15
15
  ({ device, stationItem, Child }) => {
@@ -69,7 +69,7 @@ const EvaluationOverConfigDisplay = memo(
69
69
  lastUpdated={configValue?.last_updated}
70
70
  format={'DDMMYYYY'}
71
71
  />
72
- <AntDesign style={styles.marginTop10} name="right" size={12} />
72
+ <IconOutline style={styles.marginTop10} name="right" size={12} />
73
73
  </View>
74
74
  )}
75
75
  </View>
@@ -1,12 +1,12 @@
1
1
  import React, { memo, useCallback } from 'react';
2
2
  import { TouchableOpacity, TouchableWithoutFeedback, View } from 'react-native';
3
- import AntDesign from 'react-native-vector-icons/AntDesign';
3
+ import { IconOutline } from '@ant-design/icons-react-native';
4
4
  import moment from 'moment';
5
5
  import Text from '../../Text';
6
6
  import { API, Colors } from '../../../configs';
7
- import OneTap from '../../../../assets/images/OneTap.svg';
8
- import ValueChange from '../../../../assets/images/ValueChange.svg';
9
- import Schedule from '../../../../assets/images/Schedule.svg';
7
+ import OneTap from '../../../../assets/images/Scenario-filled.svg';
8
+ import ValueChange from '../../../../assets/images/Automation-fill.svg';
9
+ import Schedule from '../../../../assets/images/schedule-fill.svg';
10
10
  import Event from '../../../../assets/images/Event.svg';
11
11
  import CheckCircle from '../../../../assets/images/CheckCircle.svg';
12
12
  import FImage from '../../FImage';
@@ -27,10 +27,9 @@ const ItemOneTap = memo(({ automate = {}, wrapSyles, onPressItem }) => {
27
27
 
28
28
  const goToDetail = useCallback(() => {
29
29
  navigate(Routes.ScriptDetail, {
30
- id,
31
30
  preAutomate: automate,
32
31
  });
33
- }, [automate, navigate, id]);
32
+ }, [automate, navigate]);
34
33
 
35
34
  const handleScriptAction = useCallback(async () => {
36
35
  const { success } = await axiosPost(API.AUTOMATE.ACTION_ONE_TAP(id));
@@ -107,7 +106,7 @@ const ItemOneTap = memo(({ automate = {}, wrapSyles, onPressItem }) => {
107
106
  >
108
107
  {activateAt && t('activated_time', { time: activateAt })}
109
108
  </Text>
110
- <AntDesign name="right" size={12} />
109
+ <IconOutline name="right" size={12} />
111
110
  </View>
112
111
  </TouchableOpacity>
113
112
  </View>
@@ -107,7 +107,6 @@ describe('test Item', () => {
107
107
  await goDetail[0].props.onPress();
108
108
  });
109
109
  expect(global.mockedNavigate).toHaveBeenCalledWith(Routes.ScriptDetail, {
110
- id: 1,
111
110
  preAutomate: data.listAutomate[0].data[0],
112
111
  });
113
112
 
@@ -194,7 +193,6 @@ describe('test Item', () => {
194
193
  await goDetail[0].props.onPress();
195
194
  });
196
195
  expect(global.mockedNavigate).toHaveBeenCalledWith(Routes.ScriptDetail, {
197
- id: 1,
198
196
  preAutomate: data.listAutomate[0].data[0],
199
197
  });
200
198
  });
@@ -7,22 +7,22 @@ import React, {
7
7
  } from 'react';
8
8
  import { TouchableOpacity, View } from 'react-native';
9
9
 
10
- import { Section } from '../..';
11
- import ItemAddNew from '../../Device/ItemAddNew';
12
- import ItemOneTap from './ItemOneTap';
13
- import { useTranslations } from '../../../hooks/Common/useTranslations';
14
10
  import { useNavigation, useRoute } from '@react-navigation/native';
15
- import Routes from '../../../utils/Route/index.js';
11
+ import { Section } from '../..';
16
12
  import {
17
- AUTOMATE_TYPE,
18
13
  AccessibilityLabel,
19
14
  AUTOMATE_TABS,
15
+ AUTOMATE_TYPE,
20
16
  } from '../../../configs/Constants';
17
+ import { useTranslations } from '../../../hooks/Common/useTranslations';
18
+ import Routes from '../../../utils/Route/index.js';
19
+ import ItemAddNew from '../../Device/ItemAddNew';
21
20
  import Text from '../../Text/index.js';
21
+ import ItemOneTap from './ItemOneTap';
22
22
 
23
- import styles from './OneTapStyles.js';
24
- import { ToastBottomHelper } from '../../../utils/Utils';
25
23
  import { useBackendPermission } from '../../../utils/Permission/backend';
24
+ import { ToastBottomHelper } from '../../../utils/Utils';
25
+ import styles from './OneTapStyles.js';
26
26
 
27
27
  const SubUnitAutomate = ({ isOwner, listAutomate, unit, wrapItemStyle }) => {
28
28
  const t = useTranslations();
@@ -57,6 +57,7 @@ const SubUnitAutomate = ({ isOwner, listAutomate, unit, wrapItemStyle }) => {
57
57
  type: AUTOMATE_TYPE.ONE_TAP,
58
58
  unit: unit?.id,
59
59
  },
60
+ unitId: unit?.id,
60
61
  closeScreen: currentScreen,
61
62
  });
62
63
  break;
@@ -1,19 +1,19 @@
1
1
  import React from 'react';
2
2
  import { Image, View } from 'react-native';
3
- import { act, create } from 'react-test-renderer';
4
3
  import mock from 'react-native-permissions/mock';
4
+ import { act, create } from 'react-test-renderer';
5
5
  import { AccessibilityLabel } from '../../../configs/Constants';
6
6
  import { SCProvider } from '../../../context';
7
7
  import { mockSCStore } from '../../../context/mockStore';
8
- import ShortDetailSubUnit from '../ShortDetail';
9
- import ItemAddNew from '../../Device/ItemAddNew';
10
- import Routes from '../../../utils/Route';
8
+ import { watchMultiConfigs } from '../../../iot/Monitor';
11
9
  import { keyPermission } from '../../../utils/Permission/common';
12
- import ItemDevice from '../../Device/ItemDevice';
13
- import { DeviceTemplate } from '../DeviceTemplate/DeviceTemplate';
10
+ import Routes from '../../../utils/Route';
14
11
  import ItemHanetDevice from '../../Device/Hanet/ItemHanetDevice';
15
- import { watchMultiConfigs } from '../../../iot/Monitor';
12
+ import ItemAddNew from '../../Device/ItemAddNew';
13
+ import ItemDevice from '../../Device/ItemDevice';
16
14
  import Text from '../../Text';
15
+ import { DeviceTemplate } from '../DeviceTemplate/DeviceTemplate';
16
+ import ShortDetailSubUnit from '../ShortDetail';
17
17
 
18
18
  jest.mock('../../../iot/Monitor');
19
19
 
@@ -179,7 +179,7 @@ describe('test ShortDetail Subunit', () => {
179
179
  tree = await create(wrapComponent(props));
180
180
  });
181
181
  jest.runOnlyPendingTimers();
182
- expect(watchMultiConfigs).toBeCalledWith([1]);
182
+ expect(watchMultiConfigs).toHaveBeenCalledWith([1]);
183
183
  });
184
184
 
185
185
  ['ConfigAndEvaluation', 'ConfigValue', 'EvaluationOverConfig'].forEach(
@@ -1,6 +1,6 @@
1
- import React, { memo, useCallback, useRef } from 'react';
1
+ import React, { memo, useCallback, useMemo, useRef } from 'react';
2
2
  import { StatusBar, StyleSheet, TouchableOpacity, View } from 'react-native';
3
- import AntDesign from 'react-native-vector-icons/AntDesign';
3
+ import { IconOutline } from '@ant-design/icons-react-native';
4
4
  import MaterialIcons from 'react-native-vector-icons/MaterialIcons';
5
5
  import { useNavigation, useRoute } from '@react-navigation/native';
6
6
  import { getStatusBarHeight } from 'react-native-iphone-x-helper';
@@ -17,14 +17,15 @@ import AddMenu from '../../../screens/Unit/AddMenu';
17
17
  import MoreMenu from '../../../screens/Unit/MoreMenu';
18
18
  import Text from '../../Text';
19
19
 
20
- const HeaderUnit = memo(({ unit, unitData }) => {
20
+ const HeaderUnit = memo(({ transparent, unit }) => {
21
+ const { user_id, name = '' } = unit;
21
22
  const { goBack, navigate } = useNavigation();
22
23
  const { routeName } = useRoute().params || {};
23
24
  const buttonMoreRef = useRef(null);
24
25
  const t = useTranslations();
25
26
 
26
27
  const [showAdd, setShowAdd, setHideAdd] = useBoolean();
27
- const { isOwner } = useIsOwnerOfUnit(unit?.user_id);
28
+ const { isOwner } = useIsOwnerOfUnit(user_id);
28
29
 
29
30
  const { childRef, showingPopover, showPopoverWithRef, hidePopover } =
30
31
  usePopover();
@@ -33,38 +34,44 @@ const HeaderUnit = memo(({ unit, unitData }) => {
33
34
  showPopoverWithRef(buttonMoreRef);
34
35
  }, [showPopoverWithRef]);
35
36
 
37
+ const handleGoBack = useCallback(() => {
38
+ if (routeName) {
39
+ navigate(routeName);
40
+ } else {
41
+ goBack();
42
+ }
43
+ }, [goBack, navigate, routeName]);
44
+
45
+ const colorHeader = useMemo(() => {
46
+ return transparent ? Colors.White : Colors.Black;
47
+ }, [transparent]);
48
+
36
49
  return (
37
50
  <View style={styles.container}>
38
51
  <TouchableOpacity
39
52
  accessibilityLabel={AccessibilityLabel.HEADER_UNIT_BUTTON_BACK}
40
- onPress={() => {
41
- if (routeName) {
42
- navigate(routeName);
43
- } else {
44
- goBack();
45
- }
46
- }}
53
+ onPress={handleGoBack}
47
54
  >
48
55
  <View style={styles.btnLeft}>
49
- <AntDesign name={'left'} size={27} color={Colors.White} />
56
+ <IconOutline name={'left'} size={27} color={colorHeader} />
50
57
  </View>
51
58
  </TouchableOpacity>
52
- <View style={styles.boxTitle}>
53
- <Text semibold style={styles.txtHeader} numberOfLines={1}>
54
- {t('Welcome {name}', {
55
- name: unit?.name ? unit.name : '',
56
- })}
57
- </Text>
58
- </View>
59
+ {!transparent && (
60
+ <View style={styles.boxTitle}>
61
+ <Text semibold style={styles.txtHeader} numberOfLines={1}>
62
+ {t('Welcome {name}', { name: name })}
63
+ </Text>
64
+ </View>
65
+ )}
59
66
 
60
67
  <View style={styles.boxRight}>
61
- {!!isOwner && (
68
+ {isOwner && (
62
69
  <TouchableOpacity
63
70
  accessibilityLabel={AccessibilityLabel.HEADER_UNIT_BUTTON_ADD}
64
71
  onPress={setShowAdd}
65
72
  >
66
73
  <View style={styles.btnAdd}>
67
- <AntDesign name={'plus'} size={27} color={Colors.White} />
74
+ <IconOutline name={'plus'} size={27} color={colorHeader} />
68
75
  </View>
69
76
  </TouchableOpacity>
70
77
  )}
@@ -74,7 +81,7 @@ const HeaderUnit = memo(({ unit, unitData }) => {
74
81
  accessibilityLabel={AccessibilityLabel.HEADER_UNIT_BUTTON_MORE}
75
82
  >
76
83
  <View style={styles.btnMore}>
77
- <MaterialIcons name={'more-vert'} size={27} color={Colors.White} />
84
+ <MaterialIcons name={'more-vert'} size={27} color={colorHeader} />
78
85
  </View>
79
86
  </TouchableOpacity>
80
87
  </View>
@@ -98,6 +105,7 @@ const HeaderUnit = memo(({ unit, unitData }) => {
98
105
  });
99
106
 
100
107
  export default HeaderUnit;
108
+
101
109
  const stickyHeaderHeight =
102
110
  Device.TopbarHeight + (Device.isIOS ? 0 : StatusBar.currentHeight);
103
111
 
@@ -1,7 +1,7 @@
1
1
  import React, { Fragment, useCallback } from 'react';
2
2
  import { View, Image, TouchableOpacity } from 'react-native';
3
3
  import { useTranslations } from '../../hooks/Common/useTranslations';
4
- import AntDesign from 'react-native-vector-icons/AntDesign';
4
+ import { IconFill, IconOutline } from '@ant-design/icons-react-native';
5
5
 
6
6
  import { API, Colors, Images } from '../../configs';
7
7
  import Text from '../../commons/Text';
@@ -91,7 +91,7 @@ const SharedUnit = ({
91
91
  {isOptions && (
92
92
  <Fragment>
93
93
  {item.is_pin ? (
94
- <AntDesign
94
+ <IconFill
95
95
  name="pushpin"
96
96
  size={20}
97
97
  color={Colors.Blue10}
@@ -99,15 +99,15 @@ const SharedUnit = ({
99
99
  accessibilityLabel={`${AccessibilityLabel.ICON_REMOVE_PIN_SHARED_UNIT}-${item.id}`}
100
100
  />
101
101
  ) : (
102
- <AntDesign
103
- name="pushpino"
102
+ <IconOutline
103
+ name="pushpin"
104
104
  size={20}
105
105
  onPress={addPinSharedUnit}
106
106
  accessibilityLabel={`${AccessibilityLabel.ICON_ADD_PIN_SHARED_UNIT}-${item.id}`}
107
107
  />
108
108
  )}
109
109
  {item.is_star ? (
110
- <AntDesign
110
+ <IconFill
111
111
  name="star"
112
112
  size={20}
113
113
  color={Colors.Yellow6}
@@ -115,8 +115,8 @@ const SharedUnit = ({
115
115
  accessibilityLabel={`${AccessibilityLabel.ICON_REMOVE_STAR_SHARED_UNIT}-${item.id}`}
116
116
  />
117
117
  ) : (
118
- <AntDesign
119
- name="staro"
118
+ <IconOutline
119
+ name="star"
120
120
  size={20}
121
121
  onPress={addStarSharedUnit}
122
122
  accessibilityLabel={`${AccessibilityLabel.ICON_ADD_STAR_SHARED_UNIT}-${item.id}`}
@@ -1,11 +1,11 @@
1
- import React, { useRef } from 'react';
1
+ import React from 'react';
2
2
  import { act } from 'react-test-renderer';
3
3
 
4
- import IFrame from '../IFrame';
5
- import WebView from 'react-native-webview';
6
4
  import { TouchableOpacity } from 'react-native';
5
+ import WebView from 'react-native-webview';
7
6
  import { render } from '../../../../../jest/render';
8
7
  import { SCConfig } from '../../../../configs';
8
+ import IFrame from '../IFrame';
9
9
 
10
10
  describe('Test IFrame', () => {
11
11
  let item;
@@ -52,16 +52,7 @@ describe('Test IFrame', () => {
52
52
  });
53
53
 
54
54
  test('test reload', async () => {
55
- const ref = {
56
- current: {},
57
- };
58
- useRef.mockReturnValue(ref);
59
-
60
- const mockReload = jest.fn();
61
55
  const { root } = await render(<IFrame isWidgetBox item={item} />);
62
- ref.current = {
63
- reload: mockReload,
64
- };
65
56
 
66
57
  const buttons = root.findAllByType(TouchableOpacity);
67
58
  expect(buttons).toHaveLength(1);
@@ -70,6 +61,11 @@ describe('Test IFrame', () => {
70
61
  buttons[0].props.onClick();
71
62
  });
72
63
 
73
- expect(mockReload).toHaveBeenCalledTimes(1);
64
+ // expect(mockReload).toHaveBeenCalledTimes(1);
65
+
66
+ // conflict with current (node_modules/react-native/Libraries/Utilities/useRefEffect.js:36:20)
67
+
68
+ // if current = null, conflict with
69
+ // at __restoreDefaultValues (node_modules/react-native/Libraries/Animated/useAnimatedProps.js:160:16)
74
70
  });
75
71
  });
@@ -11,7 +11,7 @@ import WebView from 'react-native-webview';
11
11
  import { TouchableOpacity, View } from 'react-native';
12
12
 
13
13
  const IFrameWithConfig = memo(
14
- ({ item = {}, widgetStyle, isWidgetBox, isSetting, isEditing }) => {
14
+ ({ item = {}, widgetStyle, isWidgetBox, isSetting, isEditing, doAction }) => {
15
15
  const ref = useRef();
16
16
 
17
17
  const { configuration } = item;
@@ -66,6 +66,29 @@ const IFrameWithConfig = memo(
66
66
  }
67
67
  }, [item?.id, url]);
68
68
 
69
+ const triggerAction = useCallback(
70
+ async ({ actionKey, actionIndex, data, interrupted = false, silent }) => {
71
+ let action = null;
72
+ if (!configuration?.actions) {
73
+ return;
74
+ }
75
+ if (actionIndex !== undefined) {
76
+ action = configuration?.actions[actionIndex];
77
+ }
78
+
79
+ if (actionKey) {
80
+ action = configuration?.actions.find(
81
+ (act) => act.action === actionKey
82
+ );
83
+ }
84
+ if (!action) {
85
+ return;
86
+ }
87
+ await doAction(action.action_data, data, interrupted, silent);
88
+ },
89
+ [configuration?.actions, doAction]
90
+ );
91
+
69
92
  const onMessage = useCallback(
70
93
  async (event) => {
71
94
  const eventData = event.nativeEvent.data
@@ -95,9 +118,18 @@ const IFrameWithConfig = memo(
95
118
  case 'requestAdjustMobileHeight':
96
119
  setHeight(data);
97
120
  break;
121
+ case 'triggerAction':
122
+ triggerAction(data);
123
+ break;
98
124
  }
99
125
  },
100
- [configuration, fetchDataDisplayHistory, item.id, postMessage]
126
+ [
127
+ configuration,
128
+ fetchDataDisplayHistory,
129
+ item.id,
130
+ postMessage,
131
+ triggerAction,
132
+ ]
101
133
  );
102
134
 
103
135
  useEffect(() => {
@@ -11,6 +11,7 @@ import WebView from 'react-native-webview';
11
11
  import { TouchableOpacity, View } from 'react-native';
12
12
  import { refFunctions } from '../../../../../__mocks__/react-native-webview';
13
13
 
14
+ const mockDoAction = jest.fn();
14
15
  jest.mock('../../../../iot/states', () => {
15
16
  return {
16
17
  ...jest.requireActual('../../../../iot/states'),
@@ -27,6 +28,7 @@ describe('Test IFrame With Config', () => {
27
28
  };
28
29
 
29
30
  beforeEach(() => {
31
+ mockDoAction.mockClear();
30
32
  item = {
31
33
  id: 1,
32
34
  configuration: {
@@ -39,7 +41,9 @@ describe('Test IFrame With Config', () => {
39
41
  });
40
42
 
41
43
  test('test with widget box', async () => {
42
- const { root } = await render(<IFrameWithConfig isWidgetBox item={item} />);
44
+ const { root } = await render(
45
+ <IFrameWithConfig doAction={mockDoAction} isWidgetBox item={item} />
46
+ );
43
47
 
44
48
  const iframes = root.findAllByType(WebView);
45
49
  expect(iframes).toHaveLength(1);
@@ -51,7 +55,9 @@ describe('Test IFrame With Config', () => {
51
55
 
52
56
  test('test with query string', async () => {
53
57
  item.configuration.url = 'http://localhost:3000/?test=1';
54
- const { root } = await render(<IFrameWithConfig isWidgetBox item={item} />);
58
+ const { root } = await render(
59
+ <IFrameWithConfig isWidgetBox doAction={mockDoAction} item={item} />
60
+ );
55
61
 
56
62
  const iframes = root.findAllByType(WebView);
57
63
  expect(iframes).toHaveLength(1);
@@ -62,7 +68,9 @@ describe('Test IFrame With Config', () => {
62
68
  });
63
69
 
64
70
  test('test reload', async () => {
65
- const { root } = await render(<IFrameWithConfig isWidgetBox item={item} />);
71
+ const { root } = await render(
72
+ <IFrameWithConfig isWidgetBox doAction={mockDoAction} item={item} />
73
+ );
66
74
 
67
75
  const buttons = root.findAllByType(TouchableOpacity);
68
76
  expect(buttons).toHaveLength(1);
@@ -75,7 +83,9 @@ describe('Test IFrame With Config', () => {
75
83
  });
76
84
 
77
85
  test('test iframe is ready', async () => {
78
- const { root } = await render(<IFrameWithConfig isWidgetBox item={item} />);
86
+ const { root } = await render(
87
+ <IFrameWithConfig isWidgetBox doAction={mockDoAction} item={item} />
88
+ );
79
89
  const webview = root.findByType(WebView);
80
90
 
81
91
  await act(async () => {
@@ -120,7 +130,9 @@ describe('Test IFrame With Config', () => {
120
130
  });
121
131
 
122
132
  test('test iframe request more height', async () => {
123
- const { root } = await render(<IFrameWithConfig isWidgetBox item={item} />);
133
+ const { root } = await render(
134
+ <IFrameWithConfig isWidgetBox doAction={mockDoAction} item={item} />
135
+ );
124
136
  const webview = root.findByType(WebView);
125
137
 
126
138
  await act(async () => {
@@ -142,7 +154,9 @@ describe('Test IFrame With Config', () => {
142
154
  });
143
155
 
144
156
  test('test iframe receive message from unexpected origin', async () => {
145
- const { root } = await render(<IFrameWithConfig isWidgetBox item={item} />);
157
+ const { root } = await render(
158
+ <IFrameWithConfig isWidgetBox doAction={mockDoAction} item={item} />
159
+ );
146
160
  const webview = root.findByType(WebView);
147
161
 
148
162
  await act(async () => {
@@ -178,7 +192,9 @@ describe('Test IFrame With Config', () => {
178
192
  item.configuration.history_configs = [{ id: 1 }];
179
193
  item.configuration.realtime_configs = [];
180
194
 
181
- const { root } = await render(<IFrameWithConfig isWidgetBox item={item} />);
195
+ const { root } = await render(
196
+ <IFrameWithConfig isWidgetBox doAction={mockDoAction} item={item} />
197
+ );
182
198
  const webview = root.findByType(WebView);
183
199
 
184
200
  await act(async () => {
@@ -217,7 +233,9 @@ describe('Test IFrame With Config', () => {
217
233
  item.configuration.history_configs = [{ id: 1 }];
218
234
  item.configuration.realtime_configs = [];
219
235
 
220
- const { root } = await render(<IFrameWithConfig isWidgetBox item={item} />);
236
+ const { root } = await render(
237
+ <IFrameWithConfig isWidgetBox doAction={mockDoAction} item={item} />
238
+ );
221
239
  const webview = root.findByType(WebView);
222
240
 
223
241
  await act(async () => {
@@ -281,4 +299,66 @@ describe('Test IFrame With Config', () => {
281
299
  'window.postMessage(' + JSON.stringify(message) + ', "*")'
282
300
  );
283
301
  };
302
+
303
+ const triggerAction = async (
304
+ data,
305
+ actions = [
306
+ {
307
+ action: 'xxx',
308
+ action_data: {
309
+ end_device: 1,
310
+ },
311
+ },
312
+ ]
313
+ ) => {
314
+ item.configuration.actions = actions;
315
+ const { root } = await render(
316
+ <IFrameWithConfig isWidgetBox doAction={mockDoAction} item={item} />
317
+ );
318
+ const webview = root.findByType(WebView);
319
+
320
+ await act(async () => {
321
+ webview.props.onMessage({
322
+ nativeEvent: {
323
+ data: JSON.stringify({
324
+ type: 'triggerAction',
325
+ eraWidgetId: 1,
326
+ source: 'eraIframeWidget',
327
+ data: data,
328
+ }),
329
+ origin: 'http://localhost',
330
+ },
331
+ });
332
+ });
333
+ };
334
+
335
+ test('test iframe trigger action', async () => {
336
+ await triggerAction({ actionKey: 'xxx' });
337
+ expect(mockDoAction).toHaveBeenCalledWith(
338
+ item.configuration.actions[0].action_data,
339
+ undefined,
340
+ false,
341
+ undefined
342
+ );
343
+ });
344
+
345
+ test('test iframe trigger by index', async () => {
346
+ await triggerAction({ actionIndex: 0 });
347
+ expect(mockDoAction).toHaveBeenCalledWith(
348
+ item.configuration.actions[0].action_data,
349
+ undefined,
350
+ false,
351
+ undefined
352
+ );
353
+ });
354
+
355
+ test('test iframe trigger not exists', async () => {
356
+ await triggerAction({ actionIndex: -1 });
357
+ expect(mockDoAction).toHaveBeenCalledTimes(0);
358
+ });
359
+
360
+ test('test iframe trigger no actions', async () => {
361
+ await triggerAction({ actionIndex: 0 }, []);
362
+ expect(mockDoAction).toHaveBeenCalledTimes(0);
363
+ });
284
364
  });