2 * ============LICENSE_START========================================================================
3 * ONAP : ccsdk feature sdnr wt odlux
4 * =================================================================================================
5 * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved.
6 * =================================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
8 * in compliance with the License. You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software distributed under the License
13 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
14 * or implied. See the License for the specific language governing permissions and limitations under
16 * ============LICENSE_END==========================================================================
19 import React from 'react';
20 import { BaseProps } from './baseProps';
21 import { ViewElementSelection } from '../models/uiModels';
22 import { FormControl, InputLabel, Select, FormHelperText, MenuItem, Tooltip } from '@mui/material';
24 type selectionProps = BaseProps;
26 export const UiElementSelection = (props: selectionProps) => {
28 const element = props.value as ViewElementSelection;
31 const value = String(props.inputValue);
32 if (element.mandatory && Boolean(!value)) {
36 return (props.readOnly || props.inputValue != null
37 ? (<FormControl variant="standard" style={{ width: 485, marginLeft: 20, marginRight: 20 }}>
38 <InputLabel htmlFor={`select-${element.id}`} >{element.label}</InputLabel>
39 <Select variant="standard"
40 required={!!element.mandatory}
42 onChange={(e) => { props.onChange(e.target.value as string); }}
43 readOnly={props.readOnly}
44 disabled={props.disabled}
45 value={value.toString()}
46 aria-label={element.label + '-selection'}
49 id: `select-${element.id}`,
52 {element.options.map(option => (
56 aria-label={option.key}>
57 <Tooltip disableInteractive title={option.description || ''}>
58 <div style={{ width: '100%' }}>
65 <FormHelperText>{error}</FormHelperText>