@backstage/plugin-permission-react 0.4.42-next.0 → 0.5.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
|
# @backstage/plugin-permission-react
|
|
2
2
|
|
|
3
|
+
## 0.5.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 53954e1: **BREAKING**: Removed the deprecated `PermissionedRoute` component. Use `RequirePermission` instead.
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies
|
|
12
|
+
- @backstage/config@1.3.7
|
|
13
|
+
- @backstage/core-plugin-api@1.12.5
|
|
14
|
+
- @backstage/plugin-permission-common@0.9.8
|
|
15
|
+
|
|
16
|
+
## 0.4.42-next.1
|
|
17
|
+
|
|
18
|
+
### Patch Changes
|
|
19
|
+
|
|
20
|
+
- Updated dependencies
|
|
21
|
+
- @backstage/config@1.3.7-next.0
|
|
22
|
+
- @backstage/core-plugin-api@1.12.5-next.2
|
|
23
|
+
- @backstage/plugin-permission-common@0.9.8-next.0
|
|
24
|
+
|
|
3
25
|
## 0.4.42-next.0
|
|
4
26
|
|
|
5
27
|
### Patch Changes
|
package/dist/index.d.ts
CHANGED
|
@@ -1,30 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { ReactNode, ReactElement } from 'react';
|
|
1
|
+
import { ReactNode } from 'react';
|
|
3
2
|
import { Permission, ResourcePermission, EvaluatePermissionRequest, EvaluatePermissionResponse, AuthorizePermissionRequest, AuthorizePermissionResponse } from '@backstage/plugin-permission-common';
|
|
4
3
|
import { ApiRef, DiscoveryApi, IdentityApi } from '@backstage/core-plugin-api';
|
|
5
4
|
import { Config } from '@backstage/config';
|
|
6
5
|
|
|
7
|
-
/**
|
|
8
|
-
* Returns a React Router Route which only renders the element when authorized. If unauthorized, the Route will render a
|
|
9
|
-
* NotFoundErrorPage (see {@link @backstage/core-app-api#AppComponents}).
|
|
10
|
-
*
|
|
11
|
-
* @public
|
|
12
|
-
* @deprecated This component no longer works with the most recent version of `@backstage/core-app-api` and react-router v6, use {@link RequirePermission} instead.
|
|
13
|
-
*/
|
|
14
|
-
declare const PermissionedRoute: (props: {
|
|
15
|
-
caseSensitive?: boolean;
|
|
16
|
-
children?: ReactNode;
|
|
17
|
-
element?: ReactElement | null;
|
|
18
|
-
path?: string;
|
|
19
|
-
errorComponent?: ReactElement | null;
|
|
20
|
-
} & ({
|
|
21
|
-
permission: Exclude<Permission, ResourcePermission>;
|
|
22
|
-
resourceRef?: never;
|
|
23
|
-
} | {
|
|
24
|
-
permission: ResourcePermission;
|
|
25
|
-
resourceRef: string | undefined;
|
|
26
|
-
})) => react_jsx_runtime.JSX.Element;
|
|
27
|
-
|
|
28
6
|
/**
|
|
29
7
|
* Properties for {@link RequirePermission}
|
|
30
8
|
*
|
|
@@ -121,5 +99,5 @@ declare class IdentityPermissionApi implements PermissionApi {
|
|
|
121
99
|
authorize(request: AuthorizePermissionRequest): Promise<AuthorizePermissionResponse>;
|
|
122
100
|
}
|
|
123
101
|
|
|
124
|
-
export { IdentityPermissionApi,
|
|
102
|
+
export { IdentityPermissionApi, RequirePermission, permissionApiRef, usePermission };
|
|
125
103
|
export type { AsyncPermissionResult, PermissionApi, RequirePermissionProps };
|
package/dist/index.esm.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
export { PermissionedRoute } from './components/PermissionedRoute.esm.js';
|
|
2
1
|
export { RequirePermission } from './components/RequirePermission.esm.js';
|
|
3
2
|
export { usePermission } from './hooks/usePermission.esm.js';
|
|
4
3
|
export { permissionApiRef } from './apis/PermissionApi.esm.js';
|
package/dist/index.esm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backstage/plugin-permission-react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"backstage": {
|
|
5
5
|
"role": "web-library",
|
|
6
6
|
"pluginId": "permission",
|
|
@@ -42,27 +42,25 @@
|
|
|
42
42
|
"test": "backstage-cli package test"
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@backstage/config": "1.3.
|
|
46
|
-
"@backstage/core-plugin-api": "1.12.5
|
|
47
|
-
"@backstage/plugin-permission-common": "0.9.
|
|
45
|
+
"@backstage/config": "^1.3.7",
|
|
46
|
+
"@backstage/core-plugin-api": "^1.12.5",
|
|
47
|
+
"@backstage/plugin-permission-common": "^0.9.8",
|
|
48
48
|
"dataloader": "^2.0.0",
|
|
49
49
|
"swr": "^2.0.0"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
|
-
"@backstage/cli": "0.36.1
|
|
53
|
-
"@backstage/test-utils": "1.7.17
|
|
52
|
+
"@backstage/cli": "^0.36.1",
|
|
53
|
+
"@backstage/test-utils": "^1.7.17",
|
|
54
54
|
"@testing-library/jest-dom": "^6.0.0",
|
|
55
55
|
"@testing-library/react": "^16.0.0",
|
|
56
56
|
"@types/react": "^18.0.0",
|
|
57
57
|
"react": "^18.0.2",
|
|
58
|
-
"react-dom": "^18.0.2"
|
|
59
|
-
"react-router-dom": "^6.30.2"
|
|
58
|
+
"react-dom": "^18.0.2"
|
|
60
59
|
},
|
|
61
60
|
"peerDependencies": {
|
|
62
61
|
"@types/react": "^17.0.0 || ^18.0.0",
|
|
63
62
|
"react": "^17.0.0 || ^18.0.0",
|
|
64
|
-
"react-dom": "^17.0.0 || ^18.0.0"
|
|
65
|
-
"react-router-dom": "^6.30.2"
|
|
63
|
+
"react-dom": "^17.0.0 || ^18.0.0"
|
|
66
64
|
},
|
|
67
65
|
"peerDependenciesMeta": {
|
|
68
66
|
"@types/react": {
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { jsx } from 'react/jsx-runtime';
|
|
2
|
-
import { Route } from 'react-router-dom';
|
|
3
|
-
import { useApp } from '@backstage/core-plugin-api';
|
|
4
|
-
import { usePermission } from '../hooks/usePermission.esm.js';
|
|
5
|
-
import { isResourcePermission } from '@backstage/plugin-permission-common';
|
|
6
|
-
|
|
7
|
-
const PermissionedRoute = (props) => {
|
|
8
|
-
const { permission, resourceRef, errorComponent, ...otherProps } = props;
|
|
9
|
-
const permissionResult = usePermission(
|
|
10
|
-
isResourcePermission(permission) ? { permission, resourceRef } : { permission }
|
|
11
|
-
);
|
|
12
|
-
const app = useApp();
|
|
13
|
-
const { NotFoundErrorPage } = app.getComponents();
|
|
14
|
-
let shownElement = errorComponent === void 0 ? /* @__PURE__ */ jsx(NotFoundErrorPage, {}) : errorComponent;
|
|
15
|
-
if (permissionResult.loading) {
|
|
16
|
-
shownElement = null;
|
|
17
|
-
} else if (permissionResult.allowed) {
|
|
18
|
-
shownElement = props.element;
|
|
19
|
-
}
|
|
20
|
-
return /* @__PURE__ */ jsx(Route, { ...otherProps, element: shownElement });
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
export { PermissionedRoute };
|
|
24
|
-
//# sourceMappingURL=PermissionedRoute.esm.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PermissionedRoute.esm.js","sources":["../../src/components/PermissionedRoute.tsx"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { ReactElement, ReactNode } from 'react';\nimport { Route } from 'react-router-dom';\nimport { useApp } from '@backstage/core-plugin-api';\nimport { usePermission } from '../hooks';\nimport {\n isResourcePermission,\n Permission,\n ResourcePermission,\n} from '@backstage/plugin-permission-common';\n\n/**\n * Returns a React Router Route which only renders the element when authorized. If unauthorized, the Route will render a\n * NotFoundErrorPage (see {@link @backstage/core-app-api#AppComponents}).\n *\n * @public\n * @deprecated This component no longer works with the most recent version of `@backstage/core-app-api` and react-router v6, use {@link RequirePermission} instead.\n */\nexport const PermissionedRoute = (\n props: {\n caseSensitive?: boolean;\n children?: ReactNode;\n element?: ReactElement | null;\n path?: string;\n errorComponent?: ReactElement | null;\n } & (\n | {\n permission: Exclude<Permission, ResourcePermission>;\n resourceRef?: never;\n }\n | {\n permission: ResourcePermission;\n resourceRef: string | undefined;\n }\n ),\n) => {\n const { permission, resourceRef, errorComponent, ...otherProps } = props;\n\n const permissionResult = usePermission(\n isResourcePermission(permission)\n ? { permission, resourceRef }\n : { permission },\n );\n const app = useApp();\n const { NotFoundErrorPage } = app.getComponents();\n\n let shownElement: ReactElement | null | undefined =\n errorComponent === undefined ? <NotFoundErrorPage /> : errorComponent;\n\n if (permissionResult.loading) {\n shownElement = null;\n } else if (permissionResult.allowed) {\n shownElement = props.element;\n }\n\n return <Route {...otherProps} element={shownElement} />;\n};\n"],"names":[],"mappings":";;;;;;AAiCO,MAAM,iBAAA,GAAoB,CAC/B,KAAA,KAgBG;AACH,EAAA,MAAM,EAAE,UAAA,EAAY,WAAA,EAAa,cAAA,EAAgB,GAAG,YAAW,GAAI,KAAA;AAEnE,EAAA,MAAM,gBAAA,GAAmB,aAAA;AAAA,IACvB,oBAAA,CAAqB,UAAU,CAAA,GAC3B,EAAE,YAAY,WAAA,EAAY,GAC1B,EAAE,UAAA;AAAW,GACnB;AACA,EAAA,MAAM,MAAM,MAAA,EAAO;AACnB,EAAA,MAAM,EAAE,iBAAA,EAAkB,GAAI,GAAA,CAAI,aAAA,EAAc;AAEhD,EAAA,IAAI,YAAA,GACF,cAAA,KAAmB,MAAA,mBAAY,GAAA,CAAC,qBAAkB,CAAA,GAAK,cAAA;AAEzD,EAAA,IAAI,iBAAiB,OAAA,EAAS;AAC5B,IAAA,YAAA,GAAe,IAAA;AAAA,EACjB,CAAA,MAAA,IAAW,iBAAiB,OAAA,EAAS;AACnC,IAAA,YAAA,GAAe,KAAA,CAAM,OAAA;AAAA,EACvB;AAEA,EAAA,uBAAO,GAAA,CAAC,KAAA,EAAA,EAAO,GAAG,UAAA,EAAY,SAAS,YAAA,EAAc,CAAA;AACvD;;;;"}
|