@refinedev/core 4.36.2 → 4.37.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 CHANGED
@@ -1,5 +1,27 @@
1
1
  # @refinedev/core
2
2
 
3
+ ## 4.37.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#4906](https://github.com/refinedev/refine/pull/4906) [`58d3d605510`](https://github.com/refinedev/refine/commit/58d3d605510954a4355a4db3069d68060a062e59) Thanks [@alicanerdurmaz](https://github.com/alicanerdurmaz)! - feat: added `onUnauthorized` callback to `<CanAccess />` component. This callback to be called when [`useCan`](https://refine.dev/docs/api-reference/core/hooks/accessControl/useCan/) returns false.
8
+
9
+ ```tsx
10
+ <CanAccess
11
+ onUnauthorized={({ resource, reason, action, params }) =>
12
+ console.log(
13
+ `You cannot access ${resource}-${params.id} resource with ${action} action because ${reason}`,
14
+ )
15
+ }
16
+ >
17
+ <YourComponent />
18
+ </CanAccess>
19
+ ```
20
+
21
+ ### Patch Changes
22
+
23
+ - [#4926](https://github.com/refinedev/refine/pull/4926) [`053798ae52b`](https://github.com/refinedev/refine/commit/053798ae52b172520aff624a7b518d6dd914ddb7) Thanks [@salihozdemir](https://github.com/salihozdemir)! - fix: update `useForm` warn condition
24
+
3
25
  ## 4.36.2
4
26
 
5
27
  ### Patch Changes
@@ -1,5 +1,18 @@
1
1
  import React from "react";
2
2
  import { BaseKey, IResourceItem, ITreeMenu } from "../../interfaces";
3
+ declare type CanParams = {
4
+ resource?: IResourceItem & {
5
+ children?: ITreeMenu[];
6
+ };
7
+ id?: BaseKey;
8
+ [key: string]: any;
9
+ };
10
+ declare type OnUnauthorizedProps = {
11
+ resource?: string;
12
+ reason?: string;
13
+ action: string;
14
+ params: CanParams;
15
+ };
3
16
  declare type CanAccessBaseProps = {
4
17
  /**
5
18
  * Resource name for API data interactions
@@ -13,17 +26,15 @@ declare type CanAccessBaseProps = {
13
26
  * Parameters associated with the resource
14
27
  * @type { resource?: [IResourceItem](https://refine.dev/docs/api-reference/core/interfaceReferences/#canparams), id?: [BaseKey](https://refine.dev/docs/api-reference/core/interfaceReferences/#basekey), [key: string]: any }
15
28
  */
16
- params?: {
17
- resource?: IResourceItem & {
18
- children?: ITreeMenu[];
19
- };
20
- id?: BaseKey;
21
- [key: string]: any;
22
- };
29
+ params?: CanParams;
23
30
  /**
24
31
  * Content to show if access control returns `false`
25
32
  */
26
33
  fallback?: React.ReactNode;
34
+ /**
35
+ * Callback function to be called if access control returns `can: false`
36
+ */
37
+ onUnauthorized?: (props: OnUnauthorizedProps) => void;
27
38
  children: React.ReactNode;
28
39
  };
29
40
  declare type CanAccessWithoutParamsProps = {
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/canAccess/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAErE,aAAK,kBAAkB,GAAG;IACtB;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,MAAM,CAAC,EAAE;QACL,QAAQ,CAAC,EAAE,aAAa,GAAG;YAAE,QAAQ,CAAC,EAAE,SAAS,EAAE,CAAA;SAAE,CAAC;QACtD,EAAE,CAAC,EAAE,OAAO,CAAC;QACb,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;KACtB,CAAC;IACF;;OAEG;IACH,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC7B,CAAC;AAEF,aAAK,2BAA2B,GAAG;KAC9B,GAAG,IAAI,OAAO,CACX,MAAM,kBAAkB,EACxB,UAAU,GAAG,UAAU,CAC1B,CAAC,CAAC,EAAE,SAAS;CACjB,GAA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