mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-08 14:35:45 +01:00
@@ -4,7 +4,6 @@ import { AsyncCreatable, Async } from "react-select";
|
|||||||
import type { AutocompleteObject, SelectValue } from "@scm-manager/ui-types";
|
import type { AutocompleteObject, SelectValue } from "@scm-manager/ui-types";
|
||||||
import LabelWithHelpIcon from "./forms/LabelWithHelpIcon";
|
import LabelWithHelpIcon from "./forms/LabelWithHelpIcon";
|
||||||
|
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
loadSuggestions: string => Promise<AutocompleteObject>,
|
loadSuggestions: string => Promise<AutocompleteObject>,
|
||||||
valueSelected: SelectValue => void,
|
valueSelected: SelectValue => void,
|
||||||
@@ -17,12 +16,9 @@ type Props = {
|
|||||||
creatable?: boolean
|
creatable?: boolean
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
type State = {};
|
type State = {};
|
||||||
|
|
||||||
class Autocomplete extends React.Component<Props, State> {
|
class Autocomplete extends React.Component<Props, State> {
|
||||||
|
|
||||||
|
|
||||||
static defaultProps = {
|
static defaultProps = {
|
||||||
placeholder: "Type here",
|
placeholder: "Type here",
|
||||||
loadingMessage: "Loading...",
|
loadingMessage: "Loading...",
|
||||||
@@ -34,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)
|
// 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
|
const isNotDuplicated = !selectOptions
|
||||||
.map(option => option.label)
|
.map(option => option.label)
|
||||||
.includes(inputValue);
|
.includes(inputValue);
|
||||||
@@ -43,12 +43,21 @@ class Autocomplete extends React.Component<Props, State> {
|
|||||||
};
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { label, helpText, value, placeholder, loadingMessage, noOptionsMessage, loadSuggestions, creatable } = this.props;
|
const {
|
||||||
|
label,
|
||||||
|
helpText,
|
||||||
|
value,
|
||||||
|
placeholder,
|
||||||
|
loadingMessage,
|
||||||
|
noOptionsMessage,
|
||||||
|
loadSuggestions,
|
||||||
|
creatable
|
||||||
|
} = this.props;
|
||||||
return (
|
return (
|
||||||
<div className="field">
|
<div className="field">
|
||||||
<LabelWithHelpIcon label={label} helpText={helpText} />
|
<LabelWithHelpIcon label={label} helpText={helpText} />
|
||||||
<div className="control">
|
<div className="control">
|
||||||
{creatable?
|
{creatable ? (
|
||||||
<AsyncCreatable
|
<AsyncCreatable
|
||||||
cacheOptions
|
cacheOptions
|
||||||
loadOptions={loadSuggestions}
|
loadOptions={loadSuggestions}
|
||||||
@@ -65,7 +74,7 @@ class Autocomplete extends React.Component<Props, State> {
|
|||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
:
|
) : (
|
||||||
<Async
|
<Async
|
||||||
cacheOptions
|
cacheOptions
|
||||||
loadOptions={loadSuggestions}
|
loadOptions={loadSuggestions}
|
||||||
@@ -75,13 +84,11 @@ class Autocomplete extends React.Component<Props, State> {
|
|||||||
loadingMessage={() => loadingMessage}
|
loadingMessage={() => loadingMessage}
|
||||||
noOptionsMessage={() => noOptionsMessage}
|
noOptionsMessage={() => noOptionsMessage}
|
||||||
/>
|
/>
|
||||||
|
)}
|
||||||
}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export default Autocomplete;
|
export default Autocomplete;
|
||||||
|
|||||||
@@ -10,35 +10,33 @@ type Props = {
|
|||||||
error?: Error
|
error?: Error
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class ErrorNotification extends React.Component<Props> {
|
class ErrorNotification extends React.Component<Props> {
|
||||||
render() {
|
render() {
|
||||||
const { t, error } = this.props;
|
const { t, error } = this.props;
|
||||||
if (error) {
|
if (error) {
|
||||||
if (error instanceof BackendError) {
|
if (error instanceof BackendError) {
|
||||||
return <BackendErrorNotification error={error} />
|
return <BackendErrorNotification error={error} />;
|
||||||
} else if (error instanceof UnauthorizedError) {
|
} else if (error instanceof UnauthorizedError) {
|
||||||
return (
|
return (
|
||||||
<Notification type="danger">
|
<Notification type="danger">
|
||||||
<strong>{t("error-notification.prefix")}:</strong>{" "}
|
<strong>{t("errorNotification.prefix")}:</strong>{" "}
|
||||||
{t("error-notification.timeout")}{" "}
|
{t("errorNotification.timeout")}{" "}
|
||||||
<a href="javascript:window.location.reload(true)">
|
<a href="javascript:window.location.reload(true)">
|
||||||
{t("error-notification.loginLink")}
|
{t("errorNotification.loginLink")}
|
||||||
</a>
|
</a>
|
||||||
</Notification>
|
</Notification>
|
||||||
);
|
);
|
||||||
} else if (error instanceof ForbiddenError) {
|
} else if (error instanceof ForbiddenError) {
|
||||||
return (
|
return (
|
||||||
<Notification type="danger">
|
<Notification type="danger">
|
||||||
<strong>{t("error-notification.prefix")}:</strong>{" "}
|
<strong>{t("errorNotification.prefix")}:</strong>{" "}
|
||||||
{t("error-notification.forbidden")}
|
{t("errorNotification.forbidden")}
|
||||||
</Notification>
|
</Notification>
|
||||||
)
|
);
|
||||||
} else
|
} else {
|
||||||
{
|
|
||||||
return (
|
return (
|
||||||
<Notification type="danger">
|
<Notification type="danger">
|
||||||
<strong>{t("error-notification.prefix")}:</strong> {error.message}
|
<strong>{t("errorNotification.prefix")}:</strong> {error.message}
|
||||||
</Notification>
|
</Notification>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,27 @@
|
|||||||
|
// @flow
|
||||||
|
import React from "react";
|
||||||
|
import { translate } from "react-i18next";
|
||||||
|
import type AutocompleteProps from "./UserGroupAutocomplete";
|
||||||
|
import UserGroupAutocomplete from "./UserGroupAutocomplete";
|
||||||
|
|
||||||
|
type Props = AutocompleteProps & {
|
||||||
|
// Context props
|
||||||
|
t: string => string
|
||||||
|
};
|
||||||
|
|
||||||
|
class GroupAutocomplete extends React.Component<Props> {
|
||||||
|
render() {
|
||||||
|
const { t } = this.props;
|
||||||
|
return (
|
||||||
|
<UserGroupAutocomplete
|
||||||
|
label={t("autocomplete.group")}
|
||||||
|
noOptionsMessage={t("autocomplete.noGroupOptions")}
|
||||||
|
loadingMessage={t("autocomplete.loading")}
|
||||||
|
placeholder={t("autocomplete.groupPlaceholder")}
|
||||||
|
{...this.props}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default translate("commons")(GroupAutocomplete);
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
// @flow
|
||||||
|
import React from "react";
|
||||||
|
import { translate } from "react-i18next";
|
||||||
|
import type AutocompleteProps from "./UserGroupAutocomplete";
|
||||||
|
import UserGroupAutocomplete from "./UserGroupAutocomplete";
|
||||||
|
|
||||||
|
type Props = AutocompleteProps & {
|
||||||
|
// Context props
|
||||||
|
t: string => string
|
||||||
|
};
|
||||||
|
|
||||||
|
class UserAutocomplete extends React.Component<Props> {
|
||||||
|
render() {
|
||||||
|
const { t } = this.props;
|
||||||
|
return (
|
||||||
|
<UserGroupAutocomplete
|
||||||
|
label={t("autocomplete.user")}
|
||||||
|
noOptionsMessage={t("autocomplete.noUserOptions")}
|
||||||
|
loadingMessage={t("autocomplete.loading")}
|
||||||
|
placeholder={t("autocomplete.userPlaceholder")}
|
||||||
|
{...this.props}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default translate("commons")(UserAutocomplete);
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
// @flow
|
||||||
|
import React from "react";
|
||||||
|
import type { SelectValue } from "@scm-manager/ui-types";
|
||||||
|
import Autocomplete from "./Autocomplete";
|
||||||
|
|
||||||
|
export type AutocompleteProps = {
|
||||||
|
autocompleteLink: string,
|
||||||
|
valueSelected: SelectValue => void,
|
||||||
|
value?: SelectValue
|
||||||
|
};
|
||||||
|
|
||||||
|
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=";
|
||||||
|
return fetch(link + inputValue)
|
||||||
|
.then(response => response.json())
|
||||||
|
.then(json => {
|
||||||
|
return json.map(element => {
|
||||||
|
const label = element.displayName
|
||||||
|
? `${element.displayName} (${element.id})`
|
||||||
|
: element.id;
|
||||||
|
return {
|
||||||
|
value: element,
|
||||||
|
label
|
||||||
|
};
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
selectName = (selection: SelectValue) => {
|
||||||
|
this.props.valueSelected(selection);
|
||||||
|
};
|
||||||
|
|
||||||
|
render() {
|
||||||
|
return (
|
||||||
|
<Autocomplete
|
||||||
|
loadSuggestions={this.loadSuggestions}
|
||||||
|
valueSelected={this.selectName}
|
||||||
|
creatable={true}
|
||||||
|
{...this.props}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -26,6 +26,8 @@ export { default as Tooltip } from "./Tooltip";
|
|||||||
// TODO do we need this? getPageFromMatch is already exported by urls
|
// TODO do we need this? getPageFromMatch is already exported by urls
|
||||||
export { getPageFromMatch } from "./urls";
|
export { getPageFromMatch } from "./urls";
|
||||||
export { default as Autocomplete} from "./Autocomplete";
|
export { default as Autocomplete} from "./Autocomplete";
|
||||||
|
export { default as GroupAutocomplete} from "./GroupAutocomplete";
|
||||||
|
export { default as UserAutocomplete} from "./UserAutocomplete";
|
||||||
export { default as BranchSelector } from "./BranchSelector";
|
export { default as BranchSelector } from "./BranchSelector";
|
||||||
export { default as Breadcrumb } from "./Breadcrumb";
|
export { default as Breadcrumb } from "./Breadcrumb";
|
||||||
export { default as MarkdownView } from "./MarkdownView";
|
export { default as MarkdownView } from "./MarkdownView";
|
||||||
|
|||||||
@@ -19,11 +19,11 @@
|
|||||||
"subtitle": "Ein unbekannter Fehler ist aufgetreten."
|
"subtitle": "Ein unbekannter Fehler ist aufgetreten."
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"error-notification": {
|
"errorNotification": {
|
||||||
"prefix": "Fehler",
|
"prefix": "Fehler",
|
||||||
"loginLink": "Erneute Anmeldung",
|
"loginLink": "Erneute Anmeldung",
|
||||||
"timeout": "Die Session ist abgelaufen.",
|
"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"
|
"forbidden": "Sie haben nicht die Berechtigung, diesen Datensatz zu sehen"
|
||||||
},
|
},
|
||||||
"loading": {
|
"loading": {
|
||||||
@@ -40,6 +40,15 @@
|
|||||||
"admin": "Administration"
|
"admin": "Administration"
|
||||||
},
|
},
|
||||||
"filterEntries": "Einträge filtern",
|
"filterEntries": "Einträge filtern",
|
||||||
|
"autocomplete": {
|
||||||
|
"group": "Gruppe",
|
||||||
|
"user": "Benutzer",
|
||||||
|
"noGroupOptions": "Kein Gruppenname als Vorschlag verfügbar",
|
||||||
|
"groupPlaceholder": "Gruppe eingeben",
|
||||||
|
"noUserOptions": "Kein Benutzername als Vorschlag verfügbar",
|
||||||
|
"userPlaceholder": "Benutzer eingeben",
|
||||||
|
"loading": "suche..."
|
||||||
|
},
|
||||||
"paginator": {
|
"paginator": {
|
||||||
"next": "Weiter",
|
"next": "Weiter",
|
||||||
"previous": "Zurück"
|
"previous": "Zurück"
|
||||||
|
|||||||
@@ -11,7 +11,10 @@
|
|||||||
"validation": {
|
"validation": {
|
||||||
"namespace-invalid": "Der Namespace des Repository ist ungültig",
|
"namespace-invalid": "Der Namespace des Repository ist ungültig",
|
||||||
"name-invalid": "Der Name des Repository ist ungültig",
|
"name-invalid": "Der Name des Repository ist ungültig",
|
||||||
"contact-invalid": "Der Kontakt muss eine gültige E-Mail Adresse sein"
|
"contact-invalid": "Der Kontakt muss eine gültige E-Mail Adresse sein",
|
||||||
|
"branch": {
|
||||||
|
"nameInvalid": "Der Name des Branches ist ungültig"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"help": {
|
"help": {
|
||||||
"namespaceHelpText": "Der Namespace des Repository. Dieser wird Teil der URL des Repository sein.",
|
"namespaceHelpText": "Der Namespace des Repository. Dieser wird Teil der URL des Repository sein.",
|
||||||
@@ -150,13 +153,6 @@
|
|||||||
"roleHelpText": "READ = read; WRITE = read und write; OWNER = read, write und auch die Möglichkeit Einstellungen und Berechtigungen zu verwalten. Wenn hier nichts angezeigt wird, den Erweitert-Button benutzen, um Details zu sehen.",
|
"roleHelpText": "READ = read; WRITE = read und write; OWNER = read, write und auch die Möglichkeit Einstellungen und Berechtigungen zu verwalten. Wenn hier nichts angezeigt wird, den Erweitert-Button benutzen, um Details zu sehen.",
|
||||||
"permissionsHelpText": "Hier können individuelle Berechtigungen unabhängig von vordefinierten Rollen vergeben werden."
|
"permissionsHelpText": "Hier können individuelle Berechtigungen unabhängig von vordefinierten Rollen vergeben werden."
|
||||||
},
|
},
|
||||||
"autocomplete": {
|
|
||||||
"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",
|
|
||||||
"loading": "suche..."
|
|
||||||
},
|
|
||||||
"advanced": {
|
"advanced": {
|
||||||
"dialog": {
|
"dialog": {
|
||||||
"title": "Erweiterte Berechtigungen",
|
"title": "Erweiterte Berechtigungen",
|
||||||
|
|||||||
@@ -19,11 +19,11 @@
|
|||||||
"subtitle": "Unknown error occurred"
|
"subtitle": "Unknown error occurred"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"error-notification": {
|
"errorNotification": {
|
||||||
"prefix": "Error",
|
"prefix": "Error",
|
||||||
"loginLink": "You can login here again.",
|
"loginLink": "You can login here again.",
|
||||||
"timeout": "The session has expired",
|
"timeout": "The session has expired",
|
||||||
"wrong-login-credentials": "Invalid credentials",
|
"wrongLoginCredentials": "Invalid credentials",
|
||||||
"forbidden": "You don't have permission to view this entity"
|
"forbidden": "You don't have permission to view this entity"
|
||||||
},
|
},
|
||||||
"loading": {
|
"loading": {
|
||||||
@@ -40,6 +40,15 @@
|
|||||||
"admin": "Administration"
|
"admin": "Administration"
|
||||||
},
|
},
|
||||||
"filterEntries": "filter entries",
|
"filterEntries": "filter entries",
|
||||||
|
"autocomplete": {
|
||||||
|
"group": "Group",
|
||||||
|
"user": "User",
|
||||||
|
"noGroupOptions": "No group suggestion available",
|
||||||
|
"groupPlaceholder": "Enter group",
|
||||||
|
"noUserOptions": "No user suggestion available",
|
||||||
|
"userPlaceholder": "Enter user",
|
||||||
|
"loading": "Loading..."
|
||||||
|
},
|
||||||
"paginator": {
|
"paginator": {
|
||||||
"next": "Next",
|
"next": "Next",
|
||||||
"previous": "Previous"
|
"previous": "Previous"
|
||||||
|
|||||||
@@ -153,13 +153,6 @@
|
|||||||
"roleHelpText": "READ = read; WRITE = read and write; OWNER = read, write and also the ability to manage the properties and permissions. If nothing is selected here, use the 'Advanced' Button to see detailed permissions.",
|
"roleHelpText": "READ = read; WRITE = read and write; OWNER = read, write and also the ability to manage the properties and permissions. If nothing is selected here, use the 'Advanced' Button to see detailed permissions.",
|
||||||
"permissionsHelpText": "Use this to specify your own set of permissions regardless of predefined roles."
|
"permissionsHelpText": "Use this to specify your own set of permissions regardless of predefined roles."
|
||||||
},
|
},
|
||||||
"autocomplete": {
|
|
||||||
"no-group-options": "No group suggestion available",
|
|
||||||
"group-placeholder": "Enter group",
|
|
||||||
"no-user-options": "No user suggestion available",
|
|
||||||
"user-placeholder": "Enter user",
|
|
||||||
"loading": "Loading..."
|
|
||||||
},
|
|
||||||
"advanced": {
|
"advanced": {
|
||||||
"dialog": {
|
"dialog": {
|
||||||
"title": "Advanced Permissions",
|
"title": "Advanced Permissions",
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ class Login extends React.Component<Props, State> {
|
|||||||
areCredentialsInvalid() {
|
areCredentialsInvalid() {
|
||||||
const { t, error } = this.props;
|
const { t, error } = this.props;
|
||||||
if (error instanceof UnauthorizedError) {
|
if (error instanceof UnauthorizedError) {
|
||||||
return new Error(t("error-notification.wrong-login-credentials"));
|
return new Error(t("errorNotification.wrongLoginCredentials"));
|
||||||
} else {
|
} else {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,11 +9,12 @@ import type {
|
|||||||
} from "@scm-manager/ui-types";
|
} from "@scm-manager/ui-types";
|
||||||
import {
|
import {
|
||||||
Subtitle,
|
Subtitle,
|
||||||
Autocomplete,
|
|
||||||
SubmitButton,
|
SubmitButton,
|
||||||
Button,
|
Button,
|
||||||
LabelWithHelpIcon,
|
LabelWithHelpIcon,
|
||||||
Radio
|
Radio,
|
||||||
|
GroupAutocomplete,
|
||||||
|
UserAutocomplete
|
||||||
} from "@scm-manager/ui-components";
|
} from "@scm-manager/ui-components";
|
||||||
import * as validator from "../components/permissionValidation";
|
import * as validator from "../components/permissionValidation";
|
||||||
import RoleSelector from "../components/RoleSelector";
|
import RoleSelector from "../components/RoleSelector";
|
||||||
@@ -26,8 +27,8 @@ type Props = {
|
|||||||
createPermission: (permission: PermissionCreateEntry) => void,
|
createPermission: (permission: PermissionCreateEntry) => void,
|
||||||
loading: boolean,
|
loading: boolean,
|
||||||
currentPermissions: PermissionCollection,
|
currentPermissions: PermissionCollection,
|
||||||
groupAutoCompleteLink: string,
|
groupAutocompleteLink: string,
|
||||||
userAutoCompleteLink: string,
|
userAutocompleteLink: string,
|
||||||
|
|
||||||
// Context props
|
// Context props
|
||||||
t: string => string
|
t: string => string
|
||||||
@@ -68,65 +69,27 @@ class CreatePermissionForm extends React.Component<Props, State> {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
loadUserAutocompletion = (inputValue: string) => {
|
|
||||||
return this.loadAutocompletion(this.props.userAutoCompleteLink, inputValue);
|
|
||||||
};
|
|
||||||
|
|
||||||
loadGroupAutocompletion = (inputValue: string) => {
|
|
||||||
return this.loadAutocompletion(
|
|
||||||
this.props.groupAutoCompleteLink,
|
|
||||||
inputValue
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
loadAutocompletion(url: string, inputValue: string) {
|
|
||||||
const link = url + "?q=";
|
|
||||||
return fetch(link + inputValue)
|
|
||||||
.then(response => response.json())
|
|
||||||
.then(json => {
|
|
||||||
return json.map(element => {
|
|
||||||
const label = element.displayName
|
|
||||||
? `${element.displayName} (${element.id})`
|
|
||||||
: element.id;
|
|
||||||
return {
|
|
||||||
value: element,
|
|
||||||
label
|
|
||||||
};
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
renderAutocompletionField = () => {
|
renderAutocompletionField = () => {
|
||||||
const { t } = this.props;
|
const group = this.state.groupPermission;
|
||||||
if (this.state.groupPermission) {
|
if (group) {
|
||||||
return (
|
return (
|
||||||
<Autocomplete
|
<GroupAutocomplete
|
||||||
loadSuggestions={this.loadGroupAutocompletion}
|
autocompleteLink={this.props.groupAutocompleteLink}
|
||||||
valueSelected={this.groupOrUserSelected}
|
valueSelected={this.selectName}
|
||||||
value={this.state.value ? this.state.value : ""}
|
value={this.state.value ? this.state.value : ""}
|
||||||
label={t("permission.group")}
|
|
||||||
noOptionsMessage={t("permission.autocomplete.no-group-options")}
|
|
||||||
loadingMessage={t("permission.autocomplete.loading")}
|
|
||||||
placeholder={t("permission.autocomplete.group-placeholder")}
|
|
||||||
creatable={true}
|
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
<Autocomplete
|
<UserAutocomplete
|
||||||
loadSuggestions={this.loadUserAutocompletion}
|
autocompleteLink={this.props.userAutocompleteLink}
|
||||||
valueSelected={this.groupOrUserSelected}
|
valueSelected={this.selectName}
|
||||||
value={this.state.value ? this.state.value : ""}
|
value={this.state.value ? this.state.value : ""}
|
||||||
label={t("permission.user")}
|
|
||||||
noOptionsMessage={t("permission.autocomplete.no-user-options")}
|
|
||||||
loadingMessage={t("permission.autocomplete.loading")}
|
|
||||||
placeholder={t("permission.autocomplete.user-placeholder")}
|
|
||||||
creatable={true}
|
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
groupOrUserSelected = (value: SelectValue) => {
|
selectName = (value: SelectValue) => {
|
||||||
this.setState({
|
this.setState({
|
||||||
value,
|
value,
|
||||||
name: value.value.id,
|
name: value.value.id,
|
||||||
@@ -150,15 +113,17 @@ class CreatePermissionForm extends React.Component<Props, State> {
|
|||||||
<AdvancedPermissionsDialog
|
<AdvancedPermissionsDialog
|
||||||
availableVerbs={availableVerbs}
|
availableVerbs={availableVerbs}
|
||||||
selectedVerbs={selectedVerbs}
|
selectedVerbs={selectedVerbs}
|
||||||
onClose={this.closeAdvancedPermissionsDialog}
|
onClose={this.toggleAdvancedPermissionsDialog}
|
||||||
onSubmit={this.submitAdvancedPermissionsDialog}
|
onSubmit={this.submitAdvancedPermissionsDialog}
|
||||||
/>
|
/>
|
||||||
) : null;
|
) : null;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<>
|
||||||
<hr />
|
<hr />
|
||||||
<Subtitle subtitle={t("permission.add-permission.add-permission-heading")} />
|
<Subtitle
|
||||||
|
subtitle={t("permission.add-permission.add-permission-heading")}
|
||||||
|
/>
|
||||||
{advancedDialog}
|
{advancedDialog}
|
||||||
<form onSubmit={this.submit}>
|
<form onSubmit={this.submit}>
|
||||||
<div className="field is-grouped">
|
<div className="field is-grouped">
|
||||||
@@ -201,7 +166,7 @@ class CreatePermissionForm extends React.Component<Props, State> {
|
|||||||
/>
|
/>
|
||||||
<Button
|
<Button
|
||||||
label={t("permission.advanced-button.label")}
|
label={t("permission.advanced-button.label")}
|
||||||
action={this.handleDetailedPermissionsPressed}
|
action={this.toggleAdvancedPermissionsDialog}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -217,16 +182,14 @@ class CreatePermissionForm extends React.Component<Props, State> {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
handleDetailedPermissionsPressed = () => {
|
toggleAdvancedPermissionsDialog = () => {
|
||||||
this.setState({ showAdvancedDialog: true });
|
this.setState(prevState => ({
|
||||||
};
|
showAdvancedDialog: !prevState.showAdvancedDialog
|
||||||
|
}));
|
||||||
closeAdvancedPermissionsDialog = () => {
|
|
||||||
this.setState({ showAdvancedDialog: false });
|
|
||||||
};
|
};
|
||||||
|
|
||||||
submitAdvancedPermissionsDialog = (newVerbs: string[]) => {
|
submitAdvancedPermissionsDialog = (newVerbs: string[]) => {
|
||||||
|
|||||||
@@ -60,8 +60,8 @@ type Props = {
|
|||||||
repositoryRolesLink: string,
|
repositoryRolesLink: string,
|
||||||
repositoryVerbsLink: string,
|
repositoryVerbsLink: string,
|
||||||
permissionsLink: string,
|
permissionsLink: string,
|
||||||
groupAutoCompleteLink: string,
|
groupAutocompleteLink: string,
|
||||||
userAutoCompleteLink: string,
|
userAutocompleteLink: string,
|
||||||
|
|
||||||
//dispatch functions
|
//dispatch functions
|
||||||
fetchAvailablePermissionsIfNeeded: (
|
fetchAvailablePermissionsIfNeeded: (
|
||||||
@@ -129,8 +129,8 @@ class Permissions extends React.Component<Props> {
|
|||||||
repoName,
|
repoName,
|
||||||
loadingCreatePermission,
|
loadingCreatePermission,
|
||||||
hasPermissionToCreate,
|
hasPermissionToCreate,
|
||||||
userAutoCompleteLink,
|
userAutocompleteLink,
|
||||||
groupAutoCompleteLink
|
groupAutocompleteLink
|
||||||
} = this.props;
|
} = this.props;
|
||||||
if (error) {
|
if (error) {
|
||||||
return (
|
return (
|
||||||
@@ -153,8 +153,8 @@ class Permissions extends React.Component<Props> {
|
|||||||
createPermission={permission => this.createPermission(permission)}
|
createPermission={permission => this.createPermission(permission)}
|
||||||
loading={loadingCreatePermission}
|
loading={loadingCreatePermission}
|
||||||
currentPermissions={permissions}
|
currentPermissions={permissions}
|
||||||
userAutoCompleteLink={userAutoCompleteLink}
|
userAutocompleteLink={userAutocompleteLink}
|
||||||
groupAutoCompleteLink={groupAutoCompleteLink}
|
groupAutocompleteLink={groupAutocompleteLink}
|
||||||
/>
|
/>
|
||||||
) : null;
|
) : null;
|
||||||
|
|
||||||
@@ -228,8 +228,8 @@ const mapStateToProps = (state, ownProps) => {
|
|||||||
const repositoryRolesLink = getRepositoryRolesLink(state);
|
const repositoryRolesLink = getRepositoryRolesLink(state);
|
||||||
const repositoryVerbsLink = getRepositoryVerbsLink(state);
|
const repositoryVerbsLink = getRepositoryVerbsLink(state);
|
||||||
const permissionsLink = getPermissionsLink(state, namespace, repoName);
|
const permissionsLink = getPermissionsLink(state, namespace, repoName);
|
||||||
const groupAutoCompleteLink = getGroupAutoCompleteLink(state);
|
const groupAutocompleteLink = getGroupAutoCompleteLink(state);
|
||||||
const userAutoCompleteLink = getUserAutoCompleteLink(state);
|
const userAutocompleteLink = getUserAutoCompleteLink(state);
|
||||||
const availablePermissions = getAvailablePermissions(state);
|
const availablePermissions = getAvailablePermissions(state);
|
||||||
const availableRepositoryRoles = getAvailableRepositoryRoles(state);
|
const availableRepositoryRoles = getAvailableRepositoryRoles(state);
|
||||||
const availableVerbs = getAvailableRepositoryVerbs(state);
|
const availableVerbs = getAvailableRepositoryVerbs(state);
|
||||||
@@ -248,8 +248,8 @@ const mapStateToProps = (state, ownProps) => {
|
|||||||
hasPermissionToCreate,
|
hasPermissionToCreate,
|
||||||
loadingCreatePermission,
|
loadingCreatePermission,
|
||||||
permissionsLink,
|
permissionsLink,
|
||||||
groupAutoCompleteLink,
|
groupAutocompleteLink,
|
||||||
userAutoCompleteLink
|
userAutocompleteLink
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user