@aiquants/auth-react-router 0.13.1 → 0.14.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/README.md +73 -0
- package/dist/admin.d.mts +308 -10
- package/dist/admin.d.ts +308 -10
- package/dist/admin.js +1 -1
- package/dist/admin.js.map +1 -1
- package/dist/admin.mjs +1 -1
- package/dist/admin.mjs.map +1 -1
- package/dist/styles/auth-react-router.standalone.css +1 -1
- package/package.json +12 -3
- package/src/admin/app.ts +5 -0
- package/src/admin/format.ts +10 -1
- package/src/admin/labels.ts +289 -15
- package/src/admin/server.ts +525 -35
- package/src/admin/ui.tsx +17 -4
- package/src/admin/views.tsx +913 -94
package/src/admin/ui.tsx
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module admin/ui
|
|
3
|
+
* @description The shell around the five tab views: heading, tabs, badges and banners.
|
|
4
|
+
* 5 つのタブビューを囲む外枠 (見出し・タブ・バッジ・告知)。
|
|
5
|
+
*/
|
|
1
6
|
import type { AuthDirectoryStatus, AuthGroup } from "@aiquants/auth-core"
|
|
2
7
|
import type React from "react"
|
|
3
8
|
import { Link, useLoaderData } from "react-router"
|
|
@@ -128,17 +133,25 @@ export function UserAdminShell({ children, renderHeader }: UserAdminShellProps)
|
|
|
128
133
|
* 以前は権限マップが空のとき「編集可」の固定値を描いていたため、ポート未結線・取得失敗・
|
|
129
134
|
* 付与ゼロのいずれでも「全操作できます」と表示されていた (実際には操作するとガードで拒否される)。
|
|
130
135
|
*/
|
|
136
|
+
const unavailableSummary = { text: labels.permissions.unknown, color: "#92400e", bgColor: "#fffbeb", borderColor: "#fde68a" }
|
|
131
137
|
const getSummary = (perm: UserAdminPermission | undefined) => {
|
|
132
|
-
|
|
138
|
+
// ⚠️ **鍵は在るが値が無い** のは「権限なし」ではなく「判らない」である。取得側の型が
|
|
139
|
+
// `undefined` を許す以上、その差を潰すと、拒否理由が「バッジを見てください」と案内する
|
|
140
|
+
// 相手に嘘のバッジを見せることになる
|
|
141
|
+
if (perm === undefined) return unavailableSummary
|
|
142
|
+
if (perm.canWrite) {
|
|
133
143
|
return { text: labels.permissions.canWrite, color: "#047857", bgColor: "#ecfdf5", borderColor: "#a7f3d0" }
|
|
134
144
|
}
|
|
135
|
-
if (perm
|
|
145
|
+
if (perm.canRead) {
|
|
136
146
|
return { text: labels.permissions.canRead, color: "#1d4ed8", bgColor: "#eff6ff", borderColor: "#bfdbfe" }
|
|
137
147
|
}
|
|
148
|
+
// ⚠️ 削除だけを持つ主体は実在する。読み書きが無いことを「権限なし」と描くと、
|
|
149
|
+
// 実際には削除できる相手に「何もできない」と言うことになる
|
|
150
|
+
if (perm.canDelete) {
|
|
151
|
+
return { text: labels.permissions.canDelete, color: "#b91c1c", bgColor: "#fef2f2", borderColor: "#fecaca" }
|
|
152
|
+
}
|
|
138
153
|
return { text: labels.permissions.none, color: "#475569", bgColor: "#f1f5f9", borderColor: "#cbd5e1" }
|
|
139
154
|
}
|
|
140
|
-
const unavailableSummary = { text: labels.permissions.unknown, color: "#92400e", bgColor: "#fffbeb", borderColor: "#fde68a" }
|
|
141
|
-
|
|
142
155
|
const annotation = (
|
|
143
156
|
<div style={{ display: "flex", alignItems: "center", gap: "0.4rem" }} data-testid="user-admin-header-annotation">
|
|
144
157
|
<span style={{ fontSize: "0.75rem", backgroundColor: "#e0f2fe", color: "#0369a1", padding: "2px 8px", borderRadius: "12px", fontWeight: 600 }}>{labels.heading}</span>
|