mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-07 22:15:45 +01:00
fix element types
This commit is contained in:
@@ -16,12 +16,9 @@ type Props = {
|
||||
creatable?: boolean
|
||||
};
|
||||
|
||||
|
||||
type State = {};
|
||||
|
||||
class Autocomplete extends React.Component<Props, State> {
|
||||
|
||||
|
||||
static defaultProps = {
|
||||
placeholder: "Type here",
|
||||
loadingMessage: "Loading...",
|
||||
@@ -33,7 +30,11 @@ class Autocomplete extends React.Component<Props, State> {
|
||||
};
|
||||
|
||||
// We overwrite this to avoid running into a bug (https://github.com/JedWatson/react-select/issues/2944)
|
||||
isValidNewOption = (inputValue: string, selectValue: SelectValue, selectOptions: SelectValue[]) => {
|
||||
isValidNewOption = (
|
||||
inputValue: string,
|
||||
selectValue: SelectValue,
|
||||
selectOptions: SelectValue[]
|
||||
) => {
|
||||
const isNotDuplicated = !selectOptions
|
||||
.map(option => option.label)
|
||||
.includes(inputValue);
|
||||
@@ -42,12 +43,21 @@ class Autocomplete extends React.Component<Props, State> {
|
||||
};
|
||||
|
||||
render() {
|
||||
const { label, helpText, value, placeholder, loadingMessage, noOptionsMessage, loadSuggestions, creatable } = this.props;
|
||||
const {
|
||||
label,
|
||||
helpText,
|
||||
value,
|
||||
placeholder,
|
||||
loadingMessage,
|
||||
noOptionsMessage,
|
||||
loadSuggestions,
|
||||
creatable
|
||||
} = this.props;
|
||||
return (
|
||||
<div className="field">
|
||||
<LabelWithHelpIcon label={label} helpText={helpText} />
|
||||
<div className="control">
|
||||
{creatable?
|
||||
{creatable ? (
|
||||
<AsyncCreatable
|
||||
cacheOptions
|
||||
loadOptions={loadSuggestions}
|
||||
@@ -64,7 +74,7 @@ class Autocomplete extends React.Component<Props, State> {
|
||||
});
|
||||
}}
|
||||
/>
|
||||
:
|
||||
) : (
|
||||
<Async
|
||||
cacheOptions
|
||||
loadOptions={loadSuggestions}
|
||||
@@ -74,13 +84,11 @@ class Autocomplete extends React.Component<Props, State> {
|
||||
loadingMessage={() => loadingMessage}
|
||||
noOptionsMessage={() => noOptionsMessage}
|
||||
/>
|
||||
|
||||
}
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export default Autocomplete;
|
||||
|
||||
@@ -7,7 +7,7 @@ import UserGroupAutocomplete from "./UserGroupAutocomplete";
|
||||
type Props = {
|
||||
groupAutocompleteLink: string,
|
||||
valueSelected: SelectValue => void,
|
||||
value: string,
|
||||
value?: SelectValue,
|
||||
|
||||
// Context props
|
||||
t: string => string
|
||||
|
||||
@@ -7,7 +7,7 @@ import UserGroupAutocomplete from "./UserGroupAutocomplete";
|
||||
type Props = {
|
||||
userAutocompleteLink: string,
|
||||
valueSelected: SelectValue => void,
|
||||
value: string,
|
||||
value?: SelectValue,
|
||||
|
||||
// Context props
|
||||
t: string => string
|
||||
|
||||
@@ -5,9 +5,12 @@ import Autocomplete from "./Autocomplete";
|
||||
|
||||
type Props = {
|
||||
autocompleteLink: string,
|
||||
label: string,
|
||||
noOptionsMessage: string,
|
||||
loadingMessage: string,
|
||||
placeholder: string,
|
||||
valueSelected: SelectValue => void,
|
||||
value: string,
|
||||
label: string
|
||||
value?: SelectValue
|
||||
};
|
||||
|
||||
class UserGroupAutocomplete extends React.Component<Props> {
|
||||
@@ -34,17 +37,20 @@ class UserGroupAutocomplete extends React.Component<Props> {
|
||||
};
|
||||
|
||||
render() {
|
||||
const { value, label } = this.props;
|
||||
const { autocompleteLink, label, noOptionsMessage, loadingMessage, placeholder, value } = this.props;
|
||||
return (
|
||||
<Autocomplete
|
||||
autocompleteLink={autocompleteLink}
|
||||
label={label}
|
||||
noOptionsMessage={noOptionsMessage}
|
||||
loadingMessage={loadingMessage}
|
||||
placeholder={placeholder}
|
||||
loadSuggestions={this.loadSuggestions}
|
||||
valueSelected={this.selectName}
|
||||
value={value}
|
||||
creatable={true}
|
||||
label={label}
|
||||
{...this.props}
|
||||
/>
|
||||
);
|
||||
); // {...this.props}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -43,10 +43,10 @@
|
||||
"autocomplete": {
|
||||
"group": "Gruppe",
|
||||
"user": "Benutzer",
|
||||
"no-group-options": "Kein Gruppenname als Vorschlag verfügbar",
|
||||
"group-placeholder": "Gruppe eingeben",
|
||||
"no-user-options": "Kein Benutzername als Vorschlag verfügbar",
|
||||
"user-placeholder": "Benutzer eingeben",
|
||||
"noGroupOptions": "Kein Gruppenname als Vorschlag verfügbar",
|
||||
"groupPlaceholder": "Gruppe eingeben",
|
||||
"noUserOptions": "Kein Benutzername als Vorschlag verfügbar",
|
||||
"userPlaceholder": "Benutzer eingeben",
|
||||
"loading": "suche..."
|
||||
},
|
||||
"paginator": {
|
||||
|
||||
Reference in New Issue
Block a user