@umituz/web-dashboard 8.10.0 → 8.11.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umituz/web-dashboard",
3
- "version": "8.10.0",
3
+ "version": "8.11.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",
@@ -3,8 +3,8 @@ import { ShieldAlert } from "lucide-react";
3
3
  import { Button } from "@umituz/web-design-system/atoms";
4
4
 
5
5
  export interface AccessDeniedProps {
6
- title?: string;
7
- description?: string;
6
+ title?: ReactNode;
7
+ description?: ReactNode;
8
8
  actionLabel?: string;
9
9
  onAction?: () => void;
10
10
  icon?: ReactNode;
@@ -12,8 +12,8 @@ export interface AccessDeniedProps {
12
12
  }
13
13
 
14
14
  export const AccessDenied = ({
15
- title = "Erişim Yetkisi Yok",
16
- description = "Bu sayfayı görüntülemek veya bu işlemi gerçekleştirmek için gerekli izne sahip değilsiniz.",
15
+ title,
16
+ description,
17
17
  actionLabel,
18
18
  onAction,
19
19
  icon,
@@ -24,8 +24,12 @@ export const AccessDenied = ({
24
24
  <div className="mb-4 flex h-14 w-14 items-center justify-center rounded-full bg-rose-500/10 text-rose-500">
25
25
  {icon ?? <ShieldAlert className="h-7 w-7" aria-hidden="true" />}
26
26
  </div>
27
- <h2 className="mb-2 font-display text-xl font-bold tracking-tight text-ink">{title}</h2>
28
- <p className="max-w-md text-sm text-ink-2 leading-relaxed">{description}</p>
27
+ {title && (
28
+ <h2 className="mb-2 font-display text-xl font-bold tracking-tight text-ink">{title}</h2>
29
+ )}
30
+ {description && (
31
+ <p className="max-w-md text-sm text-ink-2 leading-relaxed">{description}</p>
32
+ )}
29
33
  {children && <div className="mt-4">{children}</div>}
30
34
  {actionLabel && onAction && (
31
35
  <div className="mt-6">
@@ -172,15 +172,22 @@ describe("ProtectedRoute", () => {
172
172
  expect(screen.getByText("Protected Area")).not.toBeNull();
173
173
  });
174
174
 
175
- it("renders fallback AccessDenied when unauthorized without redirect", () => {
175
+ it("renders fallback AccessDenied with custom props when unauthorized without redirect", () => {
176
176
  mount("viewer", (
177
177
  <MemoryRouter>
178
- <ProtectedRoute permission="orders.edit">
178
+ <ProtectedRoute
179
+ permission="orders.edit"
180
+ accessDeniedProps={{
181
+ title: "Access Forbidden",
182
+ description: "You cannot view this area",
183
+ }}
184
+ >
179
185
  <span>Protected Area</span>
180
186
  </ProtectedRoute>
181
187
  </MemoryRouter>
182
188
  ));
183
189
  expect(screen.queryByText("Protected Area")).toBeNull();
184
- expect(screen.getByText("Erişim Yetkisi Yok")).not.toBeNull();
190
+ expect(screen.getByText("Access Forbidden")).not.toBeNull();
191
+ expect(screen.getByText("You cannot view this area")).not.toBeNull();
185
192
  });
186
193
  });
@@ -2,7 +2,7 @@ import { createContext, useCallback, useContext, useMemo, type ReactNode } from
2
2
  import { Navigate } from "react-router";
3
3
  import { hasAnyPermission, hasPermission } from "./hasPermission";
4
4
  import type { Permission, PermissionMatrix, RoleKey } from "./types";
5
- import { AccessDenied } from "./AccessDenied";
5
+ import { AccessDenied, type AccessDeniedProps } from "./AccessDenied";
6
6
 
7
7
  export interface PermissionsProviderProps {
8
8
  matrix: PermissionMatrix;
@@ -127,13 +127,14 @@ export interface ProtectedRouteProps {
127
127
  children: ReactNode;
128
128
  redirectTo?: string;
129
129
  fallback?: ReactNode;
130
+ accessDeniedProps?: AccessDeniedProps;
130
131
  }
131
132
 
132
133
  /**
133
134
  * Route-level permission guard. If the user lacks the permission:
134
135
  * - Renders `fallback` if provided
135
136
  * - Redirects to `redirectTo` if provided
136
- * - Otherwise displays the standard `<AccessDenied />` screen
137
+ * - Otherwise displays `<AccessDenied {...accessDeniedProps} />`
137
138
  */
138
139
  export const ProtectedRoute = ({
139
140
  permission,
@@ -141,13 +142,14 @@ export const ProtectedRoute = ({
141
142
  children,
142
143
  redirectTo,
143
144
  fallback,
145
+ accessDeniedProps,
144
146
  }: ProtectedRouteProps) => {
145
147
  const { can, canAny } = usePermissions();
146
148
  const allowed = resolveAllowed(can, canAny, permission, anyOf);
147
149
  if (!allowed) {
148
150
  if (fallback !== undefined) return <>{fallback}</>;
149
151
  if (redirectTo !== undefined) return <Navigate to={redirectTo} replace />;
150
- return <AccessDenied />;
152
+ return <AccessDenied {...accessDeniedProps} />;
151
153
  }
152
154
  return <>{children}</>;
153
155
  };
@@ -74,9 +74,9 @@ export function createProductTour(config: TourConfig): TourEngineInstance {
74
74
  onStepChange,
75
75
  } = config;
76
76
 
77
- const nextBtnDefault = labels.next ?? "İleri";
78
- const prevBtnDefault = labels.prev ?? "Geri";
79
- const doneBtnDefault = labels.done ?? "Tamamla";
77
+ const nextBtnDefault = labels.next;
78
+ const prevBtnDefault = labels.prev;
79
+ const doneBtnDefault = labels.done;
80
80
  const progressTextTemplate = labels.progress ?? "{{current}} / {{total}}";
81
81
 
82
82
  let completedSuccessfully = false;
@@ -24,7 +24,7 @@ export interface TourStep {
24
24
  */
25
25
  align?: TourAlign;
26
26
  /**
27
- * Optional small badge text displayed before the title (e.g. "Yeni", "Adım 1").
27
+ * Optional small badge text displayed before the title (e.g. "New", "Step 1").
28
28
  */
29
29
  badge?: string;
30
30
  }