mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-13 08:55:44 +01:00
apply eslint and prettier rules
This commit is contained in:
@@ -91,24 +91,13 @@ class ConfigForm extends React.Component<Props, State> {
|
||||
};
|
||||
|
||||
render() {
|
||||
const {
|
||||
loading,
|
||||
t,
|
||||
namespaceStrategies,
|
||||
configReadPermission,
|
||||
configUpdatePermission
|
||||
} = this.props;
|
||||
const { loading, t, namespaceStrategies, configReadPermission, configUpdatePermission } = this.props;
|
||||
const config = this.state.config;
|
||||
|
||||
let noPermissionNotification = null;
|
||||
|
||||
if (!configReadPermission) {
|
||||
return (
|
||||
<Notification
|
||||
type={"danger"}
|
||||
children={t("config.form.no-read-permission-notification")}
|
||||
/>
|
||||
);
|
||||
return <Notification type={"danger"} children={t("config.form.no-read-permission-notification")} />;
|
||||
}
|
||||
|
||||
if (this.state.showNotification) {
|
||||
@@ -135,27 +124,21 @@ class ConfigForm extends React.Component<Props, State> {
|
||||
pluginUrl={config.pluginUrl}
|
||||
enabledXsrfProtection={config.enabledXsrfProtection}
|
||||
namespaceStrategy={config.namespaceStrategy}
|
||||
onChange={(isValid, changedValue, name) =>
|
||||
this.onChange(isValid, changedValue, name)
|
||||
}
|
||||
onChange={(isValid, changedValue, name) => this.onChange(isValid, changedValue, name)}
|
||||
hasUpdatePermission={configUpdatePermission}
|
||||
/>
|
||||
<hr />
|
||||
<LoginAttempt
|
||||
loginAttemptLimit={config.loginAttemptLimit}
|
||||
loginAttemptLimitTimeout={config.loginAttemptLimitTimeout}
|
||||
onChange={(isValid, changedValue, name) =>
|
||||
this.onChange(isValid, changedValue, name)
|
||||
}
|
||||
onChange={(isValid, changedValue, name) => this.onChange(isValid, changedValue, name)}
|
||||
hasUpdatePermission={configUpdatePermission}
|
||||
/>
|
||||
<hr />
|
||||
<BaseUrlSettings
|
||||
baseUrl={config.baseUrl}
|
||||
forceBaseUrl={config.forceBaseUrl}
|
||||
onChange={(isValid, changedValue, name) =>
|
||||
this.onChange(isValid, changedValue, name)
|
||||
}
|
||||
onChange={(isValid, changedValue, name) => this.onChange(isValid, changedValue, name)}
|
||||
hasUpdatePermission={configUpdatePermission}
|
||||
/>
|
||||
<hr />
|
||||
@@ -166,18 +149,14 @@ class ConfigForm extends React.Component<Props, State> {
|
||||
proxyUser={config.proxyUser ? config.proxyUser : ""}
|
||||
enableProxy={config.enableProxy}
|
||||
proxyExcludes={config.proxyExcludes}
|
||||
onChange={(isValid, changedValue, name) =>
|
||||
this.onChange(isValid, changedValue, name)
|
||||
}
|
||||
onChange={(isValid, changedValue, name) => this.onChange(isValid, changedValue, name)}
|
||||
hasUpdatePermission={configUpdatePermission}
|
||||
/>
|
||||
<hr />
|
||||
<SubmitButton
|
||||
loading={loading}
|
||||
label={t("config.form.submit")}
|
||||
disabled={
|
||||
!configUpdatePermission || this.hasError() || !this.state.changed
|
||||
}
|
||||
disabled={!configUpdatePermission || this.hasError() || !this.state.changed}
|
||||
/>
|
||||
</form>
|
||||
);
|
||||
@@ -199,10 +178,7 @@ class ConfigForm extends React.Component<Props, State> {
|
||||
};
|
||||
|
||||
hasError = () => {
|
||||
return (
|
||||
this.state.error.loginAttemptLimit ||
|
||||
this.state.error.loginAttemptLimitTimeout
|
||||
);
|
||||
return this.state.error.loginAttemptLimit || this.state.error.loginAttemptLimitTimeout;
|
||||
};
|
||||
|
||||
onClose = () => {
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
import React from "react";
|
||||
import { translate } from "react-i18next";
|
||||
import {
|
||||
InputField,
|
||||
Subtitle,
|
||||
validation as validator
|
||||
} from "@scm-manager/ui-components";
|
||||
import { InputField, Subtitle, validation as validator } from "@scm-manager/ui-components";
|
||||
|
||||
type Props = {
|
||||
loginAttemptLimit: number;
|
||||
@@ -29,12 +25,7 @@ class LoginAttempt extends React.Component<Props, State> {
|
||||
};
|
||||
}
|
||||
render() {
|
||||
const {
|
||||
t,
|
||||
loginAttemptLimit,
|
||||
loginAttemptLimitTimeout,
|
||||
hasUpdatePermission
|
||||
} = this.props;
|
||||
const { t, loginAttemptLimit, loginAttemptLimitTimeout, hasUpdatePermission } = this.props;
|
||||
|
||||
return (
|
||||
<div>
|
||||
@@ -73,11 +64,7 @@ class LoginAttempt extends React.Component<Props, State> {
|
||||
...this.state,
|
||||
loginAttemptLimitError: !validator.isNumberValid(value)
|
||||
});
|
||||
this.props.onChange(
|
||||
validator.isNumberValid(value),
|
||||
value,
|
||||
"loginAttemptLimit"
|
||||
);
|
||||
this.props.onChange(validator.isNumberValid(value), value, "loginAttemptLimit");
|
||||
};
|
||||
|
||||
handleLoginAttemptLimitTimeoutChange = (value: string) => {
|
||||
@@ -85,11 +72,7 @@ class LoginAttempt extends React.Component<Props, State> {
|
||||
...this.state,
|
||||
loginAttemptLimitTimeoutError: !validator.isNumberValid(value)
|
||||
});
|
||||
this.props.onChange(
|
||||
validator.isNumberValid(value),
|
||||
value,
|
||||
"loginAttemptLimitTimeout"
|
||||
);
|
||||
this.props.onChange(validator.isNumberValid(value), value, "loginAttemptLimitTimeout");
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -37,11 +37,7 @@ class NamespaceStrategySelect extends React.Component<Props> {
|
||||
|
||||
findSelected = () => {
|
||||
const { namespaceStrategies, value } = this.props;
|
||||
if (
|
||||
!namespaceStrategies ||
|
||||
!namespaceStrategies.available ||
|
||||
namespaceStrategies.available.indexOf(value) < 0
|
||||
) {
|
||||
if (!namespaceStrategies || !namespaceStrategies.available || namespaceStrategies.available.indexOf(value) < 0) {
|
||||
return namespaceStrategies.current;
|
||||
}
|
||||
return value;
|
||||
|
||||
@@ -1,11 +1,6 @@
|
||||
import React from "react";
|
||||
import { translate } from "react-i18next";
|
||||
import {
|
||||
Checkbox,
|
||||
InputField,
|
||||
Subtitle,
|
||||
AddEntryToTableField
|
||||
} from "@scm-manager/ui-components";
|
||||
import { Checkbox, InputField, Subtitle, AddEntryToTableField } from "@scm-manager/ui-components";
|
||||
import ProxyExcludesTable from "../table/ProxyExcludesTable";
|
||||
|
||||
type Props = {
|
||||
@@ -92,9 +87,7 @@ class ProxySettings extends React.Component<Props> {
|
||||
<div className="column is-full">
|
||||
<ProxyExcludesTable
|
||||
proxyExcludes={proxyExcludes}
|
||||
onChange={(isValid, changedValue, name) =>
|
||||
this.props.onChange(isValid, changedValue, name)
|
||||
}
|
||||
onChange={(isValid, changedValue, name) => this.props.onChange(isValid, changedValue, name)}
|
||||
disabled={!enableProxy || !hasUpdatePermission}
|
||||
/>
|
||||
<AddEntryToTableField
|
||||
@@ -130,11 +123,7 @@ class ProxySettings extends React.Component<Props> {
|
||||
if (this.isProxyExcludeMember(proxyExcludeName)) {
|
||||
return;
|
||||
}
|
||||
this.props.onChange(
|
||||
true,
|
||||
[...this.props.proxyExcludes, proxyExcludeName],
|
||||
"proxyExcludes"
|
||||
);
|
||||
this.props.onChange(true, [...this.props.proxyExcludes, proxyExcludeName], "proxyExcludes");
|
||||
};
|
||||
|
||||
isProxyExcludeMember = (proxyExcludeName: string) => {
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
import React from "react";
|
||||
import {
|
||||
RemoveEntryOfTableButton,
|
||||
LabelWithHelpIcon
|
||||
} from "@scm-manager/ui-components";
|
||||
import { RemoveEntryOfTableButton, LabelWithHelpIcon } from "@scm-manager/ui-components";
|
||||
|
||||
type Props = {
|
||||
items: string[];
|
||||
|
||||
@@ -6,18 +6,8 @@ import { History } from "history";
|
||||
import { connect } from "react-redux";
|
||||
import { compose } from "redux";
|
||||
import { Links } from "@scm-manager/ui-types";
|
||||
import {
|
||||
Page,
|
||||
Navigation,
|
||||
NavLink,
|
||||
Section,
|
||||
SubNavigation
|
||||
} from "@scm-manager/ui-components";
|
||||
import {
|
||||
getLinks,
|
||||
getAvailablePluginsLink,
|
||||
getInstalledPluginsLink
|
||||
} from "../../modules/indexResource";
|
||||
import { Page, Navigation, NavLink, Section, SubNavigation } from "@scm-manager/ui-components";
|
||||
import { getLinks, getAvailablePluginsLink, getInstalledPluginsLink } from "../../modules/indexResource";
|
||||
import AdminDetails from "./AdminDetails";
|
||||
import PluginsOverview from "../plugins/containers/PluginsOverview";
|
||||
import GlobalConfig from "./GlobalConfig";
|
||||
@@ -73,96 +63,45 @@ class Admin extends React.Component<Props> {
|
||||
<Switch>
|
||||
<Redirect exact from={url} to={`${url}/info`} />
|
||||
<Route path={`${url}/info`} exact component={AdminDetails} />
|
||||
<Route
|
||||
path={`${url}/settings/general`}
|
||||
exact
|
||||
component={GlobalConfig}
|
||||
/>
|
||||
<Redirect
|
||||
exact
|
||||
from={`${url}/plugins`}
|
||||
to={`${url}/plugins/installed/`}
|
||||
/>
|
||||
<Route path={`${url}/settings/general`} exact component={GlobalConfig} />
|
||||
<Redirect exact from={`${url}/plugins`} to={`${url}/plugins/installed/`} />
|
||||
<Route
|
||||
path={`${url}/plugins/installed`}
|
||||
exact
|
||||
render={() => (
|
||||
<PluginsOverview
|
||||
baseUrl={`${url}/plugins/installed`}
|
||||
installed={true}
|
||||
/>
|
||||
)}
|
||||
render={() => <PluginsOverview baseUrl={`${url}/plugins/installed`} installed={true} />}
|
||||
/>
|
||||
<Route
|
||||
path={`${url}/plugins/installed/:page`}
|
||||
exact
|
||||
render={() => (
|
||||
<PluginsOverview
|
||||
baseUrl={`${url}/plugins/installed`}
|
||||
installed={true}
|
||||
/>
|
||||
)}
|
||||
render={() => <PluginsOverview baseUrl={`${url}/plugins/installed`} installed={true} />}
|
||||
/>
|
||||
<Route
|
||||
path={`${url}/plugins/available`}
|
||||
exact
|
||||
render={() => (
|
||||
<PluginsOverview
|
||||
baseUrl={`${url}/plugins/available`}
|
||||
installed={false}
|
||||
/>
|
||||
)}
|
||||
render={() => <PluginsOverview baseUrl={`${url}/plugins/available`} installed={false} />}
|
||||
/>
|
||||
<Route
|
||||
path={`${url}/plugins/available/:page`}
|
||||
exact
|
||||
render={() => (
|
||||
<PluginsOverview
|
||||
baseUrl={`${url}/plugins/available`}
|
||||
installed={false}
|
||||
/>
|
||||
)}
|
||||
render={() => <PluginsOverview baseUrl={`${url}/plugins/available`} installed={false} />}
|
||||
/>
|
||||
<Route
|
||||
path={`${url}/role/:role`}
|
||||
render={() => (
|
||||
<SingleRepositoryRole
|
||||
baseUrl={`${url}/roles`}
|
||||
history={this.props.history}
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
<Route
|
||||
path={`${url}/roles`}
|
||||
exact
|
||||
render={() => <RepositoryRoles baseUrl={`${url}/roles`} />}
|
||||
render={() => <SingleRepositoryRole baseUrl={`${url}/roles`} history={this.props.history} />}
|
||||
/>
|
||||
<Route path={`${url}/roles`} exact render={() => <RepositoryRoles baseUrl={`${url}/roles`} />} />
|
||||
<Route
|
||||
path={`${url}/roles/create`}
|
||||
render={() => (
|
||||
<CreateRepositoryRole history={this.props.history} />
|
||||
)}
|
||||
/>
|
||||
<Route
|
||||
path={`${url}/roles/:page`}
|
||||
exact
|
||||
render={() => <RepositoryRoles baseUrl={`${url}/roles`} />}
|
||||
/>
|
||||
<ExtensionPoint
|
||||
name="admin.route"
|
||||
props={extensionProps}
|
||||
renderAll={true}
|
||||
render={() => <CreateRepositoryRole history={this.props.history} />}
|
||||
/>
|
||||
<Route path={`${url}/roles/:page`} exact render={() => <RepositoryRoles baseUrl={`${url}/roles`} />} />
|
||||
<ExtensionPoint name="admin.route" props={extensionProps} renderAll={true} />
|
||||
</Switch>
|
||||
</div>
|
||||
<div className="column is-one-quarter">
|
||||
<Navigation>
|
||||
<Section label={t("admin.menu.navigationLabel")}>
|
||||
<NavLink
|
||||
to={`${url}/info`}
|
||||
icon="fas fa-info-circle"
|
||||
label={t("admin.menu.informationNavLink")}
|
||||
/>
|
||||
<NavLink to={`${url}/info`} icon="fas fa-info-circle" label={t("admin.menu.informationNavLink")} />
|
||||
{(availablePluginsLink || installedPluginsLink) && (
|
||||
<SubNavigation
|
||||
to={`${url}/plugins/`}
|
||||
@@ -170,16 +109,10 @@ class Admin extends React.Component<Props> {
|
||||
label={t("plugins.menu.pluginsNavLink")}
|
||||
>
|
||||
{installedPluginsLink && (
|
||||
<NavLink
|
||||
to={`${url}/plugins/installed/`}
|
||||
label={t("plugins.menu.installedNavLink")}
|
||||
/>
|
||||
<NavLink to={`${url}/plugins/installed/`} label={t("plugins.menu.installedNavLink")} />
|
||||
)}
|
||||
{availablePluginsLink && (
|
||||
<NavLink
|
||||
to={`${url}/plugins/available/`}
|
||||
label={t("plugins.menu.availableNavLink")}
|
||||
/>
|
||||
<NavLink to={`${url}/plugins/available/`} label={t("plugins.menu.availableNavLink")} />
|
||||
)}
|
||||
</SubNavigation>
|
||||
)}
|
||||
@@ -190,24 +123,10 @@ class Admin extends React.Component<Props> {
|
||||
activeWhenMatch={this.matchesRoles}
|
||||
activeOnlyWhenExact={false}
|
||||
/>
|
||||
<ExtensionPoint
|
||||
name="admin.navigation"
|
||||
props={extensionProps}
|
||||
renderAll={true}
|
||||
/>
|
||||
<SubNavigation
|
||||
to={`${url}/settings/general`}
|
||||
label={t("admin.menu.settingsNavLink")}
|
||||
>
|
||||
<NavLink
|
||||
to={`${url}/settings/general`}
|
||||
label={t("admin.menu.generalNavLink")}
|
||||
/>
|
||||
<ExtensionPoint
|
||||
name="admin.setting"
|
||||
props={extensionProps}
|
||||
renderAll={true}
|
||||
/>
|
||||
<ExtensionPoint name="admin.navigation" props={extensionProps} renderAll={true} />
|
||||
<SubNavigation to={`${url}/settings/general`} label={t("admin.menu.settingsNavLink")}>
|
||||
<NavLink to={`${url}/settings/general`} label={t("admin.menu.generalNavLink")} />
|
||||
<ExtensionPoint name="admin.setting" props={extensionProps} renderAll={true} />
|
||||
</SubNavigation>
|
||||
</Section>
|
||||
</Navigation>
|
||||
|
||||
@@ -15,8 +15,7 @@ type Props = {
|
||||
};
|
||||
|
||||
const BoxShadowBox = styled.div`
|
||||
box-shadow: 0 2px 3px rgba(40, 177, 232, 0.1),
|
||||
0 0 0 2px rgba(40, 177, 232, 0.2);
|
||||
box-shadow: 0 2px 3px rgba(40, 177, 232, 0.1), 0 0 0 2px rgba(40, 177, 232, 0.2);
|
||||
`;
|
||||
|
||||
const ImageWrapper = styled.div`
|
||||
@@ -38,22 +37,13 @@ class AdminDetails extends React.Component<Props> {
|
||||
<BoxShadowBox className="box">
|
||||
<article className="media">
|
||||
<ImageWrapper className="media-left">
|
||||
<Image
|
||||
src="/images/iconCommunitySupport.png"
|
||||
alt={t("admin.info.communityIconAlt")}
|
||||
/>
|
||||
<Image src="/images/iconCommunitySupport.png" alt={t("admin.info.communityIconAlt")} />
|
||||
</ImageWrapper>
|
||||
<div className="media-content">
|
||||
<div className="content">
|
||||
<h3 className="has-text-weight-medium">
|
||||
{t("admin.info.communityTitle")}
|
||||
</h3>
|
||||
<h3 className="has-text-weight-medium">{t("admin.info.communityTitle")}</h3>
|
||||
<p>{t("admin.info.communityInfo")}</p>
|
||||
<a
|
||||
className="button is-info is-pulled-right"
|
||||
target="_blank"
|
||||
href="https://scm-manager.org/support/"
|
||||
>
|
||||
<a className="button is-info is-pulled-right" target="_blank" href="https://scm-manager.org/support/">
|
||||
{t("admin.info.communityButton")}
|
||||
</a>
|
||||
</div>
|
||||
@@ -63,16 +53,11 @@ class AdminDetails extends React.Component<Props> {
|
||||
<BoxShadowBox className="box">
|
||||
<article className="media">
|
||||
<ImageWrapper className="media-left">
|
||||
<Image
|
||||
src="/images/iconEnterpriseSupport.png"
|
||||
alt={t("admin.info.enterpriseIconAlt")}
|
||||
/>
|
||||
<Image src="/images/iconEnterpriseSupport.png" alt={t("admin.info.enterpriseIconAlt")} />
|
||||
</ImageWrapper>
|
||||
<div className="media-content">
|
||||
<div className="content">
|
||||
<h3 className="has-text-weight-medium">
|
||||
{t("admin.info.enterpriseTitle")}
|
||||
</h3>
|
||||
<h3 className="has-text-weight-medium">{t("admin.info.enterpriseTitle")}</h3>
|
||||
<p>
|
||||
{t("admin.info.enterpriseInfo")}
|
||||
<br />
|
||||
|
||||
@@ -119,13 +119,7 @@ class GlobalConfig extends React.Component<Props, State> {
|
||||
};
|
||||
|
||||
renderContent = () => {
|
||||
const {
|
||||
error,
|
||||
loading,
|
||||
config,
|
||||
configUpdatePermission,
|
||||
namespaceStrategies
|
||||
} = this.props;
|
||||
const { error, loading, config, configUpdatePermission, namespaceStrategies } = this.props;
|
||||
const { configReadPermission } = this.state;
|
||||
if (!error) {
|
||||
return (
|
||||
@@ -165,13 +159,9 @@ const mapDispatchToProps = dispatch => {
|
||||
|
||||
const mapStateToProps = state => {
|
||||
const loading =
|
||||
isFetchConfigPending(state) ||
|
||||
isModifyConfigPending(state) ||
|
||||
isFetchNamespaceStrategiesPending(state);
|
||||
isFetchConfigPending(state) || isModifyConfigPending(state) || isFetchNamespaceStrategiesPending(state);
|
||||
const error =
|
||||
getFetchConfigFailure(state) ||
|
||||
getModifyConfigFailure(state) ||
|
||||
getFetchNamespaceStrategiesFailure(state);
|
||||
getFetchConfigFailure(state) || getModifyConfigFailure(state) || getFetchNamespaceStrategiesFailure(state);
|
||||
|
||||
const config = getConfig(state);
|
||||
const configUpdatePermission = getConfigUpdatePermission(state);
|
||||
|
||||
@@ -233,8 +233,7 @@ describe("config reducer", () => {
|
||||
|
||||
it("should return empty arrays for null values", () => {
|
||||
// $FlowFixMe
|
||||
const config = reducer({}, fetchConfigSuccess(configWithNullValues))
|
||||
.entries;
|
||||
const config = reducer({}, fetchConfigSuccess(configWithNullValues)).entries;
|
||||
expect(config.adminUsers).toEqual([]);
|
||||
expect(config.adminGroups).toEqual([]);
|
||||
expect(config.proxyExcludes).toEqual([]);
|
||||
|
||||
@@ -5,8 +5,7 @@ import { isPending } from "../../modules/pending";
|
||||
import { getFailure } from "../../modules/failure";
|
||||
import { MODIFY_CONFIG_SUCCESS } from "./config";
|
||||
|
||||
export const FETCH_NAMESPACESTRATEGIES_TYPES =
|
||||
"scm/config/FETCH_NAMESPACESTRATEGIES_TYPES";
|
||||
export const FETCH_NAMESPACESTRATEGIES_TYPES = "scm/config/FETCH_NAMESPACESTRATEGIES_TYPES";
|
||||
export const FETCH_NAMESPACESTRATEGIES_TYPES_PENDING = `${FETCH_NAMESPACESTRATEGIES_TYPES}_${types.PENDING_SUFFIX}`;
|
||||
export const FETCH_NAMESPACESTRATEGIES_TYPES_SUCCESS = `${FETCH_NAMESPACESTRATEGIES_TYPES}_${types.SUCCESS_SUFFIX}`;
|
||||
export const FETCH_NAMESPACESTRATEGIES_TYPES_FAILURE = `${FETCH_NAMESPACESTRATEGIES_TYPES}_${types.FAILURE_SUFFIX}`;
|
||||
@@ -15,10 +14,7 @@ export function fetchNamespaceStrategiesIfNeeded() {
|
||||
return function(dispatch: any, getState: () => object) {
|
||||
const state = getState();
|
||||
if (shouldFetchNamespaceStrategies(state)) {
|
||||
return fetchNamespaceStrategies(
|
||||
dispatch,
|
||||
state.indexResources.links.namespaceStrategies.href
|
||||
);
|
||||
return fetchNamespaceStrategies(dispatch, state.indexResources.links.namespaceStrategies.href);
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -37,10 +33,7 @@ function fetchNamespaceStrategies(dispatch: any, url: string) {
|
||||
}
|
||||
|
||||
export function shouldFetchNamespaceStrategies(state: object) {
|
||||
if (
|
||||
isFetchNamespaceStrategiesPending(state) ||
|
||||
getFetchNamespaceStrategiesFailure(state)
|
||||
) {
|
||||
if (isFetchNamespaceStrategiesPending(state) || getFetchNamespaceStrategiesFailure(state)) {
|
||||
return false;
|
||||
}
|
||||
return !state.namespaceStrategies || !state.namespaceStrategies.current;
|
||||
@@ -52,9 +45,7 @@ export function fetchNamespaceStrategiesPending(): Action {
|
||||
};
|
||||
}
|
||||
|
||||
export function fetchNamespaceStrategiesSuccess(
|
||||
namespaceStrategies: NamespaceStrategies
|
||||
): Action {
|
||||
export function fetchNamespaceStrategiesSuccess(namespaceStrategies: NamespaceStrategies): Action {
|
||||
return {
|
||||
type: FETCH_NAMESPACESTRATEGIES_TYPES_SUCCESS,
|
||||
payload: namespaceStrategies
|
||||
@@ -76,10 +67,7 @@ export default function reducer(
|
||||
type: "UNKNOWN"
|
||||
}
|
||||
): object {
|
||||
if (
|
||||
action.type === FETCH_NAMESPACESTRATEGIES_TYPES_SUCCESS &&
|
||||
action.payload
|
||||
) {
|
||||
if (action.type === FETCH_NAMESPACESTRATEGIES_TYPES_SUCCESS && action.payload) {
|
||||
return action.payload;
|
||||
} else if (action.type === MODIFY_CONFIG_SUCCESS && action.payload) {
|
||||
const config = action.payload;
|
||||
|
||||
@@ -39,12 +39,7 @@ class ExecutePendingAction extends React.Component<Props, State> {
|
||||
const { showModal } = this.state;
|
||||
const { pendingPlugins } = this.props;
|
||||
if (showModal) {
|
||||
return (
|
||||
<ExecutePendingModal
|
||||
pendingPlugins={pendingPlugins}
|
||||
onClose={this.closeModal}
|
||||
/>
|
||||
);
|
||||
return <ExecutePendingModal pendingPlugins={pendingPlugins} onClose={this.closeModal} />;
|
||||
}
|
||||
return null;
|
||||
};
|
||||
@@ -54,11 +49,7 @@ class ExecutePendingAction extends React.Component<Props, State> {
|
||||
return (
|
||||
<>
|
||||
{this.renderModal()}
|
||||
<Button
|
||||
color="primary"
|
||||
label={t("plugins.executePending")}
|
||||
action={this.openModal}
|
||||
/>
|
||||
<Button color="primary" label={t("plugins.executePending")} action={this.openModal} />
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -25,18 +25,14 @@ class ExecutePendingActionModal extends React.Component<Props> {
|
||||
pendingPlugins={pendingPlugins}
|
||||
execute={this.executeAndRestart}
|
||||
>
|
||||
<Notification type="warning">
|
||||
{t("plugins.modal.restartNotification")}
|
||||
</Notification>
|
||||
<Notification type="warning">{t("plugins.modal.restartNotification")}</Notification>
|
||||
</PluginActionModal>
|
||||
);
|
||||
}
|
||||
|
||||
executeAndRestart = () => {
|
||||
const { pendingPlugins } = this.props;
|
||||
return apiClient
|
||||
.post(pendingPlugins._links.execute.href)
|
||||
.then(waitForRestart);
|
||||
return apiClient.post(pendingPlugins._links.execute.href).then(waitForRestart);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -1,12 +1,5 @@
|
||||
import React from "react";
|
||||
import {
|
||||
apiClient,
|
||||
Button,
|
||||
ButtonGroup,
|
||||
ErrorNotification,
|
||||
Modal,
|
||||
Notification
|
||||
} from "@scm-manager/ui-components";
|
||||
import { apiClient, Button, ButtonGroup, ErrorNotification, Modal, Notification } from "@scm-manager/ui-components";
|
||||
import { PendingPlugins } from "@scm-manager/ui-types";
|
||||
import { translate } from "react-i18next";
|
||||
import waitForRestart from "./waitForRestart";
|
||||
@@ -43,11 +36,7 @@ class ExecutePendingModal extends React.Component<Props, State> {
|
||||
} else if (success) {
|
||||
return <SuccessNotification />;
|
||||
} else {
|
||||
return (
|
||||
<Notification type="warning">
|
||||
{t("plugins.modal.restartNotification")}
|
||||
</Notification>
|
||||
);
|
||||
return <Notification type="warning">{t("plugins.modal.restartNotification")}</Notification>;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -98,17 +87,16 @@ class ExecutePendingModal extends React.Component<Props, State> {
|
||||
const { pendingPlugins, t } = this.props;
|
||||
return (
|
||||
<>
|
||||
{pendingPlugins._embedded &&
|
||||
pendingPlugins._embedded.update.length > 0 && (
|
||||
<>
|
||||
<strong>{t("plugins.modal.updateQueue")}</strong>
|
||||
<ul>
|
||||
{pendingPlugins._embedded.update.map(plugin => (
|
||||
<li key={plugin.name}>{plugin.name}</li>
|
||||
))}
|
||||
</ul>
|
||||
</>
|
||||
)}
|
||||
{pendingPlugins._embedded && pendingPlugins._embedded.update.length > 0 && (
|
||||
<>
|
||||
<strong>{t("plugins.modal.updateQueue")}</strong>
|
||||
<ul>
|
||||
{pendingPlugins._embedded.update.map(plugin => (
|
||||
<li key={plugin.name}>{plugin.name}</li>
|
||||
))}
|
||||
</ul>
|
||||
</>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
};
|
||||
@@ -117,17 +105,16 @@ class ExecutePendingModal extends React.Component<Props, State> {
|
||||
const { pendingPlugins, t } = this.props;
|
||||
return (
|
||||
<>
|
||||
{pendingPlugins._embedded &&
|
||||
pendingPlugins._embedded.uninstall.length > 0 && (
|
||||
<>
|
||||
<strong>{t("plugins.modal.uninstallQueue")}</strong>
|
||||
<ul>
|
||||
{pendingPlugins._embedded.uninstall.map(plugin => (
|
||||
<li key={plugin.name}>{plugin.name}</li>
|
||||
))}
|
||||
</ul>
|
||||
</>
|
||||
)}
|
||||
{pendingPlugins._embedded && pendingPlugins._embedded.uninstall.length > 0 && (
|
||||
<>
|
||||
<strong>{t("plugins.modal.uninstallQueue")}</strong>
|
||||
<ul>
|
||||
{pendingPlugins._embedded.uninstall.map(plugin => (
|
||||
<li key={plugin.name}>{plugin.name}</li>
|
||||
))}
|
||||
</ul>
|
||||
</>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -1,10 +1,5 @@
|
||||
import * as React from "react";
|
||||
import {
|
||||
Button,
|
||||
ButtonGroup,
|
||||
ErrorNotification,
|
||||
Modal
|
||||
} from "@scm-manager/ui-components";
|
||||
import { Button, ButtonGroup, ErrorNotification, Modal } from "@scm-manager/ui-components";
|
||||
import { PendingPlugins, PluginCollection } from "@scm-manager/ui-types";
|
||||
import { translate } from "react-i18next";
|
||||
import SuccessNotification from "./SuccessNotification";
|
||||
@@ -89,20 +84,18 @@ class PluginActionModal extends React.Component<Props, State> {
|
||||
const { installedPlugins, t } = this.props;
|
||||
return (
|
||||
<>
|
||||
{installedPlugins &&
|
||||
installedPlugins._embedded &&
|
||||
installedPlugins._embedded.plugins && (
|
||||
<>
|
||||
<strong>{t("plugins.modal.updateQueue")}</strong>
|
||||
<ul>
|
||||
{installedPlugins._embedded.plugins
|
||||
.filter(plugin => plugin._links && plugin._links.update)
|
||||
.map(plugin => (
|
||||
<li key={plugin.name}>{plugin.name}</li>
|
||||
))}
|
||||
</ul>
|
||||
</>
|
||||
)}
|
||||
{installedPlugins && installedPlugins._embedded && installedPlugins._embedded.plugins && (
|
||||
<>
|
||||
<strong>{t("plugins.modal.updateQueue")}</strong>
|
||||
<ul>
|
||||
{installedPlugins._embedded.plugins
|
||||
.filter(plugin => plugin._links && plugin._links.update)
|
||||
.map(plugin => (
|
||||
<li key={plugin.name}>{plugin.name}</li>
|
||||
))}
|
||||
</ul>
|
||||
</>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
};
|
||||
@@ -111,18 +104,16 @@ class PluginActionModal extends React.Component<Props, State> {
|
||||
const { pendingPlugins, t } = this.props;
|
||||
return (
|
||||
<>
|
||||
{pendingPlugins &&
|
||||
pendingPlugins._embedded &&
|
||||
pendingPlugins._embedded.new.length > 0 && (
|
||||
<>
|
||||
<strong>{t("plugins.modal.installQueue")}</strong>
|
||||
<ul>
|
||||
{pendingPlugins._embedded.new.map(plugin => (
|
||||
<li key={plugin.name}>{plugin.name}</li>
|
||||
))}
|
||||
</ul>
|
||||
</>
|
||||
)}
|
||||
{pendingPlugins && pendingPlugins._embedded && pendingPlugins._embedded.new.length > 0 && (
|
||||
<>
|
||||
<strong>{t("plugins.modal.installQueue")}</strong>
|
||||
<ul>
|
||||
{pendingPlugins._embedded.new.map(plugin => (
|
||||
<li key={plugin.name}>{plugin.name}</li>
|
||||
))}
|
||||
</ul>
|
||||
</>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
};
|
||||
@@ -131,18 +122,16 @@ class PluginActionModal extends React.Component<Props, State> {
|
||||
const { pendingPlugins, t } = this.props;
|
||||
return (
|
||||
<>
|
||||
{pendingPlugins &&
|
||||
pendingPlugins._embedded &&
|
||||
pendingPlugins._embedded.update.length > 0 && (
|
||||
<>
|
||||
<strong>{t("plugins.modal.updateQueue")}</strong>
|
||||
<ul>
|
||||
{pendingPlugins._embedded.update.map(plugin => (
|
||||
<li key={plugin.name}>{plugin.name}</li>
|
||||
))}
|
||||
</ul>
|
||||
</>
|
||||
)}
|
||||
{pendingPlugins && pendingPlugins._embedded && pendingPlugins._embedded.update.length > 0 && (
|
||||
<>
|
||||
<strong>{t("plugins.modal.updateQueue")}</strong>
|
||||
<ul>
|
||||
{pendingPlugins._embedded.update.map(plugin => (
|
||||
<li key={plugin.name}>{plugin.name}</li>
|
||||
))}
|
||||
</ul>
|
||||
</>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
};
|
||||
@@ -151,18 +140,16 @@ class PluginActionModal extends React.Component<Props, State> {
|
||||
const { pendingPlugins, t } = this.props;
|
||||
return (
|
||||
<>
|
||||
{pendingPlugins &&
|
||||
pendingPlugins._embedded &&
|
||||
pendingPlugins._embedded.uninstall.length > 0 && (
|
||||
<>
|
||||
<strong>{t("plugins.modal.uninstallQueue")}</strong>
|
||||
<ul>
|
||||
{pendingPlugins._embedded.uninstall.map(plugin => (
|
||||
<li key={plugin.name}>{plugin.name}</li>
|
||||
))}
|
||||
</ul>
|
||||
</>
|
||||
)}
|
||||
{pendingPlugins && pendingPlugins._embedded && pendingPlugins._embedded.uninstall.length > 0 && (
|
||||
<>
|
||||
<strong>{t("plugins.modal.uninstallQueue")}</strong>
|
||||
<ul>
|
||||
{pendingPlugins._embedded.uninstall.map(plugin => (
|
||||
<li key={plugin.name}>{plugin.name}</li>
|
||||
))}
|
||||
</ul>
|
||||
</>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -18,10 +18,7 @@ export default class PluginAvatar extends React.Component<Props> {
|
||||
plugin
|
||||
}}
|
||||
>
|
||||
<Image
|
||||
src={plugin.avatarUrl ? plugin.avatarUrl : "/images/blib.jpg"}
|
||||
alt="Logo"
|
||||
/>
|
||||
<Image src={plugin.avatarUrl ? plugin.avatarUrl : "/images/blib.jpg"} alt="Logo" />
|
||||
</ExtensionPoint>
|
||||
</p>
|
||||
);
|
||||
|
||||
@@ -84,9 +84,7 @@ class PluginEntry extends React.Component<Props, State> {
|
||||
|
||||
isUninstallable = () => {
|
||||
const { plugin } = this.props;
|
||||
return (
|
||||
plugin._links && plugin._links.uninstall && plugin._links.uninstall.href
|
||||
);
|
||||
return plugin._links && plugin._links.uninstall && plugin._links.uninstall.href;
|
||||
};
|
||||
|
||||
createActionbar = () => {
|
||||
@@ -94,39 +92,18 @@ class PluginEntry extends React.Component<Props, State> {
|
||||
return (
|
||||
<ActionbarWrapper className="is-flex">
|
||||
{this.isInstallable() && (
|
||||
<IconWrapper
|
||||
className="level-item"
|
||||
onClick={() => this.toggleModal("showInstallModal")}
|
||||
>
|
||||
<Icon
|
||||
title={t("plugins.modal.install")}
|
||||
name="download"
|
||||
color="info"
|
||||
/>
|
||||
<IconWrapper className="level-item" onClick={() => this.toggleModal("showInstallModal")}>
|
||||
<Icon title={t("plugins.modal.install")} name="download" color="info" />
|
||||
</IconWrapper>
|
||||
)}
|
||||
{this.isUninstallable() && (
|
||||
<IconWrapper
|
||||
className="level-item"
|
||||
onClick={() => this.toggleModal("showUninstallModal")}
|
||||
>
|
||||
<Icon
|
||||
title={t("plugins.modal.uninstall")}
|
||||
name="trash"
|
||||
color="info"
|
||||
/>
|
||||
<IconWrapper className="level-item" onClick={() => this.toggleModal("showUninstallModal")}>
|
||||
<Icon title={t("plugins.modal.uninstall")} name="trash" color="info" />
|
||||
</IconWrapper>
|
||||
)}
|
||||
{this.isUpdatable() && (
|
||||
<IconWrapper
|
||||
className="level-item"
|
||||
onClick={() => this.toggleModal("showUpdateModal")}
|
||||
>
|
||||
<Icon
|
||||
title={t("plugins.modal.update")}
|
||||
name="sync-alt"
|
||||
color="info"
|
||||
/>
|
||||
<IconWrapper className="level-item" onClick={() => this.toggleModal("showUpdateModal")}>
|
||||
<Icon title={t("plugins.modal.update")} name="sync-alt" color="info" />
|
||||
</IconWrapper>
|
||||
)}
|
||||
</ActionbarWrapper>
|
||||
@@ -169,13 +146,7 @@ class PluginEntry extends React.Component<Props, State> {
|
||||
|
||||
createPendingSpinner = () => {
|
||||
const { plugin } = this.props;
|
||||
return (
|
||||
<Icon
|
||||
className="fa-spin fa-lg"
|
||||
name="spinner"
|
||||
color={plugin.markedForUninstall ? "danger" : "info"}
|
||||
/>
|
||||
);
|
||||
return <Icon className="fa-spin fa-lg" name="spinner" color={plugin.markedForUninstall ? "danger" : "info"} />;
|
||||
};
|
||||
|
||||
render() {
|
||||
@@ -189,19 +160,11 @@ class PluginEntry extends React.Component<Props, State> {
|
||||
return (
|
||||
<>
|
||||
<CardColumn
|
||||
action={
|
||||
this.isInstallable()
|
||||
? () => this.toggleModal("showInstallModal")
|
||||
: null
|
||||
}
|
||||
action={this.isInstallable() ? () => this.toggleModal("showInstallModal") : null}
|
||||
avatar={avatar}
|
||||
title={plugin.displayName ? plugin.displayName : plugin.name}
|
||||
description={plugin.description}
|
||||
contentRight={
|
||||
plugin.pending || plugin.markedForUninstall
|
||||
? this.createPendingSpinner()
|
||||
: actionbar
|
||||
}
|
||||
contentRight={plugin.pending || plugin.markedForUninstall ? this.createPendingSpinner() : actionbar}
|
||||
footerRight={footerRight}
|
||||
/>
|
||||
{modal}
|
||||
|
||||
@@ -12,9 +12,7 @@ class PluginGroupEntry extends React.Component<Props> {
|
||||
render() {
|
||||
const { group, refresh } = this.props;
|
||||
const entries = group.plugins.map(plugin => {
|
||||
return (
|
||||
<PluginEntry plugin={plugin} key={plugin.name} refresh={refresh} />
|
||||
);
|
||||
return <PluginEntry plugin={plugin} key={plugin.name} refresh={refresh} />;
|
||||
});
|
||||
return <CardColumnGroup name={group.name} elements={entries} />;
|
||||
}
|
||||
|
||||
@@ -16,13 +16,7 @@ class PluginList extends React.Component<Props> {
|
||||
return (
|
||||
<div className="content is-plugin-page">
|
||||
{groups.map(group => {
|
||||
return (
|
||||
<PluginGroupEntry
|
||||
group={group}
|
||||
key={group.name}
|
||||
refresh={refresh}
|
||||
/>
|
||||
);
|
||||
return <PluginGroupEntry group={group} key={group.name} refresh={refresh} />;
|
||||
})}
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -35,8 +35,7 @@ type State = {
|
||||
|
||||
const ListParent = styled.div`
|
||||
margin-right: 0;
|
||||
min-width: ${props =>
|
||||
props.pluginAction === PluginAction.INSTALL ? "5.5em" : "10em"};
|
||||
min-width: ${props => (props.pluginAction === PluginAction.INSTALL ? "5.5em" : "10em")};
|
||||
text-align: left;
|
||||
`;
|
||||
|
||||
@@ -182,9 +181,7 @@ class PluginModal extends React.Component<Props, State> {
|
||||
} else if (restart) {
|
||||
return (
|
||||
<div className="media">
|
||||
<Notification type="warning">
|
||||
{t("plugins.modal.restartNotification")}
|
||||
</Notification>
|
||||
<Notification type="warning">{t("plugins.modal.restartNotification")}</Notification>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -211,58 +208,33 @@ class PluginModal extends React.Component<Props, State> {
|
||||
<div className="media">
|
||||
<div className="media-content">
|
||||
<div className="field is-horizontal">
|
||||
<ListParent
|
||||
className={classNames("field-label", "is-inline-flex")}
|
||||
pluginAction={pluginAction}
|
||||
>
|
||||
<ListParent className={classNames("field-label", "is-inline-flex")} pluginAction={pluginAction}>
|
||||
{t("plugins.modal.author")}:
|
||||
</ListParent>
|
||||
<ListChild className={classNames("field-body", "is-inline-flex")}>
|
||||
{plugin.author}
|
||||
</ListChild>
|
||||
<ListChild className={classNames("field-body", "is-inline-flex")}>{plugin.author}</ListChild>
|
||||
</div>
|
||||
{pluginAction === PluginAction.INSTALL && (
|
||||
<div className="field is-horizontal">
|
||||
<ListParent
|
||||
className={classNames("field-label", "is-inline-flex")}
|
||||
pluginAction={pluginAction}
|
||||
>
|
||||
<ListParent className={classNames("field-label", "is-inline-flex")} pluginAction={pluginAction}>
|
||||
{t("plugins.modal.version")}:
|
||||
</ListParent>
|
||||
<ListChild
|
||||
className={classNames("field-body", "is-inline-flex")}
|
||||
>
|
||||
{plugin.version}
|
||||
</ListChild>
|
||||
<ListChild className={classNames("field-body", "is-inline-flex")}>{plugin.version}</ListChild>
|
||||
</div>
|
||||
)}
|
||||
{(pluginAction === PluginAction.UPDATE ||
|
||||
pluginAction === PluginAction.UNINSTALL) && (
|
||||
{(pluginAction === PluginAction.UPDATE || pluginAction === PluginAction.UNINSTALL) && (
|
||||
<div className="field is-horizontal">
|
||||
<ListParent
|
||||
className={classNames("field-label", "is-inline-flex")}
|
||||
>
|
||||
<ListParent className={classNames("field-label", "is-inline-flex")}>
|
||||
{t("plugins.modal.currentVersion")}:
|
||||
</ListParent>
|
||||
<ListChild
|
||||
className={classNames("field-body", "is-inline-flex")}
|
||||
>
|
||||
{plugin.version}
|
||||
</ListChild>
|
||||
<ListChild className={classNames("field-body", "is-inline-flex")}>{plugin.version}</ListChild>
|
||||
</div>
|
||||
)}
|
||||
{pluginAction === PluginAction.UPDATE && (
|
||||
<div className="field is-horizontal">
|
||||
<ListParent
|
||||
className={classNames("field-label", "is-inline-flex")}
|
||||
>
|
||||
<ListParent className={classNames("field-label", "is-inline-flex")}>
|
||||
{t("plugins.modal.newVersion")}:
|
||||
</ListParent>
|
||||
<ListChild
|
||||
className={classNames("field-body", "is-inline-flex")}
|
||||
>
|
||||
{plugin.newVersion}
|
||||
</ListChild>
|
||||
<ListChild className={classNames("field-body", "is-inline-flex")}>{plugin.newVersion}</ListChild>
|
||||
</div>
|
||||
)}
|
||||
{this.renderDependencies()}
|
||||
|
||||
@@ -15,14 +15,7 @@ export default class PluginTopActions extends React.Component<Props> {
|
||||
render() {
|
||||
const { children } = this.props;
|
||||
return (
|
||||
<ChildWrapper
|
||||
className={classNames(
|
||||
"column",
|
||||
"is-flex",
|
||||
"is-one-fifths",
|
||||
"is-mobile-action-spacing"
|
||||
)}
|
||||
>
|
||||
<ChildWrapper className={classNames("column", "is-flex", "is-one-fifths", "is-mobile-action-spacing")}>
|
||||
{children}
|
||||
</ChildWrapper>
|
||||
);
|
||||
|
||||
@@ -13,9 +13,7 @@ class InstallSuccessNotification extends React.Component<Props> {
|
||||
return (
|
||||
<Notification type="success">
|
||||
{t("plugins.modal.successNotification")}{" "}
|
||||
<a onClick={e => window.location.reload(true)}>
|
||||
{t("plugins.modal.reload")}
|
||||
</a>
|
||||
<a onClick={e => window.location.reload(true)}>{t("plugins.modal.reload")}</a>
|
||||
</Notification>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { Plugin, PluginGroup } from "@scm-manager/ui-types";
|
||||
|
||||
export default function groupByCategory(plugins: Plugin[]): PluginGroup[] {
|
||||
let groups = {};
|
||||
for (let plugin of plugins) {
|
||||
const groups = {};
|
||||
for (const plugin of plugins) {
|
||||
const groupName = plugin.category;
|
||||
|
||||
let group = groups[groupName];
|
||||
@@ -16,8 +16,8 @@ export default function groupByCategory(plugins: Plugin[]): PluginGroup[] {
|
||||
group.plugins.push(plugin);
|
||||
}
|
||||
|
||||
let groupArray = [];
|
||||
for (let groupName in groups) {
|
||||
const groupArray = [];
|
||||
for (const groupName in groups) {
|
||||
const group = groups[groupName];
|
||||
group.plugins.sort(sortByName);
|
||||
groupArray.push(groups[groupName]);
|
||||
|
||||
@@ -99,13 +99,7 @@ class PluginsOverview extends React.Component<Props, State> {
|
||||
<div className="columns">
|
||||
<div className="column">
|
||||
<Title title={t("plugins.title")} />
|
||||
<Subtitle
|
||||
subtitle={
|
||||
installed
|
||||
? t("plugins.installedSubtitle")
|
||||
: t("plugins.availableSubtitle")
|
||||
}
|
||||
/>
|
||||
<Subtitle subtitle={installed ? t("plugins.installedSubtitle") : t("plugins.availableSubtitle")} />
|
||||
</div>
|
||||
<PluginTopActions>{actions}</PluginTopActions>
|
||||
</div>
|
||||
@@ -123,11 +117,7 @@ class PluginsOverview extends React.Component<Props, State> {
|
||||
const { pendingPlugins, collection, t } = this.props;
|
||||
const buttons = [];
|
||||
|
||||
if (
|
||||
pendingPlugins &&
|
||||
pendingPlugins._links &&
|
||||
pendingPlugins._links.execute
|
||||
) {
|
||||
if (pendingPlugins && pendingPlugins._links && pendingPlugins._links.execute) {
|
||||
buttons.push(
|
||||
<Button
|
||||
color="primary"
|
||||
@@ -144,11 +134,7 @@ class PluginsOverview extends React.Component<Props, State> {
|
||||
);
|
||||
}
|
||||
|
||||
if (
|
||||
pendingPlugins &&
|
||||
pendingPlugins._links &&
|
||||
pendingPlugins._links.cancel
|
||||
) {
|
||||
if (pendingPlugins && pendingPlugins._links && pendingPlugins._links.cancel) {
|
||||
buttons.push(
|
||||
<Button
|
||||
color="primary"
|
||||
@@ -190,9 +176,7 @@ class PluginsOverview extends React.Component<Props, State> {
|
||||
|
||||
computeUpdateAllSize = () => {
|
||||
const { collection, t } = this.props;
|
||||
const outdatedPlugins = collection._embedded.plugins.filter(
|
||||
p => p._links.update
|
||||
).length;
|
||||
const outdatedPlugins = collection._embedded.plugins.filter(p => p._links.update).length;
|
||||
return t("plugins.outdatedPlugins", {
|
||||
count: outdatedPlugins
|
||||
});
|
||||
@@ -223,11 +207,7 @@ class PluginsOverview extends React.Component<Props, State> {
|
||||
|
||||
renderModals = () => {
|
||||
const { collection, pendingPlugins } = this.props;
|
||||
const {
|
||||
showPendingModal,
|
||||
showCancelModal,
|
||||
showUpdateAllModal
|
||||
} = this.state;
|
||||
const { showPendingModal, showCancelModal, showUpdateAllModal } = this.state;
|
||||
|
||||
if (showPendingModal) {
|
||||
return (
|
||||
@@ -273,12 +253,7 @@ class PluginsOverview extends React.Component<Props, State> {
|
||||
const { collection, t } = this.props;
|
||||
|
||||
if (collection._embedded && collection._embedded.plugins.length > 0) {
|
||||
return (
|
||||
<PluginsList
|
||||
plugins={collection._embedded.plugins}
|
||||
refresh={this.fetchPlugins}
|
||||
/>
|
||||
);
|
||||
return <PluginsList plugins={collection._embedded.plugins} refresh={this.fetchPlugins} />;
|
||||
}
|
||||
return <Notification type="info">{t("plugins.noPlugins")}</Notification>;
|
||||
}
|
||||
|
||||
@@ -132,10 +132,7 @@ describe("plugins fetch", () => {
|
||||
});
|
||||
|
||||
it("should successfully fetch scm-groupmanager-plugin by name", () => {
|
||||
fetchMock.getOnce(
|
||||
PLUGINS_URL + "/scm-groupmanager-plugin",
|
||||
groupManagerPlugin
|
||||
);
|
||||
fetchMock.getOnce(PLUGINS_URL + "/scm-groupmanager-plugin", groupManagerPlugin);
|
||||
|
||||
const expectedActions = [
|
||||
{
|
||||
@@ -153,11 +150,9 @@ describe("plugins fetch", () => {
|
||||
];
|
||||
|
||||
const store = mockStore({});
|
||||
return store
|
||||
.dispatch(fetchPluginByName(URL, "scm-groupmanager-plugin"))
|
||||
.then(() => {
|
||||
expect(store.getActions()).toEqual(expectedActions);
|
||||
});
|
||||
return store.dispatch(fetchPluginByName(URL, "scm-groupmanager-plugin")).then(() => {
|
||||
expect(store.getActions()).toEqual(expectedActions);
|
||||
});
|
||||
});
|
||||
|
||||
it("should dispatch FETCH_PLUGIN_FAILURE, if the request for scm-groupmanager-plugin by name fails", () => {
|
||||
@@ -166,23 +161,18 @@ describe("plugins fetch", () => {
|
||||
});
|
||||
|
||||
const store = mockStore({});
|
||||
return store
|
||||
.dispatch(fetchPluginByName(URL, "scm-groupmanager-plugin"))
|
||||
.then(() => {
|
||||
const actions = store.getActions();
|
||||
expect(actions[0].type).toEqual(FETCH_PLUGIN_PENDING);
|
||||
expect(actions[1].type).toEqual(FETCH_PLUGIN_FAILURE);
|
||||
expect(actions[1].payload.name).toBe("scm-groupmanager-plugin");
|
||||
expect(actions[1].payload.error).toBeDefined();
|
||||
expect(actions[1].itemId).toBe("scm-groupmanager-plugin");
|
||||
});
|
||||
return store.dispatch(fetchPluginByName(URL, "scm-groupmanager-plugin")).then(() => {
|
||||
const actions = store.getActions();
|
||||
expect(actions[0].type).toEqual(FETCH_PLUGIN_PENDING);
|
||||
expect(actions[1].type).toEqual(FETCH_PLUGIN_FAILURE);
|
||||
expect(actions[1].payload.name).toBe("scm-groupmanager-plugin");
|
||||
expect(actions[1].payload.error).toBeDefined();
|
||||
expect(actions[1].itemId).toBe("scm-groupmanager-plugin");
|
||||
});
|
||||
});
|
||||
|
||||
it("should successfully fetch scm-groupmanager-plugin", () => {
|
||||
fetchMock.getOnce(
|
||||
"http://localhost:8081/api/v2/ui/plugins/scm-groupmanager-plugin",
|
||||
groupManagerPlugin
|
||||
);
|
||||
fetchMock.getOnce("http://localhost:8081/api/v2/ui/plugins/scm-groupmanager-plugin", groupManagerPlugin);
|
||||
|
||||
const expectedActions = [
|
||||
{
|
||||
@@ -206,12 +196,9 @@ describe("plugins fetch", () => {
|
||||
});
|
||||
|
||||
it("should dispatch FETCH_PLUGIN_FAILURE, it the request for scm-groupmanager-plugin fails", () => {
|
||||
fetchMock.getOnce(
|
||||
"http://localhost:8081/api/v2/ui/plugins/scm-groupmanager-plugin",
|
||||
{
|
||||
status: 500
|
||||
}
|
||||
);
|
||||
fetchMock.getOnce("http://localhost:8081/api/v2/ui/plugins/scm-groupmanager-plugin", {
|
||||
status: 500
|
||||
});
|
||||
|
||||
const store = mockStore({});
|
||||
return store.dispatch(fetchPluginByLink(groupManagerPlugin)).then(() => {
|
||||
@@ -255,18 +242,14 @@ describe("plugins reducer", () => {
|
||||
"scm-script-plugin",
|
||||
"scm-branchwp-plugin"
|
||||
]);
|
||||
expect(newState.byNames["scm-groupmanager-plugin"]).toBe(
|
||||
groupManagerPlugin
|
||||
);
|
||||
expect(newState.byNames["scm-groupmanager-plugin"]).toBe(groupManagerPlugin);
|
||||
expect(newState.byNames["scm-script-plugin"]).toBe(scriptPlugin);
|
||||
expect(newState.byNames["scm-branchwp-plugin"]).toBe(branchwpPlugin);
|
||||
});
|
||||
|
||||
it("should store the plugin at byNames", () => {
|
||||
const newState = reducer({}, fetchPluginSuccess(groupManagerPlugin));
|
||||
expect(newState.byNames["scm-groupmanager-plugin"]).toBe(
|
||||
groupManagerPlugin
|
||||
);
|
||||
expect(newState.byNames["scm-groupmanager-plugin"]).toBe(groupManagerPlugin);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -334,9 +317,7 @@ describe("plugins selectors", () => {
|
||||
[FETCH_PLUGIN + "/scm-groupmanager-plugin"]: true
|
||||
}
|
||||
};
|
||||
expect(isFetchPluginPending(state, "scm-groupmanager-plugin")).toEqual(
|
||||
true
|
||||
);
|
||||
expect(isFetchPluginPending(state, "scm-groupmanager-plugin")).toEqual(true);
|
||||
});
|
||||
|
||||
it("should return false, when fetch plugin is not pending", () => {
|
||||
@@ -349,14 +330,10 @@ describe("plugins selectors", () => {
|
||||
[FETCH_PLUGIN + "/scm-groupmanager-plugin"]: error
|
||||
}
|
||||
};
|
||||
expect(getFetchPluginFailure(state, "scm-groupmanager-plugin")).toEqual(
|
||||
error
|
||||
);
|
||||
expect(getFetchPluginFailure(state, "scm-groupmanager-plugin")).toEqual(error);
|
||||
});
|
||||
|
||||
it("should return undefined when fetch plugin did not fail", () => {
|
||||
expect(getFetchPluginFailure({}, "scm-groupmanager-plugin")).toBe(
|
||||
undefined
|
||||
);
|
||||
expect(getFetchPluginFailure({}, "scm-groupmanager-plugin")).toBe(undefined);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -204,7 +204,7 @@ export default function reducer(
|
||||
export function getPluginCollection(state: object) {
|
||||
if (state.plugins && state.plugins.list && state.plugins.byNames) {
|
||||
const plugins = [];
|
||||
for (let pluginName of state.plugins.list._embedded.plugins) {
|
||||
for (const pluginName of state.plugins.list._embedded.plugins) {
|
||||
plugins.push(state.plugins.byNames[pluginName]);
|
||||
}
|
||||
return {
|
||||
|
||||
@@ -20,9 +20,7 @@ class AvailableVerbs extends React.Component<Props> {
|
||||
<td className="is-paddingless">
|
||||
<ul>
|
||||
{role.verbs.map(verb => {
|
||||
return (
|
||||
<li>{t("verbs.repository." + verb + ".displayName")}</li>
|
||||
);
|
||||
return <li>{t("verbs.repository." + verb + ".displayName")}</li>;
|
||||
})}
|
||||
</ul>
|
||||
</td>
|
||||
|
||||
@@ -17,13 +17,7 @@ class PermissionRoleDetails extends React.Component<Props> {
|
||||
renderEditButton() {
|
||||
const { t, url } = this.props;
|
||||
if (!!this.props.role._links.update) {
|
||||
return (
|
||||
<Button
|
||||
label={t("repositoryRole.editButton")}
|
||||
link={`${url}/edit`}
|
||||
color="primary"
|
||||
/>
|
||||
);
|
||||
return <Button label={t("repositoryRole.editButton")} link={`${url}/edit`} color="primary" />;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -23,9 +23,7 @@ class PermissionRoleTable extends React.Component<Props> {
|
||||
</thead>
|
||||
<tbody>
|
||||
{roles.map((role, index) => {
|
||||
return (
|
||||
<PermissionRoleRow key={index} baseUrl={baseUrl} role={role} />
|
||||
);
|
||||
return <PermissionRoleRow key={index} baseUrl={baseUrl} role={role} />;
|
||||
})}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
@@ -3,17 +3,9 @@ import RepositoryRoleForm from "./RepositoryRoleForm";
|
||||
import { connect } from "react-redux";
|
||||
import { translate } from "react-i18next";
|
||||
import { ErrorNotification, Subtitle, Title } from "@scm-manager/ui-components";
|
||||
import {
|
||||
createRole,
|
||||
getCreateRoleFailure,
|
||||
getFetchVerbsFailure,
|
||||
isFetchVerbsPending
|
||||
} from "../modules/roles";
|
||||
import { createRole, getCreateRoleFailure, getFetchVerbsFailure, isFetchVerbsPending } from "../modules/roles";
|
||||
import { RepositoryRole } from "@scm-manager/ui-types";
|
||||
import {
|
||||
getRepositoryRolesLink,
|
||||
getRepositoryVerbsLink
|
||||
} from "../../../modules/indexResource";
|
||||
import { getRepositoryRolesLink, getRepositoryVerbsLink } from "../../../modules/indexResource";
|
||||
import { History } from "history";
|
||||
|
||||
type Props = {
|
||||
@@ -35,9 +27,7 @@ class CreateRepositoryRole extends React.Component<Props> {
|
||||
};
|
||||
|
||||
createRepositoryRole = (role: RepositoryRole) => {
|
||||
this.props.addRole(this.props.repositoryRolesLink, role, () =>
|
||||
this.repositoryRoleCreated(role)
|
||||
);
|
||||
this.props.addRole(this.props.repositoryRolesLink, role, () => this.repositoryRoleCreated(role));
|
||||
};
|
||||
|
||||
render() {
|
||||
@@ -51,9 +41,7 @@ class CreateRepositoryRole extends React.Component<Props> {
|
||||
<>
|
||||
<Title title={t("repositoryRole.title")} />
|
||||
<Subtitle subtitle={t("repositoryRole.createSubtitle")} />
|
||||
<RepositoryRoleForm
|
||||
submitForm={role => this.createRepositoryRole(role)}
|
||||
/>
|
||||
<RepositoryRoleForm submitForm={role => this.createRepositoryRole(role)} />
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,20 +1,11 @@
|
||||
import React from "react";
|
||||
import { translate } from "react-i18next";
|
||||
import { RepositoryRole } from "@scm-manager/ui-types";
|
||||
import {
|
||||
Subtitle,
|
||||
DeleteButton,
|
||||
confirmAlert,
|
||||
ErrorNotification
|
||||
} from "@scm-manager/ui-components";
|
||||
import { Subtitle, DeleteButton, confirmAlert, ErrorNotification } from "@scm-manager/ui-components";
|
||||
import { connect } from "react-redux";
|
||||
import { withRouter } from "react-router-dom";
|
||||
import { History } from "history";
|
||||
import {
|
||||
deleteRole,
|
||||
getDeleteRoleFailure,
|
||||
isDeleteRolePending
|
||||
} from "../modules/roles";
|
||||
import { deleteRole, getDeleteRoleFailure, isDeleteRolePending } from "../modules/roles";
|
||||
|
||||
type Props = {
|
||||
loading: boolean;
|
||||
@@ -77,11 +68,7 @@ class DeleteRepositoryRole extends React.Component<Props> {
|
||||
<div className="columns">
|
||||
<div className="column">
|
||||
<ErrorNotification error={error} />
|
||||
<DeleteButton
|
||||
label={t("repositoryRole.delete.button")}
|
||||
action={action}
|
||||
loading={loading}
|
||||
/>
|
||||
<DeleteButton label={t("repositoryRole.delete.button")} action={action} loading={loading} />
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
|
||||
@@ -2,11 +2,7 @@ import React from "react";
|
||||
import RepositoryRoleForm from "./RepositoryRoleForm";
|
||||
import { connect } from "react-redux";
|
||||
import { translate } from "react-i18next";
|
||||
import {
|
||||
getModifyRoleFailure,
|
||||
isModifyRolePending,
|
||||
modifyRole
|
||||
} from "../modules/roles";
|
||||
import { getModifyRoleFailure, isModifyRolePending, modifyRole } from "../modules/roles";
|
||||
import { ErrorNotification, Subtitle } from "@scm-manager/ui-components";
|
||||
import { RepositoryRole } from "@scm-manager/ui-types";
|
||||
import { History } from "history";
|
||||
@@ -45,10 +41,7 @@ class EditRepositoryRole extends React.Component<Props> {
|
||||
return (
|
||||
<>
|
||||
<Subtitle subtitle={t("repositoryRole.editSubtitle")} />
|
||||
<RepositoryRoleForm
|
||||
role={this.props.role}
|
||||
submitForm={role => this.updateRepositoryRole(role)}
|
||||
/>
|
||||
<RepositoryRoleForm role={this.props.role} submitForm={role => this.updateRepositoryRole(role)} />
|
||||
<hr />
|
||||
<DeleteRepositoryRole role={this.props.role} />
|
||||
</>
|
||||
|
||||
@@ -4,16 +4,8 @@ import { translate } from "react-i18next";
|
||||
import { RepositoryRole } from "@scm-manager/ui-types";
|
||||
import { InputField, SubmitButton } from "@scm-manager/ui-components";
|
||||
import PermissionCheckbox from "../../../repos/permissions/components/PermissionCheckbox";
|
||||
import {
|
||||
fetchAvailableVerbs,
|
||||
getFetchVerbsFailure,
|
||||
getVerbsFromState,
|
||||
isFetchVerbsPending
|
||||
} from "../modules/roles";
|
||||
import {
|
||||
getRepositoryRolesLink,
|
||||
getRepositoryVerbsLink
|
||||
} from "../../../modules/indexResource";
|
||||
import { fetchAvailableVerbs, getFetchVerbsFailure, getVerbsFromState, isFetchVerbsPending } from "../modules/roles";
|
||||
import { getRepositoryRolesLink, getRepositoryVerbsLink } from "../../../modules/indexResource";
|
||||
|
||||
type Props = {
|
||||
role?: RepositoryRole;
|
||||
@@ -63,11 +55,7 @@ class RepositoryRoleForm extends React.Component<Props, State> {
|
||||
|
||||
isValid = () => {
|
||||
const { role } = this.state;
|
||||
return !(
|
||||
this.isFalsy(role) ||
|
||||
this.isFalsy(role.name) ||
|
||||
this.isFalsy(role.verbs.length > 0)
|
||||
);
|
||||
return !(this.isFalsy(role) || this.isFalsy(role.name) || this.isFalsy(role.verbs.length > 0));
|
||||
};
|
||||
|
||||
handleNameChange = (name: string) => {
|
||||
@@ -82,9 +70,7 @@ class RepositoryRoleForm extends React.Component<Props, State> {
|
||||
handleVerbChange = (value: boolean, name: string) => {
|
||||
const { role } = this.state;
|
||||
|
||||
const newVerbs = value
|
||||
? [...role.verbs, name]
|
||||
: role.verbs.filter(v => v !== name);
|
||||
const newVerbs = value ? [...role.verbs, name] : role.verbs.filter(v => v !== name);
|
||||
|
||||
this.setState({
|
||||
...this.state,
|
||||
@@ -127,17 +113,11 @@ class RepositoryRoleForm extends React.Component<Props, State> {
|
||||
disabled={!!this.props.role}
|
||||
/>
|
||||
<div className="field">
|
||||
<label className="label">
|
||||
{t("repositoryRole.form.permissions")}
|
||||
</label>
|
||||
<label className="label">{t("repositoryRole.form.permissions")}</label>
|
||||
{verbSelectBoxes}
|
||||
</div>
|
||||
<hr />
|
||||
<SubmitButton
|
||||
loading={loading}
|
||||
label={t("repositoryRole.form.submit")}
|
||||
disabled={!this.isValid()}
|
||||
/>
|
||||
<SubmitButton loading={loading} label={t("repositoryRole.form.submit")} disabled={!this.isValid()} />
|
||||
</form>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -4,15 +4,7 @@ import { withRouter } from "react-router-dom";
|
||||
import { translate } from "react-i18next";
|
||||
import { History } from "history";
|
||||
import { RepositoryRole, PagedCollection } from "@scm-manager/ui-types";
|
||||
import {
|
||||
Title,
|
||||
Subtitle,
|
||||
Loading,
|
||||
Notification,
|
||||
LinkPaginator,
|
||||
urls,
|
||||
CreateButton
|
||||
} from "@scm-manager/ui-components";
|
||||
import { Title, Subtitle, Loading, Notification, LinkPaginator, urls, CreateButton } from "@scm-manager/ui-components";
|
||||
import {
|
||||
fetchRolesByPage,
|
||||
getRolesFromState,
|
||||
@@ -50,14 +42,7 @@ class RepositoryRoles extends React.Component<Props> {
|
||||
}
|
||||
|
||||
componentDidUpdate = (prevProps: Props) => {
|
||||
const {
|
||||
loading,
|
||||
list,
|
||||
page,
|
||||
rolesLink,
|
||||
location,
|
||||
fetchRolesByPage
|
||||
} = this.props;
|
||||
const { loading, list, page, rolesLink, location, fetchRolesByPage } = this.props;
|
||||
if (list && page && !loading) {
|
||||
const statePage: number = list.page + 1;
|
||||
if (page !== statePage || prevProps.location.search !== location.search) {
|
||||
@@ -93,22 +78,13 @@ class RepositoryRoles extends React.Component<Props> {
|
||||
</>
|
||||
);
|
||||
}
|
||||
return (
|
||||
<Notification type="info">
|
||||
{t("repositoryRole.overview.noPermissionRoles")}
|
||||
</Notification>
|
||||
);
|
||||
return <Notification type="info">{t("repositoryRole.overview.noPermissionRoles")}</Notification>;
|
||||
}
|
||||
|
||||
renderCreateButton() {
|
||||
const { canAddRoles, baseUrl, t } = this.props;
|
||||
if (canAddRoles) {
|
||||
return (
|
||||
<CreateButton
|
||||
label={t("repositoryRole.overview.createButton")}
|
||||
link={`${baseUrl}/create`}
|
||||
/>
|
||||
);
|
||||
return <CreateButton label={t("repositoryRole.overview.createButton")} link={`${baseUrl}/create`} />;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -7,12 +7,7 @@ import { translate } from "react-i18next";
|
||||
import { RepositoryRole } from "@scm-manager/ui-types";
|
||||
import { getRepositoryRolesLink } from "../../../modules/indexResource";
|
||||
import { ExtensionPoint } from "@scm-manager/ui-extensions";
|
||||
import {
|
||||
fetchRoleByName,
|
||||
getFetchRoleFailure,
|
||||
getRoleByName,
|
||||
isFetchRolePending
|
||||
} from "../modules/roles";
|
||||
import { fetchRoleByName, getFetchRoleFailure, getRoleByName, isFetchRolePending } from "../modules/roles";
|
||||
import { withRouter } from "react-router-dom";
|
||||
import PermissionRoleDetail from "../components/PermissionRoleDetails";
|
||||
import EditRepositoryRole from "./EditRepositoryRole";
|
||||
@@ -36,10 +31,7 @@ type Props = {
|
||||
|
||||
class SingleRepositoryRole extends React.Component<Props> {
|
||||
componentDidMount() {
|
||||
this.props.fetchRoleByName(
|
||||
this.props.repositoryRolesLink,
|
||||
this.props.roleName
|
||||
);
|
||||
this.props.fetchRoleByName(this.props.repositoryRolesLink, this.props.roleName);
|
||||
}
|
||||
|
||||
stripEndingSlash = (url: string) => {
|
||||
@@ -58,11 +50,7 @@ class SingleRepositoryRole extends React.Component<Props> {
|
||||
|
||||
if (error) {
|
||||
return (
|
||||
<ErrorPage
|
||||
title={t("repositoryRole.errorTitle")}
|
||||
subtitle={t("repositoryRole.errorSubtitle")}
|
||||
error={error}
|
||||
/>
|
||||
<ErrorPage title={t("repositoryRole.errorTitle")} subtitle={t("repositoryRole.errorSubtitle")} error={error} />
|
||||
);
|
||||
}
|
||||
|
||||
@@ -80,22 +68,13 @@ class SingleRepositoryRole extends React.Component<Props> {
|
||||
return (
|
||||
<>
|
||||
<Title title={t("repositoryRole.title")} />
|
||||
<Route
|
||||
path={`${url}/info`}
|
||||
component={() => <PermissionRoleDetail role={role} url={url} />}
|
||||
/>
|
||||
<Route path={`${url}/info`} component={() => <PermissionRoleDetail role={role} url={url} />} />
|
||||
<Route
|
||||
path={`${url}/edit`}
|
||||
exact
|
||||
component={() => (
|
||||
<EditRepositoryRole role={role} history={this.props.history} />
|
||||
)}
|
||||
/>
|
||||
<ExtensionPoint
|
||||
name="roles.route"
|
||||
props={extensionProps}
|
||||
renderAll={true}
|
||||
component={() => <EditRepositoryRole role={role} history={this.props.history} />}
|
||||
/>
|
||||
<ExtensionPoint name="roles.route" props={extensionProps} renderAll={true} />
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -66,15 +66,7 @@ const role1 = {
|
||||
};
|
||||
const role2 = {
|
||||
name: "WRITE",
|
||||
verbs: [
|
||||
"read",
|
||||
"pull",
|
||||
"push",
|
||||
"createPullRequest",
|
||||
"readPullRequest",
|
||||
"commentPullRequest",
|
||||
"mergePullRequest"
|
||||
],
|
||||
verbs: ["read", "pull", "push", "createPullRequest", "readPullRequest", "commentPullRequest", "mergePullRequest"],
|
||||
system: true,
|
||||
_links: {
|
||||
self: {
|
||||
@@ -88,16 +80,13 @@ const responseBody = {
|
||||
pageTotal: 1,
|
||||
_links: {
|
||||
self: {
|
||||
href:
|
||||
"http://localhost:8081/scm/api/v2/repositoryRoles/?page=0&pageSize=10"
|
||||
href: "http://localhost:8081/scm/api/v2/repositoryRoles/?page=0&pageSize=10"
|
||||
},
|
||||
first: {
|
||||
href:
|
||||
"http://localhost:8081/scm/api/v2/repositoryRoles/?page=0&pageSize=10"
|
||||
href: "http://localhost:8081/scm/api/v2/repositoryRoles/?page=0&pageSize=10"
|
||||
},
|
||||
last: {
|
||||
href:
|
||||
"http://localhost:8081/scm/api/v2/repositoryRoles/?page=0&pageSize=10"
|
||||
href: "http://localhost:8081/scm/api/v2/repositoryRoles/?page=0&pageSize=10"
|
||||
},
|
||||
create: {
|
||||
href: "http://localhost:8081/scm/api/v2/repositoryRoles/"
|
||||
@@ -117,8 +106,7 @@ const response = {
|
||||
|
||||
const URL = "repositoryRoles";
|
||||
const ROLES_URL = "/api/v2/repositoryRoles";
|
||||
const ROLE1_URL =
|
||||
"http://localhost:8081/scm/api/v2/repositoryRoles/specialrole";
|
||||
const ROLE1_URL = "http://localhost:8081/scm/api/v2/repositoryRoles/specialrole";
|
||||
|
||||
const error = new Error("FEHLER!");
|
||||
|
||||
|
||||
@@ -168,11 +168,7 @@ export function createRoleReset() {
|
||||
};
|
||||
}
|
||||
|
||||
export function createRole(
|
||||
link: string,
|
||||
role: RepositoryRole,
|
||||
callback?: () => void
|
||||
) {
|
||||
export function createRole(link: string, role: RepositoryRole, callback?: () => void) {
|
||||
return function(dispatch: Dispatch) {
|
||||
dispatch(createRolePending(role));
|
||||
return apiClient
|
||||
@@ -338,34 +334,30 @@ export function deleteRole(role: RepositoryRole, callback?: () => void) {
|
||||
};
|
||||
}
|
||||
|
||||
function extractRolesByNames(
|
||||
roles: RepositoryRole[],
|
||||
roleNames: string[],
|
||||
oldRolesByNames: object
|
||||
) {
|
||||
function extractRolesByNames(roles: RepositoryRole[], roleNames: string[], oldRolesByNames: object) {
|
||||
const rolesByNames = {};
|
||||
|
||||
for (let role of roles) {
|
||||
for (const role of roles) {
|
||||
rolesByNames[role.name] = role;
|
||||
}
|
||||
|
||||
for (let roleName in oldRolesByNames) {
|
||||
for (const roleName in oldRolesByNames) {
|
||||
rolesByNames[roleName] = oldRolesByNames[roleName];
|
||||
}
|
||||
return rolesByNames;
|
||||
}
|
||||
|
||||
function deleteRoleInRolesByNames(roles: {}, roleName: string) {
|
||||
let newRoles = {};
|
||||
for (let rolename in roles) {
|
||||
const newRoles = {};
|
||||
for (const rolename in roles) {
|
||||
if (rolename !== roleName) newRoles[rolename] = roles[rolename];
|
||||
}
|
||||
return newRoles;
|
||||
}
|
||||
|
||||
function deleteRoleInEntries(roles: [], roleName: string) {
|
||||
let newRoles = [];
|
||||
for (let role of roles) {
|
||||
const newRoles = [];
|
||||
for (const role of roles) {
|
||||
if (role !== roleName) newRoles.push(role);
|
||||
}
|
||||
return newRoles;
|
||||
@@ -396,10 +388,7 @@ function listReducer(state: any = {}, action: any = {}) {
|
||||
|
||||
// Delete single role actions
|
||||
case DELETE_ROLE_SUCCESS:
|
||||
const newRoleEntries = deleteRoleInEntries(
|
||||
state.entries,
|
||||
action.payload.name
|
||||
);
|
||||
const newRoleEntries = deleteRoleInEntries(state.entries, action.payload.name);
|
||||
return {
|
||||
...state,
|
||||
entries: newRoleEntries
|
||||
@@ -468,7 +457,7 @@ export function getRolesFromState(state: object) {
|
||||
}
|
||||
const roleEntries: RepositoryRole[] = [];
|
||||
|
||||
for (let roleName of roleNames) {
|
||||
for (const roleName of roleNames) {
|
||||
roleEntries.push(state.roles.byNames[roleName]);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user