Skip to content

Commit

Permalink
Don't show RAW toggle when data isn't representable by REJT
Browse files Browse the repository at this point in the history
  • Loading branch information
ghengeveld committed Mar 30, 2021
1 parent 57fc3cd commit 6951762
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/components/src/controls/Object.tsx
Expand Up @@ -4,7 +4,7 @@ import React, { ComponentProps, SyntheticEvent, useCallback, useMemo, useState }
import { styled, useTheme, Theme } from '@storybook/theming';

// @ts-ignore
import { JsonTree } from './react-editable-json-tree';
import { JsonTree, getObjectType } from './react-editable-json-tree';
import type { ControlProps, ObjectValue, ObjectConfig } from './types';
import { Form } from '../form';
import { Icons, IconsProps } from '../icon/icon';
Expand Down Expand Up @@ -260,7 +260,7 @@ export const ObjectControl: React.FC<ObjectProps> = ({ name, value, onChange })

return (
<Wrapper>
{hasData && (
{hasData && ['Object', 'Array'].includes(getObjectType(data)) && (
<RawButton onClick={() => setShowRaw((v) => !v)}>
<Icons icon={showRaw ? 'eyeclose' : 'eye'} />
<span>RAW</span>
Expand Down
Expand Up @@ -166,6 +166,7 @@ JsonTree.defaultProps = {
};

export { JsonTree };
export { getObjectType };
export { ADD_DELTA_TYPE };
export { REMOVE_DELTA_TYPE };
export { UPDATE_DELTA_TYPE };
Expand Down

0 comments on commit 6951762

Please sign in to comment.