mirror of
https://github.com/Kong/insomnia
synced 2024-11-08 14:49:53 +00:00
51d3a5de32
Collapsable editor and visual design integration.
60 lines
1.4 KiB
JavaScript
60 lines
1.4 KiB
JavaScript
// @flow
|
|
import * as React from 'react';
|
|
import styled from 'styled-components';
|
|
|
|
type Props = {
|
|
onSetActiveRequest: () => void,
|
|
selectedRequestId?: string,
|
|
selectableRequests: Array<{ name: string, request: { _id: string } }>,
|
|
};
|
|
|
|
const StyledUnitTestRequestSelector: React.ComponentType<{}> = styled.div`
|
|
padding: 0 var(--padding-sm);
|
|
border: 1px solid var(--hl-md);
|
|
border-radius: var(--radius-sm);
|
|
margin: var(--padding-sm) var(--padding-sm) var(--padding-sm) auto;
|
|
max-width: 18rem;
|
|
flex: 0 0 auto;
|
|
select {
|
|
max-width: 18rem;
|
|
height: var(--line-height-xs);
|
|
border: none !important;
|
|
background: none !important;
|
|
color: var(--font-color);
|
|
|
|
&:focus {
|
|
outline: 0;
|
|
}
|
|
}
|
|
* {
|
|
margin: 0px;
|
|
}
|
|
`;
|
|
|
|
const UnitTestRequestSelector = ({
|
|
onSetActiveRequest,
|
|
selectedRequestId,
|
|
selectableRequests,
|
|
}: Props) => {
|
|
return (
|
|
<StyledUnitTestRequestSelector>
|
|
<select
|
|
name="request"
|
|
id="request"
|
|
onChange={onSetActiveRequest}
|
|
defaultValue={selectedRequestId || '__NULL__'}>
|
|
<option value="__NULL__">
|
|
{selectableRequests.length ? '-- Select Request --' : '-- No Requests --'}
|
|
</option>
|
|
{selectableRequests.map(({ name, request }) => (
|
|
<option key={request._id} value={request._id}>
|
|
{name}
|
|
</option>
|
|
))}
|
|
</select>
|
|
</StyledUnitTestRequestSelector>
|
|
);
|
|
};
|
|
|
|
export default UnitTestRequestSelector;
|