@rpcbase/client 0.227.0 → 0.231.0

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 (237) hide show
  1. package/package.json +11 -113
  2. package/src/apiClient/getServerApiClient.ts +131 -0
  3. package/src/apiClient/index.ts +86 -0
  4. package/src/index.ts +3 -0
  5. package/src/initClient.ts +32 -0
  6. package/src/types.ts +7 -0
  7. package/AppProvider/AnalyticsContainer.js +0 -56
  8. package/AppProvider/debug.js +0 -4
  9. package/AppProvider/index.tsx +0 -79
  10. package/access-control/ACLForm/components/GrantField/OpSelector.tsx +0 -129
  11. package/access-control/ACLForm/components/GrantField/ResourceSelector.tsx +0 -86
  12. package/access-control/ACLForm/components/GrantField/UsersSelector.tsx +0 -96
  13. package/access-control/ACLForm/components/GrantField/grant-field.scss +0 -26
  14. package/access-control/ACLForm/components/GrantField/icons/CheckMark.tsx +0 -16
  15. package/access-control/ACLForm/components/GrantField/icons/CollapseArrow.tsx +0 -14
  16. package/access-control/ACLForm/components/GrantField/icons/ExpandArrow.tsx +0 -14
  17. package/access-control/ACLForm/components/GrantField/index.tsx +0 -91
  18. package/access-control/ACLForm/components/GrantsList.tsx +0 -48
  19. package/access-control/ACLForm/components/RoleForm.tsx +0 -134
  20. package/access-control/ACLForm/components/RoleView.tsx +0 -115
  21. package/access-control/ACLForm/components/RolesList.tsx +0 -79
  22. package/access-control/ACLForm/components/constants.tsx +0 -1
  23. package/access-control/ACLForm/components/resolver.ts +0 -57
  24. package/access-control/ACLForm/components/role-form.scss +0 -19
  25. package/access-control/ACLForm/index.tsx +0 -48
  26. package/access-control/ACLModal/acl-modal.scss +0 -7
  27. package/access-control/ACLModal/index.tsx +0 -66
  28. package/access-control/PolicyEditor/TargetSelector/QueryBuilder.tsx +0 -48
  29. package/access-control/PolicyEditor/TargetSelector/index.tsx +0 -5
  30. package/access-control/PolicyEditor/TargetSelector/query-builder.scss +0 -9
  31. package/access-control/PolicyEditor/index.tsx +0 -165
  32. package/access-control/index.ts +0 -3
  33. package/apiClient.js +0 -15
  34. package/auth/authProps.js +0 -8
  35. package/auth/components/AccountsList/AccountListItem.js +0 -61
  36. package/auth/components/AccountsList/account-list-item.scss +0 -5
  37. package/auth/components/AccountsList/index.js +0 -17
  38. package/auth/components/Footer/index.js +0 -11
  39. package/auth/components/ForgotPassword/forgot-password.scss +0 -37
  40. package/auth/components/ForgotPassword/index.js +0 -114
  41. package/auth/components/SetNewPassword/index.js +0 -130
  42. package/auth/components/SetNewPassword/set-new-password.scss +0 -47
  43. package/auth/components/SignIn/SignInEmailForm.tsx +0 -115
  44. package/auth/components/SignIn/index.js +0 -69
  45. package/auth/components/SignIn/sign-in.scss +0 -56
  46. package/auth/components/SignOut/index.js +0 -144
  47. package/auth/components/SignOut/sign-out.scss +0 -34
  48. package/auth/components/SignUp/SignUpEmailForm.tsx +0 -98
  49. package/auth/components/SignUp/index.js +0 -66
  50. package/auth/components/SignUp/sign-up.scss +0 -56
  51. package/auth/getTenantId.js +0 -12
  52. package/auth/getUid.js +0 -11
  53. package/auth/helpers/redirectSignIn.native.js +0 -9
  54. package/auth/helpers/redirectSignIn.web.js +0 -7
  55. package/auth/index.js +0 -146
  56. package/auth/signOut.js +0 -20
  57. package/auth/useAuthRouter.js +0 -56
  58. package/env.d.ts +0 -3
  59. package/firebase/index.js +0 -1
  60. package/firebase/sw.js +0 -1
  61. package/form/FileInput/FileUploadContext.tsx +0 -162
  62. package/form/FileInput/FileUploadForm/index.tsx +0 -139
  63. package/form/FileInput/FileUploadForm/usePreventUnload.js +0 -21
  64. package/form/FileInput/UploadButton.tsx +0 -23
  65. package/form/FileInput/constants.ts +0 -16
  66. package/form/FileInput/file-input.scss +0 -1
  67. package/form/FileInput/index.tsx +0 -21
  68. package/form/FileInput/upload-worker/get_file_hash.js +0 -63
  69. package/form/FileInput/upload-worker/index.js +0 -16
  70. package/form/FileInput/upload-worker/no_compress_exts.ts +0 -33
  71. package/form/FileInput/upload-worker/upload_file.js +0 -129
  72. package/form/Form.tsx +0 -23
  73. package/form/Input.tsx +0 -62
  74. package/form/SubmitButton/index.tsx +0 -58
  75. package/form/hook-form.tsx +0 -7
  76. package/form/index.tsx +0 -5
  77. package/getBaseUrl.js +0 -14
  78. package/getObjectId.ts +0 -31
  79. package/hashState.js +0 -158
  80. package/helpers/createBatcher/index.js +0 -36
  81. package/helpers/getInitials.js +0 -39
  82. package/helpers/onReady.js +0 -15
  83. package/helpers/post.js +0 -18
  84. package/helpers/postRPC.js +0 -42
  85. package/helpers/useRPC.js +0 -41
  86. package/helpers/useStoredValue/batchedGetStoredValues.js +0 -30
  87. package/helpers/useStoredValue/index.js +0 -107
  88. package/helpers/useStoredValue/setStoredValues.js +0 -14
  89. package/i18n/en/rb.nav.json +0 -13
  90. package/i18n/en/rb.sign_in.json +0 -11
  91. package/i18n/en/rb.sign_out.json +0 -5
  92. package/i18n/fr/rb.sign_in.json +0 -11
  93. package/i18n/fr/rb.sign_out.json +0 -5
  94. package/i18n/index.js +0 -63
  95. package/index.js +0 -6
  96. package/isEqualValues.js +0 -47
  97. package/jest.config.js +0 -16
  98. package/notifications/Notification/index.js +0 -36
  99. package/notifications/Notification/notification.scss +0 -1
  100. package/notifications/NotificationItem/HeaderStatus.js +0 -93
  101. package/notifications/NotificationItem/index.js +0 -65
  102. package/notifications/NotificationItem/notification-item.scss +0 -25
  103. package/notifications/NotificationsContainer/index.js +0 -37
  104. package/notifications/NotificationsContainer/notifications-container.scss +0 -38
  105. package/notifications/NotificationsContainer/useLLTs.js +0 -28
  106. package/notifications/NotificationsContext/index.js +0 -71
  107. package/notifications/NotificationsContext/useNotificationsList.js +0 -75
  108. package/notifications/NotificationsSettingsModal/SettingsForm.js +0 -52
  109. package/notifications/NotificationsSettingsModal/index.js +0 -48
  110. package/notifications/NotificationsSettingsModal/notifications-settings.scss +0 -1
  111. package/notifications/config.js +0 -1
  112. package/notifications/index.js +0 -4
  113. package/page.js +0 -9
  114. package/publish-output.txt +0 -0
  115. package/rpc.js +0 -32
  116. package/rr-trace/get_fingerprint.js +0 -10
  117. package/rr-trace/get_perf_vitals.js +0 -24
  118. package/rr-trace/get_session_id.js +0 -29
  119. package/rr-trace/index.js +0 -138
  120. package/rr-trace/write_session_data.js +0 -86
  121. package/rts/boot.js +0 -3
  122. package/rts/getUseDocument.js +0 -21
  123. package/rts/getUseQuery/index.js +0 -233
  124. package/rts/getUseQuery/useData.js +0 -55
  125. package/rts/index.js +0 -10
  126. package/rts/rts.js +0 -243
  127. package/rts/signout.ts +0 -8
  128. package/rts/store/constants.js +0 -3
  129. package/rts/store/debug.js +0 -24
  130. package/rts/store/get_collection.js +0 -55
  131. package/rts/store/index.js +0 -100
  132. package/rts/store/replace_query_keys.js +0 -30
  133. package/rts/store/satisfies_projection.js +0 -32
  134. package/rts/store/update_docs.js +0 -47
  135. package/storage/index.jest.js +0 -15
  136. package/storage/index.native.js +0 -38
  137. package/storage/index.web.js +0 -25
  138. package/types.ts +0 -6
  139. package/ui/ActivityIndicator/index.js +0 -113
  140. package/ui/Avatar/index.native.js +0 -31
  141. package/ui/Avatar/index.web.js +0 -37
  142. package/ui/Avatar/styles.js +0 -41
  143. package/ui/ErrorBoundary/index.js +0 -12
  144. package/ui/ExpandableFloatView/exp.scss +0 -15
  145. package/ui/ExpandableFloatView/index.tsx +0 -123
  146. package/ui/ExpandableFloatView/useBackdrop.js +0 -45
  147. package/ui/LottiePlayer/LottiePlayer.js +0 -4
  148. package/ui/LottiePlayer/index.js +0 -8
  149. package/ui/Modal/HashStateModal.js +0 -30
  150. package/ui/Modal/Modal.js +0 -93
  151. package/ui/Modal/ModalForm/AlertBanner.js +0 -82
  152. package/ui/Modal/ModalForm/index.js +0 -188
  153. package/ui/Modal/ModalForm/modal-form.scss +0 -63
  154. package/ui/Modal/index.js +0 -10
  155. package/ui/Modal/modal.scss +0 -101
  156. package/ui/Modal/withHashStateModal.js +0 -24
  157. package/ui/RedboxError/index.js +0 -3
  158. package/ui/Search/SearchHistory/index.js +0 -45
  159. package/ui/Search/SearchHistory/search-history.scss +0 -9
  160. package/ui/Search/SearchHistory/useSearchHistory.tsx +0 -57
  161. package/ui/Search/SearchResults/index.tsx +0 -90
  162. package/ui/Search/index.tsx +0 -298
  163. package/ui/Search/search.scss +0 -0
  164. package/ui/SelectPills/index.tsx +0 -96
  165. package/ui/SelectPills/select-pills.scss +0 -66
  166. package/ui/Tabs/index.tsx +0 -161
  167. package/ui/Tabs/tabs.scss +0 -53
  168. package/ui/Tree/index.js +0 -257
  169. package/ui/Tree/model.js +0 -71
  170. package/ui/Tree/node.js +0 -112
  171. package/ui/Tree/tree.scss +0 -98
  172. package/ui/UserAvatar/default_colors.json +0 -82
  173. package/ui/UserAvatar/index.js +0 -55
  174. package/ui/View/index.tsx +0 -17
  175. package/ui/View/index.web.js +0 -44
  176. package/ui/animations/checkmark.json +0 -1
  177. package/ui/helpers/SizeContext/index.tsx +0 -11
  178. package/ui/helpers/helpers.scss +0 -61
  179. package/ui/helpers/index.ts +0 -6
  180. package/ui/helpers/stopEventPropagation.js +0 -5
  181. package/ui/helpers/useActiveListItemIndex/index.tsx +0 -45
  182. package/ui/helpers/useScrollSelectorIntoView/index.tsx +0 -14
  183. package/ui/helpers/useThrottledMeasure/index.js +0 -47
  184. package/ui/helpers/withSuspense/index.js +0 -37
  185. package/ui/icons/AddAccount.tsx +0 -5
  186. package/ui/icons/Billing.tsx +0 -6
  187. package/ui/icons/Close.tsx +0 -14
  188. package/ui/icons/Organization.tsx +0 -5
  189. package/ui/icons/Signout.tsx +0 -5
  190. package/ui/icons/index.tsx +0 -6
  191. package/ui/nav/AccountsDropdown/SwitchAccounts.tsx +0 -28
  192. package/ui/nav/AccountsDropdown/accounts-dropdown.scss +0 -51
  193. package/ui/nav/AccountsDropdown/index.tsx +0 -90
  194. package/ui/nav/AccountsToggle/index.tsx +0 -24
  195. package/ui/nav/ContentView/ContentViewContext.ts +0 -23
  196. package/ui/nav/ContentView/index.tsx +0 -115
  197. package/ui/nav/HeaderContainer/header.scss +0 -52
  198. package/ui/nav/HeaderContainer/index.tsx +0 -23
  199. package/ui/nav/HeaderContainer/variables.scss +0 -1
  200. package/ui/nav/MorphingDropdown/MorphingDropdownContext.tsx +0 -151
  201. package/ui/nav/MorphingDropdown/MorphingDropdownMenu.tsx +0 -38
  202. package/ui/nav/MorphingDropdown/MorphingDropdownPortal.tsx +0 -166
  203. package/ui/nav/MorphingDropdown/MorphingDropdownToggle.tsx +0 -34
  204. package/ui/nav/MorphingDropdown/index.tsx +0 -16
  205. package/ui/nav/MorphingDropdown/morphing-dropdown.scss +0 -35
  206. package/ui/nav/NotificationsDropdown/index.tsx +0 -52
  207. package/ui/nav/NotificationsDropdown/notifications-dropdown.scss +0 -5
  208. package/ui/nav/NotificationsToggle/NotificationsGlyph.tsx +0 -54
  209. package/ui/nav/NotificationsToggle/index.tsx +0 -12
  210. package/ui/nav/NotificationsToggle/notification-animation.json +0 -1
  211. package/ui/nav/NotificationsToggle/notifications-toggle.scss +0 -26
  212. package/ui/nav/SidebarContainer/index.tsx +0 -48
  213. package/ui/nav/SidebarContainer/sidebar-container.scss +0 -21
  214. package/ui/nav/SlideoutContainer/components/Body.tsx +0 -19
  215. package/ui/nav/SlideoutContainer/components/Header.tsx +0 -23
  216. package/ui/nav/SlideoutContainer/components/Wrapper.tsx +0 -46
  217. package/ui/nav/SlideoutContainer/index.tsx +0 -50
  218. package/ui/nav/SlideoutContainer/slideout-container.scss +0 -40
  219. package/ui/nav/index.ts +0 -13
  220. package/ui/oauth/GitHub.js +0 -38
  221. package/ui/oauth/getGitHubSigninUrl.js +0 -30
  222. package/ui/oauth/index.js +0 -9
  223. package/ui/oauth/oauth.scss +0 -16
  224. package/ui/sortable-hoc/AutoScroller.js +0 -76
  225. package/ui/sortable-hoc/DragHandle.js +0 -31
  226. package/ui/sortable-hoc/Manager.js +0 -54
  227. package/ui/sortable-hoc/README.md +0 -1
  228. package/ui/sortable-hoc/SortableContainer/defaultGetHelperDimensions.js +0 -7
  229. package/ui/sortable-hoc/SortableContainer/defaultShouldCancelStart.js +0 -24
  230. package/ui/sortable-hoc/SortableContainer/index.js +0 -994
  231. package/ui/sortable-hoc/SortableContainer/props.js +0 -81
  232. package/ui/sortable-hoc/SortableElement.js +0 -111
  233. package/ui/sortable-hoc/SortableHandle.js +0 -45
  234. package/ui/sortable-hoc/drag-handle.scss +0 -14
  235. package/ui/sortable-hoc/index.js +0 -9
  236. package/ui/sortable-hoc/utils.js +0 -292
  237. package/ui/springs.ts +0 -17
@@ -1,30 +0,0 @@
1
- /* @flow */
2
- import assert from "assert"
3
- import debug from "debug"
4
-
5
- import post from "../post"
6
- import createBatcher from "../createBatcher"
7
-
8
- const log = debug("useStoredValue:get")
9
-
10
- // we keep it just above the react rendering time, but it could even be a request animation frame
11
- const BATCH_TIMEOUT_MS = 4
12
-
13
- const batchedGetStoredValues = async(args) => {
14
- log("batched call to args", args)
15
-
16
- const keys = args.map((arg) => arg[0])
17
-
18
- const res = await post("/rb-api/v1/stored-values/get", keys)
19
- assert(res.status === "ok")
20
-
21
- if (debug.enabled) {
22
- for (let i = 0; i < args.length; i++) {
23
- log(args[i][0], res.values[i])
24
- }
25
- }
26
-
27
- return res.values
28
- }
29
-
30
- export default createBatcher(batchedGetStoredValues, BATCH_TIMEOUT_MS)
@@ -1,107 +0,0 @@
1
- /* @flow */
2
- import {useEffect, useState, useRef, useCallback} from "react"
3
- import _throttle from "lodash/throttle"
4
- import isEqual from "fast-deep-equal/react"
5
-
6
- import getUid from "../../auth/getUid"
7
- import storage from "../../storage"
8
-
9
- import batchedGetStoredValues from "./batchedGetStoredValues"
10
- import setStoredValues from "./setStoredValues"
11
-
12
-
13
- const DEFAULT_REMOTE = true
14
- const UPDATE_THROTTLE_DELAY = 300
15
-
16
- export const useStoredValue = (_key, defaultValueOrFn = null, options = {}) => {
17
- const uid = getUid()
18
- const key = `${uid}.${_key}`
19
-
20
- const hasRemote = typeof options.remote === "boolean" ? options.remote : DEFAULT_REMOTE
21
-
22
- const previousKey = useRef()
23
-
24
- const getInitialState = () => {
25
- const defaultValue =
26
- typeof defaultValueOrFn === "function" ? defaultValueOrFn() : defaultValueOrFn
27
-
28
- if (!_key) return defaultValue
29
-
30
- const val = storage.getItem(key)
31
-
32
- return typeof val !== "undefined" && val !== null ? val : defaultValue
33
- }
34
-
35
- const [value, setValue] = useState(getInitialState())
36
-
37
- // reload initial state when key changes
38
- useEffect(() => {
39
- const initialStateForKey = getInitialState()
40
- if (!isEqual(initialStateForKey, value)) {
41
- setValue(initialStateForKey)
42
- }
43
- }, [key])
44
-
45
-
46
- const refresh = useCallback(async() => {
47
- const nextVal = await batchedGetStoredValues(key)
48
-
49
- // TODO: we check against null here because localStorage of a non existing key returns null, but this is wrong, it should be returning undefined, in case we want to be able to store a null value
50
- if (typeof nextVal !== "undefined" && nextVal !== null && !isEqual(nextVal, value)) {
51
- setValue(nextVal)
52
- // add the value to local storage in case it wasn't present
53
- storage.setItem(key, nextVal)
54
- }
55
- }, [key])
56
-
57
-
58
- useEffect(() => {
59
- if (!hasRemote) return
60
- if (!key) return
61
- // skip when value is still undefined -> it hasnt loaded from cache / default value
62
- if (typeof value === "undefined") return
63
-
64
- if (previousKey.current !== key) {
65
- refresh()
66
- previousKey.current = key
67
- }
68
- }, [hasRemote, key, value, setValue])
69
-
70
- // TODO: are there several instances of this function that run for differents keys ?
71
- const throttledUpdateRemote = useCallback(
72
- _throttle(
73
- async(newVal) => {
74
- await setStoredValues({
75
- values: [
76
- {
77
- key,
78
- value: newVal,
79
- },
80
- ],
81
- })
82
- },
83
- UPDATE_THROTTLE_DELAY,
84
- {leading: false, trailing: true},
85
- ),
86
- [key],
87
- )
88
-
89
- const updateValue = async(newValOrFn) => {
90
- const newVal = typeof newValOrFn === "function" ? newValOrFn(value) : newValOrFn
91
-
92
- if (newVal !== value) {
93
- setValue(newVal)
94
- }
95
- if (!_key) return
96
-
97
- storage.setItem(key, newVal)
98
-
99
- if (hasRemote) {
100
- throttledUpdateRemote(newVal)
101
- }
102
- }
103
-
104
- return [value, updateValue]
105
- }
106
-
107
- export default useStoredValue
@@ -1,14 +0,0 @@
1
- /* @flow */
2
- import assert from "assert"
3
-
4
- import post from "../post"
5
-
6
-
7
- const setStoredValue = async(payload) => {
8
- const res = await post("/rb-api/v1/stored-values/set", payload)
9
-
10
- assert(res.status === "ok")
11
- return res
12
- }
13
-
14
- export default setStoredValue
@@ -1,13 +0,0 @@
1
- {
2
- "toggle_notifications": "Toggle Notifications",
3
- "notifications_settings": "Notifications Settings",
4
- "search_anything": {
5
- "placeholder": "Search Anything..."
6
- },
7
- "account_settings": "Account Settings",
8
- "organization": "Oranization",
9
- "billing": "Billing",
10
- "switch_accounts": "Switch Accounts",
11
- "add_account": "Add Account",
12
- "sign_out": "Sign Out"
13
- }
@@ -1,11 +0,0 @@
1
- {
2
- "title": "Sign In",
3
- "dont_have_account": "Don't have an account?",
4
- "sign_up_here": "Sign up here",
5
- "or": "OR",
6
- "email_address": "Email Address",
7
- "email_placeholder": "name@example.com",
8
- "password": "Password",
9
- "forgot_password": "Forgot your password?",
10
- "submit_btn": "Sign in"
11
- }
@@ -1,5 +0,0 @@
1
- {
2
- "title": "Sign Out",
3
- "click_here_signout": "Click here to sign out of your account:",
4
- "success_text": "Signed out succesfully"
5
- }
@@ -1,11 +0,0 @@
1
- {
2
- "title": "Connexion",
3
- "dont_have_account": "Vous n'avez pas de compte?",
4
- "sign_up_here": "Créez un compte ici",
5
- "or": "OU",
6
- "email_address": "Addresse Email",
7
- "email_placeholder": "nom@example.com",
8
- "password": "Mot de passe",
9
- "forgot_password": "Mot de passe oublié?",
10
- "submit_btn": "Connexion"
11
- }
@@ -1,5 +0,0 @@
1
- {
2
- "title": "Déconnexion",
3
- "click_here_signout": "Cliquez ici pour vous déconnecter:",
4
- "success_text": "Opération complétée avec succès"
5
- }
package/i18n/index.js DELETED
@@ -1,63 +0,0 @@
1
- /* @flow */
2
- import i18next from "i18next"
3
- import {initReactI18next} from "react-i18next"
4
- import ChainedBackend from "i18next-chained-backend"
5
- import resourcesToBackend from "i18next-resources-to-backend"
6
-
7
- import {getLocaleFromCode} from "@rpcbase/std"
8
-
9
- import {RB_DEFAULT_LOCALE, RB_LOCALES} from "env"
10
-
11
-
12
- const RB_LOCALE_KEY = "rb.i18n_locale"
13
-
14
- const DEFAULT_LOCALE = RB_DEFAULT_LOCALE || "en"
15
- const SUPPORTED_LOCALES = RB_LOCALES
16
- ? RB_LOCALES.split(",").map((l) => l.trim())
17
- : ["en"]
18
-
19
- // https://github.com/i18next/i18next-browser-languageDetector
20
-
21
- // get stored locale or fallback to navigator
22
- let locale = localStorage.getItem(RB_LOCALE_KEY)
23
- if (!locale) {
24
- locale = navigator.language
25
- }
26
-
27
- // DO NOT call this function directly, it is injected from babel-plugin-i18next-client by the bundler
28
- export const initializeI18N = async(backendFn) => {
29
- i18next
30
- .use(ChainedBackend)
31
- .use(initReactI18next)
32
- .init({
33
- lng: locale,
34
- fallbackLng: (code) => {
35
- const val = getLocaleFromCode({
36
- code,
37
- supported_locales: SUPPORTED_LOCALES,
38
- default_locale: DEFAULT_LOCALE,
39
- })
40
- return val
41
- },
42
- defaultNS: "common",
43
- backend: {
44
- backends: [
45
- // rb internal i18n
46
- resourcesToBackend(
47
- (lng, ns) =>
48
- import(/* webpackChunkName: "rb-i18n" */ `./${lng}/${ns}.json`),
49
- ),
50
- // users's i18n
51
- resourcesToBackend(backendFn),
52
- ],
53
- },
54
- interpolation: {
55
- escapeValue: false,
56
- },
57
- })
58
-
59
- // save preference to local storage so it works on reload
60
- i18next.on("languageChanged", (lng) => {
61
- localStorage.setItem(RB_LOCALE_KEY, lng)
62
- })
63
- }
package/index.js DELETED
@@ -1,6 +0,0 @@
1
- /* @flow */
2
- import useRPC from "./helpers/useRPC"
3
- import useStoredValue from "./helpers/useStoredValue"
4
- import {getUid} from "./auth/getUid"
5
-
6
- export {useRPC, useStoredValue, getUid}
package/isEqualValues.js DELETED
@@ -1,47 +0,0 @@
1
- /* @flow */
2
- const isEqual = require("fast-deep-equal/react")
3
-
4
-
5
- const isPlainObject = (obj) => {
6
- return Object.prototype.toString.call(obj) === "[object Object]"
7
- }
8
-
9
- const sortValuesConsideringObjects = (values) => {
10
- return values
11
- .map(val => (isPlainObject(val) ? sortValuesConsideringObjects(Object.values(val)) : val))
12
- .sort()
13
- }
14
-
15
- const isEqualValues = (a, b) => {
16
- // Extract values and sort them if they belong to plain objects
17
- const valsA = isPlainObject(a) ? sortValuesConsideringObjects(Object.values(a)) : a
18
- const valsB = isPlainObject(b) ? sortValuesConsideringObjects(Object.values(b)) : b
19
-
20
- if (valsA === null && valsB === null) {
21
- return true
22
- }
23
-
24
- if (Array.isArray(valsA) || Array.isArray(valsB)) {
25
- return isEqual(valsA, valsB)
26
- }
27
-
28
- // Check value count
29
- if (valsA.length !== valsB.length) return false
30
-
31
- // Compare the sorted arrays of values
32
- for (let i = 0; i < valsA.length; i++) {
33
- if (typeof valsA[i] === "object" && typeof valsB[i] === "object") {
34
- if (!isEqualValues(valsA[i], valsB[i])) {
35
- return false
36
- }
37
- } else {
38
- if (!isEqual(valsA[i], valsB[i])) {
39
- return false
40
- }
41
- }
42
- }
43
- return true
44
- }
45
-
46
-
47
- module.exports = isEqualValues
package/jest.config.js DELETED
@@ -1,16 +0,0 @@
1
- module.exports = {
2
- testEnvironment: "jsdom",
3
- transform: {
4
- "^.+\\.js$": ["babel-jest", {
5
- presets: ["@babel/preset-react"],
6
- plugins: [
7
- "@babel/plugin-transform-runtime",
8
- "@babel/plugin-transform-modules-commonjs",
9
- ],
10
- }],
11
- },
12
- moduleNameMapper: {
13
- "^react-native$": "react-native-web",
14
- },
15
- moduleFileExtensions: ["jest.js", "web.js", "js", "json"],
16
- }
@@ -1,36 +0,0 @@
1
- /* @flow */
2
- import * as React from "react"
3
- import { useCallback } from "react";
4
-
5
- import type {Notification as NotificationType} from "types/notification"
6
-
7
- import "./notification.scss"
8
-
9
- type Props = {
10
- notification: NotificationType,
11
- onClick?: () => void,
12
- }
13
-
14
- const Notification = ({ ref, notification, onClick }: Props) => {
15
- const handleClick = useCallback(() => {
16
- if (onClick) {
17
- onClick();
18
- }
19
- }, [onClick]);
20
-
21
- return (
22
- <a
23
- className={cx(["dropdown-item", notification.ack && "disabled"])}
24
- href="#"
25
- ref={ref}
26
- onClick={handleClick}
27
- >
28
- <span>{notification.title}</span>
29
- <p className="text-secondary mb-0" style={{whiteSpace: "initial"}}>
30
- {notification.description}
31
- </p>
32
- </a>
33
- );
34
- }
35
-
36
- export default Notification
@@ -1 +0,0 @@
1
- @import "helpers";
@@ -1,93 +0,0 @@
1
- /* @flow */
2
- import {motion} from "framer-motion"
3
- import {useEffect, useRef, useState} from "react"
4
-
5
- import ActivityIndicator from "../../ui/ActivityIndicator"
6
- import LottiePlayer from "../../ui/LottiePlayer"
7
-
8
- import {SPRING_BOUNCY} from "../../ui/springs"
9
-
10
- import checkmarkAnimation from "../../ui/animations/checkmark.json"
11
-
12
- // TODO: we should have a way to unmount loader when animation complete
13
- const HeaderStatus = ({isLoading, status}) => {
14
- const playerRef = useRef()
15
-
16
- const initiallyLoading = useRef(isLoading)
17
-
18
- const [hasLoader, setHasLoader] = useState(isLoading)
19
-
20
- const [statusAnimatedVals, setStatusAnimatedVals] = useState({})
21
- const [loaderAnimatedVals, setLoaderAnimatedVals] = useState({})
22
-
23
- useEffect(() => {
24
- // set initial seeker position, TODO: this doesn't work without the animation frame
25
- requestAnimationFrame(() => {
26
- playerRef.current?.setSeeker(16, false)
27
- })
28
- }, [])
29
-
30
- const runTransition = () => {
31
- setStatusAnimatedVals({scale: 1, opacity: 1})
32
- setLoaderAnimatedVals({scale: 0, opacity: 0})
33
- requestAnimationFrame(() => {
34
- playerRef.current?.play()
35
- })
36
- }
37
-
38
- useEffect(() => {
39
- // TODO: why was it checking on initiallyLoading.current ?
40
- // if (!isLoading && initiallyLoading.current) {
41
- if (!isLoading) {
42
- runTransition()
43
- }
44
- }, [isLoading])
45
-
46
- const onLoaderAnimationComplete = () => {
47
- setHasLoader(false)
48
- }
49
-
50
- return (
51
- <div style={{position: "relative", background: "red", width: 28}}>
52
- <motion.div
53
- className="status-icon"
54
- style={{position: "absolute", top: -11}}
55
- initial={{scale: 0.5, opacity: 0}}
56
- // initial={{scale: 1, opacity: 1}}
57
- transition={SPRING_BOUNCY}
58
- animate={statusAnimatedVals}
59
- >
60
- <LottiePlayer
61
- className={cx("", {})}
62
- ref={playerRef}
63
- autoplay={false}
64
- loop={false}
65
- speed={1}
66
- keepLastFrame={true}
67
- src={checkmarkAnimation}
68
- style={{
69
- height: `${23}px`,
70
- width: `${23}px`,
71
- // opacity: .15,
72
- }}
73
- // onEvent={this.onPlayerEvent}
74
- />
75
- </motion.div>
76
-
77
- {hasLoader && (
78
- <motion.div
79
- style={{position: "absolute", left: 1, top: -9}}
80
- initial={{scale: 1, opacity: 1}}
81
- // initial={{scale: 1, opacity: 0}}
82
- transition={SPRING_BOUNCY}
83
- animate={loaderAnimatedVals}
84
- onAnimationComplete={onLoaderAnimationComplete}
85
- >
86
- <ActivityIndicator size={19} />
87
- </motion.div>
88
- )}
89
- </div>
90
- )
91
- }
92
-
93
- export default HeaderStatus
@@ -1,65 +0,0 @@
1
- /* @flow */
2
- import assert from "assert"
3
- import {useRef} from "react"
4
- import Toast from "react-bootstrap/Toast"
5
-
6
- import {useNotifications} from "../NotificationsContext"
7
-
8
- import HeaderStatus from "./HeaderStatus"
9
-
10
- // TODO: mv to rb server
11
- // import ack_notification from "rpc!server/notifications/ack_notification"
12
-
13
- import "./notification-item.scss"
14
-
15
-
16
- export const NotificationItem = ({ nodeRef, notification }) => {
17
- const { setNotifications } = useNotifications()
18
-
19
- const { isLoading = false, status = "success", zIndex = 999 } = notification
20
-
21
- const onClick = () => {
22
- console.log("onclicknotif", notification)
23
- }
24
-
25
- // remove notification on close
26
- const onClose = async () => {
27
- console.log("onClose!!!")
28
- if (notification.id) {
29
- console.warn("ACK NOTIFICATION not copied to rb-server yet")
30
- // const res = await ack_notification({
31
- // notification_id: notification.id,
32
- // ack_at_ms: Date.now(),
33
- // })
34
- // assert(res.status === "ok")
35
- }
36
-
37
- setNotifications((current) => {
38
- return current.filter((n) => n.id !== notification.id)
39
- })
40
- }
41
-
42
- // no header when no body
43
- const hasBody = !!notification.body
44
-
45
- return (
46
- <Toast
47
- ref={nodeRef}
48
- id={notification.id}
49
- className={cx("notification-item mt-2 notification-toast", {"has-no-body": !hasBody})}
50
- style={{position: "relative", zIndex}}
51
- onClose={onClose}
52
- animation={false}
53
- >
54
- <Toast.Header className="ps-2 py-2" closeButton={true}>
55
- {notification.icon ? <div>{"<IC>"}</div> : <HeaderStatus isLoading={isLoading} status={status} />}
56
-
57
- <div className="me-auto">{notification.title}</div>
58
- {notification.type === "workflow" && <small>{notification.formatted_timestamp}</small>}
59
- {notification.type === "intent" && <small>INTENT</small>}
60
- </Toast.Header>
61
-
62
- {hasBody && <Toast.Body onClick={onClick}>{notification.body}</Toast.Body>}
63
- </Toast>
64
- )
65
- }
@@ -1,25 +0,0 @@
1
- @import "helpers";
2
-
3
- .notification-item.toast {
4
- max-width: 260px;
5
-
6
- .toast-header {
7
- color: $gray-900;
8
- font-weight: 600;
9
- }
10
-
11
- &.has-no-body {
12
- background: $white !important;
13
-
14
- .toast-header {
15
- background: transparent !important;
16
- border-bottom: none;
17
- }
18
- }
19
-
20
- svg {
21
- path {
22
- fill: $green-500 !important;
23
- }
24
- }
25
- }
@@ -1,37 +0,0 @@
1
- /* @flow */
2
- import {createRef} from "react"
3
- import {CSSTransition, TransitionGroup} from "react-transition-group"
4
-
5
- import ToastContainer from "react-bootstrap/ToastContainer"
6
-
7
- // import {useQuery} from "@rpcbase/client/rts"
8
-
9
- import {useNotifications} from "../NotificationsContext"
10
- import {NotificationItem} from "../NotificationItem"
11
-
12
- // import useLLTs from "./useLLTs"
13
-
14
- import "./notifications-container.scss"
15
-
16
- export const NotificationsContainer = () => {
17
- const {notifications} = useNotifications()
18
-
19
- const renderNotification = (notification, i) => {
20
- const key = notification.id
21
- const nodeRef = createRef()
22
-
23
- return (
24
- <CSSTransition key={notification.id} nodeRef={nodeRef} timeout={200} classNames="notification-item">
25
- <NotificationItem key={key} nodeRef={nodeRef} notification={notification} />
26
- </CSSTransition>
27
- )
28
- }
29
-
30
- return (
31
- <ToastContainer id="notifications-container" position="bottom-end" className="pb-4 pe-3 ps-4">
32
- <TransitionGroup className="transition-list">
33
- {notifications.map(renderNotification)}
34
- </TransitionGroup>
35
- </ToastContainer>
36
- )
37
- }
@@ -1,38 +0,0 @@
1
- @import "helpers";
2
-
3
- $transition-duration: 200ms;
4
-
5
- #notifications-container {
6
- position: absolute;
7
- bottom: 0;
8
- right: 0;
9
- max-height: 100vh;
10
- overflow-y: scroll;
11
-
12
- .action-notification {
13
- cursor: pointer;
14
- }
15
-
16
- .transition-list {
17
- transition: max-height $transition-duration ease-in-out;
18
- }
19
-
20
- .notification-item-enter {
21
- opacity: 0;
22
- }
23
-
24
- .notification-item-enter-active {
25
- opacity: 1;
26
- transition: opacity 400ms;
27
- }
28
-
29
- .notification-item-exit {
30
- opacity: 1;
31
- }
32
-
33
- .notification-item-exit-active {
34
- transform: translateX(390px);
35
-
36
- transition: all $transition-duration ease-out;
37
- }
38
- }
@@ -1,28 +0,0 @@
1
- /* @flow */
2
- import assert from "assert"
3
- import {useEffect, useState} from "react"
4
-
5
- // TODO: fix ltts import to rb
6
- // import get_llts from "rpc!server/notifications/llt/get_llts"
7
-
8
-
9
- const useLLTs = () => {
10
- const [llts, setLLTs] = useState([])
11
-
12
- useEffect(() => {
13
- const load = async() => {
14
- // const res = await get_llts({
15
- // env_id: envContext.envId,
16
- // })
17
- const res = {status: "ok", llts: []}
18
- assert(res.status === "ok", "unable to retrieve llts")
19
- setLLTs(res.llts)
20
- }
21
-
22
- load()
23
- }, [])
24
-
25
- return llts
26
- }
27
-
28
- export default useLLTs