mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2026-04-21 22:16:17 +00:00
Created SortableBarGraph test
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
|
||||
const ScrollToTop = (window) => class ScrollToTop extends React.Component {
|
||||
const ScrollToTop = ({ scrollTo }) => class ScrollToTop extends React.Component {
|
||||
static propTypes = {
|
||||
location: PropTypes.object,
|
||||
children: PropTypes.node,
|
||||
@@ -11,7 +11,7 @@ const ScrollToTop = (window) => class ScrollToTop extends React.Component {
|
||||
const { location } = this.props;
|
||||
|
||||
if (location !== prevProps.location) {
|
||||
window.scrollTo(0, 0);
|
||||
scrollTo(0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -13,11 +13,12 @@ import provideUtilsServices from '../utils/services/provideServices';
|
||||
const bottle = new Bottle();
|
||||
const { container } = bottle;
|
||||
|
||||
const lazyService = (container, serviceName) => (...args) => container[serviceName](...args);
|
||||
const mapActionService = (map, actionName) => ({
|
||||
...map,
|
||||
|
||||
// Wrap actual action service in a function so that it is lazily created the first time it is called
|
||||
[actionName]: (...args) => container[actionName](...args),
|
||||
[actionName]: lazyService(container, actionName),
|
||||
});
|
||||
const connect = (propsFromState, actionServiceNames) =>
|
||||
reduxConnect(
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import React from 'react';
|
||||
import { UncontrolledTooltip } from 'reactstrap';
|
||||
import { assoc } from 'ramda';
|
||||
import { assoc, map } from 'ramda';
|
||||
import { v4 as uuid } from 'uuid';
|
||||
import PropTypes from 'prop-types';
|
||||
|
||||
@@ -22,11 +22,16 @@ const ImportServersBtn = (serversImporter) => class ImportServersBtn extends Rea
|
||||
render() {
|
||||
const { importServersFromFile } = serversImporter;
|
||||
const { onImport, createServers } = this.props;
|
||||
const onChange = (e) =>
|
||||
importServersFromFile(e.target.files[0])
|
||||
.then((servers) => servers.map((server) => assoc('id', uuid(), server)))
|
||||
const assocId = (server) => assoc('id', uuid(), server);
|
||||
const onChange = ({ target }) =>
|
||||
importServersFromFile(target.files[0])
|
||||
.then(map(assocId))
|
||||
.then(createServers)
|
||||
.then(onImport);
|
||||
.then(onImport)
|
||||
.then(() => {
|
||||
// Reset input after processing file
|
||||
target.value = null;
|
||||
});
|
||||
|
||||
return (
|
||||
<React.Fragment>
|
||||
|
||||
@@ -14,18 +14,21 @@ export const listServers = (serversService) => () => ({
|
||||
servers: serversService.listServers(),
|
||||
});
|
||||
|
||||
// FIXME listServers action should be injected and not directly invoked
|
||||
export const createServer = (serversService) => (server) => {
|
||||
serversService.createServer(server);
|
||||
|
||||
return listServers(serversService)();
|
||||
};
|
||||
|
||||
// FIXME listServers action should be injected and not directly invoked
|
||||
export const deleteServer = (serversService) => (server) => {
|
||||
serversService.deleteServer(server);
|
||||
|
||||
return listServers(serversService)();
|
||||
};
|
||||
|
||||
// FIXME listServers action should be injected and not directly invoked
|
||||
export const createServers = (serversService) => (servers) => {
|
||||
serversService.createServers(servers);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user