@umituz/web-dashboard 7.5.0 → 7.7.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 +2 -2
- package/src/domains/permissions/PermissionsContext.test.tsx +144 -0
- package/src/domains/permissions/PermissionsContext.tsx +50 -17
- package/src/domains/permissions/hasPermission.test.ts +51 -1
- package/src/domains/permissions/hasPermission.ts +27 -4
- package/src/domains/permissions/index.ts +8 -1
- package/src/domains/permissions/types.ts +17 -0
- package/src/domains/settings/components/OrganizationProfileForm.test.tsx +114 -0
- package/src/domains/settings/components/OrganizationProfileForm.tsx +164 -0
- package/src/domains/settings/components/PermissionMatrixScreen.test.tsx +90 -0
- package/src/domains/settings/components/PermissionMatrixScreen.tsx +65 -33
- package/src/domains/settings/components/index.ts +9 -0
- package/src/styles/chrome.css +27 -29
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umituz/web-dashboard",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.7.0",
|
|
4
4
|
"description": "Installable app skeleton for the fleet — layouts, analytics (dependency-free SVG charts), calendar, onboarding flow permissions/module registry; udb-* stylesheet on design-system tokens",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.ts",
|
|
@@ -80,7 +80,7 @@
|
|
|
80
80
|
"@types/react-dom": "^19.2.3",
|
|
81
81
|
"@typescript-eslint/eslint-plugin": "^8.57.2",
|
|
82
82
|
"@typescript-eslint/parser": "^8.57.2",
|
|
83
|
-
"@umituz/web-design-system": "^4.
|
|
83
|
+
"@umituz/web-design-system": "^4.29.4",
|
|
84
84
|
"eslint": "^10.0.2",
|
|
85
85
|
"framer-motion": "^12.23.12",
|
|
86
86
|
"jsdom": "^29.1.1",
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { render, screen } from "@testing-library/react";
|
|
3
|
+
import { MemoryRouter, Route, Routes } from "react-router";
|
|
4
|
+
import {
|
|
5
|
+
Can,
|
|
6
|
+
PermissionsProvider,
|
|
7
|
+
RequirePermission,
|
|
8
|
+
usePermissions,
|
|
9
|
+
} from "./PermissionsContext";
|
|
10
|
+
import type { PermissionMatrix } from "./types";
|
|
11
|
+
|
|
12
|
+
const MATRIX: PermissionMatrix = {
|
|
13
|
+
owner: "*",
|
|
14
|
+
editor: ["orders.view", "orders.edit"],
|
|
15
|
+
viewer: ["orders.view"],
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const mount = (role: string | null, node: React.ReactNode) =>
|
|
19
|
+
render(
|
|
20
|
+
<PermissionsProvider matrix={MATRIX} role={role}>
|
|
21
|
+
{node}
|
|
22
|
+
</PermissionsProvider>,
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
describe("usePermissions", () => {
|
|
26
|
+
it("exposes role, can and canAny from the provider", () => {
|
|
27
|
+
const captured: ReturnType<typeof usePermissions>[] = [];
|
|
28
|
+
const Probe = () => {
|
|
29
|
+
captured.push(usePermissions());
|
|
30
|
+
return null;
|
|
31
|
+
};
|
|
32
|
+
mount("editor", <Probe />);
|
|
33
|
+
const value = captured[0]!;
|
|
34
|
+
expect(value.role).toBe("editor");
|
|
35
|
+
expect(value.can("orders.edit")).toBe(true);
|
|
36
|
+
expect(value.can("settings.manage")).toBe(false);
|
|
37
|
+
expect(value.canAny(["settings.manage", "orders.view"])).toBe(true);
|
|
38
|
+
expect(value.canAny(["settings.manage", "x.y"])).toBe(false);
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it("denies everything without a role", () => {
|
|
42
|
+
const captured: ReturnType<typeof usePermissions>[] = [];
|
|
43
|
+
const Probe = () => {
|
|
44
|
+
captured.push(usePermissions());
|
|
45
|
+
return null;
|
|
46
|
+
};
|
|
47
|
+
mount(null, <Probe />);
|
|
48
|
+
const value = captured[0]!;
|
|
49
|
+
expect(value.can("orders.view")).toBe(false);
|
|
50
|
+
expect(value.canAny(["orders.view"])).toBe(false);
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
describe("RequirePermission", () => {
|
|
55
|
+
it("renders children when the permission is granted", () => {
|
|
56
|
+
mount("editor", (
|
|
57
|
+
<RequirePermission permission="orders.edit">
|
|
58
|
+
<span>Edit tools</span>
|
|
59
|
+
</RequirePermission>
|
|
60
|
+
));
|
|
61
|
+
expect(screen.getByText("Edit tools")).not.toBeNull();
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
it("renders the fallback when denied", () => {
|
|
65
|
+
mount("viewer", (
|
|
66
|
+
<RequirePermission permission="orders.edit" fallback={<span>No access</span>}>
|
|
67
|
+
<span>Edit tools</span>
|
|
68
|
+
</RequirePermission>
|
|
69
|
+
));
|
|
70
|
+
expect(screen.queryByText("Edit tools")).toBeNull();
|
|
71
|
+
expect(screen.getByText("No access")).not.toBeNull();
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
it("accepts anyOf for alternative permissions", () => {
|
|
75
|
+
mount("viewer", (
|
|
76
|
+
<RequirePermission anyOf={["orders.edit", "orders.view"]}>
|
|
77
|
+
<span>Visible</span>
|
|
78
|
+
</RequirePermission>
|
|
79
|
+
));
|
|
80
|
+
expect(screen.getByText("Visible")).not.toBeNull();
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
it("denies when neither permission nor anyOf is given", () => {
|
|
84
|
+
mount("owner", (
|
|
85
|
+
<RequirePermission fallback={<span>Denied</span>}>
|
|
86
|
+
<span>Visible</span>
|
|
87
|
+
</RequirePermission>
|
|
88
|
+
));
|
|
89
|
+
expect(screen.queryByText("Visible")).toBeNull();
|
|
90
|
+
expect(screen.getByText("Denied")).not.toBeNull();
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
it("redirects to redirectTo when denied", () => {
|
|
94
|
+
render(
|
|
95
|
+
<MemoryRouter initialEntries={["/dashboard"]}>
|
|
96
|
+
<Routes>
|
|
97
|
+
<Route
|
|
98
|
+
path="/dashboard"
|
|
99
|
+
element={
|
|
100
|
+
<PermissionsProvider matrix={MATRIX} role="viewer">
|
|
101
|
+
<RequirePermission permission="orders.edit" redirectTo="/signin">
|
|
102
|
+
<span>Dashboard</span>
|
|
103
|
+
</RequirePermission>
|
|
104
|
+
</PermissionsProvider>
|
|
105
|
+
}
|
|
106
|
+
/>
|
|
107
|
+
<Route path="/signin" element={<span>Sign in</span>} />
|
|
108
|
+
</Routes>
|
|
109
|
+
</MemoryRouter>,
|
|
110
|
+
);
|
|
111
|
+
expect(screen.queryByText("Dashboard")).toBeNull();
|
|
112
|
+
expect(screen.getByText("Sign in")).not.toBeNull();
|
|
113
|
+
});
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
describe("Can", () => {
|
|
117
|
+
it("renders children while allowed and the fallback otherwise", () => {
|
|
118
|
+
const { rerender } = mount("editor", (
|
|
119
|
+
<Can permission="orders.view" fallback={<span>Hidden</span>}>
|
|
120
|
+
<span>Orders</span>
|
|
121
|
+
</Can>
|
|
122
|
+
));
|
|
123
|
+
expect(screen.getByText("Orders")).not.toBeNull();
|
|
124
|
+
|
|
125
|
+
rerender(
|
|
126
|
+
<PermissionsProvider matrix={MATRIX} role="viewer">
|
|
127
|
+
<Can permission="orders.edit" fallback={<span>Hidden</span>}>
|
|
128
|
+
<span>Orders</span>
|
|
129
|
+
</Can>
|
|
130
|
+
</PermissionsProvider>,
|
|
131
|
+
);
|
|
132
|
+
expect(screen.queryByText("Orders")).toBeNull();
|
|
133
|
+
expect(screen.getByText("Hidden")).not.toBeNull();
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
it("supports anyOf", () => {
|
|
137
|
+
mount("viewer", (
|
|
138
|
+
<Can anyOf={["settings.manage", "orders.view"]}>
|
|
139
|
+
<span>Orders</span>
|
|
140
|
+
</Can>
|
|
141
|
+
));
|
|
142
|
+
expect(screen.getByText("Orders")).not.toBeNull();
|
|
143
|
+
});
|
|
144
|
+
});
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { createContext, useCallback, useContext, useMemo, type ReactNode } from "react";
|
|
2
|
-
import {
|
|
2
|
+
import { Navigate } from "react-router";
|
|
3
|
+
import { hasAnyPermission, hasPermission } from "./hasPermission";
|
|
3
4
|
import type { Permission, PermissionMatrix, RoleKey } from "./types";
|
|
4
5
|
|
|
5
6
|
export interface PermissionsProviderProps {
|
|
@@ -12,6 +13,7 @@ interface PermissionsContextValue {
|
|
|
12
13
|
matrix: PermissionMatrix;
|
|
13
14
|
role: RoleKey | null;
|
|
14
15
|
can: (permission: Permission) => boolean;
|
|
16
|
+
canAny: (permissions: readonly Permission[]) => boolean;
|
|
15
17
|
}
|
|
16
18
|
|
|
17
19
|
const PermissionsContext = createContext<PermissionsContextValue | null>(null);
|
|
@@ -26,16 +28,21 @@ export const PermissionsProvider = ({
|
|
|
26
28
|
[matrix, role],
|
|
27
29
|
);
|
|
28
30
|
|
|
31
|
+
const canAny = useCallback(
|
|
32
|
+
(permissions: readonly Permission[]) =>
|
|
33
|
+
hasAnyPermission(matrix, role, permissions),
|
|
34
|
+
[matrix, role],
|
|
35
|
+
);
|
|
36
|
+
|
|
29
37
|
const value = useMemo<PermissionsContextValue>(
|
|
30
|
-
() => ({ matrix, role: role ?? null, can }),
|
|
31
|
-
[matrix, role, can],
|
|
38
|
+
() => ({ matrix, role: role ?? null, can, canAny }),
|
|
39
|
+
[matrix, role, can, canAny],
|
|
32
40
|
);
|
|
33
41
|
|
|
34
42
|
return (
|
|
35
43
|
<PermissionsContext.Provider value={value}>
|
|
36
44
|
{children}
|
|
37
45
|
</PermissionsContext.Provider>
|
|
38
|
-
|
|
39
46
|
);
|
|
40
47
|
};
|
|
41
48
|
|
|
@@ -47,29 +54,55 @@ export const usePermissions = (): PermissionsContextValue => {
|
|
|
47
54
|
return context;
|
|
48
55
|
};
|
|
49
56
|
|
|
57
|
+
const resolveAllowed = (
|
|
58
|
+
can: (permission: Permission) => boolean,
|
|
59
|
+
canAny: (permissions: readonly Permission[]) => boolean,
|
|
60
|
+
permission?: Permission,
|
|
61
|
+
anyOf?: readonly Permission[],
|
|
62
|
+
): boolean =>
|
|
63
|
+
permission
|
|
64
|
+
? anyOf
|
|
65
|
+
? can(permission) || canAny(anyOf)
|
|
66
|
+
: can(permission)
|
|
67
|
+
: anyOf
|
|
68
|
+
? canAny(anyOf)
|
|
69
|
+
: false;
|
|
70
|
+
|
|
50
71
|
export interface RequirePermissionProps {
|
|
51
|
-
permission
|
|
52
|
-
|
|
72
|
+
permission?: Permission;
|
|
73
|
+
anyOf?: readonly Permission[];
|
|
74
|
+
children?: ReactNode;
|
|
53
75
|
fallback?: ReactNode;
|
|
76
|
+
redirectTo?: string;
|
|
54
77
|
}
|
|
55
78
|
|
|
56
79
|
export const RequirePermission = ({
|
|
57
80
|
permission,
|
|
81
|
+
anyOf,
|
|
58
82
|
children,
|
|
59
83
|
fallback = null,
|
|
84
|
+
redirectTo,
|
|
60
85
|
}: RequirePermissionProps) => {
|
|
61
|
-
const { can } = usePermissions();
|
|
62
|
-
if (can
|
|
63
|
-
|
|
86
|
+
const { can, canAny } = usePermissions();
|
|
87
|
+
if (resolveAllowed(can, canAny, permission, anyOf)) return <>{children}</>;
|
|
88
|
+
if (redirectTo !== undefined) return <Navigate to={redirectTo} replace />;
|
|
64
89
|
return <>{fallback}</>;
|
|
65
|
-
|
|
66
90
|
};
|
|
67
91
|
|
|
68
|
-
export interface CanProps
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
92
|
+
export interface CanProps {
|
|
93
|
+
permission?: Permission;
|
|
94
|
+
anyOf?: readonly Permission[];
|
|
95
|
+
children?: ReactNode;
|
|
96
|
+
fallback?: ReactNode;
|
|
97
|
+
}
|
|
74
98
|
|
|
75
|
-
|
|
99
|
+
export const Can = ({
|
|
100
|
+
permission,
|
|
101
|
+
anyOf,
|
|
102
|
+
children,
|
|
103
|
+
fallback = null,
|
|
104
|
+
}: CanProps) => {
|
|
105
|
+
const { can, canAny } = usePermissions();
|
|
106
|
+
const allowed = resolveAllowed(can, canAny, permission, anyOf);
|
|
107
|
+
return allowed ? <>{children}</> : <>{fallback}</>;
|
|
108
|
+
};
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
import { describe, expect, it } from "vitest";
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
effectivePermissions,
|
|
4
|
+
hasAnyPermission,
|
|
5
|
+
hasPermission,
|
|
6
|
+
} from "./hasPermission";
|
|
3
7
|
import type { PermissionMatrix } from "./types";
|
|
4
8
|
|
|
5
9
|
const MATRIX: PermissionMatrix = {
|
|
6
10
|
owner: "*",
|
|
7
11
|
admin: ["dashboard.view", "sales.*", "reports.view"],
|
|
12
|
+
colonAdmin: ["orders:*"],
|
|
8
13
|
viewer: ["dashboard.view"],
|
|
9
14
|
nobody: [],
|
|
10
15
|
};
|
|
@@ -30,6 +35,12 @@ describe("hasPermission", () => {
|
|
|
30
35
|
expect(hasPermission(MATRIX, "admin", "salesforce.view")).toBe(false);
|
|
31
36
|
});
|
|
32
37
|
|
|
38
|
+
it("honors colon-separated module wildcards", () => {
|
|
39
|
+
expect(hasPermission(MATRIX, "colonAdmin", "orders:create")).toBe(true);
|
|
40
|
+
expect(hasPermission(MATRIX, "colonAdmin", "orders:delete")).toBe(true);
|
|
41
|
+
expect(hasPermission(MATRIX, "colonAdmin", "ordersArchive:create")).toBe(false);
|
|
42
|
+
});
|
|
43
|
+
|
|
33
44
|
it("denies unknown roles", () => {
|
|
34
45
|
expect(hasPermission(MATRIX, "intruder", "dashboard.view")).toBe(false);
|
|
35
46
|
});
|
|
@@ -47,4 +58,43 @@ describe("hasPermission", () => {
|
|
|
47
58
|
expect(hasPermission(MATRIX, null, "dashboard.view")).toBe(false);
|
|
48
59
|
expect(hasPermission(undefined, undefined, "x")).toBe(false);
|
|
49
60
|
});
|
|
61
|
+
|
|
62
|
+
it("hasAnyPermission requires at least one grant", () => {
|
|
63
|
+
expect(
|
|
64
|
+
hasAnyPermission(MATRIX, "admin", ["sales.view", "settings.manage"]),
|
|
65
|
+
).toBe(true);
|
|
66
|
+
expect(
|
|
67
|
+
hasAnyPermission(MATRIX, "viewer", ["sales.view", "settings.manage"]),
|
|
68
|
+
).toBe(false);
|
|
69
|
+
expect(hasAnyPermission(MATRIX, "viewer", [])).toBe(false);
|
|
70
|
+
expect(hasAnyPermission(MATRIX, null, ["dashboard.view"])).toBe(false);
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
describe("effectivePermissions", () => {
|
|
75
|
+
it("returns the base set without overrides", () => {
|
|
76
|
+
const result = effectivePermissions(["a.b", "c.d"]);
|
|
77
|
+
expect([...result].sort()).toEqual(["a.b", "c.d"]);
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
it("unions grants and subtracts revokes", () => {
|
|
81
|
+
const result = effectivePermissions(["a.b", "c.d"], {
|
|
82
|
+
grant: ["e.f"],
|
|
83
|
+
revoke: ["a.b"],
|
|
84
|
+
});
|
|
85
|
+
expect([...result].sort()).toEqual(["c.d", "e.f"]);
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
it("lets revokes win over grants", () => {
|
|
89
|
+
const result = effectivePermissions(["a.b"], {
|
|
90
|
+
grant: ["c.d"],
|
|
91
|
+
revoke: ["c.d"],
|
|
92
|
+
});
|
|
93
|
+
expect([...result]).toEqual(["a.b"]);
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
it("deduplicates repeated permissions", () => {
|
|
97
|
+
const result = effectivePermissions(["a.b"], { grant: ["a.b"] });
|
|
98
|
+
expect(result.size).toBe(1);
|
|
99
|
+
});
|
|
50
100
|
});
|
|
@@ -2,19 +2,27 @@ import {
|
|
|
2
2
|
PERMISSION_WILDCARD,
|
|
3
3
|
type Permission,
|
|
4
4
|
type PermissionMatrix,
|
|
5
|
+
type PermissionOverrides,
|
|
5
6
|
type RoleGrant,
|
|
6
7
|
type RoleKey,
|
|
7
8
|
} from "./types";
|
|
8
9
|
|
|
9
|
-
const
|
|
10
|
+
const MODULE_WILDCARD_SUFFIXES = [".*", ":*"] as const;
|
|
11
|
+
|
|
12
|
+
const matchesModuleWildcard = (
|
|
13
|
+
entry: Permission,
|
|
14
|
+
permission: Permission,
|
|
15
|
+
): boolean =>
|
|
16
|
+
MODULE_WILDCARD_SUFFIXES.some((suffix) => {
|
|
17
|
+
if (!entry.endsWith(suffix)) return false;
|
|
18
|
+
return permission.startsWith(entry.slice(0, -suffix.length + 1));
|
|
19
|
+
});
|
|
10
20
|
|
|
11
21
|
const grantIncludes = (grant: RoleGrant, permission: Permission): boolean => {
|
|
12
22
|
if (grant === PERMISSION_WILDCARD) return true;
|
|
13
23
|
return grant.some(
|
|
14
24
|
(entry) =>
|
|
15
|
-
entry === permission ||
|
|
16
|
-
(entry.endsWith(MODULE_WILDCARD_SUFFIX) &&
|
|
17
|
-
permission.startsWith(entry.slice(0, -1))),
|
|
25
|
+
entry === permission || matchesModuleWildcard(entry, permission),
|
|
18
26
|
);
|
|
19
27
|
};
|
|
20
28
|
|
|
@@ -28,3 +36,18 @@ export const hasPermission = (
|
|
|
28
36
|
if (grant === undefined) return false;
|
|
29
37
|
return grantIncludes(grant, permission);
|
|
30
38
|
};
|
|
39
|
+
|
|
40
|
+
export const hasAnyPermission = (
|
|
41
|
+
matrix: PermissionMatrix | null | undefined,
|
|
42
|
+
role: RoleKey | null | undefined,
|
|
43
|
+
permissions: readonly Permission[],
|
|
44
|
+
): boolean => permissions.some((p) => hasPermission(matrix, role, p));
|
|
45
|
+
|
|
46
|
+
export const effectivePermissions = (
|
|
47
|
+
base: readonly Permission[],
|
|
48
|
+
overrides?: PermissionOverrides,
|
|
49
|
+
): Set<Permission> => {
|
|
50
|
+
const grants = overrides?.grant ?? [];
|
|
51
|
+
const revokes = overrides?.revoke ?? [];
|
|
52
|
+
return new Set([...base, ...grants].filter((p) => !revokes.includes(p)));
|
|
53
|
+
};
|
|
@@ -7,11 +7,18 @@ export {
|
|
|
7
7
|
type RequirePermissionProps,
|
|
8
8
|
type CanProps,
|
|
9
9
|
} from "./PermissionsContext";
|
|
10
|
-
export {
|
|
10
|
+
export {
|
|
11
|
+
hasPermission,
|
|
12
|
+
hasAnyPermission,
|
|
13
|
+
effectivePermissions,
|
|
14
|
+
} from "./hasPermission";
|
|
11
15
|
export {
|
|
12
16
|
PERMISSION_WILDCARD,
|
|
13
17
|
type Permission,
|
|
14
18
|
type PermissionMatrix,
|
|
19
|
+
type PermissionOverrides,
|
|
20
|
+
type PermissionEntry,
|
|
21
|
+
type PermissionGroup,
|
|
15
22
|
type RoleGrant,
|
|
16
23
|
type RoleKey,
|
|
17
24
|
type RoleInfo,
|
|
@@ -13,3 +13,20 @@ export interface RoleInfo {
|
|
|
13
13
|
label: string;
|
|
14
14
|
description?: string;
|
|
15
15
|
}
|
|
16
|
+
|
|
17
|
+
export interface PermissionOverrides {
|
|
18
|
+
grant?: readonly Permission[];
|
|
19
|
+
revoke?: readonly Permission[];
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface PermissionEntry {
|
|
23
|
+
key: Permission;
|
|
24
|
+
label?: string;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface PermissionGroup {
|
|
28
|
+
key?: string;
|
|
29
|
+
label?: string;
|
|
30
|
+
permissions: readonly (Permission | PermissionEntry)[];
|
|
31
|
+
}
|
|
32
|
+
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { describe, expect, it, vi } from "vitest";
|
|
2
|
+
import { fireEvent, render, screen } from "@testing-library/react";
|
|
3
|
+
import { OrganizationProfileForm } from "./OrganizationProfileForm";
|
|
4
|
+
|
|
5
|
+
const ORG = {
|
|
6
|
+
name: "Northwind Labs",
|
|
7
|
+
legalName: "Northwind Laboratories GmbH",
|
|
8
|
+
timezone: "Europe/Berlin",
|
|
9
|
+
email: "ops@northwind.example",
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
const mount = (props: Partial<Parameters<typeof OrganizationProfileForm>[0]> = {}) =>
|
|
13
|
+
render(
|
|
14
|
+
<OrganizationProfileForm value={ORG} onSave={() => undefined} {...props} />,
|
|
15
|
+
);
|
|
16
|
+
|
|
17
|
+
const saveButton = () =>
|
|
18
|
+
screen.getByText("Save changes").closest("button") as HTMLButtonElement;
|
|
19
|
+
|
|
20
|
+
const resetButton = () =>
|
|
21
|
+
screen.getByText("Reset").closest("button") as HTMLButtonElement;
|
|
22
|
+
|
|
23
|
+
describe("OrganizationProfileForm", () => {
|
|
24
|
+
it("renders the fields present in value by default, in canonical order", () => {
|
|
25
|
+
mount();
|
|
26
|
+
expect(screen.getByLabelText("Organization name")).not.toBeNull();
|
|
27
|
+
expect(screen.getByLabelText("Legal name")).not.toBeNull();
|
|
28
|
+
expect(screen.getByLabelText("Timezone")).not.toBeNull();
|
|
29
|
+
expect(screen.getByLabelText("Email")).not.toBeNull();
|
|
30
|
+
expect(screen.queryByLabelText("City")).toBeNull();
|
|
31
|
+
expect(screen.queryByLabelText("Website")).toBeNull();
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it("limits the form to the fields prop when given", () => {
|
|
35
|
+
mount({ fields: ["name", "timezone"] });
|
|
36
|
+
expect(screen.getByLabelText("Organization name")).not.toBeNull();
|
|
37
|
+
expect(screen.getByLabelText("Timezone")).not.toBeNull();
|
|
38
|
+
expect(screen.queryByLabelText("Legal name")).toBeNull();
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it("overrides labels", () => {
|
|
42
|
+
mount({ labels: { name: "Kurum adı", save: "Kaydet" } });
|
|
43
|
+
expect(screen.getByLabelText("Kurum adı")).not.toBeNull();
|
|
44
|
+
expect(screen.getByText("Kaydet")).not.toBeNull();
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it("starts clean and enables save only after an edit", () => {
|
|
48
|
+
mount();
|
|
49
|
+
expect(saveButton().disabled).toBe(true);
|
|
50
|
+
expect(resetButton().disabled).toBe(true);
|
|
51
|
+
|
|
52
|
+
fireEvent.change(screen.getByLabelText("Legal name"), {
|
|
53
|
+
target: { value: "Northwind Labs AG" },
|
|
54
|
+
});
|
|
55
|
+
expect(saveButton().disabled).toBe(false);
|
|
56
|
+
expect(resetButton().disabled).toBe(false);
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
it("hands the edited draft to onSave and keeps untouched fields", () => {
|
|
60
|
+
const onSave = vi.fn();
|
|
61
|
+
mount({ onSave });
|
|
62
|
+
fireEvent.change(screen.getByLabelText("Organization name"), {
|
|
63
|
+
target: { value: "Northwind Group" },
|
|
64
|
+
});
|
|
65
|
+
fireEvent.click(saveButton());
|
|
66
|
+
expect(onSave).toHaveBeenCalledWith({
|
|
67
|
+
...ORG,
|
|
68
|
+
name: "Northwind Group",
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
it("reset restores the initial values", () => {
|
|
73
|
+
mount();
|
|
74
|
+
const input = screen.getByLabelText("Organization name") as HTMLInputElement;
|
|
75
|
+
fireEvent.change(input, { target: { value: "Temporary" } });
|
|
76
|
+
fireEvent.click(resetButton());
|
|
77
|
+
expect(input.value).toBe("Northwind Labs");
|
|
78
|
+
expect(saveButton().disabled).toBe(true);
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
it("blocks save while the name is blank", () => {
|
|
82
|
+
mount();
|
|
83
|
+
fireEvent.change(screen.getByLabelText("Organization name"), {
|
|
84
|
+
target: { value: " " },
|
|
85
|
+
});
|
|
86
|
+
expect(saveButton().disabled).toBe(true);
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
it("renders a select for fields with options", () => {
|
|
90
|
+
mount({
|
|
91
|
+
selects: {
|
|
92
|
+
timezone: [
|
|
93
|
+
{ value: "Europe/Berlin", label: "Berlin" },
|
|
94
|
+
{ value: "Europe/Istanbul", label: "Istanbul" },
|
|
95
|
+
],
|
|
96
|
+
},
|
|
97
|
+
});
|
|
98
|
+
const select = screen.getByLabelText("Timezone") as HTMLSelectElement;
|
|
99
|
+
expect(select.tagName).toBe("SELECT");
|
|
100
|
+
expect(select.value).toBe("Europe/Berlin");
|
|
101
|
+
expect(
|
|
102
|
+
withinOptions(select).some((option) => option.textContent === "Istanbul"),
|
|
103
|
+
).toBe(true);
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
it("disables both actions while busy", () => {
|
|
107
|
+
mount({ busy: true });
|
|
108
|
+
expect(saveButton().disabled).toBe(true);
|
|
109
|
+
expect(resetButton().disabled).toBe(true);
|
|
110
|
+
});
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
const withinOptions = (select: HTMLSelectElement): HTMLOptionElement[] =>
|
|
114
|
+
Array.from(select.querySelectorAll("option"));
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import { useEffect, useMemo, useState } from "react";
|
|
2
|
+
import {
|
|
3
|
+
Button,
|
|
4
|
+
Input,
|
|
5
|
+
NativeSelect,
|
|
6
|
+
} from "@umituz/web-design-system/atoms";
|
|
7
|
+
|
|
8
|
+
export interface OrganizationProfile {
|
|
9
|
+
name: string;
|
|
10
|
+
legalName?: string;
|
|
11
|
+
timezone?: string;
|
|
12
|
+
locale?: string;
|
|
13
|
+
currency?: string;
|
|
14
|
+
address?: string;
|
|
15
|
+
city?: string;
|
|
16
|
+
country?: string;
|
|
17
|
+
phone?: string;
|
|
18
|
+
email?: string;
|
|
19
|
+
website?: string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export type OrganizationFieldKey = keyof OrganizationProfile;
|
|
23
|
+
|
|
24
|
+
export type OrganizationSelectKey = "timezone" | "locale" | "currency";
|
|
25
|
+
|
|
26
|
+
export interface OrganizationSelectOption {
|
|
27
|
+
value: string;
|
|
28
|
+
label: string;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface OrganizationFormLabels {
|
|
32
|
+
name: string;
|
|
33
|
+
legalName: string;
|
|
34
|
+
timezone: string;
|
|
35
|
+
locale: string;
|
|
36
|
+
currency: string;
|
|
37
|
+
address: string;
|
|
38
|
+
city: string;
|
|
39
|
+
country: string;
|
|
40
|
+
phone: string;
|
|
41
|
+
email: string;
|
|
42
|
+
website: string;
|
|
43
|
+
save: string;
|
|
44
|
+
reset: string;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export interface OrganizationProfileFormProps {
|
|
48
|
+
value: OrganizationProfile;
|
|
49
|
+
fields?: readonly OrganizationFieldKey[];
|
|
50
|
+
selects?: Partial<
|
|
51
|
+
Record<OrganizationSelectKey, readonly OrganizationSelectOption[]>
|
|
52
|
+
>;
|
|
53
|
+
labels?: Partial<OrganizationFormLabels>;
|
|
54
|
+
busy?: boolean;
|
|
55
|
+
onSave: (next: OrganizationProfile) => void;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const FIELD_ORDER: readonly OrganizationFieldKey[] = [
|
|
59
|
+
"name",
|
|
60
|
+
"legalName",
|
|
61
|
+
"timezone",
|
|
62
|
+
"locale",
|
|
63
|
+
"currency",
|
|
64
|
+
"address",
|
|
65
|
+
"city",
|
|
66
|
+
"country",
|
|
67
|
+
"phone",
|
|
68
|
+
"email",
|
|
69
|
+
"website",
|
|
70
|
+
];
|
|
71
|
+
|
|
72
|
+
const DEFAULT_LABELS: OrganizationFormLabels = {
|
|
73
|
+
name: "Organization name",
|
|
74
|
+
legalName: "Legal name",
|
|
75
|
+
timezone: "Timezone",
|
|
76
|
+
locale: "Language",
|
|
77
|
+
currency: "Currency",
|
|
78
|
+
address: "Address",
|
|
79
|
+
city: "City",
|
|
80
|
+
country: "Country",
|
|
81
|
+
phone: "Phone",
|
|
82
|
+
email: "Email",
|
|
83
|
+
website: "Website",
|
|
84
|
+
save: "Save changes",
|
|
85
|
+
reset: "Reset",
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
export const OrganizationProfileForm = ({
|
|
89
|
+
value,
|
|
90
|
+
fields,
|
|
91
|
+
selects,
|
|
92
|
+
labels,
|
|
93
|
+
busy = false,
|
|
94
|
+
onSave,
|
|
95
|
+
}: OrganizationProfileFormProps) => {
|
|
96
|
+
const text = { ...DEFAULT_LABELS, ...labels };
|
|
97
|
+
const [draft, setDraft] = useState<OrganizationProfile>(value);
|
|
98
|
+
|
|
99
|
+
useEffect(() => {
|
|
100
|
+
setDraft(value);
|
|
101
|
+
}, [value]);
|
|
102
|
+
|
|
103
|
+
const rendered = useMemo(
|
|
104
|
+
() =>
|
|
105
|
+
fields ??
|
|
106
|
+
FIELD_ORDER.filter((key) => key === "name" || value[key] !== undefined),
|
|
107
|
+
[fields, value],
|
|
108
|
+
);
|
|
109
|
+
|
|
110
|
+
const dirty = rendered.some(
|
|
111
|
+
(key) => (draft[key] ?? "") !== (value[key] ?? ""),
|
|
112
|
+
);
|
|
113
|
+
const nameEmpty = draft.name.trim().length === 0;
|
|
114
|
+
|
|
115
|
+
const setField = (key: OrganizationFieldKey, next: string) =>
|
|
116
|
+
setDraft((current) => ({ ...current, [key]: next }));
|
|
117
|
+
|
|
118
|
+
return (
|
|
119
|
+
<div className="udb-org-form">
|
|
120
|
+
<div className="udb-org-form__grid">
|
|
121
|
+
{rendered.map((key) => {
|
|
122
|
+
const options = selects?.[key as OrganizationSelectKey];
|
|
123
|
+
if (options) {
|
|
124
|
+
return (
|
|
125
|
+
<NativeSelect
|
|
126
|
+
key={key}
|
|
127
|
+
label={text[key]}
|
|
128
|
+
value={draft[key] ?? ""}
|
|
129
|
+
options={options}
|
|
130
|
+
onValueChange={(next) => setField(key, next)}
|
|
131
|
+
/>
|
|
132
|
+
);
|
|
133
|
+
}
|
|
134
|
+
return (
|
|
135
|
+
<Input
|
|
136
|
+
key={key}
|
|
137
|
+
label={text[key]}
|
|
138
|
+
value={draft[key] ?? ""}
|
|
139
|
+
onChange={(event) => setField(key, event.target.value)}
|
|
140
|
+
/>
|
|
141
|
+
);
|
|
142
|
+
})}
|
|
143
|
+
</div>
|
|
144
|
+
<div className="udb-org-form__actions">
|
|
145
|
+
<Button
|
|
146
|
+
variant="secondary"
|
|
147
|
+
disabled={!dirty || busy}
|
|
148
|
+
onClick={() => setDraft(value)}
|
|
149
|
+
>
|
|
150
|
+
{text.reset}
|
|
151
|
+
</Button>
|
|
152
|
+
<Button
|
|
153
|
+
loading={busy}
|
|
154
|
+
disabled={!dirty || busy || nameEmpty}
|
|
155
|
+
onClick={() => onSave(draft)}
|
|
156
|
+
>
|
|
157
|
+
{text.save}
|
|
158
|
+
</Button>
|
|
159
|
+
</div>
|
|
160
|
+
</div>
|
|
161
|
+
);
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
export default OrganizationProfileForm;
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { renderToString } from "react-dom/server";
|
|
3
|
+
import { PermissionMatrixScreen } from "./PermissionMatrixScreen";
|
|
4
|
+
import type { PermissionMatrix } from "../../permissions/types";
|
|
5
|
+
|
|
6
|
+
const MATRIX: PermissionMatrix = {
|
|
7
|
+
owner: "*",
|
|
8
|
+
editor: ["orders.view", "orders.edit"],
|
|
9
|
+
viewer: ["orders.view"],
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
const ROLES = [
|
|
13
|
+
{ key: "owner", label: "Owner" },
|
|
14
|
+
{ key: "editor", label: "Editor" },
|
|
15
|
+
{ key: "viewer", label: "Viewer" },
|
|
16
|
+
];
|
|
17
|
+
|
|
18
|
+
describe("PermissionMatrixScreen", () => {
|
|
19
|
+
it("renders grouped columns with labels and colSpan headers", () => {
|
|
20
|
+
const html = renderToString(
|
|
21
|
+
<PermissionMatrixScreen
|
|
22
|
+
matrix={MATRIX}
|
|
23
|
+
roles={ROLES}
|
|
24
|
+
groups={[
|
|
25
|
+
{
|
|
26
|
+
key: "orders",
|
|
27
|
+
label: "Orders",
|
|
28
|
+
permissions: [
|
|
29
|
+
{ key: "orders.view", label: "View orders" },
|
|
30
|
+
{ key: "orders.edit", label: "Edit orders" },
|
|
31
|
+
],
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
key: "settings",
|
|
35
|
+
label: "Settings",
|
|
36
|
+
permissions: ["settings.manage"],
|
|
37
|
+
},
|
|
38
|
+
]}
|
|
39
|
+
/>,
|
|
40
|
+
);
|
|
41
|
+
expect(html).toContain('colSpan="2"');
|
|
42
|
+
expect(html).toContain("Orders");
|
|
43
|
+
expect(html).toContain("Settings");
|
|
44
|
+
expect(html).toContain("View orders");
|
|
45
|
+
expect(html).toContain("Edit orders");
|
|
46
|
+
expect(html).toContain("settings.manage");
|
|
47
|
+
expect(html).toContain("udb-matrix__check");
|
|
48
|
+
expect(html).toContain("udb-matrix__deny");
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it("renders flat string columns when groups are omitted", () => {
|
|
52
|
+
const html = renderToString(
|
|
53
|
+
<PermissionMatrixScreen
|
|
54
|
+
matrix={MATRIX}
|
|
55
|
+
roles={ROLES}
|
|
56
|
+
permissions={["orders.view", "orders.edit"]}
|
|
57
|
+
/>,
|
|
58
|
+
);
|
|
59
|
+
expect(html).not.toContain("udb-matrix__group");
|
|
60
|
+
expect(html).toContain("orders.view");
|
|
61
|
+
expect(html).toContain("orders.edit");
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
it("renders toggle buttons with aria-pressed in editable mode", () => {
|
|
65
|
+
const html = renderToString(
|
|
66
|
+
<PermissionMatrixScreen
|
|
67
|
+
matrix={MATRIX}
|
|
68
|
+
roles={ROLES}
|
|
69
|
+
permissions={["orders.view", "orders.edit"]}
|
|
70
|
+
onToggle={() => undefined}
|
|
71
|
+
/>,
|
|
72
|
+
);
|
|
73
|
+
expect(html).toContain('aria-pressed="true"');
|
|
74
|
+
expect(html).toContain('aria-pressed="false"');
|
|
75
|
+
expect(html).toContain('aria-label="Editor — orders.view"');
|
|
76
|
+
expect(html).toContain("udb-matrix__cell--on");
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
it("stays read-only without onToggle", () => {
|
|
80
|
+
const html = renderToString(
|
|
81
|
+
<PermissionMatrixScreen
|
|
82
|
+
matrix={MATRIX}
|
|
83
|
+
roles={ROLES}
|
|
84
|
+
permissions={["orders.view"]}
|
|
85
|
+
/>,
|
|
86
|
+
);
|
|
87
|
+
expect(html).not.toContain("<button");
|
|
88
|
+
expect(html).not.toContain("aria-pressed");
|
|
89
|
+
});
|
|
90
|
+
});
|
|
@@ -1,8 +1,18 @@
|
|
|
1
1
|
import { Check, Minus } from "lucide-react";
|
|
2
|
+
import {
|
|
3
|
+
Table,
|
|
4
|
+
TableBody,
|
|
5
|
+
TableCell,
|
|
6
|
+
TableHead,
|
|
7
|
+
TableHeader,
|
|
8
|
+
TableRow,
|
|
9
|
+
} from "@umituz/web-design-system/organisms";
|
|
2
10
|
import { cn } from "@umituz/web-design-system/utils/cn";
|
|
3
11
|
import { hasPermission } from "../../permissions/hasPermission";
|
|
4
12
|
import type {
|
|
5
13
|
Permission,
|
|
14
|
+
PermissionEntry,
|
|
15
|
+
PermissionGroup,
|
|
6
16
|
PermissionMatrix,
|
|
7
17
|
RoleInfo,
|
|
8
18
|
} from "../../permissions/types";
|
|
@@ -10,45 +20,72 @@ import type {
|
|
|
10
20
|
export interface PermissionMatrixScreenProps {
|
|
11
21
|
matrix: PermissionMatrix;
|
|
12
22
|
roles: RoleInfo[];
|
|
13
|
-
|
|
23
|
+
groups?: PermissionGroup[];
|
|
24
|
+
permissions?: (Permission | PermissionEntry)[];
|
|
14
25
|
onToggle?: (role: string, permission: Permission, granted: boolean) => void;
|
|
15
26
|
}
|
|
16
27
|
|
|
28
|
+
const toEntry = (
|
|
29
|
+
column: Permission | PermissionEntry,
|
|
30
|
+
): { key: Permission; label: string } =>
|
|
31
|
+
typeof column === "string"
|
|
32
|
+
? { key: column, label: column }
|
|
33
|
+
: { key: column.key, label: column.label ?? column.key };
|
|
34
|
+
|
|
17
35
|
export const PermissionMatrixScreen = ({
|
|
18
36
|
matrix,
|
|
19
37
|
roles,
|
|
38
|
+
groups,
|
|
20
39
|
permissions,
|
|
21
40
|
onToggle,
|
|
22
|
-
}: PermissionMatrixScreenProps) =>
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
<th className="udb-table__th" />
|
|
28
|
-
{permissions.map((permission) => (
|
|
29
|
-
<th key={permission} className="udb-table__th udb-table__th--code">
|
|
30
|
-
{permission}
|
|
31
|
-
</th>
|
|
41
|
+
}: PermissionMatrixScreenProps) => {
|
|
42
|
+
const columns = groups
|
|
43
|
+
? groups.flatMap((group) => group.permissions.map(toEntry))
|
|
44
|
+
: (permissions ?? []).map(toEntry);
|
|
45
|
+
const hasGroups = Boolean(groups && groups.length > 0);
|
|
32
46
|
|
|
47
|
+
return (
|
|
48
|
+
<Table className="udb-matrix">
|
|
49
|
+
<TableHeader>
|
|
50
|
+
{hasGroups && (
|
|
51
|
+
<TableRow className="udb-matrix__group-row">
|
|
52
|
+
<TableHead className="udb-matrix__corner" />
|
|
53
|
+
{groups!.map((group, index) => (
|
|
54
|
+
<TableHead
|
|
55
|
+
key={group.key ?? group.label ?? index}
|
|
56
|
+
colSpan={group.permissions.length}
|
|
57
|
+
scope="colgroup"
|
|
58
|
+
className="udb-matrix__group"
|
|
59
|
+
>
|
|
60
|
+
{group.label ?? ""}
|
|
61
|
+
</TableHead>
|
|
62
|
+
))}
|
|
63
|
+
</TableRow>
|
|
64
|
+
)}
|
|
65
|
+
<TableRow>
|
|
66
|
+
<TableHead />
|
|
67
|
+
{columns.map((column) => (
|
|
68
|
+
<TableHead key={column.key} className="udb-matrix__col">
|
|
69
|
+
{column.label}
|
|
70
|
+
</TableHead>
|
|
33
71
|
))}
|
|
34
|
-
</
|
|
35
|
-
|
|
36
|
-
</thead>
|
|
72
|
+
</TableRow>
|
|
73
|
+
</TableHeader>
|
|
37
74
|
|
|
38
|
-
<
|
|
75
|
+
<TableBody>
|
|
39
76
|
{roles.map((role) => (
|
|
40
|
-
<
|
|
41
|
-
<
|
|
77
|
+
<TableRow key={role.key}>
|
|
78
|
+
<TableCell className="udb-matrix__role">{role.label}</TableCell>
|
|
42
79
|
|
|
43
|
-
{
|
|
44
|
-
const granted = hasPermission(matrix, role.key,
|
|
80
|
+
{columns.map((column) => {
|
|
81
|
+
const granted = hasPermission(matrix, role.key, column.key);
|
|
45
82
|
const cell = granted ? (
|
|
46
83
|
<Check className="udb-matrix__check" aria-hidden="true" />
|
|
47
84
|
) : (
|
|
48
85
|
<Minus className="udb-matrix__deny" aria-hidden="true" />
|
|
49
86
|
);
|
|
50
87
|
return (
|
|
51
|
-
<
|
|
88
|
+
<TableCell key={column.key} className="udb-matrix__cell-td">
|
|
52
89
|
{onToggle ? (
|
|
53
90
|
<button
|
|
54
91
|
type="button"
|
|
@@ -57,27 +94,22 @@ export const PermissionMatrixScreen = ({
|
|
|
57
94
|
granted && "udb-matrix__cell--on",
|
|
58
95
|
)}
|
|
59
96
|
aria-pressed={granted}
|
|
60
|
-
|
|
97
|
+
aria-label={`${role.label} — ${column.label}`}
|
|
98
|
+
onClick={() => onToggle(role.key, column.key, granted)}
|
|
61
99
|
>
|
|
62
100
|
{cell}
|
|
63
101
|
</button>
|
|
64
|
-
|
|
65
102
|
) : (
|
|
66
103
|
cell
|
|
67
104
|
)}
|
|
68
|
-
</
|
|
69
|
-
|
|
105
|
+
</TableCell>
|
|
70
106
|
);
|
|
71
107
|
})}
|
|
72
|
-
</
|
|
73
|
-
|
|
108
|
+
</TableRow>
|
|
74
109
|
))}
|
|
75
|
-
</
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
</div>
|
|
80
|
-
|
|
81
|
-
);
|
|
110
|
+
</TableBody>
|
|
111
|
+
</Table>
|
|
112
|
+
);
|
|
113
|
+
};
|
|
82
114
|
|
|
83
115
|
export default PermissionMatrixScreen;
|
|
@@ -10,3 +10,12 @@ export {
|
|
|
10
10
|
type PermissionMatrixScreenProps,
|
|
11
11
|
} from './PermissionMatrixScreen';
|
|
12
12
|
export { AuditLogList, type AuditLogListProps, type AuditEntry } from './AuditLogList';
|
|
13
|
+
export {
|
|
14
|
+
OrganizationProfileForm,
|
|
15
|
+
type OrganizationProfileFormProps,
|
|
16
|
+
type OrganizationProfile,
|
|
17
|
+
type OrganizationFieldKey,
|
|
18
|
+
type OrganizationSelectKey,
|
|
19
|
+
type OrganizationSelectOption,
|
|
20
|
+
type OrganizationFormLabels,
|
|
21
|
+
} from './OrganizationProfileForm';
|
package/src/styles/chrome.css
CHANGED
|
@@ -1275,50 +1275,48 @@
|
|
|
1275
1275
|
font-size: var(--udb-font-size-sm);
|
|
1276
1276
|
color: var(--color-muted-foreground);
|
|
1277
1277
|
}
|
|
1278
|
-
.udb-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
border-radius: var(--radius-lg);
|
|
1283
|
-
background: var(--color-card);
|
|
1278
|
+
.udb-org-form {
|
|
1279
|
+
display: flex;
|
|
1280
|
+
flex-direction: column;
|
|
1281
|
+
gap: var(--udb-space-4);
|
|
1284
1282
|
}
|
|
1285
|
-
.udb-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1283
|
+
.udb-org-form__grid {
|
|
1284
|
+
display: grid;
|
|
1285
|
+
grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
|
|
1286
|
+
gap: var(--udb-space-3) var(--udb-space-4);
|
|
1289
1287
|
}
|
|
1290
|
-
.udb-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1288
|
+
.udb-org-form__actions {
|
|
1289
|
+
display: flex;
|
|
1290
|
+
justify-content: flex-end;
|
|
1291
|
+
gap: var(--udb-space-2);
|
|
1292
|
+
}
|
|
1293
|
+
.udb-matrix__group-row th {
|
|
1294
1294
|
font-size: var(--udb-font-size-xs);
|
|
1295
1295
|
font-weight: var(--font-weight-bold);
|
|
1296
1296
|
text-transform: uppercase;
|
|
1297
1297
|
letter-spacing: 0.06em;
|
|
1298
1298
|
color: var(--color-muted-foreground);
|
|
1299
|
-
|
|
1299
|
+
text-align: center;
|
|
1300
|
+
border-bottom: none;
|
|
1301
|
+
padding-bottom: 0;
|
|
1302
|
+
}
|
|
1303
|
+
.udb-matrix__corner {
|
|
1304
|
+
border-bottom: none;
|
|
1305
|
+
padding-bottom: 0;
|
|
1300
1306
|
}
|
|
1301
|
-
.udb-
|
|
1307
|
+
.udb-matrix__col {
|
|
1302
1308
|
font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
|
|
1309
|
+
font-size: var(--udb-font-size-xs);
|
|
1303
1310
|
text-transform: none;
|
|
1304
1311
|
letter-spacing: 0;
|
|
1312
|
+
text-align: center;
|
|
1313
|
+
white-space: nowrap;
|
|
1305
1314
|
}
|
|
1306
|
-
.udb-
|
|
1307
|
-
padding: var(--udb-space-3);
|
|
1308
|
-
border-bottom: 1px solid var(--color-border);
|
|
1309
|
-
color: var(--color-foreground);
|
|
1310
|
-
}
|
|
1311
|
-
.udb-table__row:last-child .udb-table__td {
|
|
1312
|
-
border-bottom: none;
|
|
1313
|
-
}
|
|
1314
|
-
.udb-table__row:hover .udb-table__td {
|
|
1315
|
-
background: var(--color-muted);
|
|
1316
|
-
}
|
|
1317
|
-
.udb-table__td--strong {
|
|
1315
|
+
.udb-matrix__role {
|
|
1318
1316
|
font-weight: var(--font-weight-medium);
|
|
1319
1317
|
white-space: nowrap;
|
|
1320
1318
|
}
|
|
1321
|
-
.udb-
|
|
1319
|
+
.udb-matrix__cell-td {
|
|
1322
1320
|
text-align: center;
|
|
1323
1321
|
}
|
|
1324
1322
|
.udb-matrix__cell {
|