## Description Fixes #39554 _or_ Fixes `Issue URL` > [!WARNING] > _If no issue exists, please create an issue first, and check with the maintainers if the issue is valid._ ## Automation /ok-to-test tags="@tag.Sanity" ### 🔍 Cypress test results <!-- This is an auto-generated comment: Cypress test results --> > [!TIP] > 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉 > Workflow run: <https://github.com/appsmithorg/appsmith/actions/runs/13811044062> > Commit: 1a5b458e43a338ad74eb48908a16ce695a6f53e2 > <a href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=13811044062&attempt=1" target="_blank">Cypress dashboard</a>. > Tags: `@tag.Sanity` > Spec: > <hr>Wed, 12 Mar 2025 12:57:34 UTC <!-- end of auto-generated comment: Cypress test results --> ## Communication Should the DevRel and Marketing teams inform users about this change? - [ ] Yes - [ ] No <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit ## Summary by CodeRabbit - **New Features** - Added a new forward arrow icon for enhanced design consistency. - Expanded sidebar functionality to support an optional extra title button for additional actions. - Introduced a comprehensive visualization experience, including interactive components for generating, saving, and displaying visualizations, along with prompt inputs, suggestions, and a results view. - Enhanced action capabilities to support visualization data and debugging with a new visualization tab. - Enabled new release functionalities via an updated feature flag system. - **Style** - Refined sidebar title spacing and layout for improved presentation. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
85 lines
2.6 KiB
TypeScript
85 lines
2.6 KiB
TypeScript
import type { FeatureFlag } from "ee/entities/FeatureFlag";
|
|
import {
|
|
setFeatureFlagOverridesAction,
|
|
updateFeatureFlagOverrideAction,
|
|
} from "actions/featureFlagActions";
|
|
import { isBoolean } from "lodash";
|
|
import { useEffect } from "react";
|
|
import { useDispatch, useSelector } from "react-redux";
|
|
import { getFeatureFlagsFetched } from "selectors/usersSelectors";
|
|
import {
|
|
getFeatureFlagOverrideValues,
|
|
setFeatureFlagOverrideValues,
|
|
} from "utils/storage";
|
|
|
|
export const AvailableFeaturesToOverride: FeatureFlag[] = [
|
|
"release_anvil_enabled",
|
|
"release_layout_conversion_enabled",
|
|
"release_anvil_toggle_enabled",
|
|
"release_fn_calling_enabled",
|
|
];
|
|
export type OverriddenFeatureFlags = Partial<Record<FeatureFlag, boolean>>;
|
|
|
|
export const useFeatureFlagOverride = () => {
|
|
const dispatch = useDispatch();
|
|
const areFeatureFlagsFetched = useSelector(getFeatureFlagsFetched);
|
|
|
|
/**
|
|
* Fetches the feature flag override values and updates the state.
|
|
*/
|
|
useEffect(() => {
|
|
if (areFeatureFlagsFetched) {
|
|
getFeatureFlagOverrideValues().then((flagValues) => {
|
|
const filteredFlagValues = (
|
|
Object.entries(flagValues) as [FeatureFlag, boolean][]
|
|
).reduce((acc, [flagName, flagValue]) => {
|
|
if (
|
|
AvailableFeaturesToOverride.includes(flagName) &&
|
|
isBoolean(flagValue)
|
|
) {
|
|
acc[flagName] = flagValues[flagName];
|
|
}
|
|
|
|
return acc;
|
|
}, {} as OverriddenFeatureFlags);
|
|
|
|
if (filteredFlagValues) {
|
|
dispatch(setFeatureFlagOverridesAction(filteredFlagValues));
|
|
}
|
|
});
|
|
}
|
|
}, [areFeatureFlagsFetched, dispatch]);
|
|
|
|
/**
|
|
* Sets up a global function to toggle the feature flag override.
|
|
*/
|
|
useEffect(() => {
|
|
// TODO: Fix this the next time the file is edited
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
(window as any).overrideFeatureFlag = (
|
|
featureFlagValues: OverriddenFeatureFlags,
|
|
) => {
|
|
const areAllFlagsValid = (
|
|
Object.entries(featureFlagValues) as [FeatureFlag, boolean][]
|
|
).every(
|
|
([flagName, flagValue]) =>
|
|
AvailableFeaturesToOverride.includes(flagName) &&
|
|
isBoolean(flagValue),
|
|
);
|
|
|
|
if (areAllFlagsValid) {
|
|
dispatch(updateFeatureFlagOverrideAction(featureFlagValues));
|
|
setFeatureFlagOverrideValues(featureFlagValues);
|
|
window.console.log(
|
|
"Feature flag override values set to: ",
|
|
featureFlagValues,
|
|
);
|
|
} else {
|
|
window.console.error(
|
|
"Invalid feature flag override values. Please check the feature flags being overridden.",
|
|
);
|
|
}
|
|
};
|
|
}, [dispatch]);
|
|
};
|