Files
portainer--portainer/app/react/portainer/feature-flags/withEdition.tsx
T
2026-07-13 12:08:39 +08:00

23 lines
609 B
TypeScript

import { ComponentType } from 'react';
export function withEdition<T>(
WrappedComponent: ComponentType<T>,
edition: 'BE' | 'CE'
): ComponentType<T> {
// Try to create a nice displayName for React Dev Tools.
const displayName =
WrappedComponent.displayName || WrappedComponent.name || 'Component';
function WrapperComponent(props: T & JSX.IntrinsicAttributes) {
if (process.env.PORTAINER_EDITION !== edition) {
return null;
}
return <WrappedComponent {...props} />;
}
WrapperComponent.displayName = `with${edition}Edition(${displayName})`;
return WrapperComponent;
}