mirror of
https://github.com/Unleash/unleash.git
synced 2025-03-27 00:19:39 +01:00
* refactor: ensure that [hidden] overrides other display styles * refactor: use numeric font weights * refactor: remove unnecessary Jest mock * refactor: add a fullWidth prop to GeneralSelect * refactor: remove unnecessary label id prop * refactor: the showActive prop is optional * refactor: add hooks for managing query string state * refactor: add a hour/minute timestamp formatter * refactor: add labels to button icons * feat: add new feature metrics page * refactor: remove prev feature metrics page * refactor: use new metric boxes on overview page * refactor: lazy-load the new metrics page * refactor: fix type error when formatting unknown error * refactor: extract interfaces for props * refactor: destructure all props * refactor: expand arg names * refactor: reorg component dirs and files * refactor: improve chart element label * refactor: hide chart dots until hover * refactor: add section titles to environments/applications * refactor: simplify FeatureMetricsHours types * refactor: sort chart tooltip items * refactor: add more chart labels * refactor: always show a dot in single point charts * refactor: improve chart tooltip styles * refactor: adjut metric page spacing * refactor: decrease legend box size * refactor: move date fmt fn inline * refactor: improve chart legend styles * refactor: increase Cypress timeouts * refactor: sort environment and application chips * refactor: format files * refactor: use stable lists of apps and envs * refactor: fix FeatureMetrics dir name * refactor: avoid ScrollToTop on query string change * refactor: use ConditionallyRender instead of inline condition * refactor: use makeStyles instead of styled API
83 lines
1.9 KiB
TypeScript
83 lines
1.9 KiB
TypeScript
import React from 'react';
|
|
import { FormControl, InputLabel, MenuItem, Select } from '@material-ui/core';
|
|
import { SELECT_ITEM_ID } from '../../../testIds';
|
|
|
|
export interface ISelectOption {
|
|
key: string;
|
|
title?: string;
|
|
label?: string;
|
|
}
|
|
|
|
export interface ISelectMenuProps {
|
|
name: string;
|
|
id: string;
|
|
value?: string;
|
|
label?: string;
|
|
options: ISelectOption[];
|
|
style?: object;
|
|
onChange?: OnGeneralSelectChange;
|
|
disabled?: boolean;
|
|
fullWidth?: boolean;
|
|
className?: string;
|
|
classes?: any;
|
|
defaultValue?: string;
|
|
}
|
|
|
|
export type OnGeneralSelectChange = (
|
|
event: React.ChangeEvent<{ name?: string; value: unknown }>,
|
|
child: React.ReactNode
|
|
) => void;
|
|
|
|
const GeneralSelect: React.FC<ISelectMenuProps> = ({
|
|
name,
|
|
value = '',
|
|
label = '',
|
|
options,
|
|
onChange,
|
|
defaultValue,
|
|
id,
|
|
disabled = false,
|
|
className,
|
|
classes,
|
|
fullWidth,
|
|
...rest
|
|
}) => {
|
|
const renderSelectItems = () =>
|
|
options.map(option => (
|
|
<MenuItem
|
|
key={option.key}
|
|
value={option.key}
|
|
title={option.title || ''}
|
|
data-test={`${SELECT_ITEM_ID}-${option.label}`}
|
|
>
|
|
{option.label}
|
|
</MenuItem>
|
|
));
|
|
|
|
return (
|
|
<FormControl
|
|
variant="outlined"
|
|
size="small"
|
|
classes={classes}
|
|
fullWidth={fullWidth}
|
|
>
|
|
<InputLabel htmlFor={id}>{label}</InputLabel>
|
|
<Select
|
|
defaultValue={defaultValue}
|
|
name={name}
|
|
disabled={disabled}
|
|
onChange={onChange}
|
|
className={className}
|
|
label={label}
|
|
id={id}
|
|
value={value}
|
|
{...rest}
|
|
>
|
|
{renderSelectItems()}
|
|
</Select>
|
|
</FormControl>
|
|
);
|
|
};
|
|
|
|
export default GeneralSelect;
|