insomnia/packages/insomnia-components/components/sidebar/sidebar-schemas.js

49 lines
1.4 KiB
JavaScript
Raw Normal View History

Design sidebar (#2328) * updated lock file * Rolling sidebar from SB into application * Type fix on the method label output * Update packages/insomnia-components/components/sidebar.js Co-authored-by: Opender Singh <opender94@gmail.com> * PR Feedback - Keys, useCallback Hook * stubbing component breakout * PR Feedback - Breaking out most UI elements into components - Filter component in place - Various CSS tweaks * Removing unused file * Updating toggle * Resuable sidebar section (#2359) * Introduce resuable sidebar section * Stop eslint complaining * add react-use * Lint fixes * Make the storybook story less wide * Component development Abstracting out line level components i.e. Section > Header > Filter > Panel > Items Various code fixes * Cleaning up section visibility state * Reverting visibiilty state updater * Adding paths on click for spec scrolling * refreshing package-lock to resolve conflict * PR feedback for sidebar components * Update packages/insomnia-components/components/sidebar/sidebar-header.js Co-authored-by: Opender Singh <opender94@gmail.com> * Including lock * Merge fix * Component structuring, prop clean-up, css updates * Cleaning up components, pr feedback, fixing styling * array index reference clean-up/clarity * Leveraging useToggle rather than manual useState toggling * Cleaning up logs * Hide info section if missing from spec. * Update packages/insomnia-components/components/sidebar/sidebar-responses.js Co-authored-by: Opender Singh <opender94@gmail.com> * Update packages/insomnia-components/components/sidebar/sidebar-schemas.js Co-authored-by: Opender Singh <opender94@gmail.com> * Pull fragment * Destructuring and filter cleanup * Clearing filter value and DOM on section collapse * Merge latest * Merge conflict cleanup Co-authored-by: Opender Singh <opender94@gmail.com>
2020-07-22 13:13:06 +00:00
// @flow
import * as React from 'react';
import SidebarItem from './sidebar-item';
import SvgIcon, { IconEnum } from '../svg-icon';
import SidebarSection from './sidebar-section';
import StyledInvalidSection from './sidebar-invalid-section';
Design sidebar (#2328) * updated lock file * Rolling sidebar from SB into application * Type fix on the method label output * Update packages/insomnia-components/components/sidebar.js Co-authored-by: Opender Singh <opender94@gmail.com> * PR Feedback - Keys, useCallback Hook * stubbing component breakout * PR Feedback - Breaking out most UI elements into components - Filter component in place - Various CSS tweaks * Removing unused file * Updating toggle * Resuable sidebar section (#2359) * Introduce resuable sidebar section * Stop eslint complaining * add react-use * Lint fixes * Make the storybook story less wide * Component development Abstracting out line level components i.e. Section > Header > Filter > Panel > Items Various code fixes * Cleaning up section visibility state * Reverting visibiilty state updater * Adding paths on click for spec scrolling * refreshing package-lock to resolve conflict * PR feedback for sidebar components * Update packages/insomnia-components/components/sidebar/sidebar-header.js Co-authored-by: Opender Singh <opender94@gmail.com> * Including lock * Merge fix * Component structuring, prop clean-up, css updates * Cleaning up components, pr feedback, fixing styling * array index reference clean-up/clarity * Leveraging useToggle rather than manual useState toggling * Cleaning up logs * Hide info section if missing from spec. * Update packages/insomnia-components/components/sidebar/sidebar-responses.js Co-authored-by: Opender Singh <opender94@gmail.com> * Update packages/insomnia-components/components/sidebar/sidebar-schemas.js Co-authored-by: Opender Singh <opender94@gmail.com> * Pull fragment * Destructuring and filter cleanup * Clearing filter value and DOM on section collapse * Merge latest * Merge conflict cleanup Co-authored-by: Opender Singh <opender94@gmail.com>
2020-07-22 13:13:06 +00:00
type Props = {
schemas: Object,
onClick: (section: string, ...args: any) => void,
Design sidebar (#2328) * updated lock file * Rolling sidebar from SB into application * Type fix on the method label output * Update packages/insomnia-components/components/sidebar.js Co-authored-by: Opender Singh <opender94@gmail.com> * PR Feedback - Keys, useCallback Hook * stubbing component breakout * PR Feedback - Breaking out most UI elements into components - Filter component in place - Various CSS tweaks * Removing unused file * Updating toggle * Resuable sidebar section (#2359) * Introduce resuable sidebar section * Stop eslint complaining * add react-use * Lint fixes * Make the storybook story less wide * Component development Abstracting out line level components i.e. Section > Header > Filter > Panel > Items Various code fixes * Cleaning up section visibility state * Reverting visibiilty state updater * Adding paths on click for spec scrolling * refreshing package-lock to resolve conflict * PR feedback for sidebar components * Update packages/insomnia-components/components/sidebar/sidebar-header.js Co-authored-by: Opender Singh <opender94@gmail.com> * Including lock * Merge fix * Component structuring, prop clean-up, css updates * Cleaning up components, pr feedback, fixing styling * array index reference clean-up/clarity * Leveraging useToggle rather than manual useState toggling * Cleaning up logs * Hide info section if missing from spec. * Update packages/insomnia-components/components/sidebar/sidebar-responses.js Co-authored-by: Opender Singh <opender94@gmail.com> * Update packages/insomnia-components/components/sidebar/sidebar-schemas.js Co-authored-by: Opender Singh <opender94@gmail.com> * Pull fragment * Destructuring and filter cleanup * Clearing filter value and DOM on section collapse * Merge latest * Merge conflict cleanup Co-authored-by: Opender Singh <opender94@gmail.com>
2020-07-22 13:13:06 +00:00
};
// Implemented as a class component because of a caveat with render props
// https://reactjs.org/docs/render-props.html#be-careful-when-using-render-props-with-reactpurecomponent
export default class SidebarSchemas extends React.Component<Props> {
renderBody = (filter: string): null | React.Node => {
const { schemas, onClick } = this.props;
if (Object.prototype.toString.call(schemas) !== '[object Object]') {
return <StyledInvalidSection name={'schema'} />;
}
const filteredValues = Object.keys(schemas).filter(schema =>
Design sidebar (#2328) * updated lock file * Rolling sidebar from SB into application * Type fix on the method label output * Update packages/insomnia-components/components/sidebar.js Co-authored-by: Opender Singh <opender94@gmail.com> * PR Feedback - Keys, useCallback Hook * stubbing component breakout * PR Feedback - Breaking out most UI elements into components - Filter component in place - Various CSS tweaks * Removing unused file * Updating toggle * Resuable sidebar section (#2359) * Introduce resuable sidebar section * Stop eslint complaining * add react-use * Lint fixes * Make the storybook story less wide * Component development Abstracting out line level components i.e. Section > Header > Filter > Panel > Items Various code fixes * Cleaning up section visibility state * Reverting visibiilty state updater * Adding paths on click for spec scrolling * refreshing package-lock to resolve conflict * PR feedback for sidebar components * Update packages/insomnia-components/components/sidebar/sidebar-header.js Co-authored-by: Opender Singh <opender94@gmail.com> * Including lock * Merge fix * Component structuring, prop clean-up, css updates * Cleaning up components, pr feedback, fixing styling * array index reference clean-up/clarity * Leveraging useToggle rather than manual useState toggling * Cleaning up logs * Hide info section if missing from spec. * Update packages/insomnia-components/components/sidebar/sidebar-responses.js Co-authored-by: Opender Singh <opender94@gmail.com> * Update packages/insomnia-components/components/sidebar/sidebar-schemas.js Co-authored-by: Opender Singh <opender94@gmail.com> * Pull fragment * Destructuring and filter cleanup * Clearing filter value and DOM on section collapse * Merge latest * Merge conflict cleanup Co-authored-by: Opender Singh <opender94@gmail.com>
2020-07-22 13:13:06 +00:00
schema.toLowerCase().includes(filter.toLocaleLowerCase()),
);
if (!filteredValues.length) {
return null;
}
return (
<div>
{filteredValues.map(schema => (
<SidebarItem key={schema} onClick={() => onClick('components', 'schemas', schema)}>
Design sidebar (#2328) * updated lock file * Rolling sidebar from SB into application * Type fix on the method label output * Update packages/insomnia-components/components/sidebar.js Co-authored-by: Opender Singh <opender94@gmail.com> * PR Feedback - Keys, useCallback Hook * stubbing component breakout * PR Feedback - Breaking out most UI elements into components - Filter component in place - Various CSS tweaks * Removing unused file * Updating toggle * Resuable sidebar section (#2359) * Introduce resuable sidebar section * Stop eslint complaining * add react-use * Lint fixes * Make the storybook story less wide * Component development Abstracting out line level components i.e. Section > Header > Filter > Panel > Items Various code fixes * Cleaning up section visibility state * Reverting visibiilty state updater * Adding paths on click for spec scrolling * refreshing package-lock to resolve conflict * PR feedback for sidebar components * Update packages/insomnia-components/components/sidebar/sidebar-header.js Co-authored-by: Opender Singh <opender94@gmail.com> * Including lock * Merge fix * Component structuring, prop clean-up, css updates * Cleaning up components, pr feedback, fixing styling * array index reference clean-up/clarity * Leveraging useToggle rather than manual useState toggling * Cleaning up logs * Hide info section if missing from spec. * Update packages/insomnia-components/components/sidebar/sidebar-responses.js Co-authored-by: Opender Singh <opender94@gmail.com> * Update packages/insomnia-components/components/sidebar/sidebar-schemas.js Co-authored-by: Opender Singh <opender94@gmail.com> * Pull fragment * Destructuring and filter cleanup * Clearing filter value and DOM on section collapse * Merge latest * Merge conflict cleanup Co-authored-by: Opender Singh <opender94@gmail.com>
2020-07-22 13:13:06 +00:00
<div>
<SvgIcon icon={IconEnum.brackets} />
</div>
<span>{schema}</span>
Design sidebar (#2328) * updated lock file * Rolling sidebar from SB into application * Type fix on the method label output * Update packages/insomnia-components/components/sidebar.js Co-authored-by: Opender Singh <opender94@gmail.com> * PR Feedback - Keys, useCallback Hook * stubbing component breakout * PR Feedback - Breaking out most UI elements into components - Filter component in place - Various CSS tweaks * Removing unused file * Updating toggle * Resuable sidebar section (#2359) * Introduce resuable sidebar section * Stop eslint complaining * add react-use * Lint fixes * Make the storybook story less wide * Component development Abstracting out line level components i.e. Section > Header > Filter > Panel > Items Various code fixes * Cleaning up section visibility state * Reverting visibiilty state updater * Adding paths on click for spec scrolling * refreshing package-lock to resolve conflict * PR feedback for sidebar components * Update packages/insomnia-components/components/sidebar/sidebar-header.js Co-authored-by: Opender Singh <opender94@gmail.com> * Including lock * Merge fix * Component structuring, prop clean-up, css updates * Cleaning up components, pr feedback, fixing styling * array index reference clean-up/clarity * Leveraging useToggle rather than manual useState toggling * Cleaning up logs * Hide info section if missing from spec. * Update packages/insomnia-components/components/sidebar/sidebar-responses.js Co-authored-by: Opender Singh <opender94@gmail.com> * Update packages/insomnia-components/components/sidebar/sidebar-schemas.js Co-authored-by: Opender Singh <opender94@gmail.com> * Pull fragment * Destructuring and filter cleanup * Clearing filter value and DOM on section collapse * Merge latest * Merge conflict cleanup Co-authored-by: Opender Singh <opender94@gmail.com>
2020-07-22 13:13:06 +00:00
</SidebarItem>
))}
</div>
);
};
render() {
return <SidebarSection title="SCHEMAS" renderBody={this.renderBody} />;
}
}