@rpcbase/client 0.217.0 → 0.218.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.
@@ -1,16 +1,68 @@
1
1
  import {useState} from "react"
2
2
 
3
3
 
4
+ const POLICY_EFFECT = [
5
+ {
6
+ name: "Grant",
7
+ key: "grant",
8
+ },
9
+ {
10
+ name: "Deny",
11
+ key: "deny",
12
+ },
13
+ ]
14
+
4
15
  const TARGET_TYPES = [
5
16
  {
6
17
  name: "Collection:",
7
- key: "collection",
8
- description: "Applies to all documents within the collection.",
18
+ key: "collections",
19
+ description: "Applies to all documents within the collection",
20
+ },
21
+ {
22
+ name: "Documents:",
23
+ key: "documents",
24
+ description: "Applies only to certain specific documents",
25
+ },
26
+ {
27
+ name: "Field:",
28
+ key: "fields",
29
+ description: "Applies only specific fields of documents",
30
+ },
31
+ ]
32
+
33
+ const OPERATIONS = [
34
+ {
35
+ name: "Create",
36
+ key: "create",
37
+ },
38
+ {
39
+ name: "Read",
40
+ key: "read",
41
+ },
42
+ {
43
+ name: "Update",
44
+ key: "update",
45
+ },
46
+ {
47
+ name: "Delete",
48
+ key: "delete",
49
+ },
50
+ {
51
+ name: "All of the above",
52
+ key: "all",
53
+ },
54
+ ]
55
+
56
+
57
+ //
58
+ const APPLIES_TO = [
59
+ {
60
+ name: "Users",
61
+ key: "users",
9
62
  },
10
63
  {
11
- name: "Document:",
12
- key: "document",
13
- description: "Applies only to certain specific documents.",
64
+ name: "Groups",
65
+ key: "groups",
14
66
  },
15
67
  ]
16
68
 
@@ -24,7 +76,31 @@ export const PolicyEditor = () => {
24
76
  return (
25
77
  <div>
26
78
  <h6>Policy Editor</h6>
27
- <br />
79
+ <hr />
80
+
81
+ <h6>Effect:</h6>
82
+ <div className="mb-3" style={{maxWidth: 300}}>
83
+ {POLICY_EFFECT.map((type) => (
84
+ <div key={type.key} className="d-flex flex-row mb-1">
85
+ <input
86
+ className="form-check-input"
87
+ type="radio"
88
+ name="targetTypeOptions"
89
+ id={type.key}
90
+ value={type.key}
91
+ checked={targetType === type.key}
92
+ onChange={onChangeTargetType}
93
+ />
94
+ <label
95
+ className="form-check-label cursor-pointer ps-2"
96
+ htmlFor={type.key}
97
+ >
98
+ <b>{type.name}</b>
99
+ </label>
100
+ </div>
101
+ ))}
102
+ </div>
103
+
28
104
  <div className="d-flex flex-row">
29
105
  <div className="me-2">
30
106
  <h6>Target Type:</h6>
@@ -58,11 +134,30 @@ export const PolicyEditor = () => {
58
134
  </div>
59
135
  </div>
60
136
  </div>
61
- grant / deny
62
- <br />
63
- Scope: document, field
64
- <br />
65
- operation: create read write delete
137
+
138
+ <h6 className="mt-3">Operation:</h6>
139
+ <div className="" style={{maxWidth: 300}}>
140
+ {OPERATIONS.map((type) => (
141
+ <div key={type.key} className="d-flex flex-row mb-1">
142
+ <input
143
+ className="form-check-input"
144
+ type="radio"
145
+ name="targetTypeOptions"
146
+ id={type.key}
147
+ value={type.key}
148
+ checked={targetType === type.key}
149
+ onChange={onChangeTargetType}
150
+ />
151
+ <label
152
+ className="form-check-label cursor-pointer ps-2"
153
+ htmlFor={type.key}
154
+ >
155
+ <b>{type.name}</b>
156
+ </label>
157
+ </div>
158
+ ))}
159
+ </div>
160
+
66
161
  <br />
67
162
  to attributes / conditions add support for expiry date
68
163
  </div>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rpcbase/client",
3
- "version": "0.217.0",
3
+ "version": "0.218.0",
4
4
  "scripts": {
5
5
  "build": "../../node_modules/.bin/wireit",
6
6
  "test": "../../node_modules/.bin/wireit"
@@ -48,7 +48,6 @@ export const SearchResults = ({
48
48
  const key = getItemId(index)
49
49
 
50
50
  const onClick = () => {
51
- console.log("CLICK item", item)
52
51
  onSelectItem(index)
53
52
  }
54
53
 
@@ -11,6 +11,7 @@ type ContentViewContextType = {
11
11
  contentViewHeight: number;
12
12
  sidebarWidth: number;
13
13
  setSidebarWidth: Dispatch<SetStateAction<number>>;
14
+ headerHeight: number;
14
15
  };
15
16
 
16
17
  export const ContentViewContext = createContext<ContentViewContextType>(
@@ -13,9 +13,11 @@ const SIDEVIEW_WIDTH = "sideview_width"
13
13
 
14
14
  export const ContentView = memo(
15
15
  ({
16
+ headerHeight = 45,
16
17
  children,
17
18
  storageKeyPrefix: _storageKeyPrefix,
18
19
  }: {
20
+ headerHeight?: number;
19
21
  children: ReactNode;
20
22
  storageKeyPrefix?: string;
21
23
  }) => {
@@ -76,6 +78,7 @@ export const ContentView = memo(
76
78
  contentViewHeight,
77
79
  sidebarWidth,
78
80
  setSidebarWidth,
81
+ headerHeight,
79
82
  }}
80
83
  >
81
84
  <div
@@ -85,15 +88,15 @@ export const ContentView = memo(
85
88
  flexDirection: "row",
86
89
  }}
87
90
  >
88
- <div id="sidebar-container" />
91
+ <div id="sidebar-container" style={{top: headerHeight}} />
89
92
 
90
93
  <div
91
94
  ref={contentViewRef}
92
95
  key={`content-wrapper-${"content_view_"}`}
93
96
  style={{
94
97
  width: `calc(100vw - ${contentWidthOffset}px)`,
95
- height: "calc(100vh - 45px)",
96
- marginTop: 45,
98
+ height: `calc(100vh - ${headerHeight}px)`,
99
+ marginTop: headerHeight,
97
100
  overflowY: "scroll",
98
101
  marginLeft: sidebarWidth,
99
102
  }}
@@ -10,7 +10,6 @@ $img-border-radius: 3px;
10
10
  #header-container {
11
11
  border-bottom: 1px solid $black;
12
12
  background-color: $black !important;
13
- height: 45px;
14
13
 
15
14
  .nav-link {
16
15
  color: $gray-200;
@@ -28,7 +28,7 @@ import {ReactNode} from "react"
28
28
  // import EnvSettingsDropdown from "./components/EnvSettingsDropdown"
29
29
 
30
30
  import "./header.scss"
31
-
31
+ import {useContentViewContext} from "../ContentView/ContentViewContext"
32
32
 
33
33
  // const DefaultHeader = () => {
34
34
  // return (
@@ -136,14 +136,18 @@ import "./header.scss"
136
136
  // )
137
137
  // }
138
138
 
139
- export const HeaderContainer = ({children}: {children: ReactNode}) => {
139
+ export const HeaderContainer = ({children}: { children: ReactNode }) => {
140
+ const contentViewContext = useContentViewContext()
140
141
 
141
142
  if (!children) return null
142
143
 
143
144
  return (
144
145
  <nav
145
146
  id="header-container"
146
- className={"d-flex align-items-center fixed-top bg-dark flex-md-nowrap shadow p-0 text-light"}
147
+ className={
148
+ "d-flex align-items-center fixed-top bg-dark flex-md-nowrap shadow p-0 text-light"
149
+ }
150
+ style={{height: contentViewContext.headerHeight}}
147
151
  >
148
152
  {children}
149
153
  </nav>
@@ -2,7 +2,6 @@
2
2
 
3
3
  #sidebar-container {
4
4
  position: fixed;
5
- top: 45px;
6
5
  left: 0;
7
6
  max-height: calc(100vh - 45px);
8
7