@rpcbase/client 0.230.0 → 0.232.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.
- package/package.json +13 -114
- package/src/apiClient/getServerApiClient.ts +131 -0
- package/src/apiClient/index.ts +86 -0
- package/src/index.ts +3 -0
- package/src/initClient.ts +32 -0
- package/src/types.ts +7 -0
- package/AppProvider/AnalyticsContainer.js +0 -56
- package/AppProvider/debug.js +0 -4
- package/AppProvider/index.tsx +0 -79
- package/access-control/ACLForm/components/GrantField/OpSelector.tsx +0 -129
- package/access-control/ACLForm/components/GrantField/ResourceSelector.tsx +0 -86
- package/access-control/ACLForm/components/GrantField/UsersSelector.tsx +0 -96
- package/access-control/ACLForm/components/GrantField/grant-field.scss +0 -26
- package/access-control/ACLForm/components/GrantField/icons/CheckMark.tsx +0 -16
- package/access-control/ACLForm/components/GrantField/icons/CollapseArrow.tsx +0 -14
- package/access-control/ACLForm/components/GrantField/icons/ExpandArrow.tsx +0 -14
- package/access-control/ACLForm/components/GrantField/index.tsx +0 -91
- package/access-control/ACLForm/components/GrantsList.tsx +0 -48
- package/access-control/ACLForm/components/RoleForm.tsx +0 -134
- package/access-control/ACLForm/components/RoleView.tsx +0 -115
- package/access-control/ACLForm/components/RolesList.tsx +0 -79
- package/access-control/ACLForm/components/constants.tsx +0 -1
- package/access-control/ACLForm/components/resolver.ts +0 -57
- package/access-control/ACLForm/components/role-form.scss +0 -19
- package/access-control/ACLForm/index.tsx +0 -48
- package/access-control/ACLModal/acl-modal.scss +0 -7
- package/access-control/ACLModal/index.tsx +0 -66
- package/access-control/PolicyEditor/TargetSelector/QueryBuilder.tsx +0 -48
- package/access-control/PolicyEditor/TargetSelector/index.tsx +0 -5
- package/access-control/PolicyEditor/TargetSelector/query-builder.scss +0 -9
- package/access-control/PolicyEditor/index.tsx +0 -165
- package/access-control/index.ts +0 -3
- package/apiClient.js +0 -15
- package/auth/authProps.js +0 -8
- package/auth/components/AccountsList/AccountListItem.js +0 -61
- package/auth/components/AccountsList/account-list-item.scss +0 -5
- package/auth/components/AccountsList/index.js +0 -17
- package/auth/components/Footer/index.js +0 -11
- package/auth/components/ForgotPassword/forgot-password.scss +0 -37
- package/auth/components/ForgotPassword/index.js +0 -114
- package/auth/components/SetNewPassword/index.js +0 -130
- package/auth/components/SetNewPassword/set-new-password.scss +0 -47
- package/auth/components/SignIn/SignInEmailForm.tsx +0 -115
- package/auth/components/SignIn/index.js +0 -69
- package/auth/components/SignIn/sign-in.scss +0 -56
- package/auth/components/SignOut/index.js +0 -144
- package/auth/components/SignOut/sign-out.scss +0 -34
- package/auth/components/SignUp/SignUpEmailForm.tsx +0 -98
- package/auth/components/SignUp/index.js +0 -66
- package/auth/components/SignUp/sign-up.scss +0 -56
- package/auth/getTenantId.js +0 -12
- package/auth/getUid.js +0 -11
- package/auth/helpers/redirectSignIn.native.js +0 -9
- package/auth/helpers/redirectSignIn.web.js +0 -7
- package/auth/index.js +0 -146
- package/auth/signOut.js +0 -20
- package/auth/useAuthRouter.js +0 -56
- package/env.d.ts +0 -3
- package/firebase/index.js +0 -1
- package/firebase/sw.js +0 -1
- package/form/FileInput/FileUploadContext.tsx +0 -162
- package/form/FileInput/FileUploadForm/index.tsx +0 -139
- package/form/FileInput/FileUploadForm/usePreventUnload.js +0 -21
- package/form/FileInput/UploadButton.tsx +0 -23
- package/form/FileInput/constants.ts +0 -16
- package/form/FileInput/file-input.scss +0 -1
- package/form/FileInput/index.tsx +0 -21
- package/form/FileInput/upload-worker/get_file_hash.js +0 -63
- package/form/FileInput/upload-worker/index.js +0 -16
- package/form/FileInput/upload-worker/no_compress_exts.ts +0 -33
- package/form/FileInput/upload-worker/upload_file.js +0 -129
- package/form/Form.tsx +0 -23
- package/form/Input.tsx +0 -62
- package/form/SubmitButton/index.tsx +0 -58
- package/form/hook-form.tsx +0 -7
- package/form/index.tsx +0 -5
- package/getBaseUrl.js +0 -14
- package/getObjectId.ts +0 -31
- package/hashState.js +0 -158
- package/helpers/createBatcher/index.js +0 -36
- package/helpers/getInitials.js +0 -39
- package/helpers/onReady.js +0 -15
- package/helpers/post.js +0 -18
- package/helpers/postRPC.js +0 -42
- package/helpers/useRPC.js +0 -41
- package/helpers/useStoredValue/batchedGetStoredValues.js +0 -30
- package/helpers/useStoredValue/index.js +0 -107
- package/helpers/useStoredValue/setStoredValues.js +0 -14
- package/i18n/en/rb.nav.json +0 -13
- package/i18n/en/rb.sign_in.json +0 -11
- package/i18n/en/rb.sign_out.json +0 -5
- package/i18n/fr/rb.sign_in.json +0 -11
- package/i18n/fr/rb.sign_out.json +0 -5
- package/i18n/index.js +0 -63
- package/index.js +0 -6
- package/isEqualValues.js +0 -47
- package/jest.config.js +0 -16
- package/notifications/Notification/index.js +0 -36
- package/notifications/Notification/notification.scss +0 -1
- package/notifications/NotificationItem/HeaderStatus.js +0 -93
- package/notifications/NotificationItem/index.js +0 -65
- package/notifications/NotificationItem/notification-item.scss +0 -25
- package/notifications/NotificationsContainer/index.js +0 -37
- package/notifications/NotificationsContainer/notifications-container.scss +0 -38
- package/notifications/NotificationsContainer/useLLTs.js +0 -28
- package/notifications/NotificationsContext/index.js +0 -71
- package/notifications/NotificationsContext/useNotificationsList.js +0 -75
- package/notifications/NotificationsSettingsModal/SettingsForm.js +0 -52
- package/notifications/NotificationsSettingsModal/index.js +0 -48
- package/notifications/NotificationsSettingsModal/notifications-settings.scss +0 -1
- package/notifications/config.js +0 -1
- package/notifications/index.js +0 -4
- package/page.js +0 -9
- package/publish-output.txt +0 -0
- package/rpc.js +0 -32
- package/rr-trace/get_fingerprint.js +0 -10
- package/rr-trace/get_perf_vitals.js +0 -24
- package/rr-trace/get_session_id.js +0 -29
- package/rr-trace/index.js +0 -138
- package/rr-trace/write_session_data.js +0 -86
- package/rts/boot.js +0 -3
- package/rts/getUseDocument.js +0 -21
- package/rts/getUseQuery/index.js +0 -233
- package/rts/getUseQuery/useData.js +0 -55
- package/rts/index.js +0 -10
- package/rts/rts.js +0 -243
- package/rts/signout.ts +0 -8
- package/rts/store/constants.js +0 -3
- package/rts/store/debug.js +0 -24
- package/rts/store/get_collection.js +0 -55
- package/rts/store/index.js +0 -100
- package/rts/store/replace_query_keys.js +0 -31
- package/rts/store/satisfies_projection.js +0 -32
- package/rts/store/update_docs.js +0 -47
- package/storage/index.jest.js +0 -15
- package/storage/index.native.js +0 -38
- package/storage/index.web.js +0 -25
- package/types.ts +0 -6
- package/ui/ActivityIndicator/index.js +0 -113
- package/ui/Avatar/index.native.js +0 -31
- package/ui/Avatar/index.web.js +0 -37
- package/ui/Avatar/styles.js +0 -41
- package/ui/ErrorBoundary/index.js +0 -12
- package/ui/ExpandableFloatView/exp.scss +0 -15
- package/ui/ExpandableFloatView/index.tsx +0 -123
- package/ui/ExpandableFloatView/useBackdrop.js +0 -45
- package/ui/LottiePlayer/LottiePlayer.js +0 -4
- package/ui/LottiePlayer/index.js +0 -8
- package/ui/Modal/HashStateModal.js +0 -30
- package/ui/Modal/Modal.js +0 -93
- package/ui/Modal/ModalForm/AlertBanner.js +0 -82
- package/ui/Modal/ModalForm/index.js +0 -188
- package/ui/Modal/ModalForm/modal-form.scss +0 -63
- package/ui/Modal/index.js +0 -10
- package/ui/Modal/modal.scss +0 -101
- package/ui/Modal/withHashStateModal.js +0 -24
- package/ui/RedboxError/index.js +0 -3
- package/ui/Search/SearchHistory/index.js +0 -45
- package/ui/Search/SearchHistory/search-history.scss +0 -9
- package/ui/Search/SearchHistory/useSearchHistory.tsx +0 -57
- package/ui/Search/SearchResults/index.tsx +0 -90
- package/ui/Search/index.tsx +0 -298
- package/ui/Search/search.scss +0 -0
- package/ui/SelectPills/index.tsx +0 -96
- package/ui/SelectPills/select-pills.scss +0 -66
- package/ui/Tabs/index.tsx +0 -161
- package/ui/Tabs/tabs.scss +0 -53
- package/ui/Tree/index.js +0 -257
- package/ui/Tree/model.js +0 -71
- package/ui/Tree/node.js +0 -112
- package/ui/Tree/tree.scss +0 -98
- package/ui/UserAvatar/default_colors.json +0 -82
- package/ui/UserAvatar/index.js +0 -55
- package/ui/View/index.tsx +0 -17
- package/ui/View/index.web.js +0 -44
- package/ui/animations/checkmark.json +0 -1
- package/ui/helpers/SizeContext/index.tsx +0 -11
- package/ui/helpers/helpers.scss +0 -61
- package/ui/helpers/index.ts +0 -6
- package/ui/helpers/stopEventPropagation.js +0 -5
- package/ui/helpers/useActiveListItemIndex/index.tsx +0 -45
- package/ui/helpers/useScrollSelectorIntoView/index.tsx +0 -14
- package/ui/helpers/useThrottledMeasure/index.js +0 -47
- package/ui/helpers/withSuspense/index.js +0 -37
- package/ui/icons/AddAccount.tsx +0 -5
- package/ui/icons/Billing.tsx +0 -6
- package/ui/icons/Close.tsx +0 -14
- package/ui/icons/Organization.tsx +0 -5
- package/ui/icons/Signout.tsx +0 -5
- package/ui/icons/index.tsx +0 -6
- package/ui/nav/AccountsDropdown/SwitchAccounts.tsx +0 -28
- package/ui/nav/AccountsDropdown/accounts-dropdown.scss +0 -51
- package/ui/nav/AccountsDropdown/index.tsx +0 -90
- package/ui/nav/AccountsToggle/index.tsx +0 -24
- package/ui/nav/ContentView/ContentViewContext.ts +0 -23
- package/ui/nav/ContentView/index.tsx +0 -115
- package/ui/nav/HeaderContainer/header.scss +0 -52
- package/ui/nav/HeaderContainer/index.tsx +0 -23
- package/ui/nav/HeaderContainer/variables.scss +0 -1
- package/ui/nav/MorphingDropdown/MorphingDropdownContext.tsx +0 -151
- package/ui/nav/MorphingDropdown/MorphingDropdownMenu.tsx +0 -38
- package/ui/nav/MorphingDropdown/MorphingDropdownPortal.tsx +0 -166
- package/ui/nav/MorphingDropdown/MorphingDropdownToggle.tsx +0 -34
- package/ui/nav/MorphingDropdown/index.tsx +0 -16
- package/ui/nav/MorphingDropdown/morphing-dropdown.scss +0 -35
- package/ui/nav/NotificationsDropdown/index.tsx +0 -52
- package/ui/nav/NotificationsDropdown/notifications-dropdown.scss +0 -5
- package/ui/nav/NotificationsToggle/NotificationsGlyph.tsx +0 -54
- package/ui/nav/NotificationsToggle/index.tsx +0 -12
- package/ui/nav/NotificationsToggle/notification-animation.json +0 -1
- package/ui/nav/NotificationsToggle/notifications-toggle.scss +0 -26
- package/ui/nav/SidebarContainer/index.tsx +0 -48
- package/ui/nav/SidebarContainer/sidebar-container.scss +0 -21
- package/ui/nav/SlideoutContainer/components/Body.tsx +0 -19
- package/ui/nav/SlideoutContainer/components/Header.tsx +0 -23
- package/ui/nav/SlideoutContainer/components/Wrapper.tsx +0 -46
- package/ui/nav/SlideoutContainer/index.tsx +0 -50
- package/ui/nav/SlideoutContainer/slideout-container.scss +0 -40
- package/ui/nav/index.ts +0 -13
- package/ui/oauth/GitHub.js +0 -38
- package/ui/oauth/getGitHubSigninUrl.js +0 -30
- package/ui/oauth/index.js +0 -9
- package/ui/oauth/oauth.scss +0 -16
- package/ui/sortable-hoc/AutoScroller.js +0 -76
- package/ui/sortable-hoc/DragHandle.js +0 -31
- package/ui/sortable-hoc/Manager.js +0 -54
- package/ui/sortable-hoc/README.md +0 -1
- package/ui/sortable-hoc/SortableContainer/defaultGetHelperDimensions.js +0 -7
- package/ui/sortable-hoc/SortableContainer/defaultShouldCancelStart.js +0 -24
- package/ui/sortable-hoc/SortableContainer/index.js +0 -994
- package/ui/sortable-hoc/SortableContainer/props.js +0 -81
- package/ui/sortable-hoc/SortableElement.js +0 -111
- package/ui/sortable-hoc/SortableHandle.js +0 -45
- package/ui/sortable-hoc/drag-handle.scss +0 -14
- package/ui/sortable-hoc/index.js +0 -9
- package/ui/sortable-hoc/utils.js +0 -292
- package/ui/springs.ts +0 -17
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
/* @flow */
|
|
2
|
-
import _get from "lodash/get"
|
|
3
|
-
import {useState, useEffect} from "react"
|
|
4
|
-
|
|
5
|
-
import {useFormContext} from "react-hook-form"
|
|
6
|
-
import {Typeahead} from "react-bootstrap-typeahead"
|
|
7
|
-
import Form from "react-bootstrap/Form"
|
|
8
|
-
|
|
9
|
-
import {GRANTS_FIELD} from "../constants"
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
export const ResourceSelector = ({field, index, update}) => {
|
|
13
|
-
const {
|
|
14
|
-
formState: {errors},
|
|
15
|
-
setValue,
|
|
16
|
-
} = useFormContext()
|
|
17
|
-
|
|
18
|
-
const fieldKey = `${GRANTS_FIELD}.${index}.resources`
|
|
19
|
-
|
|
20
|
-
const err = _get(errors, fieldKey, null)
|
|
21
|
-
|
|
22
|
-
// const [selectedAll, setSelectedAll] = useState(field.resources?.[0] === "*")
|
|
23
|
-
const [selectedAll, setSelectedAll] = useState(false)
|
|
24
|
-
|
|
25
|
-
const [users, setUsers] = useState([])
|
|
26
|
-
const [selected, setSelected] = useState([])
|
|
27
|
-
|
|
28
|
-
useEffect(() => {
|
|
29
|
-
setUsers([{name: "tmp res 1"}, {name: "tmp res 2"}])
|
|
30
|
-
}, [setUsers])
|
|
31
|
-
|
|
32
|
-
const updateValue = (val) => {
|
|
33
|
-
setValue(fieldKey, val, {
|
|
34
|
-
shouldTouch: true,
|
|
35
|
-
shouldValidate: !!err, // revalidate if there is an error
|
|
36
|
-
})
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
const onChangeSelectedAll = (e) => {
|
|
40
|
-
const {checked} = e.target
|
|
41
|
-
console.log("Ochahge", checked)
|
|
42
|
-
setSelectedAll(checked)
|
|
43
|
-
updateValue(checked ? ["*"] : null)
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
const onSelectResource = (sel) => {
|
|
47
|
-
setSelected(sel)
|
|
48
|
-
updateValue(sel)
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
return (
|
|
52
|
-
<div className="mb-3">
|
|
53
|
-
<div className="h6 fw-bold">On Resources:</div>
|
|
54
|
-
<div>
|
|
55
|
-
All and any new resources in this group:
|
|
56
|
-
<Form.Check
|
|
57
|
-
className="d-block w-100"
|
|
58
|
-
type="switch"
|
|
59
|
-
id={`field-${field.id}-${index}-res-all-switch`}
|
|
60
|
-
label={selectedAll ? "Grant applies to every resource in this group" : "Not applied"}
|
|
61
|
-
// TODO: is this a bug ? why does it need both value and checked
|
|
62
|
-
// this was fixed by using field.id and not index I think
|
|
63
|
-
checked={selectedAll}
|
|
64
|
-
value={selectedAll}
|
|
65
|
-
onChange={onChangeSelectedAll}
|
|
66
|
-
/>
|
|
67
|
-
<div className={cx({"text-secondary": selectedAll})}>
|
|
68
|
-
<i>OR:</i> Select Resources:
|
|
69
|
-
</div>
|
|
70
|
-
<Typeahead
|
|
71
|
-
id={`field-${field.id}-${index}-input-role-resources`}
|
|
72
|
-
isInvalid={!!err}
|
|
73
|
-
labelKey="name"
|
|
74
|
-
multiple
|
|
75
|
-
highlightOnlyResult
|
|
76
|
-
disabled={selectedAll}
|
|
77
|
-
onChange={onSelectResource}
|
|
78
|
-
options={users}
|
|
79
|
-
placeholder="Select items..."
|
|
80
|
-
selected={selected}
|
|
81
|
-
/>
|
|
82
|
-
{!!err && <p className="text-danger">{err.message}</p>}
|
|
83
|
-
</div>
|
|
84
|
-
</div>
|
|
85
|
-
)
|
|
86
|
-
}
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
/* @flow */
|
|
2
|
-
import assert from "assert"
|
|
3
|
-
import _get from "lodash/get"
|
|
4
|
-
import {useState, useEffect} from "react"
|
|
5
|
-
|
|
6
|
-
import {useFormContext} from "react-hook-form"
|
|
7
|
-
import {Typeahead} from "react-bootstrap-typeahead"
|
|
8
|
-
import Form from "react-bootstrap/Form"
|
|
9
|
-
|
|
10
|
-
import {GRANTS_FIELD} from "../constants"
|
|
11
|
-
|
|
12
|
-
// import list_users from "rpc!server/users/list_users"
|
|
13
|
-
|
|
14
|
-
// TODO: user selector render avatar next to name
|
|
15
|
-
export const UsersSelector = ({field, index}) => {
|
|
16
|
-
const {
|
|
17
|
-
formState: {errors},
|
|
18
|
-
setValue,
|
|
19
|
-
} = useFormContext()
|
|
20
|
-
|
|
21
|
-
const fieldKey = `${GRANTS_FIELD}.${index}.users`
|
|
22
|
-
|
|
23
|
-
const err = _get(errors, fieldKey, null)
|
|
24
|
-
|
|
25
|
-
const [selectedAll, setSelectedAll] = useState(field.resources?.[0] === "*")
|
|
26
|
-
|
|
27
|
-
const [users, setUsers] = useState([])
|
|
28
|
-
const [selected, setSelected] = useState([])
|
|
29
|
-
|
|
30
|
-
useEffect(() => {
|
|
31
|
-
const load = async() => {
|
|
32
|
-
console.log("LOAD LIST USERS NOT IMPLEMENTED")
|
|
33
|
-
// const res = await list_users()
|
|
34
|
-
|
|
35
|
-
// assert(res.status === "ok")
|
|
36
|
-
// // map user props to get a label, if no name, fallback to email
|
|
37
|
-
// const result = res.users.map((user) => {
|
|
38
|
-
// const name = `${user.first_name} ${user.last_name}`.trim()
|
|
39
|
-
// user.label = name || user.email
|
|
40
|
-
// return user
|
|
41
|
-
// })
|
|
42
|
-
// setUsers(result)
|
|
43
|
-
}
|
|
44
|
-
load()
|
|
45
|
-
}, [setUsers])
|
|
46
|
-
|
|
47
|
-
const updateValue = (val) => {
|
|
48
|
-
setValue(fieldKey, val, {
|
|
49
|
-
shouldTouch: true,
|
|
50
|
-
shouldValidate: !!err, // revalidate if there is an error
|
|
51
|
-
})
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
const onChangeSelectedAll = (e) => {
|
|
55
|
-
const {checked} = e.target
|
|
56
|
-
setSelectedAll(checked)
|
|
57
|
-
updateValue(checked ? ["*"] : null)
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
const onSelectUsers = (sel) => {
|
|
61
|
-
setSelected(sel)
|
|
62
|
-
updateValue(sel.map((s) => s._id))
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
return (
|
|
66
|
-
<div className="mb-2">
|
|
67
|
-
<div className="h6 fw-bold">To Users:</div>
|
|
68
|
-
<div>
|
|
69
|
-
All and any new users in this group:
|
|
70
|
-
<Form.Check
|
|
71
|
-
className="d-block w-100"
|
|
72
|
-
type="switch"
|
|
73
|
-
id={`field-${field.id}-${index}-users-all-switch`}
|
|
74
|
-
label={selectedAll ? "Grant applies to every user in this group" : "Not applied"}
|
|
75
|
-
checked={selectedAll}
|
|
76
|
-
value={selectedAll}
|
|
77
|
-
onChange={onChangeSelectedAll}
|
|
78
|
-
/>
|
|
79
|
-
<div className={cx({"text-secondary": selectedAll})}>OR: Select Users:</div>
|
|
80
|
-
<Typeahead
|
|
81
|
-
id={`field-${field.id}-${index}-input-role-users`}
|
|
82
|
-
isInvalid={!!err}
|
|
83
|
-
labelKey={(option) => `${option.label} ${option.email}`}
|
|
84
|
-
multiple
|
|
85
|
-
highlightOnlyResult
|
|
86
|
-
disabled={selectedAll}
|
|
87
|
-
onChange={onSelectUsers}
|
|
88
|
-
options={users}
|
|
89
|
-
placeholder="Select users..."
|
|
90
|
-
selected={selected}
|
|
91
|
-
/>
|
|
92
|
-
{!!err && <p className="text-danger">{err.message}</p>}
|
|
93
|
-
</div>
|
|
94
|
-
</div>
|
|
95
|
-
)
|
|
96
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
@import "helpers";
|
|
2
|
-
|
|
3
|
-
.grant-field-card {
|
|
4
|
-
&:not(:first-of-type) {
|
|
5
|
-
// TODO: what is the way to reuse bootstrap classes here??
|
|
6
|
-
margin-top: $spacer;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
.grant-field-remove-button {
|
|
10
|
-
position: absolute;
|
|
11
|
-
width: 14px;
|
|
12
|
-
height: 14px;
|
|
13
|
-
right: 0;
|
|
14
|
-
top: 0;
|
|
15
|
-
cursor: pointer;
|
|
16
|
-
color: $gray-500;
|
|
17
|
-
|
|
18
|
-
&:hover {
|
|
19
|
-
color: $gray-700;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
&:active {
|
|
23
|
-
color: $gray-900;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
export const CheckMark = ({hide = true}) => (
|
|
2
|
-
<svg
|
|
3
|
-
style={{
|
|
4
|
-
marginLeft: -18,
|
|
5
|
-
marginTop: -4,
|
|
6
|
-
marginRight: 3,
|
|
7
|
-
visibility: hide ? "hidden" : undefined,
|
|
8
|
-
}}
|
|
9
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
10
|
-
viewBox="0 0 64 64"
|
|
11
|
-
width={18}
|
|
12
|
-
height={18}
|
|
13
|
-
>
|
|
14
|
-
<path fill="#0d6efd" d="M27 55L6 33 9 29 26 41 55 12 59 16z" />
|
|
15
|
-
</svg>
|
|
16
|
-
)
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export const CollapseArrow = () => (
|
|
2
|
-
<svg
|
|
3
|
-
style={{marginRight: 4}}
|
|
4
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
5
|
-
viewBox="0 0 30 30"
|
|
6
|
-
width={21}
|
|
7
|
-
height={21}
|
|
8
|
-
>
|
|
9
|
-
<path
|
|
10
|
-
fill="currentColor"
|
|
11
|
-
d="M 14.984375 9 A 1.0001 1.0001 0 0 0 14.292969 9.2929688 L 4.2929688 19.292969 A 1.0001 1.0001 0 1 0 5.7070312 20.707031 L 15 11.414062 L 24.292969 20.707031 A 1.0001 1.0001 0 1 0 25.707031 19.292969 L 15.707031 9.2929688 A 1.0001 1.0001 0 0 0 14.984375 9 z"
|
|
12
|
-
/>
|
|
13
|
-
</svg>
|
|
14
|
-
)
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export const ExpandArrow = () => (
|
|
2
|
-
<svg
|
|
3
|
-
style={{marginRight: 4}}
|
|
4
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
5
|
-
viewBox="0 0 30 30"
|
|
6
|
-
width={21}
|
|
7
|
-
height={21}
|
|
8
|
-
>
|
|
9
|
-
<path
|
|
10
|
-
fill="currentColor"
|
|
11
|
-
d="M 24.990234 8.9863281 A 1.0001 1.0001 0 0 0 24.292969 9.2929688 L 15 18.585938 L 5.7070312 9.2929688 A 1.0001 1.0001 0 0 0 4.9902344 8.9902344 A 1.0001 1.0001 0 0 0 4.2929688 10.707031 L 14.292969 20.707031 A 1.0001 1.0001 0 0 0 15.707031 20.707031 L 25.707031 10.707031 A 1.0001 1.0001 0 0 0 24.990234 8.9863281 z"
|
|
12
|
-
/>
|
|
13
|
-
</svg>
|
|
14
|
-
)
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
import {useState} from "react"
|
|
2
|
-
import Collapse from "react-bootstrap/Collapse"
|
|
3
|
-
|
|
4
|
-
import {useFormContext} from "react-hook-form"
|
|
5
|
-
|
|
6
|
-
import {CloseIcon} from "../../../../ui/icons"
|
|
7
|
-
import {View} from "../../../../ui/View"
|
|
8
|
-
|
|
9
|
-
import {OpSelector} from "./OpSelector"
|
|
10
|
-
import {ResourceSelector} from "./ResourceSelector"
|
|
11
|
-
import {UsersSelector} from "./UsersSelector"
|
|
12
|
-
|
|
13
|
-
import {ExpandArrow} from "./icons/ExpandArrow"
|
|
14
|
-
import {CollapseArrow} from "./icons/CollapseArrow"
|
|
15
|
-
|
|
16
|
-
import "./grant-field.scss"
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
export const GrantField = ({remove, field, index}) => {
|
|
20
|
-
const {getValues} = useFormContext()
|
|
21
|
-
|
|
22
|
-
const {_isEditing} = getValues()
|
|
23
|
-
|
|
24
|
-
const shouldInitiallyBeOpen = () => {
|
|
25
|
-
if (_isEditing && field.ops && field.resources && field.users) {
|
|
26
|
-
return false
|
|
27
|
-
}
|
|
28
|
-
return true
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
const [isCollapseOpen, setIsCollapseOpen] = useState(shouldInitiallyBeOpen())
|
|
32
|
-
// used to remove only after transition is complete
|
|
33
|
-
const [scheduledRemove, setScheduledRemove] = useState(false)
|
|
34
|
-
|
|
35
|
-
const removeField = () => {
|
|
36
|
-
remove(index)
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
const onExited = () => {
|
|
40
|
-
if (scheduledRemove) {
|
|
41
|
-
removeField()
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
const onClickRemove = () => {
|
|
46
|
-
if (isCollapseOpen) {
|
|
47
|
-
setScheduledRemove(true)
|
|
48
|
-
setIsCollapseOpen(false)
|
|
49
|
-
} else {
|
|
50
|
-
removeField()
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
const onClickCollapse = () => setIsCollapseOpen(!isCollapseOpen)
|
|
55
|
-
|
|
56
|
-
return (
|
|
57
|
-
<div className="card grant-field-card p-2">
|
|
58
|
-
{/* Remove Button */}
|
|
59
|
-
<View
|
|
60
|
-
className="grant-field-remove-button mt-3 me-3"
|
|
61
|
-
onClick={onClickRemove}
|
|
62
|
-
tooltip="Remove Grant"
|
|
63
|
-
>
|
|
64
|
-
<CloseIcon size={14} />
|
|
65
|
-
</View>
|
|
66
|
-
|
|
67
|
-
<div className="">
|
|
68
|
-
Allow create, read update delete on hardcoded
|
|
69
|
-
<br />
|
|
70
|
-
grant summary on users Test User, and Another One
|
|
71
|
-
</div>
|
|
72
|
-
|
|
73
|
-
<Collapse appear in={isCollapseOpen} onExited={onExited}>
|
|
74
|
-
<div>
|
|
75
|
-
<OpSelector field={field} index={index} />
|
|
76
|
-
<ResourceSelector field={field} index={index} />
|
|
77
|
-
<UsersSelector field={field} index={index} />
|
|
78
|
-
</div>
|
|
79
|
-
</Collapse>
|
|
80
|
-
|
|
81
|
-
<button
|
|
82
|
-
type="button"
|
|
83
|
-
className="btn btn-link btn-collapse-expand d-flex flex-row align-items-center ps-0"
|
|
84
|
-
onClick={onClickCollapse}
|
|
85
|
-
>
|
|
86
|
-
{isCollapseOpen ? <CollapseArrow /> : <ExpandArrow />}
|
|
87
|
-
{isCollapseOpen ? "Collapse" : "Expand"}
|
|
88
|
-
</button>
|
|
89
|
-
</div>
|
|
90
|
-
)
|
|
91
|
-
}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import {useFieldArray, useFormContext} from "react-hook-form"
|
|
2
|
-
|
|
3
|
-
import {GrantField} from "./GrantField"
|
|
4
|
-
import {GRANTS_FIELD} from "./constants"
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export const GrantsList = () => {
|
|
8
|
-
// TODO: integrate sortable-hoc list
|
|
9
|
-
// const {fields, append, prepend, remove, swap, update, move, insert} = useFieldArray({
|
|
10
|
-
const {
|
|
11
|
-
formState: {errors},
|
|
12
|
-
} = useFormContext()
|
|
13
|
-
const {fields, append, remove, update} = useFieldArray({name: GRANTS_FIELD})
|
|
14
|
-
|
|
15
|
-
return (
|
|
16
|
-
<>
|
|
17
|
-
<div className="mt-2">
|
|
18
|
-
<label className="h6">Grants</label>
|
|
19
|
-
{fields.map((field, index) => (
|
|
20
|
-
<GrantField
|
|
21
|
-
// IMPORTANT: key must be field id to avoid rerenders
|
|
22
|
-
key={field.id}
|
|
23
|
-
index={index}
|
|
24
|
-
field={field}
|
|
25
|
-
remove={remove}
|
|
26
|
-
update={update}
|
|
27
|
-
/>
|
|
28
|
-
))}
|
|
29
|
-
{fields.length === 0 && (
|
|
30
|
-
<div className="text-secondary">This role doesn't have any Grants</div>
|
|
31
|
-
)}
|
|
32
|
-
{errors.grants?.message && <div className="text-danger">{errors.grants.message}</div>}
|
|
33
|
-
</div>
|
|
34
|
-
|
|
35
|
-
<button
|
|
36
|
-
type="button"
|
|
37
|
-
className="btn btn-light mt-2 px-3"
|
|
38
|
-
onClick={() => {
|
|
39
|
-
append({})
|
|
40
|
-
// trigger()
|
|
41
|
-
}}
|
|
42
|
-
style={{width: "fit-content"}}
|
|
43
|
-
>
|
|
44
|
-
Add {fields.length > 0 && "another"} Grant
|
|
45
|
-
</button>
|
|
46
|
-
</>
|
|
47
|
-
)
|
|
48
|
-
}
|
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
/* eslint no-unused-vars: "warn" */
|
|
2
|
-
import assert from "assert"
|
|
3
|
-
import {useState} from "react"
|
|
4
|
-
import {useForm, FormProvider} from "react-hook-form"
|
|
5
|
-
import Collapse from "react-bootstrap/Collapse"
|
|
6
|
-
|
|
7
|
-
import {SubmitButton} from "@rpcbase/client/form"
|
|
8
|
-
|
|
9
|
-
import {CloseIcon} from "../../../ui/icons/Close"
|
|
10
|
-
import {View} from "../../../ui/View"
|
|
11
|
-
|
|
12
|
-
import {resolver} from "./resolver"
|
|
13
|
-
import {GrantsList} from "./GrantsList"
|
|
14
|
-
|
|
15
|
-
// import create_role from "rpc!server/access-control/create_role"
|
|
16
|
-
|
|
17
|
-
import "./role-form.scss"
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
export const RoleForm = ({onDone}) => {
|
|
21
|
-
const [isLoading, setIsLoading] = useState(false)
|
|
22
|
-
|
|
23
|
-
// react hook form submit on edit
|
|
24
|
-
// https://stackoverflow.com/a/70119332
|
|
25
|
-
const form = useForm({
|
|
26
|
-
defaultValues: {
|
|
27
|
-
name: "",
|
|
28
|
-
description: "",
|
|
29
|
-
grants: [{}],
|
|
30
|
-
},
|
|
31
|
-
resolver,
|
|
32
|
-
reValidateMode: "onChange",
|
|
33
|
-
})
|
|
34
|
-
|
|
35
|
-
const {
|
|
36
|
-
register,
|
|
37
|
-
handleSubmit,
|
|
38
|
-
// watch,
|
|
39
|
-
getValues,
|
|
40
|
-
formState: {errors},
|
|
41
|
-
} = form
|
|
42
|
-
|
|
43
|
-
const onSubmit = async(data) => {
|
|
44
|
-
// console.log("submit", group_id, data)
|
|
45
|
-
setIsLoading(true)
|
|
46
|
-
// const res = await create_role({...data})
|
|
47
|
-
// assert(res.status === "ok")
|
|
48
|
-
// TODO: error handling here
|
|
49
|
-
setIsLoading(false)
|
|
50
|
-
onDone()
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
// TODO: ask for user confirmation is form is touched
|
|
54
|
-
// TODO: should we save touched fields in url hashState?
|
|
55
|
-
const onClickCancel = () => {
|
|
56
|
-
onDone()
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
const onClickRemove = () => {
|
|
60
|
-
onDone()
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
// useEffect(() => {
|
|
64
|
-
// console.log("le vals", getValues())
|
|
65
|
-
// }, [formState])
|
|
66
|
-
|
|
67
|
-
return (
|
|
68
|
-
<FormProvider {...form}>
|
|
69
|
-
<div className="mx-3" style={{position: "relative"}}>
|
|
70
|
-
<Collapse appear in={true}>
|
|
71
|
-
<form className="mt-2 mb-1 card" onSubmit={handleSubmit(onSubmit)}>
|
|
72
|
-
<div className="p-2">
|
|
73
|
-
<div className="h6 fw-bold">Create New Role:</div>
|
|
74
|
-
<div className="mt-2">
|
|
75
|
-
<label htmlFor="input-role-name" className="h6">
|
|
76
|
-
Name
|
|
77
|
-
</label>
|
|
78
|
-
<input
|
|
79
|
-
type="text"
|
|
80
|
-
className={cx("form-control", {"is-invalid": !!errors.name})}
|
|
81
|
-
id="input-role-name"
|
|
82
|
-
{...register("name", {required: true})}
|
|
83
|
-
placeholder="Role Name"
|
|
84
|
-
/>
|
|
85
|
-
{errors.name && <div className="text-danger">{errors.name.message}</div>}
|
|
86
|
-
</div>
|
|
87
|
-
|
|
88
|
-
<div className="mt-2">
|
|
89
|
-
<label htmlFor="input-view-name" className="h6">
|
|
90
|
-
Description
|
|
91
|
-
</label>
|
|
92
|
-
<input
|
|
93
|
-
type="text"
|
|
94
|
-
className={cx("form-control", {"is-invalid": !!errors.description})}
|
|
95
|
-
id="input-role-description"
|
|
96
|
-
{...register("description", {required: true})}
|
|
97
|
-
placeholder="Description"
|
|
98
|
-
/>
|
|
99
|
-
{errors.description && (
|
|
100
|
-
<div className="text-danger">{errors.description.message}</div>
|
|
101
|
-
)}
|
|
102
|
-
</div>
|
|
103
|
-
|
|
104
|
-
{/* Grants list */}
|
|
105
|
-
<GrantsList />
|
|
106
|
-
</div>
|
|
107
|
-
|
|
108
|
-
<div className="card-footer">
|
|
109
|
-
<SubmitButton className="me-2" isLoading={isLoading}>
|
|
110
|
-
{isLoading ? "Saving Role..." : "Save Role"}
|
|
111
|
-
</SubmitButton>
|
|
112
|
-
|
|
113
|
-
<button
|
|
114
|
-
type="button"
|
|
115
|
-
className="btn btn-link link-secondary ps-0"
|
|
116
|
-
onClick={onClickCancel}
|
|
117
|
-
disabled={isLoading}
|
|
118
|
-
>
|
|
119
|
-
Cancel
|
|
120
|
-
</button>
|
|
121
|
-
</div>
|
|
122
|
-
</form>
|
|
123
|
-
</Collapse>
|
|
124
|
-
<View
|
|
125
|
-
className="role-remove-button mt-3 me-3"
|
|
126
|
-
onClick={onClickRemove}
|
|
127
|
-
tooltip="Remove Role"
|
|
128
|
-
>
|
|
129
|
-
<CloseIcon size={14} />
|
|
130
|
-
</View>
|
|
131
|
-
</div>
|
|
132
|
-
</FormProvider>
|
|
133
|
-
)
|
|
134
|
-
}
|
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
import assert from "assert"
|
|
2
|
-
import {useForm, FormProvider} from "react-hook-form"
|
|
3
|
-
|
|
4
|
-
import FloatingLabel from "react-bootstrap/FloatingLabel"
|
|
5
|
-
import Form from "react-bootstrap/Form"
|
|
6
|
-
|
|
7
|
-
// import {useEnvContext} from "helpers/EnvContext"
|
|
8
|
-
import {CloseIcon} from "../../../ui/icons/Close"
|
|
9
|
-
import {View} from "../../../ui/View"
|
|
10
|
-
|
|
11
|
-
import {resolver} from "./resolver"
|
|
12
|
-
import {GrantsList} from "./GrantsList"
|
|
13
|
-
|
|
14
|
-
// import create_role from "rpc!server/access-control/create_role"
|
|
15
|
-
// import delete_role from "rpc!server/access-control/delete_role"
|
|
16
|
-
|
|
17
|
-
import "./role-form.scss"
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
export const RoleView = ({role}) => {
|
|
21
|
-
// const envContext = useEnvContext()
|
|
22
|
-
|
|
23
|
-
// const [isLoading, setIsLoading] = useState(false)
|
|
24
|
-
// TODO:
|
|
25
|
-
// react hook form submit on edit
|
|
26
|
-
// https://stackoverflow.com/a/70119332
|
|
27
|
-
const form = useForm({
|
|
28
|
-
defaultValues: {
|
|
29
|
-
...role,
|
|
30
|
-
_isEditing: true,
|
|
31
|
-
},
|
|
32
|
-
resolver,
|
|
33
|
-
reValidateMode: "onChange",
|
|
34
|
-
})
|
|
35
|
-
|
|
36
|
-
const {
|
|
37
|
-
register,
|
|
38
|
-
handleSubmit,
|
|
39
|
-
// watch,
|
|
40
|
-
// getValues,
|
|
41
|
-
formState: {errors},
|
|
42
|
-
} = form
|
|
43
|
-
|
|
44
|
-
const onSubmit = async(data) => {
|
|
45
|
-
const {groupId} = envContext
|
|
46
|
-
console.log("roleview submit", groupId, data)
|
|
47
|
-
// setIsLoading(true)
|
|
48
|
-
// const res = await create_role({group_id: groupId, ...data})
|
|
49
|
-
// assert(res.status === "ok")
|
|
50
|
-
// // TODO: error handling here
|
|
51
|
-
// setIsLoading(false)
|
|
52
|
-
// onDone()
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
const onClickRemove = async() => {
|
|
56
|
-
// const res = await delete_role({role_id: role._id})
|
|
57
|
-
// assert(res.status === "ok")
|
|
58
|
-
console.log("NYI DELETE ROLE", role._id)
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
// useEffect(() => {
|
|
62
|
-
// console.log("le vals", getValues())
|
|
63
|
-
// }, [formState])
|
|
64
|
-
|
|
65
|
-
// TODO: WARNING: DANGER: input should be mapped to field id + index to avoid duplicates in form
|
|
66
|
-
|
|
67
|
-
return (
|
|
68
|
-
<FormProvider {...form}>
|
|
69
|
-
<div className="w-100" style={{position: "relative"}}>
|
|
70
|
-
<form className="mb-1 me-4 card" onSubmit={handleSubmit(onSubmit)}>
|
|
71
|
-
<div className="p-2">
|
|
72
|
-
<div className="d-flex flex-row w-100 mt-1">
|
|
73
|
-
<FloatingLabel controlId="input-name" label="Name" className="me-2">
|
|
74
|
-
<Form.Control type="text" {...register("name")} />
|
|
75
|
-
{errors.name && <div className="text-danger">{errors.name.message}</div>}
|
|
76
|
-
</FloatingLabel>
|
|
77
|
-
|
|
78
|
-
<FloatingLabel
|
|
79
|
-
controlId="input-description"
|
|
80
|
-
label="Description"
|
|
81
|
-
className="flex-grow-1"
|
|
82
|
-
>
|
|
83
|
-
<Form.Control type="text" {...register("description")} />
|
|
84
|
-
{errors.description && (
|
|
85
|
-
<div className="text-danger">{errors.description.message}</div>
|
|
86
|
-
)}
|
|
87
|
-
</FloatingLabel>
|
|
88
|
-
</div>
|
|
89
|
-
|
|
90
|
-
{/* Grants list */}
|
|
91
|
-
<GrantsList />
|
|
92
|
-
</div>
|
|
93
|
-
</form>
|
|
94
|
-
<View
|
|
95
|
-
className="role-remove-button mt-1 me-1"
|
|
96
|
-
onClick={onClickRemove}
|
|
97
|
-
tooltip="Remove Role"
|
|
98
|
-
>
|
|
99
|
-
<CloseIcon size={14} />
|
|
100
|
-
</View>
|
|
101
|
-
</div>
|
|
102
|
-
</FormProvider>
|
|
103
|
-
)
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
// <label htmlFor="input-role-name" className="h6">
|
|
107
|
-
// Name
|
|
108
|
-
// </label>
|
|
109
|
-
// <input
|
|
110
|
-
// type="text"
|
|
111
|
-
// className={cx("form-control", {"is-invalid": !!errors.name})}
|
|
112
|
-
// id="input-role-name"
|
|
113
|
-
// {...register("name")}
|
|
114
|
-
// placeholder="Role Name"
|
|
115
|
-
// />
|