@checkstack/command-frontend 0.0.4 → 0.1.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/CHANGELOG.md +90 -0
- package/package.json +1 -1
- package/src/components/SearchDialog.tsx +7 -0
- package/src/index.tsx +11 -11
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,95 @@
|
|
|
1
1
|
# @checkstack/command-frontend
|
|
2
2
|
|
|
3
|
+
## 0.1.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 9faec1f: # Unified AccessRule Terminology Refactoring
|
|
8
|
+
|
|
9
|
+
This release completes a comprehensive terminology refactoring from "permission" to "accessRule" across the entire codebase, establishing a consistent and modern access control vocabulary.
|
|
10
|
+
|
|
11
|
+
## Changes
|
|
12
|
+
|
|
13
|
+
### Core Infrastructure (`@checkstack/common`)
|
|
14
|
+
|
|
15
|
+
- Introduced `AccessRule` interface as the primary access control type
|
|
16
|
+
- Added `accessPair()` helper for creating read/manage access rule pairs
|
|
17
|
+
- Added `access()` builder for individual access rules
|
|
18
|
+
- Replaced `Permission` type with `AccessRule` throughout
|
|
19
|
+
|
|
20
|
+
### API Changes
|
|
21
|
+
|
|
22
|
+
- `env.registerPermissions()` → `env.registerAccessRules()`
|
|
23
|
+
- `meta.permissions` → `meta.access` in RPC contracts
|
|
24
|
+
- `usePermission()` → `useAccess()` in frontend hooks
|
|
25
|
+
- Route `permission:` field → `accessRule:` field
|
|
26
|
+
|
|
27
|
+
### UI Changes
|
|
28
|
+
|
|
29
|
+
- "Roles & Permissions" tab → "Roles & Access Rules"
|
|
30
|
+
- "You don't have permission..." → "You don't have access..."
|
|
31
|
+
- All permission-related UI text updated
|
|
32
|
+
|
|
33
|
+
### Documentation & Templates
|
|
34
|
+
|
|
35
|
+
- Updated 18 documentation files with AccessRule terminology
|
|
36
|
+
- Updated 7 scaffolding templates with `accessPair()` pattern
|
|
37
|
+
- All code examples use new AccessRule API
|
|
38
|
+
|
|
39
|
+
## Migration Guide
|
|
40
|
+
|
|
41
|
+
### Backend Plugins
|
|
42
|
+
|
|
43
|
+
```diff
|
|
44
|
+
- import { permissionList } from "./permissions";
|
|
45
|
+
- env.registerPermissions(permissionList);
|
|
46
|
+
+ import { accessRules } from "./access";
|
|
47
|
+
+ env.registerAccessRules(accessRules);
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### RPC Contracts
|
|
51
|
+
|
|
52
|
+
```diff
|
|
53
|
+
- .meta({ userType: "user", permissions: [permissions.read.id] })
|
|
54
|
+
+ .meta({ userType: "user", access: [access.read] })
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### Frontend Hooks
|
|
58
|
+
|
|
59
|
+
```diff
|
|
60
|
+
- const canRead = accessApi.usePermission(permissions.read.id);
|
|
61
|
+
+ const canRead = accessApi.useAccess(access.read);
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### Routes
|
|
65
|
+
|
|
66
|
+
```diff
|
|
67
|
+
- permission: permissions.entityRead.id,
|
|
68
|
+
+ accessRule: access.read,
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### Patch Changes
|
|
72
|
+
|
|
73
|
+
- Updated dependencies [9faec1f]
|
|
74
|
+
- Updated dependencies [f533141]
|
|
75
|
+
- @checkstack/command-common@0.1.0
|
|
76
|
+
- @checkstack/common@0.2.0
|
|
77
|
+
- @checkstack/frontend-api@0.1.0
|
|
78
|
+
- @checkstack/ui@0.2.0
|
|
79
|
+
|
|
80
|
+
## 0.0.5
|
|
81
|
+
|
|
82
|
+
### Patch Changes
|
|
83
|
+
|
|
84
|
+
- 97c5a6b: Fix Radix UI accessibility warning in dialog components by adding visually hidden DialogDescription components
|
|
85
|
+
- Updated dependencies [8e43507]
|
|
86
|
+
- Updated dependencies [97c5a6b]
|
|
87
|
+
- Updated dependencies [8e43507]
|
|
88
|
+
- @checkstack/ui@0.1.0
|
|
89
|
+
- @checkstack/common@0.1.0
|
|
90
|
+
- @checkstack/command-common@0.0.4
|
|
91
|
+
- @checkstack/frontend-api@0.0.4
|
|
92
|
+
|
|
3
93
|
## 0.0.4
|
|
4
94
|
|
|
5
95
|
### Patch Changes
|
package/package.json
CHANGED
|
@@ -3,6 +3,8 @@ import { useNavigate } from "react-router-dom";
|
|
|
3
3
|
import {
|
|
4
4
|
Dialog,
|
|
5
5
|
DialogContent,
|
|
6
|
+
DialogDescription,
|
|
7
|
+
DialogTitle,
|
|
6
8
|
Input,
|
|
7
9
|
DynamicIcon,
|
|
8
10
|
type LucideIconName,
|
|
@@ -163,6 +165,11 @@ export const SearchDialog: React.FC<SearchDialogProps> = ({
|
|
|
163
165
|
className="p-0 gap-0 overflow-hidden"
|
|
164
166
|
onKeyDown={handleKeyDown}
|
|
165
167
|
>
|
|
168
|
+
{/* Visually hidden but accessible title and description */}
|
|
169
|
+
<DialogTitle className="sr-only">Search</DialogTitle>
|
|
170
|
+
<DialogDescription className="sr-only">
|
|
171
|
+
Search commands and systems using the input below
|
|
172
|
+
</DialogDescription>
|
|
166
173
|
{/* Search input */}
|
|
167
174
|
<div className="flex items-center gap-3 px-4 py-3 border-b border-border">
|
|
168
175
|
<Search className="w-5 h-5 text-muted-foreground flex-shrink-0" />
|
package/src/index.tsx
CHANGED
|
@@ -118,16 +118,16 @@ export function formatShortcut(shortcut: string, isMac: boolean): string {
|
|
|
118
118
|
*
|
|
119
119
|
* @param commands - Array of commands with shortcuts
|
|
120
120
|
* @param navigate - Navigation function to call when a command is triggered
|
|
121
|
-
* @param
|
|
121
|
+
* @param userAccessRules - Array of access rule IDs the user has
|
|
122
122
|
*/
|
|
123
123
|
export function useGlobalShortcuts(
|
|
124
124
|
commands: SearchResult[],
|
|
125
125
|
navigate: (route: string) => void,
|
|
126
|
-
|
|
126
|
+
userAccessRules: string[]
|
|
127
127
|
): void {
|
|
128
128
|
useEffect(() => {
|
|
129
|
-
// Check if user has wildcard
|
|
130
|
-
const hasWildcard =
|
|
129
|
+
// Check if user has wildcard access rule (admin)
|
|
130
|
+
const hasWildcard = userAccessRules.includes("*");
|
|
131
131
|
|
|
132
132
|
const handleKeyDown = (event: KeyboardEvent) => {
|
|
133
133
|
// Don't trigger in input fields
|
|
@@ -144,12 +144,12 @@ export function useGlobalShortcuts(
|
|
|
144
144
|
for (const command of commands) {
|
|
145
145
|
if (!command.shortcuts || !command.route) continue;
|
|
146
146
|
|
|
147
|
-
// Check
|
|
148
|
-
if (!hasWildcard && command.
|
|
149
|
-
const
|
|
150
|
-
|
|
147
|
+
// Check access rules (skip if user has wildcard)
|
|
148
|
+
if (!hasWildcard && command.requiredAccessRules?.length) {
|
|
149
|
+
const hasAccess = command.requiredAccessRules.every((rule) =>
|
|
150
|
+
userAccessRules.includes(rule)
|
|
151
151
|
);
|
|
152
|
-
if (!
|
|
152
|
+
if (!hasAccess) continue;
|
|
153
153
|
}
|
|
154
154
|
|
|
155
155
|
for (const shortcut of command.shortcuts) {
|
|
@@ -165,7 +165,7 @@ export function useGlobalShortcuts(
|
|
|
165
165
|
|
|
166
166
|
globalThis.addEventListener("keydown", handleKeyDown);
|
|
167
167
|
return () => globalThis.removeEventListener("keydown", handleKeyDown);
|
|
168
|
-
}, [commands, navigate,
|
|
168
|
+
}, [commands, navigate, userAccessRules]);
|
|
169
169
|
}
|
|
170
170
|
|
|
171
171
|
/**
|
|
@@ -359,7 +359,7 @@ export function GlobalShortcuts(): React.ReactNode {
|
|
|
359
359
|
globalThis.location.href = route;
|
|
360
360
|
}, []);
|
|
361
361
|
|
|
362
|
-
// For now, pass "*" as
|
|
362
|
+
// For now, pass "*" as access rule since the backend already filters
|
|
363
363
|
// The commands returned from getCommands are already filtered
|
|
364
364
|
useGlobalShortcuts(commands, navigate, ["*"]);
|
|
365
365
|
|