The global record filter refactor will derive everything at runtime from objectMetadataItemsState, thus removing the need for a filter definition concept. Here we don't yet remove available filter definition usage but we replace the available filter definitions states, we now derive the same value from objectMetadataItemsState. This will allow us to progressively remove the usage of the concept of filter definition, at the end it will then be easy to just remove from the codebase because nothing will use it anymore.
23 lines
612 B
TypeScript
23 lines
612 B
TypeScript
import { CurrentWorkspace } from '@/auth/states/currentWorkspaceState';
|
|
import { isDefined } from 'twenty-shared';
|
|
import { FeatureFlagKey } from '~/generated-metadata/graphql';
|
|
|
|
export const checkIfFeatureFlagIsEnabledOnWorkspace = (
|
|
featureKey: FeatureFlagKey | null | undefined,
|
|
workspace: CurrentWorkspace | null | undefined,
|
|
) => {
|
|
if (
|
|
!isDefined(featureKey) ||
|
|
!isDefined(workspace) ||
|
|
!isDefined(workspace.featureFlags)
|
|
) {
|
|
return false;
|
|
}
|
|
|
|
const featureFlag = workspace.featureFlags.find(
|
|
(flag) => flag.key === featureKey,
|
|
);
|
|
|
|
return featureFlag?.value === true;
|
|
};
|