mirror of
https://github.com/scm-manager/scm-manager.git
synced 2026-03-11 23:00:19 +01:00
merged
This commit is contained in:
@@ -10,35 +10,33 @@ type Props = {
|
||||
error?: Error
|
||||
};
|
||||
|
||||
|
||||
class ErrorNotification extends React.Component<Props> {
|
||||
render() {
|
||||
const { t, error } = this.props;
|
||||
if (error) {
|
||||
if (error instanceof BackendError) {
|
||||
return <BackendErrorNotification error={error} />
|
||||
return <BackendErrorNotification error={error} />;
|
||||
} else if (error instanceof UnauthorizedError) {
|
||||
return (
|
||||
<Notification type="danger">
|
||||
<strong>{t("error-notification.prefix")}:</strong>{" "}
|
||||
{t("error-notification.timeout")}{" "}
|
||||
<strong>{t("errorNotification.prefix")}:</strong>{" "}
|
||||
{t("errorNotification.timeout")}{" "}
|
||||
<a href="javascript:window.location.reload(true)">
|
||||
{t("error-notification.loginLink")}
|
||||
{t("errorNotification.loginLink")}
|
||||
</a>
|
||||
</Notification>
|
||||
);
|
||||
} else if (error instanceof ForbiddenError) {
|
||||
return (
|
||||
<Notification type="danger">
|
||||
<strong>{t("error-notification.prefix")}:</strong>{" "}
|
||||
{t("error-notification.forbidden")}
|
||||
<strong>{t("errorNotification.prefix")}:</strong>{" "}
|
||||
{t("errorNotification.forbidden")}
|
||||
</Notification>
|
||||
)
|
||||
} else
|
||||
{
|
||||
);
|
||||
} else {
|
||||
return (
|
||||
<Notification type="danger">
|
||||
<strong>{t("error-notification.prefix")}:</strong> {error.message}
|
||||
<strong>{t("errorNotification.prefix")}:</strong> {error.message}
|
||||
</Notification>
|
||||
);
|
||||
}
|
||||
@@ -47,4 +45,4 @@ class ErrorNotification extends React.Component<Props> {
|
||||
}
|
||||
}
|
||||
|
||||
export default translate("commons")(ErrorNotification);
|
||||
export default translate("commons")(ErrorNotification);
|
||||
|
||||
@@ -1,34 +1,24 @@
|
||||
// @flow
|
||||
import React from "react";
|
||||
import { translate } from "react-i18next";
|
||||
import type { SelectValue } from "@scm-manager/ui-types";
|
||||
import type AutocompleteProps from "./UserGroupAutocomplete";
|
||||
import UserGroupAutocomplete from "./UserGroupAutocomplete";
|
||||
|
||||
type Props = {
|
||||
groupAutocompleteLink: string,
|
||||
valueSelected: SelectValue => void,
|
||||
value?: SelectValue,
|
||||
|
||||
type Props = AutocompleteProps & {
|
||||
// Context props
|
||||
t: string => string
|
||||
};
|
||||
|
||||
class GroupAutocomplete extends React.Component<Props> {
|
||||
selectName = (selection: SelectValue) => {
|
||||
this.props.valueSelected(selection);
|
||||
};
|
||||
|
||||
render() {
|
||||
const { groupAutocompleteLink, t, value } = this.props;
|
||||
const { t } = this.props;
|
||||
return (
|
||||
<UserGroupAutocomplete
|
||||
autocompleteLink={groupAutocompleteLink}
|
||||
label={t("autocomplete.group")}
|
||||
noOptionsMessage={t("autocomplete.noGroupOptions")}
|
||||
loadingMessage={t("autocomplete.loading")}
|
||||
placeholder={t("autocomplete.groupPlaceholder")}
|
||||
valueSelected={this.selectName}
|
||||
value={value}
|
||||
{...this.props}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,34 +1,24 @@
|
||||
// @flow
|
||||
import React from "react";
|
||||
import { translate } from "react-i18next";
|
||||
import type { SelectValue } from "@scm-manager/ui-types";
|
||||
import type AutocompleteProps from "./UserGroupAutocomplete";
|
||||
import UserGroupAutocomplete from "./UserGroupAutocomplete";
|
||||
|
||||
type Props = {
|
||||
userAutocompleteLink: string,
|
||||
valueSelected: SelectValue => void,
|
||||
value?: SelectValue,
|
||||
|
||||
type Props = AutocompleteProps & {
|
||||
// Context props
|
||||
t: string => string
|
||||
};
|
||||
|
||||
class UserAutocomplete extends React.Component<Props> {
|
||||
selectName = (selection: SelectValue) => {
|
||||
this.props.valueSelected(selection);
|
||||
};
|
||||
|
||||
render() {
|
||||
const { userAutocompleteLink, t, value } = this.props;
|
||||
const { t } = this.props;
|
||||
return (
|
||||
<UserGroupAutocomplete
|
||||
autocompleteLink={userAutocompleteLink}
|
||||
label={t("autocomplete.user")}
|
||||
noOptionsMessage={t("autocomplete.noUserOptions")}
|
||||
loadingMessage={t("autocomplete.loading")}
|
||||
placeholder={t("autocomplete.userPlaceholder")}
|
||||
valueSelected={this.selectName}
|
||||
value={value}
|
||||
{...this.props}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -3,12 +3,20 @@ import React from "react";
|
||||
import type { SelectValue } from "@scm-manager/ui-types";
|
||||
import Autocomplete from "./Autocomplete";
|
||||
|
||||
type Props = {
|
||||
export type AutocompleteProps = {
|
||||
autocompleteLink: string,
|
||||
valueSelected: SelectValue => void
|
||||
valueSelected: SelectValue => void,
|
||||
value?: SelectValue
|
||||
};
|
||||
|
||||
class UserGroupAutocomplete extends React.Component<Props> {
|
||||
type Props = AutocompleteProps & {
|
||||
label: string,
|
||||
noOptionsMessage: string,
|
||||
loadingMessage: string,
|
||||
placeholder: string
|
||||
};
|
||||
|
||||
export default class UserGroupAutocomplete extends React.Component<Props> {
|
||||
loadSuggestions = (inputValue: string) => {
|
||||
const url = this.props.autocompleteLink;
|
||||
const link = url + "?q=";
|
||||
@@ -42,5 +50,3 @@ class UserGroupAutocomplete extends React.Component<Props> {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default UserGroupAutocomplete;
|
||||
|
||||
@@ -19,11 +19,11 @@
|
||||
"subtitle": "Ein unbekannter Fehler ist aufgetreten."
|
||||
}
|
||||
},
|
||||
"error-notification": {
|
||||
"errorNotification": {
|
||||
"prefix": "Fehler",
|
||||
"loginLink": "Erneute Anmeldung",
|
||||
"timeout": "Die Session ist abgelaufen.",
|
||||
"wrong-login-credentials": "Ungültige Anmeldedaten",
|
||||
"wrongLoginCredentials": "Ungültige Anmeldedaten",
|
||||
"forbidden": "Sie haben nicht die Berechtigung, diesen Datensatz zu sehen"
|
||||
},
|
||||
"loading": {
|
||||
|
||||
@@ -19,11 +19,11 @@
|
||||
"subtitle": "Unknown error occurred"
|
||||
}
|
||||
},
|
||||
"error-notification": {
|
||||
"errorNotification": {
|
||||
"prefix": "Error",
|
||||
"loginLink": "You can login here again.",
|
||||
"timeout": "The session has expired",
|
||||
"wrong-login-credentials": "Invalid credentials",
|
||||
"wrongLoginCredentials": "Invalid credentials",
|
||||
"forbidden": "You don't have permission to view this entity"
|
||||
},
|
||||
"loading": {
|
||||
|
||||
@@ -95,7 +95,7 @@ class Login extends React.Component<Props, State> {
|
||||
areCredentialsInvalid() {
|
||||
const { t, error } = this.props;
|
||||
if (error instanceof UnauthorizedError) {
|
||||
return new Error(t("error-notification.wrong-login-credentials"));
|
||||
return new Error(t("errorNotification.wrongLoginCredentials"));
|
||||
} else {
|
||||
return error;
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ class CreatePermissionForm extends React.Component<Props, State> {
|
||||
if (group) {
|
||||
return (
|
||||
<GroupAutocomplete
|
||||
groupAutocompleteLink={this.props.groupAutocompleteLink}
|
||||
autocompleteLink={this.props.groupAutocompleteLink}
|
||||
valueSelected={this.selectName}
|
||||
value={this.state.value ? this.state.value : ""}
|
||||
/>
|
||||
@@ -82,7 +82,7 @@ class CreatePermissionForm extends React.Component<Props, State> {
|
||||
}
|
||||
return (
|
||||
<UserAutocomplete
|
||||
userAutocompleteLink={this.props.userAutocompleteLink}
|
||||
autocompleteLink={this.props.userAutocompleteLink}
|
||||
valueSelected={this.selectName}
|
||||
value={this.state.value ? this.state.value : ""}
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user