@refinedev/core 4.36.2 → 4.38.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 +44 -0
- package/dist/components/canAccess/index.d.ts +18 -7
- package/dist/components/canAccess/index.d.ts.map +1 -1
- package/dist/esm/index.js +6 -6
- package/dist/esm/index.js.map +1 -1
- package/dist/hooks/form/useForm.d.ts.map +1 -1
- package/dist/iife/index.js +6 -6
- package/dist/iife/index.js.map +1 -1
- package/dist/index.js +6 -6
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/canAccess/index.tsx +44 -15
- package/src/hooks/form/useForm.ts +2 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,49 @@
|
|
|
1
1
|
# @refinedev/core
|
|
2
2
|
|
|
3
|
+
## 4.38.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
|
+
|
|
25
|
+
## 4.37.0
|
|
26
|
+
|
|
27
|
+
### Minor Changes
|
|
28
|
+
|
|
29
|
+
- [#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.
|
|
30
|
+
|
|
31
|
+
```tsx
|
|
32
|
+
<CanAccess
|
|
33
|
+
onUnauthorized={({ resource, reason, action, params }) =>
|
|
34
|
+
console.log(
|
|
35
|
+
`You cannot access ${resource}-${params.id} resource with ${action} action because ${reason}`,
|
|
36
|
+
)
|
|
37
|
+
}
|
|
38
|
+
>
|
|
39
|
+
<YourComponent />
|
|
40
|
+
</CanAccess>
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### Patch Changes
|
|
44
|
+
|
|
45
|
+
- [#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
|
|
46
|
+
|
|
3
47
|
## 4.36.2
|
|
4
48
|
|
|
5
49
|
### 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,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/canAccess/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAoB,MAAM,OAAO,CAAC;AAGzC,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAErE,aAAK,SAAS,GAAG;IACb,QAAQ,CAAC,EAAE,aAAa,GAAG;QAAE,QAAQ,CAAC,EAAE,SAAS,EAAE,CAAA;KAAE,CAAC;IACtD,EAAE,CAA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