mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2024-12-23 17:40:23 +03:00
Added list of servers connected to store in ServerError component
This commit is contained in:
parent
d1a5ee43e9
commit
9804a2d18d
7 changed files with 18 additions and 14 deletions
|
@ -1,8 +1,8 @@
|
||||||
@import '../utils/base';
|
@import '../utils/base';
|
||||||
|
|
||||||
.home {
|
.home {
|
||||||
height: calc(100vh - #{$headerHeight});
|
|
||||||
text-align: center;
|
text-align: center;
|
||||||
|
height: calc(100vh - #{$headerHeight});
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
|
|
|
@ -7,7 +7,6 @@ import classNames from 'classnames';
|
||||||
import * as PropTypes from 'prop-types';
|
import * as PropTypes from 'prop-types';
|
||||||
import { serverType } from '../servers/prop-types';
|
import { serverType } from '../servers/prop-types';
|
||||||
import Message from '../utils/Message';
|
import Message from '../utils/Message';
|
||||||
import { ServerError } from '../servers/helpers/ServerError';
|
|
||||||
import NotFound from './NotFound';
|
import NotFound from './NotFound';
|
||||||
import './MenuLayout.scss';
|
import './MenuLayout.scss';
|
||||||
|
|
||||||
|
@ -18,7 +17,7 @@ const propTypes = {
|
||||||
selectedServer: serverType,
|
selectedServer: serverType,
|
||||||
};
|
};
|
||||||
|
|
||||||
const MenuLayout = (TagsList, ShortUrls, AsideMenu, CreateShortUrl, ShortUrlVisits, ShlinkVersions) => {
|
const MenuLayout = (TagsList, ShortUrls, AsideMenu, CreateShortUrl, ShortUrlVisits, ShlinkVersions, ServerError) => {
|
||||||
const MenuLayoutComp = ({ match, location, selectedServer, selectServer }) => {
|
const MenuLayoutComp = ({ match, location, selectedServer, selectServer }) => {
|
||||||
const [ showSideBar, setShowSidebar ] = useState(false);
|
const [ showSideBar, setShowSidebar ] = useState(false);
|
||||||
const { params: { serverId } } = match;
|
const { params: { serverId } } = match;
|
||||||
|
|
|
@ -27,7 +27,8 @@ const provideServices = (bottle, connect, withRouter) => {
|
||||||
'AsideMenu',
|
'AsideMenu',
|
||||||
'CreateShortUrl',
|
'CreateShortUrl',
|
||||||
'ShortUrlVisits',
|
'ShortUrlVisits',
|
||||||
'ShlinkVersions'
|
'ShlinkVersions',
|
||||||
|
'ServerError'
|
||||||
);
|
);
|
||||||
bottle.decorator('MenuLayout', connect([ 'selectedServer', 'shortUrlsListParams' ], [ 'selectServer' ]));
|
bottle.decorator('MenuLayout', connect([ 'selectedServer', 'shortUrlsListParams' ], [ 'selectServer' ]));
|
||||||
bottle.decorator('MenuLayout', withRouter);
|
bottle.decorator('MenuLayout', withRouter);
|
||||||
|
|
|
@ -10,7 +10,6 @@ import './ServersListGroup.scss';
|
||||||
const propTypes = {
|
const propTypes = {
|
||||||
servers: PropTypes.arrayOf(serverType).isRequired,
|
servers: PropTypes.arrayOf(serverType).isRequired,
|
||||||
children: PropTypes.node.isRequired,
|
children: PropTypes.node.isRequired,
|
||||||
className: PropTypes.string,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const ServerListItem = ({ id, name }) => (
|
const ServerListItem = ({ id, name }) => (
|
||||||
|
@ -25,15 +24,15 @@ ServerListItem.propTypes = {
|
||||||
name: PropTypes.string,
|
name: PropTypes.string,
|
||||||
};
|
};
|
||||||
|
|
||||||
const ServersListGroup = ({ servers, children, className }) => (
|
const ServersListGroup = ({ servers, children }) => (
|
||||||
<div className={className}>
|
<React.Fragment>
|
||||||
<h5>{children}</h5>
|
<h5>{children}</h5>
|
||||||
{servers.length > 0 && (
|
{servers.length > 0 && (
|
||||||
<ListGroup className="servers-list__list-group">
|
<ListGroup className="servers-list__list-group mt-md-3">
|
||||||
{servers.map(({ id, name }) => <ServerListItem key={id} id={id} name={name} />)}
|
{servers.map(({ id, name }) => <ServerListItem key={id} id={id} name={name} />)}
|
||||||
</ListGroup>
|
</ListGroup>
|
||||||
)}
|
)}
|
||||||
</div>
|
</React.Fragment>
|
||||||
);
|
);
|
||||||
|
|
||||||
ServersListGroup.propTypes = propTypes;
|
ServersListGroup.propTypes = propTypes;
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
@import '../utils/mixins/vertical-align';
|
@import '../utils/mixins/vertical-align';
|
||||||
|
|
||||||
.servers-list__list-group {
|
.servers-list__list-group {
|
||||||
margin-top: 1rem;
|
|
||||||
width: 100%;
|
width: 100%;
|
||||||
max-width: 400px;
|
max-width: 400px;
|
||||||
}
|
}
|
||||||
|
@ -14,5 +13,6 @@
|
||||||
|
|
||||||
.servers-list__server-item-icon {
|
.servers-list__server-item-icon {
|
||||||
@include vertical-align();
|
@include vertical-align();
|
||||||
|
|
||||||
right: 1rem;
|
right: 1rem;
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,12 +6,13 @@ import ServersListGroup from '../ServersListGroup';
|
||||||
import './ServerError.scss';
|
import './ServerError.scss';
|
||||||
|
|
||||||
const propTypes = {
|
const propTypes = {
|
||||||
|
servers: PropTypes.object,
|
||||||
type: PropTypes.oneOf([ 'not-found', 'not-reachable' ]).isRequired,
|
type: PropTypes.oneOf([ 'not-found', 'not-reachable' ]).isRequired,
|
||||||
};
|
};
|
||||||
|
|
||||||
export const ServerError = ({ type }) => (
|
export const ServerError = ({ type, servers: { list } }) => (
|
||||||
<div className="server-error-container flex-column">
|
<div className="server-error-container flex-column">
|
||||||
<div className="row w-100">
|
<div className="row w-100 mb-3 mb-md-5">
|
||||||
<Message type="error">
|
<Message type="error">
|
||||||
{type === 'not-found' && 'Could not find this Shlink server.'}
|
{type === 'not-found' && 'Could not find this Shlink server.'}
|
||||||
{type === 'not-reachable' && (
|
{type === 'not-reachable' && (
|
||||||
|
@ -22,8 +23,8 @@ export const ServerError = ({ type }) => (
|
||||||
)}
|
)}
|
||||||
</Message>
|
</Message>
|
||||||
</div>
|
</div>
|
||||||
<ServersListGroup servers={[]} className="mt-3 mt-md-5">
|
<ServersListGroup servers={Object.values(list)}>
|
||||||
These are the {type === 'not-reachable' ? 'other' : ''} servers currently configured. Choose one of
|
These are the {type === 'not-reachable' ? 'other' : ''} Shlink servers currently configured. Choose one of
|
||||||
them or <Link to="/server/create">add a new one</Link>.
|
them or <Link to="/server/create">add a new one</Link>.
|
||||||
</ServersListGroup>
|
</ServersListGroup>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -7,6 +7,7 @@ import ImportServersBtn from '../helpers/ImportServersBtn';
|
||||||
import { resetSelectedServer, selectServer } from '../reducers/selectedServer';
|
import { resetSelectedServer, selectServer } from '../reducers/selectedServer';
|
||||||
import { createServer, createServers, deleteServer, listServers } from '../reducers/server';
|
import { createServer, createServers, deleteServer, listServers } from '../reducers/server';
|
||||||
import ForServerVersion from '../helpers/ForServerVersion';
|
import ForServerVersion from '../helpers/ForServerVersion';
|
||||||
|
import { ServerError } from '../helpers/ServerError';
|
||||||
import ServersImporter from './ServersImporter';
|
import ServersImporter from './ServersImporter';
|
||||||
import ServersService from './ServersService';
|
import ServersService from './ServersService';
|
||||||
import ServersExporter from './ServersExporter';
|
import ServersExporter from './ServersExporter';
|
||||||
|
@ -32,6 +33,9 @@ const provideServices = (bottle, connect, withRouter) => {
|
||||||
bottle.serviceFactory('ForServerVersion', () => ForServerVersion);
|
bottle.serviceFactory('ForServerVersion', () => ForServerVersion);
|
||||||
bottle.decorator('ForServerVersion', connect([ 'selectedServer' ]));
|
bottle.decorator('ForServerVersion', connect([ 'selectedServer' ]));
|
||||||
|
|
||||||
|
bottle.serviceFactory('ServerError', () => ServerError);
|
||||||
|
bottle.decorator('ServerError', connect([ 'servers' ]));
|
||||||
|
|
||||||
// Services
|
// Services
|
||||||
bottle.constant('csvjson', csvjson);
|
bottle.constant('csvjson', csvjson);
|
||||||
bottle.service('ServersImporter', ServersImporter, 'csvjson');
|
bottle.service('ServersImporter', ServersImporter, 'csvjson');
|
||||||
|
|
Loading…
Reference in a new issue