Do not unpack arguments directly on exported items

Signed-off-by: Fredrik Adelöw <freben@gmail.com>
This commit is contained in:
Fredrik Adelöw
2021-12-07 19:42:10 +01:00
parent 95ab7baba6
commit dcd1a0c3f4
66 changed files with 433 additions and 708 deletions
@@ -34,15 +34,12 @@ export class IdentityPermissionApi implements PermissionApi {
private readonly identityApi: IdentityApi,
) {}
static create({
configApi,
discoveryApi,
identityApi,
}: {
static create(options: {
configApi: Config;
discoveryApi: DiscoveryApi;
identityApi: IdentityApi;
}) {
const { configApi, discoveryApi, identityApi } = options;
const permissionClient = new PermissionClient({ discoveryApi, configApi });
return new IdentityPermissionApi(permissionClient, identityApi);
}
@@ -21,20 +21,19 @@ import { usePermission } from '../hooks';
import { Permission } from '@backstage/plugin-permission-common';
/**
* Returns a React Router Route which only renders the element when authorized. If unathorized, the Route will render a
* Returns a React Router Route which only renders the element when authorized. If unauthorized, the Route will render a
* NotFoundErrorPage (see {@link @backstage/core-app-api#AppComponents}).
*
* @public
*/
export const PermissionedRoute = ({
permission,
resourceRef,
errorComponent,
...props
}: ComponentProps<typeof Route> & {
permission: Permission;
resourceRef?: string;
errorComponent?: ReactElement | null;
}) => {
export const PermissionedRoute = (
props: ComponentProps<typeof Route> & {
permission: Permission;
resourceRef?: string;
errorComponent?: ReactElement | null;
},
) => {
const { permission, resourceRef, errorComponent, ...otherProps } = props;
const permissionResult = usePermission(permission, resourceRef);
const app = useApp();
const { NotFoundErrorPage } = app.getComponents();
@@ -48,5 +47,5 @@ export const PermissionedRoute = ({
shownElement = props.element;
}
return <Route {...props} element={shownElement} />;
return <Route {...otherProps} element={shownElement} />;
};