mirror of
https://github.com/Kong/insomnia
synced 2024-11-08 14:49:53 +00:00
74a3967fce
* Set cursor focus on active filter * Click targets and info panel fix Fixing inconsistently treated click targets and info panel items. * Font (for SVGs) sizing and layout fixes. * Layout & alignment fixes * Update packages/insomnia-components/components/sidebar/sidebar-info.js Co-authored-by: Opender Singh <opender94@gmail.com> * Spacing increase on first child elment in panel, click specificity Co-authored-by: Opender Singh <opender94@gmail.com>
49 lines
1.4 KiB
JavaScript
49 lines
1.4 KiB
JavaScript
// @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';
|
|
|
|
type Props = {
|
|
schemas: Object,
|
|
onClick: (section: string, ...args: any) => void,
|
|
};
|
|
|
|
// 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 =>
|
|
schema.toLowerCase().includes(filter.toLocaleLowerCase()),
|
|
);
|
|
|
|
if (!filteredValues.length) {
|
|
return null;
|
|
}
|
|
|
|
return (
|
|
<div>
|
|
{filteredValues.map(schema => (
|
|
<SidebarItem key={schema} onClick={() => onClick('components', 'schemas', schema)}>
|
|
<div>
|
|
<SvgIcon icon={IconEnum.brackets} />
|
|
</div>
|
|
<span>{schema}</span>
|
|
</SidebarItem>
|
|
))}
|
|
</div>
|
|
);
|
|
};
|
|
|
|
render() {
|
|
return <SidebarSection title="SCHEMAS" renderBody={this.renderBody} />;
|
|
}
|
|
}
|