apply prettier, removed flow related config and added tsconfig

This commit is contained in:
Sebastian Sdorra
2019-10-20 18:02:52 +02:00
parent 0e017dcadd
commit 490418d06e
231 changed files with 5771 additions and 30386 deletions

View File

@@ -1,8 +1,8 @@
import React from 'react';
import PluginActionModal from './PluginActionModal';
import { PendingPlugins } from '@scm-manager/ui-types';
import { apiClient } from '@scm-manager/ui-components';
import { translate } from 'react-i18next';
import React from "react";
import PluginActionModal from "./PluginActionModal";
import { PendingPlugins } from "@scm-manager/ui-types";
import { apiClient } from "@scm-manager/ui-components";
import { translate } from "react-i18next";
type Props = {
onClose: () => void;
@@ -19,8 +19,8 @@ class CancelPendingActionModal extends React.Component<Props> {
return (
<PluginActionModal
description={t('plugins.modal.cancelPending')}
label={t('plugins.cancelPending')}
description={t("plugins.modal.cancelPending")}
label={t("plugins.cancelPending")}
onClose={onClose}
pendingPlugins={pendingPlugins}
execute={this.cancelPending}
@@ -37,4 +37,4 @@ class CancelPendingActionModal extends React.Component<Props> {
};
}
export default translate('admin')(CancelPendingActionModal);
export default translate("admin")(CancelPendingActionModal);

View File

@@ -1,8 +1,8 @@
import React from 'react';
import { Button } from '@scm-manager/ui-components';
import { PendingPlugins } from '@scm-manager/ui-types';
import { translate } from 'react-i18next';
import ExecutePendingModal from './ExecutePendingModal';
import React from "react";
import { Button } from "@scm-manager/ui-components";
import { PendingPlugins } from "@scm-manager/ui-types";
import { translate } from "react-i18next";
import ExecutePendingModal from "./ExecutePendingModal";
type Props = {
pendingPlugins: PendingPlugins;
@@ -19,19 +19,19 @@ class ExecutePendingAction extends React.Component<Props, State> {
constructor(props: Props) {
super(props);
this.state = {
showModal: false,
showModal: false
};
}
openModal = () => {
this.setState({
showModal: true,
showModal: true
});
};
closeModal = () => {
this.setState({
showModal: false,
showModal: false
});
};
@@ -56,7 +56,7 @@ class ExecutePendingAction extends React.Component<Props, State> {
{this.renderModal()}
<Button
color="primary"
label={t('plugins.executePending')}
label={t("plugins.executePending")}
action={this.openModal}
/>
</>
@@ -64,4 +64,4 @@ class ExecutePendingAction extends React.Component<Props, State> {
}
}
export default translate('admin')(ExecutePendingAction);
export default translate("admin")(ExecutePendingAction);

View File

@@ -1,9 +1,9 @@
import React from 'react';
import PluginActionModal from './PluginActionModal';
import { PendingPlugins } from '@scm-manager/ui-types';
import waitForRestart from './waitForRestart';
import { apiClient, Notification } from '@scm-manager/ui-components';
import { translate } from 'react-i18next';
import React from "react";
import PluginActionModal from "./PluginActionModal";
import { PendingPlugins } from "@scm-manager/ui-types";
import waitForRestart from "./waitForRestart";
import { apiClient, Notification } from "@scm-manager/ui-components";
import { translate } from "react-i18next";
type Props = {
onClose: () => void;
@@ -19,14 +19,14 @@ class ExecutePendingActionModal extends React.Component<Props> {
return (
<PluginActionModal
description={t('plugins.modal.executePending')}
label={t('plugins.modal.executeAndRestart')}
description={t("plugins.modal.executePending")}
label={t("plugins.modal.executeAndRestart")}
onClose={onClose}
pendingPlugins={pendingPlugins}
execute={this.executeAndRestart}
>
<Notification type="warning">
{t('plugins.modal.restartNotification')}
{t("plugins.modal.restartNotification")}
</Notification>
</PluginActionModal>
);
@@ -40,4 +40,4 @@ class ExecutePendingActionModal extends React.Component<Props> {
};
}
export default translate('admin')(ExecutePendingActionModal);
export default translate("admin")(ExecutePendingActionModal);

View File

@@ -1,16 +1,16 @@
import React from 'react';
import React from "react";
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';
import SuccessNotification from './SuccessNotification';
Notification
} from "@scm-manager/ui-components";
import { PendingPlugins } from "@scm-manager/ui-types";
import { translate } from "react-i18next";
import waitForRestart from "./waitForRestart";
import SuccessNotification from "./SuccessNotification";
type Props = {
onClose: () => void;
@@ -31,7 +31,7 @@ class ExecutePendingModal extends React.Component<Props, State> {
super(props);
this.state = {
loading: false,
success: false,
success: false
};
}
@@ -45,7 +45,7 @@ class ExecutePendingModal extends React.Component<Props, State> {
} else {
return (
<Notification type="warning">
{t('plugins.modal.restartNotification')}
{t("plugins.modal.restartNotification")}
</Notification>
);
}
@@ -54,7 +54,7 @@ class ExecutePendingModal extends React.Component<Props, State> {
executeAndRestart = () => {
const { pendingPlugins } = this.props;
this.setState({
loading: true,
loading: true
});
apiClient
@@ -64,14 +64,14 @@ class ExecutePendingModal extends React.Component<Props, State> {
this.setState({
success: true,
loading: false,
error: undefined,
error: undefined
});
})
.catch(error => {
this.setState({
success: false,
loading: false,
error: error,
error: error
});
});
};
@@ -82,7 +82,7 @@ class ExecutePendingModal extends React.Component<Props, State> {
<>
{pendingPlugins._embedded && pendingPlugins._embedded.new.length > 0 && (
<>
<strong>{t('plugins.modal.installQueue')}</strong>
<strong>{t("plugins.modal.installQueue")}</strong>
<ul>
{pendingPlugins._embedded.new.map(plugin => (
<li key={plugin.name}>{plugin.name}</li>
@@ -101,7 +101,7 @@ class ExecutePendingModal extends React.Component<Props, State> {
{pendingPlugins._embedded &&
pendingPlugins._embedded.update.length > 0 && (
<>
<strong>{t('plugins.modal.updateQueue')}</strong>
<strong>{t("plugins.modal.updateQueue")}</strong>
<ul>
{pendingPlugins._embedded.update.map(plugin => (
<li key={plugin.name}>{plugin.name}</li>
@@ -120,7 +120,7 @@ class ExecutePendingModal extends React.Component<Props, State> {
{pendingPlugins._embedded &&
pendingPlugins._embedded.uninstall.length > 0 && (
<>
<strong>{t('plugins.modal.uninstallQueue')}</strong>
<strong>{t("plugins.modal.uninstallQueue")}</strong>
<ul>
{pendingPlugins._embedded.uninstall.map(plugin => (
<li key={plugin.name}>{plugin.name}</li>
@@ -138,7 +138,7 @@ class ExecutePendingModal extends React.Component<Props, State> {
<>
<div className="media">
<div className="content">
<p>{t('plugins.modal.executePending')}</p>
<p>{t("plugins.modal.executePending")}</p>
{this.renderInstallQueue()}
{this.renderUpdateQueue()}
{this.renderUninstallQueue()}
@@ -156,12 +156,12 @@ class ExecutePendingModal extends React.Component<Props, State> {
<ButtonGroup>
<Button
color="warning"
label={t('plugins.modal.executeAndRestart')}
label={t("plugins.modal.executeAndRestart")}
loading={loading}
action={this.executeAndRestart}
disabled={error || success}
/>
<Button label={t('plugins.modal.abort')} action={onClose} />
<Button label={t("plugins.modal.abort")} action={onClose} />
</ButtonGroup>
);
};
@@ -170,7 +170,7 @@ class ExecutePendingModal extends React.Component<Props, State> {
const { onClose, t } = this.props;
return (
<Modal
title={t('plugins.modal.executeAndRestart')}
title={t("plugins.modal.executeAndRestart")}
closeFunction={onClose}
body={this.renderBody()}
footer={this.renderFooter()}
@@ -180,4 +180,4 @@ class ExecutePendingModal extends React.Component<Props, State> {
}
}
export default translate('admin')(ExecutePendingModal);
export default translate("admin")(ExecutePendingModal);

View File

@@ -1,13 +1,13 @@
import * as React from 'react';
import * as React from "react";
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';
Modal
} from "@scm-manager/ui-components";
import { PendingPlugins, PluginCollection } from "@scm-manager/ui-types";
import { translate } from "react-i18next";
import SuccessNotification from "./SuccessNotification";
type Props = {
onClose: () => void;
@@ -36,7 +36,7 @@ class PluginActionModal extends React.Component<Props, State> {
super(props);
this.state = {
loading: false,
success: false,
success: false
};
}
@@ -54,7 +54,7 @@ class PluginActionModal extends React.Component<Props, State> {
executeAction = () => {
this.setState({
loading: true,
loading: true
});
this.props
@@ -62,14 +62,14 @@ class PluginActionModal extends React.Component<Props, State> {
.then(() => {
this.setState({
success: true,
loading: false,
loading: false
});
})
.catch(error => {
this.setState({
success: false,
loading: false,
error: error,
error: error
});
});
};
@@ -93,7 +93,7 @@ class PluginActionModal extends React.Component<Props, State> {
installedPlugins._embedded &&
installedPlugins._embedded.plugins && (
<>
<strong>{t('plugins.modal.updateQueue')}</strong>
<strong>{t("plugins.modal.updateQueue")}</strong>
<ul>
{installedPlugins._embedded.plugins
.filter(plugin => plugin._links && plugin._links.update)
@@ -115,7 +115,7 @@ class PluginActionModal extends React.Component<Props, State> {
pendingPlugins._embedded &&
pendingPlugins._embedded.new.length > 0 && (
<>
<strong>{t('plugins.modal.installQueue')}</strong>
<strong>{t("plugins.modal.installQueue")}</strong>
<ul>
{pendingPlugins._embedded.new.map(plugin => (
<li key={plugin.name}>{plugin.name}</li>
@@ -135,7 +135,7 @@ class PluginActionModal extends React.Component<Props, State> {
pendingPlugins._embedded &&
pendingPlugins._embedded.update.length > 0 && (
<>
<strong>{t('plugins.modal.updateQueue')}</strong>
<strong>{t("plugins.modal.updateQueue")}</strong>
<ul>
{pendingPlugins._embedded.update.map(plugin => (
<li key={plugin.name}>{plugin.name}</li>
@@ -155,7 +155,7 @@ class PluginActionModal extends React.Component<Props, State> {
pendingPlugins._embedded &&
pendingPlugins._embedded.uninstall.length > 0 && (
<>
<strong>{t('plugins.modal.uninstallQueue')}</strong>
<strong>{t("plugins.modal.uninstallQueue")}</strong>
<ul>
{pendingPlugins._embedded.uninstall.map(plugin => (
<li key={plugin.name}>{plugin.name}</li>
@@ -193,7 +193,7 @@ class PluginActionModal extends React.Component<Props, State> {
action={this.executeAction}
disabled={error || success}
/>
<Button label={t('plugins.modal.abort')} action={onClose} />
<Button label={t("plugins.modal.abort")} action={onClose} />
</ButtonGroup>
);
};
@@ -212,4 +212,4 @@ class PluginActionModal extends React.Component<Props, State> {
}
}
export default translate('admin')(PluginActionModal);
export default translate("admin")(PluginActionModal);

View File

@@ -1,7 +1,7 @@
import React from 'react';
import { ExtensionPoint } from '@scm-manager/ui-extensions';
import { Plugin } from '@scm-manager/ui-types';
import { Image } from '@scm-manager/ui-components';
import React from "react";
import { ExtensionPoint } from "@scm-manager/ui-extensions";
import { Plugin } from "@scm-manager/ui-types";
import { Image } from "@scm-manager/ui-components";
type Props = {
plugin: Plugin;
@@ -15,11 +15,11 @@ export default class PluginAvatar extends React.Component<Props> {
<ExtensionPoint
name="plugins.plugin-avatar"
props={{
plugin,
plugin
}}
>
<Image
src={plugin.avatarUrl ? plugin.avatarUrl : '/images/blib.jpg'}
src={plugin.avatarUrl ? plugin.avatarUrl : "/images/blib.jpg"}
alt="Logo"
/>
</ExtensionPoint>

View File

@@ -1,5 +1,5 @@
import * as React from 'react';
import styled from 'styled-components';
import * as React from "react";
import styled from "styled-components";
type Props = {
children?: React.Node;

View File

@@ -1,16 +1,16 @@
import React from 'react';
import { translate } from 'react-i18next';
import classNames from 'classnames';
import styled from 'styled-components';
import { Plugin } from '@scm-manager/ui-types';
import { CardColumn, Icon } from '@scm-manager/ui-components';
import PluginAvatar from './PluginAvatar';
import PluginModal from './PluginModal';
import React from "react";
import { translate } from "react-i18next";
import classNames from "classnames";
import styled from "styled-components";
import { Plugin } from "@scm-manager/ui-types";
import { CardColumn, Icon } from "@scm-manager/ui-components";
import PluginAvatar from "./PluginAvatar";
import PluginModal from "./PluginModal";
export const PluginAction = {
INSTALL: 'install',
UPDATE: 'update',
UNINSTALL: 'uninstall',
INSTALL: "install",
UPDATE: "update",
UNINSTALL: "uninstall"
};
type Props = {
@@ -53,7 +53,7 @@ class PluginEntry extends React.Component<Props, State> {
this.state = {
showInstallModal: false,
showUpdateModal: false,
showUninstallModal: false,
showUninstallModal: false
};
}
@@ -64,7 +64,7 @@ class PluginEntry extends React.Component<Props, State> {
toggleModal = (showModal: string) => {
const oldValue = this.state[showModal];
this.setState({
[showModal]: !oldValue,
[showModal]: !oldValue
});
};
@@ -96,10 +96,10 @@ class PluginEntry extends React.Component<Props, State> {
{this.isInstallable() && (
<IconWrapper
className="level-item"
onClick={() => this.toggleModal('showInstallModal')}
onClick={() => this.toggleModal("showInstallModal")}
>
<Icon
title={t('plugins.modal.install')}
title={t("plugins.modal.install")}
name="download"
color="info"
/>
@@ -108,10 +108,10 @@ class PluginEntry extends React.Component<Props, State> {
{this.isUninstallable() && (
<IconWrapper
className="level-item"
onClick={() => this.toggleModal('showUninstallModal')}
onClick={() => this.toggleModal("showUninstallModal")}
>
<Icon
title={t('plugins.modal.uninstall')}
title={t("plugins.modal.uninstall")}
name="trash"
color="info"
/>
@@ -120,10 +120,10 @@ class PluginEntry extends React.Component<Props, State> {
{this.isUpdatable() && (
<IconWrapper
className="level-item"
onClick={() => this.toggleModal('showUpdateModal')}
onClick={() => this.toggleModal("showUpdateModal")}
>
<Icon
title={t('plugins.modal.update')}
title={t("plugins.modal.update")}
name="sync-alt"
color="info"
/>
@@ -141,7 +141,7 @@ class PluginEntry extends React.Component<Props, State> {
plugin={plugin}
pluginAction={PluginAction.INSTALL}
refresh={refresh}
onClose={() => this.toggleModal('showInstallModal')}
onClose={() => this.toggleModal("showInstallModal")}
/>
);
} else if (this.state.showUpdateModal && this.isUpdatable()) {
@@ -150,7 +150,7 @@ class PluginEntry extends React.Component<Props, State> {
plugin={plugin}
pluginAction={PluginAction.UPDATE}
refresh={refresh}
onClose={() => this.toggleModal('showUpdateModal')}
onClose={() => this.toggleModal("showUpdateModal")}
/>
);
} else if (this.state.showUninstallModal && this.isUninstallable()) {
@@ -159,7 +159,7 @@ class PluginEntry extends React.Component<Props, State> {
plugin={plugin}
pluginAction={PluginAction.UNINSTALL}
refresh={refresh}
onClose={() => this.toggleModal('showUninstallModal')}
onClose={() => this.toggleModal("showUninstallModal")}
/>
);
} else {
@@ -173,7 +173,7 @@ class PluginEntry extends React.Component<Props, State> {
<Icon
className="fa-spin fa-lg"
name="spinner"
color={plugin.markedForUninstall ? 'danger' : 'info'}
color={plugin.markedForUninstall ? "danger" : "info"}
/>
);
};
@@ -191,7 +191,7 @@ class PluginEntry extends React.Component<Props, State> {
<CardColumn
action={
this.isInstallable()
? () => this.toggleModal('showInstallModal')
? () => this.toggleModal("showInstallModal")
: null
}
avatar={avatar}
@@ -210,4 +210,4 @@ class PluginEntry extends React.Component<Props, State> {
}
}
export default translate('admin')(PluginEntry);
export default translate("admin")(PluginEntry);

View File

@@ -1,7 +1,7 @@
import React from 'react';
import { CardColumnGroup } from '@scm-manager/ui-components';
import { PluginGroup } from '@scm-manager/ui-types';
import PluginEntry from './PluginEntry';
import React from "react";
import { CardColumnGroup } from "@scm-manager/ui-components";
import { PluginGroup } from "@scm-manager/ui-types";
import PluginEntry from "./PluginEntry";
type Props = {
group: PluginGroup;

View File

@@ -1,7 +1,7 @@
import React from 'react';
import { Plugin } from '@scm-manager/ui-types';
import PluginGroupEntry from '../components/PluginGroupEntry';
import groupByCategory from './groupByCategory';
import React from "react";
import { Plugin } from "@scm-manager/ui-types";
import PluginGroupEntry from "../components/PluginGroupEntry";
import groupByCategory from "./groupByCategory";
type Props = {
plugins: Plugin[];

View File

@@ -1,8 +1,8 @@
import React from 'react';
import { translate } from 'react-i18next';
import classNames from 'classnames';
import styled from 'styled-components';
import { Plugin } from '@scm-manager/ui-types';
import React from "react";
import { translate } from "react-i18next";
import classNames from "classnames";
import styled from "styled-components";
import { Plugin } from "@scm-manager/ui-types";
import {
apiClient,
Button,
@@ -10,11 +10,11 @@ import {
Checkbox,
ErrorNotification,
Modal,
Notification,
} from '@scm-manager/ui-components';
import waitForRestart from './waitForRestart';
import SuccessNotification from './SuccessNotification';
import { PluginAction } from './PluginEntry';
Notification
} from "@scm-manager/ui-components";
import waitForRestart from "./waitForRestart";
import SuccessNotification from "./SuccessNotification";
import { PluginAction } from "./PluginEntry";
type Props = {
plugin: Plugin;
@@ -36,7 +36,7 @@ type State = {
const ListParent = styled.div`
margin-right: 0;
min-width: ${props =>
props.pluginAction === PluginAction.INSTALL ? '5.5em' : '10em'};
props.pluginAction === PluginAction.INSTALL ? "5.5em" : "10em"};
text-align: left;
`;
@@ -50,7 +50,7 @@ class PluginModal extends React.Component<Props, State> {
this.state = {
loading: false,
restart: false,
success: false,
success: false
};
}
@@ -60,7 +60,7 @@ class PluginModal extends React.Component<Props, State> {
const newState = {
loading: false,
error: undefined,
error: undefined
};
if (restart) {
@@ -68,14 +68,14 @@ class PluginModal extends React.Component<Props, State> {
.then(() => {
this.setState({
...newState,
success: true,
success: true
});
})
.catch(error => {
this.setState({
loading: false,
success: false,
error,
error
});
});
} else {
@@ -90,7 +90,7 @@ class PluginModal extends React.Component<Props, State> {
const { plugin, pluginAction } = this.props;
const { restart } = this.state;
let pluginActionLink = '';
let pluginActionLink = "";
if (pluginAction === PluginAction.INSTALL) {
pluginActionLink = plugin._links.install.href;
@@ -99,12 +99,12 @@ class PluginModal extends React.Component<Props, State> {
} else if (pluginAction === PluginAction.UNINSTALL) {
pluginActionLink = plugin._links.uninstall.href;
}
return pluginActionLink + '?restart=' + restart.toString();
return pluginActionLink + "?restart=" + restart.toString();
};
handlePluginAction = (e: Event) => {
this.setState({
loading: true,
loading: true
});
e.preventDefault();
apiClient
@@ -114,7 +114,7 @@ class PluginModal extends React.Component<Props, State> {
this.setState({
loading: false,
success: false,
error: error,
error: error
});
});
};
@@ -123,10 +123,10 @@ class PluginModal extends React.Component<Props, State> {
const { pluginAction, onClose, t } = this.props;
const { loading, error, restart, success } = this.state;
let color = pluginAction === PluginAction.UNINSTALL ? 'warning' : 'primary';
let color = pluginAction === PluginAction.UNINSTALL ? "warning" : "primary";
let label = `plugins.modal.${pluginAction}`;
if (restart) {
color = 'warning';
color = "warning";
label = `plugins.modal.${pluginAction}AndRestart`;
}
return (
@@ -138,7 +138,7 @@ class PluginModal extends React.Component<Props, State> {
loading={loading}
disabled={!!error || success}
/>
<Button label={t('plugins.modal.abort')} action={onClose} />
<Button label={t("plugins.modal.abort")} action={onClose} />
</ButtonGroup>
);
};
@@ -151,7 +151,7 @@ class PluginModal extends React.Component<Props, State> {
dependencies = (
<div className="media">
<Notification type="warning">
<strong>{t('plugins.modal.dependencyNotification')}</strong>
<strong>{t("plugins.modal.dependencyNotification")}</strong>
<ul>
{plugin.dependencies.map((dependency, index) => {
return <li key={index}>{dependency}</li>;
@@ -183,7 +183,7 @@ class PluginModal extends React.Component<Props, State> {
return (
<div className="media">
<Notification type="warning">
{t('plugins.modal.restartNotification')}
{t("plugins.modal.restartNotification")}
</Notification>
</div>
);
@@ -193,7 +193,7 @@ class PluginModal extends React.Component<Props, State> {
handleRestartChange = (value: boolean) => {
this.setState({
restart: value,
restart: value
});
};
@@ -212,25 +212,25 @@ class PluginModal extends React.Component<Props, State> {
<div className="media-content">
<div className="field is-horizontal">
<ListParent
className={classNames('field-label', 'is-inline-flex')}
className={classNames("field-label", "is-inline-flex")}
pluginAction={pluginAction}
>
{t('plugins.modal.author')}:
{t("plugins.modal.author")}:
</ListParent>
<ListChild className={classNames('field-body', 'is-inline-flex')}>
<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')}
className={classNames("field-label", "is-inline-flex")}
pluginAction={pluginAction}
>
{t('plugins.modal.version')}:
{t("plugins.modal.version")}:
</ListParent>
<ListChild
className={classNames('field-body', 'is-inline-flex')}
className={classNames("field-body", "is-inline-flex")}
>
{plugin.version}
</ListChild>
@@ -240,12 +240,12 @@ class PluginModal extends React.Component<Props, State> {
pluginAction === PluginAction.UNINSTALL) && (
<div className="field is-horizontal">
<ListParent
className={classNames('field-label', 'is-inline-flex')}
className={classNames("field-label", "is-inline-flex")}
>
{t('plugins.modal.currentVersion')}:
{t("plugins.modal.currentVersion")}:
</ListParent>
<ListChild
className={classNames('field-body', 'is-inline-flex')}
className={classNames("field-body", "is-inline-flex")}
>
{plugin.version}
</ListChild>
@@ -254,12 +254,12 @@ class PluginModal extends React.Component<Props, State> {
{pluginAction === PluginAction.UPDATE && (
<div className="field is-horizontal">
<ListParent
className={classNames('field-label', 'is-inline-flex')}
className={classNames("field-label", "is-inline-flex")}
>
{t('plugins.modal.newVersion')}:
{t("plugins.modal.newVersion")}:
</ListParent>
<ListChild
className={classNames('field-body', 'is-inline-flex')}
className={classNames("field-body", "is-inline-flex")}
>
{plugin.newVersion}
</ListChild>
@@ -272,7 +272,7 @@ class PluginModal extends React.Component<Props, State> {
<div className="media-content">
<Checkbox
checked={restart}
label={t('plugins.modal.restart')}
label={t("plugins.modal.restart")}
onChange={this.handleRestartChange}
disabled={false}
/>
@@ -285,7 +285,7 @@ class PluginModal extends React.Component<Props, State> {
return (
<Modal
title={t(`plugins.modal.title.${pluginAction}`, {
name: plugin.displayName ? plugin.displayName : plugin.name,
name: plugin.displayName ? plugin.displayName : plugin.name
})}
closeFunction={() => onClose()}
body={body}
@@ -296,4 +296,4 @@ class PluginModal extends React.Component<Props, State> {
}
}
export default translate('admin')(PluginModal);
export default translate("admin")(PluginModal);

View File

@@ -1,6 +1,6 @@
import * as React from 'react';
import classNames from 'classnames';
import styled from 'styled-components';
import * as React from "react";
import classNames from "classnames";
import styled from "styled-components";
type Props = {
children?: React.Node;
@@ -17,10 +17,10 @@ export default class PluginTopActions extends React.Component<Props> {
return (
<ChildWrapper
className={classNames(
'column',
'is-flex',
'is-one-fifths',
'is-mobile-action-spacing',
"column",
"is-flex",
"is-one-fifths",
"is-mobile-action-spacing"
)}
>
{children}

View File

@@ -1,6 +1,6 @@
import React from 'react';
import { translate } from 'react-i18next';
import { Notification } from '@scm-manager/ui-components';
import React from "react";
import { translate } from "react-i18next";
import { Notification } from "@scm-manager/ui-components";
type Props = {
// context props
@@ -12,13 +12,13 @@ class InstallSuccessNotification extends React.Component<Props> {
const { t } = this.props;
return (
<Notification type="success">
{t('plugins.modal.successNotification')}{' '}
{t("plugins.modal.successNotification")}{" "}
<a onClick={e => window.location.reload(true)}>
{t('plugins.modal.reload')}
{t("plugins.modal.reload")}
</a>
</Notification>
);
}
}
export default translate('admin')(InstallSuccessNotification);
export default translate("admin")(InstallSuccessNotification);

View File

@@ -1,8 +1,8 @@
import React from 'react';
import PluginActionModal from './PluginActionModal';
import { PluginCollection } from '@scm-manager/ui-types';
import { apiClient } from '@scm-manager/ui-components';
import { translate } from 'react-i18next';
import React from "react";
import PluginActionModal from "./PluginActionModal";
import { PluginCollection } from "@scm-manager/ui-types";
import { apiClient } from "@scm-manager/ui-components";
import { translate } from "react-i18next";
type Props = {
onClose: () => void;
@@ -19,8 +19,8 @@ class UpdateAllActionModal extends React.Component<Props> {
return (
<PluginActionModal
description={t('plugins.modal.updateAll')}
label={t('plugins.updateAll')}
description={t("plugins.modal.updateAll")}
label={t("plugins.updateAll")}
onClose={onClose}
installedPlugins={installedPlugins}
execute={this.updateAll}
@@ -37,4 +37,4 @@ class UpdateAllActionModal extends React.Component<Props> {
};
}
export default translate('admin')(UpdateAllActionModal);
export default translate("admin")(UpdateAllActionModal);

View File

@@ -1,4 +1,4 @@
import { Plugin, PluginGroup } from '@scm-manager/ui-types';
import { Plugin, PluginGroup } from "@scm-manager/ui-types";
export default function groupByCategory(plugins: Plugin[]): PluginGroup[] {
let groups = {};
@@ -9,7 +9,7 @@ export default function groupByCategory(plugins: Plugin[]): PluginGroup[] {
if (!group) {
group = {
name: groupName,
plugins: [],
plugins: []
};
groups[groupName] = group;
}

View File

@@ -1,4 +1,4 @@
import { apiClient } from '@scm-manager/ui-components';
import { apiClient } from "@scm-manager/ui-components";
const waitForRestart = () => {
const endTime = Number(new Date()) + 10000;
@@ -11,13 +11,13 @@ const waitForRestart = () => {
setTimeout(executor, 1000, resolve, reject);
} else {
apiClient
.get('')
.get("")
.then(resolve)
.catch(() => {
if (Number(new Date()) < endTime) {
setTimeout(executor, 500, resolve, reject);
} else {
reject(new Error('timeout reached'));
reject(new Error("timeout reached"));
}
});
}

View File

@@ -1,8 +1,8 @@
import * as React from 'react';
import { connect } from 'react-redux';
import { translate } from 'react-i18next';
import { compose } from 'redux';
import { PendingPlugins, PluginCollection } from '@scm-manager/ui-types';
import * as React from "react";
import { connect } from "react-redux";
import { translate } from "react-i18next";
import { compose } from "redux";
import { PendingPlugins, PluginCollection } from "@scm-manager/ui-types";
import {
ButtonGroup,
ErrorNotification,
@@ -10,27 +10,27 @@ import {
Notification,
Subtitle,
Title,
Button,
} from '@scm-manager/ui-components';
Button
} from "@scm-manager/ui-components";
import {
fetchPendingPlugins,
fetchPluginsByLink,
getFetchPluginsFailure,
getPendingPlugins,
getPluginCollection,
isFetchPluginsPending,
} from '../modules/plugins';
import PluginsList from '../components/PluginList';
isFetchPluginsPending
} from "../modules/plugins";
import PluginsList from "../components/PluginList";
import {
getAvailablePluginsLink,
getInstalledPluginsLink,
getPendingPluginsLink,
} from '../../../modules/indexResource';
import PluginTopActions from '../components/PluginTopActions';
import PluginBottomActions from '../components/PluginBottomActions';
import ExecutePendingActionModal from '../components/ExecutePendingActionModal';
import CancelPendingActionModal from '../components/CancelPendingActionModal';
import UpdateAllActionModal from '../components/UpdateAllActionModal';
getPendingPluginsLink
} from "../../../modules/indexResource";
import PluginTopActions from "../components/PluginTopActions";
import PluginBottomActions from "../components/PluginBottomActions";
import ExecutePendingActionModal from "../components/ExecutePendingActionModal";
import CancelPendingActionModal from "../components/CancelPendingActionModal";
import UpdateAllActionModal from "../components/UpdateAllActionModal";
type Props = {
loading: boolean;
@@ -63,7 +63,7 @@ class PluginsOverview extends React.Component<Props, State> {
this.state = {
showPendingModal: false,
showUpdateAllModal: false,
showCancelModal: false,
showCancelModal: false
};
}
@@ -85,7 +85,7 @@ class PluginsOverview extends React.Component<Props, State> {
availablePluginsLink,
installedPluginsLink,
pendingPluginsLink,
fetchPendingPlugins,
fetchPendingPlugins
} = this.props;
fetchPluginsByLink(installed ? installedPluginsLink : availablePluginsLink);
if (pendingPluginsLink) {
@@ -98,12 +98,12 @@ class PluginsOverview extends React.Component<Props, State> {
return (
<div className="columns">
<div className="column">
<Title title={t('plugins.title')} />
<Title title={t("plugins.title")} />
<Subtitle
subtitle={
installed
? t('plugins.installedSubtitle')
: t('plugins.availableSubtitle')
? t("plugins.installedSubtitle")
: t("plugins.availableSubtitle")
}
/>
</div>
@@ -132,15 +132,15 @@ class PluginsOverview extends React.Component<Props, State> {
<Button
color="primary"
reducedMobile={true}
key={'executePending'}
icon={'arrow-circle-right'}
label={t('plugins.executePending')}
key={"executePending"}
icon={"arrow-circle-right"}
label={t("plugins.executePending")}
action={() =>
this.setState({
showPendingModal: true,
showPendingModal: true
})
}
/>,
/>
);
}
@@ -153,15 +153,15 @@ class PluginsOverview extends React.Component<Props, State> {
<Button
color="primary"
reducedMobile={true}
key={'cancelPending'}
icon={'times'}
label={t('plugins.cancelPending')}
key={"cancelPending"}
icon={"times"}
label={t("plugins.cancelPending")}
action={() =>
this.setState({
showCancelModal: true,
showCancelModal: true
})
}
/>,
/>
);
}
@@ -170,15 +170,15 @@ class PluginsOverview extends React.Component<Props, State> {
<Button
color="primary"
reducedMobile={true}
key={'updateAll'}
icon={'sync-alt'}
key={"updateAll"}
icon={"sync-alt"}
label={this.computeUpdateAllSize()}
action={() =>
this.setState({
showUpdateAllModal: true,
showUpdateAllModal: true
})
}
/>,
/>
);
}
@@ -191,10 +191,10 @@ class PluginsOverview extends React.Component<Props, State> {
computeUpdateAllSize = () => {
const { collection, t } = this.props;
const outdatedPlugins = collection._embedded.plugins.filter(
p => p._links.update,
p => p._links.update
).length;
return t('plugins.outdatedPlugins', {
count: outdatedPlugins,
return t("plugins.outdatedPlugins", {
count: outdatedPlugins
});
};
@@ -226,7 +226,7 @@ class PluginsOverview extends React.Component<Props, State> {
const {
showPendingModal,
showCancelModal,
showUpdateAllModal,
showUpdateAllModal
} = this.state;
if (showPendingModal) {
@@ -234,7 +234,7 @@ class PluginsOverview extends React.Component<Props, State> {
<ExecutePendingActionModal
onClose={() =>
this.setState({
showPendingModal: false,
showPendingModal: false
})
}
pendingPlugins={pendingPlugins}
@@ -246,7 +246,7 @@ class PluginsOverview extends React.Component<Props, State> {
<CancelPendingActionModal
onClose={() =>
this.setState({
showCancelModal: false,
showCancelModal: false
})
}
refresh={this.fetchPlugins}
@@ -259,7 +259,7 @@ class PluginsOverview extends React.Component<Props, State> {
<UpdateAllActionModal
onClose={() =>
this.setState({
showUpdateAllModal: false,
showUpdateAllModal: false
})
}
refresh={this.fetchPlugins}
@@ -280,7 +280,7 @@ class PluginsOverview extends React.Component<Props, State> {
/>
);
}
return <Notification type="info">{t('plugins.noPlugins')}</Notification>;
return <Notification type="info">{t("plugins.noPlugins")}</Notification>;
}
}
@@ -300,7 +300,7 @@ const mapStateToProps = state => {
availablePluginsLink,
installedPluginsLink,
pendingPluginsLink,
pendingPlugins,
pendingPlugins
};
};
@@ -311,14 +311,14 @@ const mapDispatchToProps = dispatch => {
},
fetchPendingPlugins: (link: string) => {
dispatch(fetchPendingPlugins(link));
},
}
};
};
export default compose(
translate('admin'),
translate("admin"),
connect(
mapStateToProps,
mapDispatchToProps,
),
mapDispatchToProps
)
)(PluginsOverview);

View File

@@ -1,6 +1,6 @@
import configureMockStore from 'redux-mock-store';
import thunk from 'redux-thunk';
import fetchMock from 'fetch-mock';
import configureMockStore from "redux-mock-store";
import thunk from "redux-thunk";
import fetchMock from "fetch-mock";
import reducer, {
FETCH_PLUGINS,
FETCH_PLUGINS_PENDING,
@@ -20,77 +20,77 @@ import reducer, {
fetchPluginSuccess,
getPlugin,
isFetchPluginPending,
getFetchPluginFailure,
} from './plugins';
import { Plugin, PluginCollection } from '@scm-manager/ui-types';
getFetchPluginFailure
} from "./plugins";
import { Plugin, PluginCollection } from "@scm-manager/ui-types";
const groupManagerPlugin: Plugin = {
name: 'scm-groupmanager-plugin',
bundles: ['/scm/groupmanager-plugin.bundle.js'],
type: 'Administration',
version: '2.0.0-SNAPSHOT',
author: 'Sebastian Sdorra',
description: 'Notify a remote webserver whenever a plugin is pushed to.',
name: "scm-groupmanager-plugin",
bundles: ["/scm/groupmanager-plugin.bundle.js"],
type: "Administration",
version: "2.0.0-SNAPSHOT",
author: "Sebastian Sdorra",
description: "Notify a remote webserver whenever a plugin is pushed to.",
_links: {
self: {
href: 'http://localhost:8081/api/v2/ui/plugins/scm-groupmanager-plugin',
},
},
href: "http://localhost:8081/api/v2/ui/plugins/scm-groupmanager-plugin"
}
}
};
const scriptPlugin: Plugin = {
name: 'scm-script-plugin',
bundles: ['/scm/script-plugin.bundle.js'],
type: 'Miscellaneous',
version: '2.0.0-SNAPSHOT',
author: 'Sebastian Sdorra',
description: 'Script support for scm-manager.',
name: "scm-script-plugin",
bundles: ["/scm/script-plugin.bundle.js"],
type: "Miscellaneous",
version: "2.0.0-SNAPSHOT",
author: "Sebastian Sdorra",
description: "Script support for scm-manager.",
_links: {
self: {
href: 'http://localhost:8081/api/v2/ui/plugins/scm-script-plugin',
},
},
href: "http://localhost:8081/api/v2/ui/plugins/scm-script-plugin"
}
}
};
const branchwpPlugin: Plugin = {
name: 'scm-branchwp-plugin',
bundles: ['/scm/branchwp-plugin.bundle.js'],
type: 'Miscellaneous',
version: '2.0.0-SNAPSHOT',
author: 'Sebastian Sdorra',
description: 'This plugin adds branch write protection for plugins.',
name: "scm-branchwp-plugin",
bundles: ["/scm/branchwp-plugin.bundle.js"],
type: "Miscellaneous",
version: "2.0.0-SNAPSHOT",
author: "Sebastian Sdorra",
description: "This plugin adds branch write protection for plugins.",
_links: {
self: {
href: 'http://localhost:8081/api/v2/ui/plugins/scm-branchwp-plugin',
},
},
href: "http://localhost:8081/api/v2/ui/plugins/scm-branchwp-plugin"
}
}
};
const pluginCollectionWithNames: PluginCollection = {
_links: {
self: {
href: 'http://localhost:8081/api/v2/ui/plugins',
},
href: "http://localhost:8081/api/v2/ui/plugins"
}
},
_embedded: {
plugins: [groupManagerPlugin.name, scriptPlugin.name, branchwpPlugin.name],
},
plugins: [groupManagerPlugin.name, scriptPlugin.name, branchwpPlugin.name]
}
};
const pluginCollection: PluginCollection = {
_links: {
self: {
href: 'http://localhost:8081/api/v2/ui/plugins',
},
href: "http://localhost:8081/api/v2/ui/plugins"
}
},
_embedded: {
plugins: [groupManagerPlugin, scriptPlugin, branchwpPlugin],
},
plugins: [groupManagerPlugin, scriptPlugin, branchwpPlugin]
}
};
describe('plugins fetch', () => {
const URL = 'ui/plugins';
const PLUGINS_URL = '/api/v2/ui/plugins';
describe("plugins fetch", () => {
const URL = "ui/plugins";
const PLUGINS_URL = "/api/v2/ui/plugins";
const mockStore = configureMockStore([thunk]);
afterEach(() => {
@@ -98,17 +98,17 @@ describe('plugins fetch', () => {
fetchMock.restore();
});
it('should successfully fetch plugins from link', () => {
it("should successfully fetch plugins from link", () => {
fetchMock.getOnce(PLUGINS_URL, pluginCollection);
const expectedActions = [
{
type: FETCH_PLUGINS_PENDING,
type: FETCH_PLUGINS_PENDING
},
{
type: FETCH_PLUGINS_SUCCESS,
payload: pluginCollection,
},
payload: pluginCollection
}
];
const store = mockStore({});
@@ -117,9 +117,9 @@ describe('plugins fetch', () => {
});
});
it('should dispatch FETCH_PLUGINS_FAILURE if request fails', () => {
it("should dispatch FETCH_PLUGINS_FAILURE if request fails", () => {
fetchMock.getOnce(PLUGINS_URL, {
status: 500,
status: 500
});
const store = mockStore({});
@@ -131,72 +131,72 @@ describe('plugins fetch', () => {
});
});
it('should successfully fetch scm-groupmanager-plugin by name', () => {
it("should successfully fetch scm-groupmanager-plugin by name", () => {
fetchMock.getOnce(
PLUGINS_URL + '/scm-groupmanager-plugin',
groupManagerPlugin,
PLUGINS_URL + "/scm-groupmanager-plugin",
groupManagerPlugin
);
const expectedActions = [
{
type: FETCH_PLUGIN_PENDING,
payload: {
name: 'scm-groupmanager-plugin',
name: "scm-groupmanager-plugin"
},
itemId: 'scm-groupmanager-plugin',
itemId: "scm-groupmanager-plugin"
},
{
type: FETCH_PLUGIN_SUCCESS,
payload: groupManagerPlugin,
itemId: 'scm-groupmanager-plugin',
},
itemId: "scm-groupmanager-plugin"
}
];
const store = mockStore({});
return store
.dispatch(fetchPluginByName(URL, 'scm-groupmanager-plugin'))
.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', () => {
fetchMock.getOnce(PLUGINS_URL + '/scm-groupmanager-plugin', {
status: 500,
it("should dispatch FETCH_PLUGIN_FAILURE, if the request for scm-groupmanager-plugin by name fails", () => {
fetchMock.getOnce(PLUGINS_URL + "/scm-groupmanager-plugin", {
status: 500
});
const store = mockStore({});
return store
.dispatch(fetchPluginByName(URL, 'scm-groupmanager-plugin'))
.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.name).toBe("scm-groupmanager-plugin");
expect(actions[1].payload.error).toBeDefined();
expect(actions[1].itemId).toBe('scm-groupmanager-plugin');
expect(actions[1].itemId).toBe("scm-groupmanager-plugin");
});
});
it('should successfully fetch scm-groupmanager-plugin', () => {
it("should successfully fetch scm-groupmanager-plugin", () => {
fetchMock.getOnce(
'http://localhost:8081/api/v2/ui/plugins/scm-groupmanager-plugin',
groupManagerPlugin,
"http://localhost:8081/api/v2/ui/plugins/scm-groupmanager-plugin",
groupManagerPlugin
);
const expectedActions = [
{
type: FETCH_PLUGIN_PENDING,
payload: {
name: 'scm-groupmanager-plugin',
name: "scm-groupmanager-plugin"
},
itemId: 'scm-groupmanager-plugin',
itemId: "scm-groupmanager-plugin"
},
{
type: FETCH_PLUGIN_SUCCESS,
payload: groupManagerPlugin,
itemId: 'scm-groupmanager-plugin',
},
itemId: "scm-groupmanager-plugin"
}
];
const store = mockStore({});
@@ -205,12 +205,12 @@ describe('plugins fetch', () => {
});
});
it('should dispatch FETCH_PLUGIN_FAILURE, it the request for scm-groupmanager-plugin fails', () => {
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',
"http://localhost:8081/api/v2/ui/plugins/scm-groupmanager-plugin",
{
status: 500,
},
status: 500
}
);
const store = mockStore({});
@@ -218,145 +218,145 @@ describe('plugins fetch', () => {
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.name).toBe("scm-groupmanager-plugin");
expect(actions[1].payload.error).toBeDefined();
expect(actions[1].itemId).toBe('scm-groupmanager-plugin');
expect(actions[1].itemId).toBe("scm-groupmanager-plugin");
});
});
});
describe('plugins reducer', () => {
it('should return empty object, if state and action is undefined', () => {
describe("plugins reducer", () => {
it("should return empty object, if state and action is undefined", () => {
expect(reducer()).toEqual({});
});
it('should return the same state, if the action is undefined', () => {
it("should return the same state, if the action is undefined", () => {
const state = {
x: true,
x: true
};
expect(reducer(state)).toBe(state);
});
it('should return the same state, if the action is unknown to the reducer', () => {
it("should return the same state, if the action is unknown to the reducer", () => {
const state = {
x: true,
x: true
};
expect(
reducer(state, {
type: 'EL_SPECIALE',
}),
type: "EL_SPECIALE"
})
).toBe(state);
});
it("should store the plugins by it's type and name on FETCH_PLUGINS_SUCCESS", () => {
const newState = reducer({}, fetchPluginsSuccess(pluginCollection));
expect(newState.list._embedded.plugins).toEqual([
'scm-groupmanager-plugin',
'scm-script-plugin',
'scm-branchwp-plugin',
"scm-groupmanager-plugin",
"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);
expect(newState.byNames["scm-script-plugin"]).toBe(scriptPlugin);
expect(newState.byNames["scm-branchwp-plugin"]).toBe(branchwpPlugin);
});
it('should store the plugin at byNames', () => {
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
);
});
});
describe('plugins selectors', () => {
const error = new Error('something went wrong');
describe("plugins selectors", () => {
const error = new Error("something went wrong");
it('should return the plugins collection', () => {
it("should return the plugins collection", () => {
const state = {
plugins: {
list: pluginCollectionWithNames,
byNames: {
'scm-groupmanager-plugin': groupManagerPlugin,
'scm-script-plugin': scriptPlugin,
'scm-branchwp-plugin': branchwpPlugin,
},
},
"scm-groupmanager-plugin": groupManagerPlugin,
"scm-script-plugin": scriptPlugin,
"scm-branchwp-plugin": branchwpPlugin
}
}
};
const collection = getPluginCollection(state);
expect(collection).toEqual(pluginCollection);
});
it('should return true, when fetch plugins is pending', () => {
it("should return true, when fetch plugins is pending", () => {
const state = {
pending: {
[FETCH_PLUGINS]: true,
},
[FETCH_PLUGINS]: true
}
};
expect(isFetchPluginsPending(state)).toEqual(true);
});
it('should return false, when fetch plugins is not pending', () => {
it("should return false, when fetch plugins is not pending", () => {
expect(isFetchPluginsPending({})).toEqual(false);
});
it('should return error when fetch plugins did fail', () => {
it("should return error when fetch plugins did fail", () => {
const state = {
failure: {
[FETCH_PLUGINS]: error,
},
[FETCH_PLUGINS]: error
}
};
expect(getFetchPluginsFailure(state)).toEqual(error);
});
it('should return undefined when fetch plugins did not fail', () => {
it("should return undefined when fetch plugins did not fail", () => {
expect(getFetchPluginsFailure({})).toBe(undefined);
});
it('should return the plugin collection', () => {
it("should return the plugin collection", () => {
const state = {
plugins: {
byNames: {
'scm-groupmanager-plugin': groupManagerPlugin,
},
},
"scm-groupmanager-plugin": groupManagerPlugin
}
}
};
const plugin = getPlugin(state, 'scm-groupmanager-plugin');
const plugin = getPlugin(state, "scm-groupmanager-plugin");
expect(plugin).toEqual(groupManagerPlugin);
});
it('should return true, when fetch plugin is pending', () => {
it("should return true, when fetch plugin is pending", () => {
const state = {
pending: {
[FETCH_PLUGIN + '/scm-groupmanager-plugin']: true,
},
[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', () => {
expect(isFetchPluginPending({}, 'scm-groupmanager-plugin')).toEqual(false);
it("should return false, when fetch plugin is not pending", () => {
expect(isFetchPluginPending({}, "scm-groupmanager-plugin")).toEqual(false);
});
it('should return error when fetch plugin did fail', () => {
it("should return error when fetch plugin did fail", () => {
const state = {
failure: {
[FETCH_PLUGIN + '/scm-groupmanager-plugin']: error,
},
[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,
it("should return undefined when fetch plugin did not fail", () => {
expect(getFetchPluginFailure({}, "scm-groupmanager-plugin")).toBe(
undefined
);
});
});

View File

@@ -1,20 +1,20 @@
import * as types from '../../../modules/types';
import { isPending } from '../../../modules/pending';
import { getFailure } from '../../../modules/failure';
import { Action, Plugin, PluginCollection } from '@scm-manager/ui-types';
import { apiClient } from '@scm-manager/ui-components';
import * as types from "../../../modules/types";
import { isPending } from "../../../modules/pending";
import { getFailure } from "../../../modules/failure";
import { Action, Plugin, PluginCollection } from "@scm-manager/ui-types";
import { apiClient } from "@scm-manager/ui-components";
export const FETCH_PLUGINS = 'scm/plugins/FETCH_PLUGINS';
export const FETCH_PLUGINS = "scm/plugins/FETCH_PLUGINS";
export const FETCH_PLUGINS_PENDING = `${FETCH_PLUGINS}_${types.PENDING_SUFFIX}`;
export const FETCH_PLUGINS_SUCCESS = `${FETCH_PLUGINS}_${types.SUCCESS_SUFFIX}`;
export const FETCH_PLUGINS_FAILURE = `${FETCH_PLUGINS}_${types.FAILURE_SUFFIX}`;
export const FETCH_PLUGIN = 'scm/plugins/FETCH_PLUGIN';
export const FETCH_PLUGIN = "scm/plugins/FETCH_PLUGIN";
export const FETCH_PLUGIN_PENDING = `${FETCH_PLUGIN}_${types.PENDING_SUFFIX}`;
export const FETCH_PLUGIN_SUCCESS = `${FETCH_PLUGIN}_${types.SUCCESS_SUFFIX}`;
export const FETCH_PLUGIN_FAILURE = `${FETCH_PLUGIN}_${types.FAILURE_SUFFIX}`;
export const FETCH_PENDING_PLUGINS = 'scm/plugins/FETCH_PENDING_PLUGINS';
export const FETCH_PENDING_PLUGINS = "scm/plugins/FETCH_PENDING_PLUGINS";
export const FETCH_PENDING_PLUGINS_PENDING = `${FETCH_PENDING_PLUGINS}_${types.PENDING_SUFFIX}`;
export const FETCH_PENDING_PLUGINS_SUCCESS = `${FETCH_PENDING_PLUGINS}_${types.SUCCESS_SUFFIX}`;
export const FETCH_PENDING_PLUGINS_FAILURE = `${FETCH_PENDING_PLUGINS}_${types.FAILURE_SUFFIX}`;
@@ -37,21 +37,21 @@ export function fetchPluginsByLink(link: string) {
export function fetchPluginsPending(): Action {
return {
type: FETCH_PLUGINS_PENDING,
type: FETCH_PLUGINS_PENDING
};
}
export function fetchPluginsSuccess(plugins: PluginCollection): Action {
return {
type: FETCH_PLUGINS_SUCCESS,
payload: plugins,
payload: plugins
};
}
export function fetchPluginsFailure(err: Error): Action {
return {
type: FETCH_PLUGINS_FAILURE,
payload: err,
payload: err
};
}
@@ -61,7 +61,7 @@ export function fetchPluginByLink(plugin: Plugin) {
}
export function fetchPluginByName(link: string, name: string) {
const pluginUrl = link.endsWith('/') ? link : link + '/';
const pluginUrl = link.endsWith("/") ? link : link + "/";
return fetchPlugin(pluginUrl + name, name);
}
@@ -84,9 +84,9 @@ export function fetchPluginPending(name: string): Action {
return {
type: FETCH_PLUGIN_PENDING,
payload: {
name,
name
},
itemId: name,
itemId: name
};
}
@@ -94,7 +94,7 @@ export function fetchPluginSuccess(plugin: Plugin): Action {
return {
type: FETCH_PLUGIN_SUCCESS,
payload: plugin,
itemId: plugin.name,
itemId: plugin.name
};
}
@@ -103,9 +103,9 @@ export function fetchPluginFailure(name: string, error: Error): Action {
type: FETCH_PLUGIN_FAILURE,
payload: {
name,
error,
error
},
itemId: name,
itemId: name
};
}
@@ -127,21 +127,21 @@ export function fetchPendingPlugins(link: string) {
export function fetchPendingPluginsPending(): Action {
return {
type: FETCH_PENDING_PLUGINS_PENDING,
type: FETCH_PENDING_PLUGINS_PENDING
};
}
export function fetchPendingPluginsSuccess(PendingPlugins: {}): Action {
return {
type: FETCH_PENDING_PLUGINS_SUCCESS,
payload: PendingPlugins,
payload: PendingPlugins
};
}
export function fetchPendingPluginsFailure(err: Error): Action {
return {
type: FETCH_PENDING_PLUGINS_FAILURE,
payload: err,
payload: err
};
}
@@ -158,10 +158,10 @@ function normalizeByName(state: object, pluginCollection: PluginCollection) {
list: {
...pluginCollection,
_embedded: {
plugins: names,
},
plugins: names
}
},
byNames: byNames,
byNames: byNames
};
}
@@ -170,16 +170,16 @@ const reducerByNames = (state: object, plugin: Plugin) => {
...state,
byNames: {
...state.byNames,
[plugin.name]: plugin,
},
[plugin.name]: plugin
}
};
};
export default function reducer(
state: object = {},
action: Action = {
type: 'UNKNOWN',
},
type: "UNKNOWN"
}
): object {
if (!action.payload) {
return state;
@@ -193,7 +193,7 @@ export default function reducer(
case FETCH_PENDING_PLUGINS_SUCCESS:
return {
...state,
pending: action.payload,
pending: action.payload
};
default:
return state;
@@ -210,8 +210,8 @@ export function getPluginCollection(state: object) {
return {
...state.plugins.list,
_embedded: {
plugins,
},
plugins
}
};
}
}