@stream-io/video-react-bindings 0.0.10 → 0.0.12
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 +20 -0
- package/dist/src/contexts/StreamVideoContext.js +20 -1
- package/dist/src/contexts/StreamVideoContext.js.map +1 -1
- package/dist/src/hooks/call.d.ts +0 -16
- package/dist/src/hooks/call.js +0 -22
- package/dist/src/hooks/call.js.map +1 -1
- package/dist/src/wrappers/Restricted.d.ts +11 -3
- package/dist/src/wrappers/Restricted.js +5 -1
- package/dist/src/wrappers/Restricted.js.map +1 -1
- package/package.json +3 -3
- package/src/contexts/StreamVideoContext.tsx +33 -1
- package/src/hooks/call.ts +0 -24
- package/src/wrappers/Restricted.tsx +19 -2
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,26 @@
|
|
|
2
2
|
|
|
3
3
|
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
|
|
4
4
|
|
|
5
|
+
### [0.0.12](https://github.com/GetStream/stream-video-js/compare/@stream-io/video-react-bindings-0.0.11...@stream-io/video-react-bindings-0.0.12) (2023-06-13)
|
|
6
|
+
|
|
7
|
+
### Dependency Updates
|
|
8
|
+
|
|
9
|
+
* `@stream-io/video-client` updated to version `0.0.1`
|
|
10
|
+
|
|
11
|
+
### Features
|
|
12
|
+
|
|
13
|
+
* Make it possible to provide user and token in StreamVideoClient… ([#631](https://github.com/GetStream/stream-video-js/issues/631)) ([93f9b03](https://github.com/GetStream/stream-video-js/commit/93f9b03313ac74179f1d93b513ea4de306312291))
|
|
14
|
+
|
|
15
|
+
### [0.0.11](https://github.com/GetStream/stream-video-js/compare/@stream-io/video-react-bindings-0.0.10...@stream-io/video-react-bindings-0.0.11) (2023-06-13)
|
|
16
|
+
|
|
17
|
+
### Dependency Updates
|
|
18
|
+
|
|
19
|
+
* `@stream-io/video-client` updated to version `0.0.1`
|
|
20
|
+
|
|
21
|
+
### Features
|
|
22
|
+
|
|
23
|
+
* add audio room demo app ([#572](https://github.com/GetStream/stream-video-js/issues/572)) ([77f7b65](https://github.com/GetStream/stream-video-js/commit/77f7b6596047d59e10c8e58abad38c4f48cc162f))
|
|
24
|
+
|
|
5
25
|
### [0.0.10](https://github.com/GetStream/stream-video-js/compare/@stream-io/video-react-bindings-0.0.9...@stream-io/video-react-bindings-0.0.10) (2023-06-12)
|
|
6
26
|
|
|
7
27
|
### Dependency Updates
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { createContext, useContext } from 'react';
|
|
2
|
+
import { createContext, useContext, useEffect, useRef, } from 'react';
|
|
3
3
|
import { StreamI18nProvider, } from './StreamI18nContext';
|
|
4
4
|
const StreamVideoContext = createContext(undefined);
|
|
5
5
|
/**
|
|
@@ -9,6 +9,25 @@ const StreamVideoContext = createContext(undefined);
|
|
|
9
9
|
* @category Client State
|
|
10
10
|
*/
|
|
11
11
|
export const StreamVideo = ({ children, client, i18nInstance, language, translationsOverrides, }) => {
|
|
12
|
+
const prevClient = useRef(undefined);
|
|
13
|
+
useEffect(() => {
|
|
14
|
+
if (prevClient.current) {
|
|
15
|
+
prevClient.current
|
|
16
|
+
.disconnectUser()
|
|
17
|
+
.catch((error) => console.error(`Failed to disconnect`, error));
|
|
18
|
+
}
|
|
19
|
+
if (client.user) {
|
|
20
|
+
client
|
|
21
|
+
.connectUser()
|
|
22
|
+
.catch((error) => console.error('Failed to establish connection', error));
|
|
23
|
+
}
|
|
24
|
+
prevClient.current = client;
|
|
25
|
+
return () => {
|
|
26
|
+
client
|
|
27
|
+
.disconnectUser()
|
|
28
|
+
.catch((error) => console.error(`Failed to disconnect`, error));
|
|
29
|
+
};
|
|
30
|
+
}, [client]);
|
|
12
31
|
return (_jsx(StreamVideoContext.Provider, Object.assign({ value: client }, { children: _jsx(StreamI18nProvider, Object.assign({ i18nInstance: i18nInstance, language: language, translationsOverrides: translationsOverrides }, { children: children })) })));
|
|
13
32
|
};
|
|
14
33
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StreamVideoContext.js","sourceRoot":"","sources":["../../../src/contexts/StreamVideoContext.tsx"],"names":[],"mappings":";AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"StreamVideoContext.js","sourceRoot":"","sources":["../../../src/contexts/StreamVideoContext.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,aAAa,EAEb,UAAU,EACV,SAAS,EACT,MAAM,GACP,MAAM,OAAO,CAAC;AAEf,OAAO,EACL,kBAAkB,GAEnB,MAAM,qBAAqB,CAAC;AAE7B,MAAM,kBAAkB,GAAG,aAAa,CACtC,SAAS,CACV,CAAC;AAUF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,EAC1B,QAAQ,EACR,MAAM,EACN,YAAY,EACZ,QAAQ,EACR,qBAAqB,GACe,EAAE,EAAE;IACxC,MAAM,UAAU,GAAG,MAAM,CAAgC,SAAS,CAAC,CAAC;IAEpE,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,UAAU,CAAC,OAAO,EAAE;YACtB,UAAU,CAAC,OAAO;iBACf,cAAc,EAAE;iBAChB,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,sBAAsB,EAAE,KAAK,CAAC,CAAC,CAAC;SACnE;QAED,IAAI,MAAM,CAAC,IAAI,EAAE;YACf,MAAM;iBACH,WAAW,EAAE;iBACb,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE,CACf,OAAO,CAAC,KAAK,CAAC,gCAAgC,EAAE,KAAK,CAAC,CACvD,CAAC;SACL;QAED,UAAU,CAAC,OAAO,GAAG,MAAM,CAAC;QAE5B,OAAO,GAAG,EAAE;YACV,MAAM;iBACH,cAAc,EAAE;iBAChB,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,sBAAsB,EAAE,KAAK,CAAC,CAAC,CAAC;QACpE,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC;IAEb,OAAO,CACL,KAAC,kBAAkB,CAAC,QAAQ,kBAAC,KAAK,EAAE,MAAM,gBACxC,KAAC,kBAAkB,kBACjB,YAAY,EAAE,YAAY,EAC1B,QAAQ,EAAE,QAAQ,EAClB,qBAAqB,EAAE,qBAAqB,gBAE3C,QAAQ,IACU,IACO,CAC/B,CAAC;AACJ,CAAC,CAAC;AAEF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,GAAG,EAAE;IACvC,OAAO,UAAU,CAAC,kBAAkB,CAAC,CAAC;AACxC,CAAC,CAAC"}
|
package/dist/src/hooks/call.d.ts
CHANGED
|
@@ -50,22 +50,6 @@ export declare const useDominantSpeaker: () => import("@stream-io/video-client")
|
|
|
50
50
|
* @category Client State
|
|
51
51
|
*/
|
|
52
52
|
export declare const useCalls: () => import("@stream-io/video-client").Call[];
|
|
53
|
-
/**
|
|
54
|
-
* Utility hook which provides a list of all incoming ring calls (somebody calls me).
|
|
55
|
-
*
|
|
56
|
-
* @deprecated derive from useCalls()/useCall() instead.
|
|
57
|
-
* @internal
|
|
58
|
-
* @category Client State
|
|
59
|
-
*/
|
|
60
|
-
export declare const useIncomingCalls: () => import("@stream-io/video-client").Call[];
|
|
61
|
-
/**
|
|
62
|
-
* Utility hook which provides a list of all outgoing ring calls (I call somebody).
|
|
63
|
-
*
|
|
64
|
-
* @deprecated derive from useCalls()/useCall() instead.
|
|
65
|
-
* @internal
|
|
66
|
-
* @category Client State
|
|
67
|
-
*/
|
|
68
|
-
export declare const useOutgoingCalls: () => import("@stream-io/video-client").Call[];
|
|
69
53
|
/**
|
|
70
54
|
* Utility hook which provides call metadata (such as blocked users and own capabilities).
|
|
71
55
|
*
|
package/dist/src/hooks/call.js
CHANGED
|
@@ -73,28 +73,6 @@ export const useCalls = () => {
|
|
|
73
73
|
const { calls$ } = useStore();
|
|
74
74
|
return useObservableValue(calls$);
|
|
75
75
|
};
|
|
76
|
-
/**
|
|
77
|
-
* Utility hook which provides a list of all incoming ring calls (somebody calls me).
|
|
78
|
-
*
|
|
79
|
-
* @deprecated derive from useCalls()/useCall() instead.
|
|
80
|
-
* @internal
|
|
81
|
-
* @category Client State
|
|
82
|
-
*/
|
|
83
|
-
export const useIncomingCalls = () => {
|
|
84
|
-
const { incomingCalls$ } = useStore();
|
|
85
|
-
return useObservableValue(incomingCalls$);
|
|
86
|
-
};
|
|
87
|
-
/**
|
|
88
|
-
* Utility hook which provides a list of all outgoing ring calls (I call somebody).
|
|
89
|
-
*
|
|
90
|
-
* @deprecated derive from useCalls()/useCall() instead.
|
|
91
|
-
* @internal
|
|
92
|
-
* @category Client State
|
|
93
|
-
*/
|
|
94
|
-
export const useOutgoingCalls = () => {
|
|
95
|
-
const { outgoingCalls$ } = useStore();
|
|
96
|
-
return useObservableValue(outgoingCalls$);
|
|
97
|
-
};
|
|
98
76
|
/**
|
|
99
77
|
* Utility hook which provides call metadata (such as blocked users and own capabilities).
|
|
100
78
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"call.js","sourceRoot":"","sources":["../../../src/hooks/call.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAEjD;;;;GAIG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAAG,GAAG,EAAE;IAC/C,MAAM,QAAQ,GAAG,eAAe,EAAE,CAAC;IACnC,OAAO,CAAC,CAAC,CAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,SAAS,CAAA,CAAC;AAC/B,CAAC,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,+BAA+B,GAAG,GAAG,EAAE;IAClD,MAAM,QAAQ,GAAG,eAAe,EAAE,CAAC;IACnC,OAAO,CAAC,CAA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|
3
3
|
type RestrictedProps = PropsWithChildren<{
|
|
4
|
+
/**
|
|
5
|
+
* Required grants for the component to be able to render supplied children elements
|
|
6
|
+
*/
|
|
7
|
+
requiredGrants: OwnCapability[];
|
|
4
8
|
/**
|
|
5
9
|
* OwnCapabilities of the participant - grants they have available
|
|
6
10
|
*/
|
|
7
11
|
availableGrants?: OwnCapability[];
|
|
8
12
|
/**
|
|
9
|
-
*
|
|
13
|
+
* Render children only if user can request capability, but does not have it
|
|
10
14
|
*/
|
|
11
|
-
|
|
15
|
+
canRequestOnly?: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Render children only if user has capability
|
|
18
|
+
*/
|
|
19
|
+
hasPermissionsOnly?: boolean;
|
|
12
20
|
/**
|
|
13
21
|
* Require all grants specified in `requiredGrants` to be available in the `availableGrants`,
|
|
14
22
|
* component by default requires only one grant to appear in both arrays to render its children
|
|
15
23
|
*/
|
|
16
24
|
requireAll?: boolean;
|
|
17
25
|
}>;
|
|
18
|
-
export declare const Restricted: ({ availableGrants: availableGrantsFromProps, requiredGrants, requireAll, children, }: RestrictedProps) => JSX.Element | null;
|
|
26
|
+
export declare const Restricted: ({ availableGrants: availableGrantsFromProps, canRequestOnly, hasPermissionsOnly, requiredGrants, requireAll, children, }: RestrictedProps) => JSX.Element | null;
|
|
19
27
|
export {};
|
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { useCall } from '../contexts';
|
|
3
3
|
import { useOwnCapabilities } from '../hooks';
|
|
4
|
-
export const Restricted = ({ availableGrants: availableGrantsFromProps, requiredGrants, requireAll = true, children, }) => {
|
|
4
|
+
export const Restricted = ({ availableGrants: availableGrantsFromProps, canRequestOnly, hasPermissionsOnly, requiredGrants, requireAll = true, children, }) => {
|
|
5
5
|
const call = useCall();
|
|
6
6
|
const ownCapabilities = useOwnCapabilities();
|
|
7
7
|
const availableGrants = availableGrantsFromProps !== null && availableGrantsFromProps !== void 0 ? availableGrantsFromProps : ownCapabilities;
|
|
8
8
|
const hasPermissions = requiredGrants[requireAll ? 'every' : 'some']((capability) => availableGrants.includes(capability));
|
|
9
|
+
if (hasPermissionsOnly)
|
|
10
|
+
return hasPermissions ? _jsx(_Fragment, { children: children }) : null;
|
|
9
11
|
const canRequest = requiredGrants.some((capability) => !!call && call.permissionsContext.canRequest(capability));
|
|
12
|
+
if (canRequestOnly)
|
|
13
|
+
return canRequest ? _jsx(_Fragment, { children: children }) : null;
|
|
10
14
|
if (hasPermissions || canRequest)
|
|
11
15
|
return _jsx(_Fragment, { children: children });
|
|
12
16
|
return null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Restricted.js","sourceRoot":"","sources":["../../../src/wrappers/Restricted.tsx"],"names":[],"mappings":";AAGA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"Restricted.js","sourceRoot":"","sources":["../../../src/wrappers/Restricted.tsx"],"names":[],"mappings":";AAGA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AA0B9C,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,EACzB,eAAe,EAAE,wBAAwB,EACzC,cAAc,EACd,kBAAkB,EAClB,cAAc,EACd,UAAU,GAAG,IAAI,EACjB,QAAQ,GACQ,EAAE,EAAE;IACpB,MAAM,IAAI,GAAG,OAAO,EAAE,CAAC;IACvB,MAAM,eAAe,GAAG,kBAAkB,EAAE,CAAC;IAC7C,MAAM,eAAe,GAAG,wBAAwB,aAAxB,wBAAwB,cAAxB,wBAAwB,GAAI,eAAe,CAAC;IACpE,MAAM,cAAc,GAAG,cAAc,CAAC,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAClE,CAAC,UAAU,EAAE,EAAE,CAAC,eAAe,CAAC,QAAQ,CAAC,UAAU,CAAC,CACrD,CAAC;IAEF,IAAI,kBAAkB;QAAE,OAAO,cAAc,CAAC,CAAC,CAAC,4BAAG,QAAQ,GAAI,CAAC,CAAC,CAAC,IAAI,CAAC;IAEvE,MAAM,UAAU,GAAG,cAAc,CAAC,IAAI,CACpC,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,IAAI,IAAI,CAAC,kBAAkB,CAAC,UAAU,CAAC,UAAU,CAAC,CACzE,CAAC;IAEF,IAAI,cAAc;QAAE,OAAO,UAAU,CAAC,CAAC,CAAC,4BAAG,QAAQ,GAAI,CAAC,CAAC,CAAC,IAAI,CAAC;IAE/D,IAAI,cAAc,IAAI,UAAU;QAAE,OAAO,4BAAG,QAAQ,GAAI,CAAC;IAEzD,OAAO,IAAI,CAAC;AACd,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -24,12 +24,12 @@
|
|
|
24
24
|
},
|
|
25
25
|
"peerDependencies": {
|
|
26
26
|
"@stream-io/i18n": "^0.0.3",
|
|
27
|
-
"@stream-io/video-client": "^0.0.
|
|
27
|
+
"@stream-io/video-client": "^0.0.12",
|
|
28
28
|
"react": ">=17.0.0"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@stream-io/i18n": "^0.0.3",
|
|
32
|
-
"@stream-io/video-client": "^0.0.
|
|
32
|
+
"@stream-io/video-client": "^0.0.12",
|
|
33
33
|
"@types/react": "^18.0.26",
|
|
34
34
|
"@types/rimraf": "^3.0.2",
|
|
35
35
|
"react": "^18.2.0",
|
|
@@ -39,5 +39,5 @@
|
|
|
39
39
|
"typedoc-plugin-markdown": "^3.15.3",
|
|
40
40
|
"typescript": "^4.9.5"
|
|
41
41
|
},
|
|
42
|
-
"version": "0.0.
|
|
42
|
+
"version": "0.0.12"
|
|
43
43
|
}
|
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
createContext,
|
|
3
|
+
PropsWithChildren,
|
|
4
|
+
useContext,
|
|
5
|
+
useEffect,
|
|
6
|
+
useRef,
|
|
7
|
+
} from 'react';
|
|
2
8
|
import { StreamVideoClient } from '@stream-io/video-client';
|
|
3
9
|
import {
|
|
4
10
|
StreamI18nProvider,
|
|
@@ -30,6 +36,32 @@ export const StreamVideo = ({
|
|
|
30
36
|
language,
|
|
31
37
|
translationsOverrides,
|
|
32
38
|
}: PropsWithChildren<StreamVideoProps>) => {
|
|
39
|
+
const prevClient = useRef<StreamVideoClient | undefined>(undefined);
|
|
40
|
+
|
|
41
|
+
useEffect(() => {
|
|
42
|
+
if (prevClient.current) {
|
|
43
|
+
prevClient.current
|
|
44
|
+
.disconnectUser()
|
|
45
|
+
.catch((error) => console.error(`Failed to disconnect`, error));
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
if (client.user) {
|
|
49
|
+
client
|
|
50
|
+
.connectUser()
|
|
51
|
+
.catch((error) =>
|
|
52
|
+
console.error('Failed to establish connection', error),
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
prevClient.current = client;
|
|
57
|
+
|
|
58
|
+
return () => {
|
|
59
|
+
client
|
|
60
|
+
.disconnectUser()
|
|
61
|
+
.catch((error) => console.error(`Failed to disconnect`, error));
|
|
62
|
+
};
|
|
63
|
+
}, [client]);
|
|
64
|
+
|
|
33
65
|
return (
|
|
34
66
|
<StreamVideoContext.Provider value={client}>
|
|
35
67
|
<StreamI18nProvider
|
package/src/hooks/call.ts
CHANGED
|
@@ -81,30 +81,6 @@ export const useCalls = () => {
|
|
|
81
81
|
return useObservableValue(calls$);
|
|
82
82
|
};
|
|
83
83
|
|
|
84
|
-
/**
|
|
85
|
-
* Utility hook which provides a list of all incoming ring calls (somebody calls me).
|
|
86
|
-
*
|
|
87
|
-
* @deprecated derive from useCalls()/useCall() instead.
|
|
88
|
-
* @internal
|
|
89
|
-
* @category Client State
|
|
90
|
-
*/
|
|
91
|
-
export const useIncomingCalls = () => {
|
|
92
|
-
const { incomingCalls$ } = useStore();
|
|
93
|
-
return useObservableValue(incomingCalls$);
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
/**
|
|
97
|
-
* Utility hook which provides a list of all outgoing ring calls (I call somebody).
|
|
98
|
-
*
|
|
99
|
-
* @deprecated derive from useCalls()/useCall() instead.
|
|
100
|
-
* @internal
|
|
101
|
-
* @category Client State
|
|
102
|
-
*/
|
|
103
|
-
export const useOutgoingCalls = () => {
|
|
104
|
-
const { outgoingCalls$ } = useStore();
|
|
105
|
-
return useObservableValue(outgoingCalls$);
|
|
106
|
-
};
|
|
107
|
-
|
|
108
84
|
/**
|
|
109
85
|
* Utility hook which provides call metadata (such as blocked users and own capabilities).
|
|
110
86
|
*
|
|
@@ -5,14 +5,22 @@ import { useCall } from '../contexts';
|
|
|
5
5
|
import { useOwnCapabilities } from '../hooks';
|
|
6
6
|
|
|
7
7
|
type RestrictedProps = PropsWithChildren<{
|
|
8
|
+
/**
|
|
9
|
+
* Required grants for the component to be able to render supplied children elements
|
|
10
|
+
*/
|
|
11
|
+
requiredGrants: OwnCapability[];
|
|
8
12
|
/**
|
|
9
13
|
* OwnCapabilities of the participant - grants they have available
|
|
10
14
|
*/
|
|
11
15
|
availableGrants?: OwnCapability[];
|
|
12
16
|
/**
|
|
13
|
-
*
|
|
17
|
+
* Render children only if user can request capability, but does not have it
|
|
14
18
|
*/
|
|
15
|
-
|
|
19
|
+
canRequestOnly?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Render children only if user has capability
|
|
22
|
+
*/
|
|
23
|
+
hasPermissionsOnly?: boolean;
|
|
16
24
|
/**
|
|
17
25
|
* Require all grants specified in `requiredGrants` to be available in the `availableGrants`,
|
|
18
26
|
* component by default requires only one grant to appear in both arrays to render its children
|
|
@@ -22,6 +30,8 @@ type RestrictedProps = PropsWithChildren<{
|
|
|
22
30
|
|
|
23
31
|
export const Restricted = ({
|
|
24
32
|
availableGrants: availableGrantsFromProps,
|
|
33
|
+
canRequestOnly,
|
|
34
|
+
hasPermissionsOnly,
|
|
25
35
|
requiredGrants,
|
|
26
36
|
requireAll = true,
|
|
27
37
|
children,
|
|
@@ -32,9 +42,16 @@ export const Restricted = ({
|
|
|
32
42
|
const hasPermissions = requiredGrants[requireAll ? 'every' : 'some'](
|
|
33
43
|
(capability) => availableGrants.includes(capability),
|
|
34
44
|
);
|
|
45
|
+
|
|
46
|
+
if (hasPermissionsOnly) return hasPermissions ? <>{children}</> : null;
|
|
47
|
+
|
|
35
48
|
const canRequest = requiredGrants.some(
|
|
36
49
|
(capability) => !!call && call.permissionsContext.canRequest(capability),
|
|
37
50
|
);
|
|
51
|
+
|
|
52
|
+
if (canRequestOnly) return canRequest ? <>{children}</> : null;
|
|
53
|
+
|
|
38
54
|
if (hasPermissions || canRequest) return <>{children}</>;
|
|
55
|
+
|
|
39
56
|
return null;
|
|
40
57
|
};
|