Skip to content

Commit

Permalink
Split expressioncontent into two new components
Browse files Browse the repository at this point in the history
  • Loading branch information
standeren committed Nov 22, 2023
1 parent a377e88 commit f3546ff
Show file tree
Hide file tree
Showing 19 changed files with 881 additions and 774 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@ import { useFormContext } from '../../containers/FormContext';
import {
addFeatureFlagToLocalStorage,
removeFeatureFlagFromLocalStorage,
shouldDisplayFeature
shouldDisplayFeature,
} from 'app-shared/utils/featureToggleUtils';
import classes from './Properties.module.css';

export const Properties = () => {
const { t } = useTranslation();
const [showNewExpressions, setShowNewExpressions] = React.useState<boolean>(shouldDisplayFeature('expressions'));
const [showNewExpressions, setShowNewExpressions] = React.useState<boolean>(
shouldDisplayFeature('expressions'),
);
const { formId } = useFormContext();
const formIdRef = React.useRef(formId);

Expand All @@ -39,7 +41,7 @@ export const Properties = () => {
const handleToggleNewDynamics = (event: React.ChangeEvent<HTMLInputElement>) => {
setShowNewExpressions(event.target.checked);
// Ensure choice of feature toggling is persisted in local storage
if(event.target.checked){
if (event.target.checked) {
addFeatureFlagToLocalStorage('expressions');
} else {
removeFeatureFlagFromLocalStorage('expressions');
Expand All @@ -64,14 +66,18 @@ export const Properties = () => {
<Accordion.Content>
<>
<Switch
name={'new-dynamics-switch'}
onChange={handleToggleNewDynamics}
checked={showNewExpressions}
size={'small'}
name={'new-dynamics-switch'}
onChange={handleToggleNewDynamics}
checked={showNewExpressions}
size={'small'}
>
{t('right_menu.show_new_dynamics')}
</Switch>
{showNewExpressions ? (<Expressions/>) : (<ConditionalRendering/>)}
{showNewExpressions ? (
formId && <Expressions key={formId} />
) : (
<ConditionalRendering />
)}
</>
</Accordion.Content>
</Accordion.Item>
Expand Down
Loading

0 comments on commit f3546ff

Please sign in to comment.