Skip to content

Commit

Permalink
fix(composer): gate empty overlay section in inspector
Browse files Browse the repository at this point in the history
  • Loading branch information
sheilaXu committed Apr 6, 2023
1 parent 9ea3f75 commit 2726f10
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@ import React, { useCallback, useContext } from 'react';
import { useIntl } from 'react-intl';
import { Box, Button } from '@awsui/components-react';

import { COMPOSER_FEATURES, KnownComponentType } from '../../interfaces';
import { KnownComponentType } from '../../interfaces';
import { IDataOverlayComponentInternal, useStore } from '../../store';
import { sceneComposerIdContext } from '../../common/sceneComposerIdContext';
import { findComponentByType } from '../../utils/nodeUtils';
import { getGlobalSettings } from '../../common/GlobalSettings';
import { Component } from '../../models/SceneModels';

export const AddOrRemoveOverlayButton: React.FC = () => {
Expand All @@ -16,7 +15,6 @@ export const AddOrRemoveOverlayButton: React.FC = () => {
const getSceneNodeByRef = useStore(sceneComposerId)((state) => state.getSceneNodeByRef);
const addComponentInternal = useStore(sceneComposerId)((state) => state.addComponentInternal);
const removeComponent = useStore(sceneComposerId)((state) => state.removeComponent);
const overlayEnabled = getGlobalSettings().featureConfig[COMPOSER_FEATURES.Overlay];
const selectedSceneNode = getSceneNodeByRef(selectedSceneNodeRef);
const intl = useIntl();

Expand Down Expand Up @@ -51,7 +49,7 @@ export const AddOrRemoveOverlayButton: React.FC = () => {
}, [selectedSceneNodeRef, isOverlayComponent, selectedSceneNode]);

return (
(overlayEnabled && isTagComponent && (
(isTagComponent && (
<div style={{ overflow: 'auto' }}>
<Box margin={{ top: 'xs' }} float={isOverlayComponent ? 'right' : 'left'}>
<Button onClick={onClick}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export const SceneNodeInspectorPanel: React.FC = () => {
const intl = useIntl();

const subModelMovementEnabled = getGlobalSettings().featureConfig[COMPOSER_FEATURES.SubModelMovement];
const overlayEnabled = getGlobalSettings().featureConfig[COMPOSER_FEATURES.Overlay];

const i18nKnownComponentTypesStrings = defineMessages({
[KnownComponentType.ModelRef]: {
Expand Down Expand Up @@ -141,7 +142,7 @@ export const SceneNodeInspectorPanel: React.FC = () => {

{/* If the component is a Tag and there is no overlay component in the selected node, then an empty
overlay sections is added. */}
{component.type === KnownComponentType.Tag && !isOverlayComponent && (
{overlayEnabled && component.type === KnownComponentType.Tag && !isOverlayComponent && (
<ExpandableInfoSection
withoutSpaceBetween
key={KnownComponentType.DataOverlay + '_' + index}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ import { act, render } from '@testing-library/react';

import { AddOrRemoveOverlayButton } from '../AddOrRemoveOverlayButton';
import { useStore } from '../../../store';
import { setFeatureConfig } from '../../../common/GlobalSettings';
import { COMPOSER_FEATURES, KnownComponentType } from '../../../interfaces';
import { KnownComponentType } from '../../../interfaces';
import { Component } from '../../../models/SceneModels';

jest.mock('@awsui/components-react', () => ({
Expand All @@ -17,7 +16,6 @@ describe('AddOrRemoveOverlayButton', () => {
const removeComponent = jest.fn();

beforeEach(() => {
setFeatureConfig({ [COMPOSER_FEATURES.Overlay]: true });
useStore('default').setState({
selectedSceneNodeRef: 'selected',
getSceneNodeByRef,
Expand Down

0 comments on commit 2726f10

Please sign in to comment.