b11f77df2a
## PR Description - Uses `expr-eval` to enable front components (SDK plugins) to define conditional availability as declarative expressions. - Moves shared types and constants to `twenty-shared` - Introduces a `conditionalAvailabilityExpression` field on `CommandMenuItemEntity`, allowing command menu items to store an `expr-eval` compatible expression string that is evaluated against a CommandMenuContext to determine if the item should be shown. - Creates an esbuild transform plugin `conditional-availability-transform-plugin` in `twenty-sdk` that converts TypeScript conditional availability expressions into `expr-eval` compatible syntax at build time, so SDK developers can write natural TS expressions that get transformed to evaluable strings. - Removes deprecated `forceRegisteredActionsByKey` state and its usage. - Creates `useCommandMenuContext` hook that builds the full `CommandMenuContext` object from React state, which is then passed to `useCommandMenuItemFrontComponentActions` for evaluating conditional availability expressions.
42 lines
1.4 KiB
TypeScript
42 lines
1.4 KiB
TypeScript
import { makeMetadataAPIRequest } from 'test/integration/metadata/suites/utils/make-metadata-api-request.util';
|
|
import { updateFeatureFlagFactory } from 'test/integration/graphql/utils/update-feature-flag-factory.util';
|
|
import { warnIfErrorButNotExpectedToFail } from 'test/integration/metadata/utils/warn-if-error-but-not-expected-to-fail.util';
|
|
import { warnIfNoErrorButExpectedToFail } from 'test/integration/metadata/utils/warn-if-no-error-but-expected-to-fail.util';
|
|
import { type FeatureFlagKey } from 'twenty-shared/types';
|
|
|
|
import { SEED_APPLE_WORKSPACE_ID } from 'src/engine/workspace-manager/dev-seeder/core/constants/seeder-workspaces.constant';
|
|
|
|
export const updateFeatureFlag = async ({
|
|
featureFlag,
|
|
value,
|
|
workspaceId = SEED_APPLE_WORKSPACE_ID,
|
|
expectToFail,
|
|
}: {
|
|
featureFlag: FeatureFlagKey;
|
|
value: boolean;
|
|
workspaceId?: string;
|
|
expectToFail: boolean;
|
|
}) => {
|
|
const enablePermissionsQuery = updateFeatureFlagFactory(
|
|
workspaceId,
|
|
featureFlag,
|
|
value,
|
|
);
|
|
|
|
const response = await makeMetadataAPIRequest(enablePermissionsQuery);
|
|
|
|
if (expectToFail === false) {
|
|
warnIfErrorButNotExpectedToFail({
|
|
errorMessage: 'Update feature flag should not have failed',
|
|
response,
|
|
});
|
|
}
|
|
|
|
if (expectToFail === true) {
|
|
warnIfNoErrorButExpectedToFail({
|
|
errorMessage: 'Update feature flag should have failed',
|
|
response,
|
|
});
|
|
}
|
|
};
|