@backstage/plugin-permission-react 0.4.32 → 0.4.33

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,31 @@
1
1
  # @backstage/plugin-permission-react
2
2
 
3
+ ## 0.4.33
4
+
5
+ ### Patch Changes
6
+
7
+ - a47fd39: Removes instances of default React imports, a necessary update for the upcoming React 19 migration.
8
+
9
+ <https://legacy.reactjs.org/blog/2020/09/22/introducing-the-new-jsx-transform.html>
10
+
11
+ - Updated dependencies
12
+ - @backstage/core-plugin-api@1.10.6
13
+ - @backstage/config@1.3.2
14
+ - @backstage/plugin-permission-common@0.8.4
15
+
16
+ ## 0.4.33-next.0
17
+
18
+ ### Patch Changes
19
+
20
+ - a47fd39: Removes instances of default React imports, a necessary update for the upcoming React 19 migration.
21
+
22
+ <https://legacy.reactjs.org/blog/2020/09/22/introducing-the-new-jsx-transform.html>
23
+
24
+ - Updated dependencies
25
+ - @backstage/core-plugin-api@1.10.6-next.0
26
+ - @backstage/config@1.3.2
27
+ - @backstage/plugin-permission-common@0.8.4
28
+
3
29
  ## 0.4.32
4
30
 
5
31
  ### Patch Changes
@@ -1,4 +1,4 @@
1
- import React from 'react';
1
+ import { jsx } from 'react/jsx-runtime';
2
2
  import { Route } from 'react-router-dom';
3
3
  import { useApp } from '@backstage/core-plugin-api';
4
4
  import { usePermission } from '../hooks/usePermission.esm.js';
@@ -11,13 +11,13 @@ const PermissionedRoute = (props) => {
11
11
  );
12
12
  const app = useApp();
13
13
  const { NotFoundErrorPage } = app.getComponents();
14
- let shownElement = errorComponent === void 0 ? /* @__PURE__ */ React.createElement(NotFoundErrorPage, null) : errorComponent;
14
+ let shownElement = errorComponent === void 0 ? /* @__PURE__ */ jsx(NotFoundErrorPage, {}) : errorComponent;
15
15
  if (permissionResult.loading) {
16
16
  shownElement = null;
17
17
  } else if (permissionResult.allowed) {
18
18
  shownElement = props.element;
19
19
  }
20
- return /* @__PURE__ */ React.createElement(Route, { ...otherProps, element: shownElement });
20
+ return /* @__PURE__ */ jsx(Route, { ...otherProps, element: shownElement });
21
21
  };
22
22
 
23
23
  export { PermissionedRoute };
@@ -1 +1 @@
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 React, { 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":";;;;;;AAiCa,MAAA,iBAAA,GAAoB,CAC/B,KAgBG,KAAA;AACH,EAAA,MAAM,EAAE,UAAY,EAAA,WAAA,EAAa,cAAgB,EAAA,GAAG,YAAe,GAAA,KAAA;AAEnE,EAAA,MAAM,gBAAmB,GAAA,aAAA;AAAA,IACvB,oBAAA,CAAqB,UAAU,CAC3B,GAAA,EAAE,YAAY,WAAY,EAAA,GAC1B,EAAE,UAAW;AAAA,GACnB;AACA,EAAA,MAAM,MAAM,MAAO,EAAA;AACnB,EAAA,MAAM,EAAE,iBAAA,EAAsB,GAAA,GAAA,CAAI,aAAc,EAAA;AAEhD,EAAA,IAAI,YACF,GAAA,cAAA,KAAmB,KAAY,CAAA,mBAAA,KAAA,CAAA,aAAA,CAAC,uBAAkB,CAAK,GAAA,cAAA;AAEzD,EAAA,IAAI,iBAAiB,OAAS,EAAA;AAC5B,IAAe,YAAA,GAAA,IAAA;AAAA,GACjB,MAAA,IAAW,iBAAiB,OAAS,EAAA;AACnC,IAAA,YAAA,GAAe,KAAM,CAAA,OAAA;AAAA;AAGvB,EAAA,uBAAQ,KAAA,CAAA,aAAA,CAAA,KAAA,EAAA,EAAO,GAAG,UAAA,EAAY,SAAS,YAAc,EAAA,CAAA;AACvD;;;;"}
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":";;;;;;AAiCa,MAAA,iBAAA,GAAoB,CAC/B,KAgBG,KAAA;AACH,EAAA,MAAM,EAAE,UAAY,EAAA,WAAA,EAAa,cAAgB,EAAA,GAAG,YAAe,GAAA,KAAA;AAEnE,EAAA,MAAM,gBAAmB,GAAA,aAAA;AAAA,IACvB,oBAAA,CAAqB,UAAU,CAC3B,GAAA,EAAE,YAAY,WAAY,EAAA,GAC1B,EAAE,UAAW;AAAA,GACnB;AACA,EAAA,MAAM,MAAM,MAAO,EAAA;AACnB,EAAA,MAAM,EAAE,iBAAA,EAAsB,GAAA,GAAA,CAAI,aAAc,EAAA;AAEhD,EAAA,IAAI,YACF,GAAA,cAAA,KAAmB,KAAY,CAAA,mBAAA,GAAA,CAAC,qBAAkB,CAAK,GAAA,cAAA;AAEzD,EAAA,IAAI,iBAAiB,OAAS,EAAA;AAC5B,IAAe,YAAA,GAAA,IAAA;AAAA,GACjB,MAAA,IAAW,iBAAiB,OAAS,EAAA;AACnC,IAAA,YAAA,GAAe,KAAM,CAAA,OAAA;AAAA;AAGvB,EAAA,uBAAQ,GAAA,CAAA,KAAA,EAAA,EAAO,GAAG,UAAA,EAAY,SAAS,YAAc,EAAA,CAAA;AACvD;;;;"}
@@ -1,4 +1,4 @@
1
- import React from 'react';
1
+ import { jsx, Fragment } from 'react/jsx-runtime';
2
2
  import { useApp } from '@backstage/core-plugin-api';
3
3
  import { usePermission } from '../hooks/usePermission.esm.js';
4
4
  import { isResourcePermission } from '@backstage/plugin-permission-common';
@@ -12,13 +12,13 @@ function RequirePermission(props) {
12
12
  if (permissionResult.loading) {
13
13
  return null;
14
14
  } else if (permissionResult.allowed) {
15
- return /* @__PURE__ */ React.createElement(React.Fragment, null, props.children);
15
+ return /* @__PURE__ */ jsx(Fragment, { children: props.children });
16
16
  }
17
17
  if (props.errorPage) {
18
- return /* @__PURE__ */ React.createElement(React.Fragment, null, props.errorPage);
18
+ return /* @__PURE__ */ jsx(Fragment, { children: props.errorPage });
19
19
  }
20
20
  const { NotFoundErrorPage } = app.getComponents();
21
- return /* @__PURE__ */ React.createElement(NotFoundErrorPage, null);
21
+ return /* @__PURE__ */ jsx(NotFoundErrorPage, {});
22
22
  }
23
23
 
24
24
  export { RequirePermission };
@@ -1 +1 @@
1
- {"version":3,"file":"RequirePermission.esm.js","sources":["../../src/components/RequirePermission.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 React, { ReactNode } from 'react';\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 * Properties for {@link RequirePermission}\n *\n * @public\n */\nexport type RequirePermissionProps = (\n | {\n permission: Exclude<Permission, ResourcePermission>;\n resourceRef?: never;\n }\n | {\n permission: ResourcePermission;\n resourceRef: string | undefined;\n }\n) & {\n /**\n * The error page to be displayed if the user is not allowed access.\n *\n * Defaults to the `NotFoundErrorPage` app component.\n */\n errorPage?: ReactNode;\n children: ReactNode;\n};\n\n/**\n * A boundary that only renders its child elements if the user has the specified permission.\n *\n * While loading, nothing will be rendered. If the user does not have\n * permission, the `errorPage` element will be rendered, falling back\n * to the `NotFoundErrorPage` app component if no `errorPage` is provider.\n *\n * @public\n */\nexport function RequirePermission(\n props: RequirePermissionProps,\n): JSX.Element | null {\n const { permission, resourceRef } = props;\n const permissionResult = usePermission(\n isResourcePermission(permission)\n ? { permission, resourceRef }\n : { permission },\n );\n const app = useApp();\n\n if (permissionResult.loading) {\n return null;\n } else if (permissionResult.allowed) {\n return <>{props.children}</>;\n }\n\n if (props.errorPage) {\n return <>{props.errorPage}</>;\n }\n // If no explicit error element is provided, the not found page is used as fallback.\n const { NotFoundErrorPage } = app.getComponents();\n return <NotFoundErrorPage />;\n}\n"],"names":[],"mappings":";;;;;AA0DO,SAAS,kBACd,KACoB,EAAA;AACpB,EAAM,MAAA,EAAE,UAAY,EAAA,WAAA,EAAgB,GAAA,KAAA;AACpC,EAAA,MAAM,gBAAmB,GAAA,aAAA;AAAA,IACvB,oBAAA,CAAqB,UAAU,CAC3B,GAAA,EAAE,YAAY,WAAY,EAAA,GAC1B,EAAE,UAAW;AAAA,GACnB;AACA,EAAA,MAAM,MAAM,MAAO,EAAA;AAEnB,EAAA,IAAI,iBAAiB,OAAS,EAAA;AAC5B,IAAO,OAAA,IAAA;AAAA,GACT,MAAA,IAAW,iBAAiB,OAAS,EAAA;AACnC,IAAO,uBAAA,KAAA,CAAA,aAAA,CAAA,KAAA,CAAA,QAAA,EAAA,IAAA,EAAG,MAAM,QAAS,CAAA;AAAA;AAG3B,EAAA,IAAI,MAAM,SAAW,EAAA;AACnB,IAAO,uBAAA,KAAA,CAAA,aAAA,CAAA,KAAA,CAAA,QAAA,EAAA,IAAA,EAAG,MAAM,SAAU,CAAA;AAAA;AAG5B,EAAA,MAAM,EAAE,iBAAA,EAAsB,GAAA,GAAA,CAAI,aAAc,EAAA;AAChD,EAAA,2CAAQ,iBAAkB,EAAA,IAAA,CAAA;AAC5B;;;;"}
1
+ {"version":3,"file":"RequirePermission.esm.js","sources":["../../src/components/RequirePermission.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 { ReactNode } from 'react';\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 * Properties for {@link RequirePermission}\n *\n * @public\n */\nexport type RequirePermissionProps = (\n | {\n permission: Exclude<Permission, ResourcePermission>;\n resourceRef?: never;\n }\n | {\n permission: ResourcePermission;\n resourceRef: string | undefined;\n }\n) & {\n /**\n * The error page to be displayed if the user is not allowed access.\n *\n * Defaults to the `NotFoundErrorPage` app component.\n */\n errorPage?: ReactNode;\n children: ReactNode;\n};\n\n/**\n * A boundary that only renders its child elements if the user has the specified permission.\n *\n * While loading, nothing will be rendered. If the user does not have\n * permission, the `errorPage` element will be rendered, falling back\n * to the `NotFoundErrorPage` app component if no `errorPage` is provider.\n *\n * @public\n */\nexport function RequirePermission(\n props: RequirePermissionProps,\n): JSX.Element | null {\n const { permission, resourceRef } = props;\n const permissionResult = usePermission(\n isResourcePermission(permission)\n ? { permission, resourceRef }\n : { permission },\n );\n const app = useApp();\n\n if (permissionResult.loading) {\n return null;\n } else if (permissionResult.allowed) {\n return <>{props.children}</>;\n }\n\n if (props.errorPage) {\n return <>{props.errorPage}</>;\n }\n // If no explicit error element is provided, the not found page is used as fallback.\n const { NotFoundErrorPage } = app.getComponents();\n return <NotFoundErrorPage />;\n}\n"],"names":[],"mappings":";;;;;AA0DO,SAAS,kBACd,KACoB,EAAA;AACpB,EAAM,MAAA,EAAE,UAAY,EAAA,WAAA,EAAgB,GAAA,KAAA;AACpC,EAAA,MAAM,gBAAmB,GAAA,aAAA;AAAA,IACvB,oBAAA,CAAqB,UAAU,CAC3B,GAAA,EAAE,YAAY,WAAY,EAAA,GAC1B,EAAE,UAAW;AAAA,GACnB;AACA,EAAA,MAAM,MAAM,MAAO,EAAA;AAEnB,EAAA,IAAI,iBAAiB,OAAS,EAAA;AAC5B,IAAO,OAAA,IAAA;AAAA,GACT,MAAA,IAAW,iBAAiB,OAAS,EAAA;AACnC,IAAO,uBAAA,GAAA,CAAA,QAAA,EAAA,EAAG,gBAAM,QAAS,EAAA,CAAA;AAAA;AAG3B,EAAA,IAAI,MAAM,SAAW,EAAA;AACnB,IAAO,uBAAA,GAAA,CAAA,QAAA,EAAA,EAAG,gBAAM,SAAU,EAAA,CAAA;AAAA;AAG5B,EAAA,MAAM,EAAE,iBAAA,EAAsB,GAAA,GAAA,CAAI,aAAc,EAAA;AAChD,EAAA,2BAAQ,iBAAkB,EAAA,EAAA,CAAA;AAC5B;;;;"}
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
- import React, { ReactNode, ReactElement } from 'react';
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { ReactNode, ReactElement } from 'react';
2
3
  import { Permission, ResourcePermission, EvaluatePermissionRequest, EvaluatePermissionResponse, AuthorizePermissionRequest, AuthorizePermissionResponse } from '@backstage/plugin-permission-common';
3
4
  import { ApiRef, DiscoveryApi, IdentityApi } from '@backstage/core-plugin-api';
4
5
  import { Config } from '@backstage/config';
@@ -22,7 +23,7 @@ declare const PermissionedRoute: (props: {
22
23
  } | {
23
24
  permission: ResourcePermission;
24
25
  resourceRef: string | undefined;
25
- })) => React.JSX.Element;
26
+ })) => react_jsx_runtime.JSX.Element;
26
27
 
27
28
  /**
28
29
  * Properties for {@link RequirePermission}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backstage/plugin-permission-react",
3
- "version": "0.4.32",
3
+ "version": "0.4.33",
4
4
  "backstage": {
5
5
  "role": "web-library",
6
6
  "pluginId": "permission",
@@ -43,13 +43,13 @@
43
43
  },
44
44
  "dependencies": {
45
45
  "@backstage/config": "^1.3.2",
46
- "@backstage/core-plugin-api": "^1.10.5",
46
+ "@backstage/core-plugin-api": "^1.10.6",
47
47
  "@backstage/plugin-permission-common": "^0.8.4",
48
48
  "swr": "^2.0.0"
49
49
  },
50
50
  "devDependencies": {
51
- "@backstage/cli": "^0.31.0",
52
- "@backstage/test-utils": "^1.7.6",
51
+ "@backstage/cli": "^0.32.0",
52
+ "@backstage/test-utils": "^1.7.7",
53
53
  "@testing-library/jest-dom": "^6.0.0",
54
54
  "@testing-library/react": "^16.0.0",
55
55
  "@types/react": "^18.0.0",
@@ -68,5 +68,12 @@
68
68
  "optional": true
69
69
  }
70
70
  },
71
+ "typesVersions": {
72
+ "*": {
73
+ "package.json": [
74
+ "package.json"
75
+ ]
76
+ }
77
+ },
71
78
  "module": "./dist/index.esm.js"
72
79
  }