Merge pull request #512 from acelaya-forks/feature/server-auto-connect

Feature/server auto connect
This commit is contained in:
Alejandro Celaya 2021-10-31 00:16:54 +02:00 committed by GitHub
commit e28f74169d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 39368 additions and 63 deletions

View file

@ -11,6 +11,6 @@ jobs:
ci: ci:
uses: shlinkio/github-actions/.github/workflows/web-app-ci.yml@main uses: shlinkio/github-actions/.github/workflows/web-app-ci.yml@main
with: with:
node-version: 14.17 node-version: 16.13
with-mutation-tests: true with-mutation-tests: true
publish-coverage: true publish-coverage: true

View file

@ -13,10 +13,10 @@ jobs:
with: with:
repository: ${{ github.event.pull_request.head.repo.full_name }} repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.ref }} ref: ${{ github.event.pull_request.head.ref }}
- name: Use node.js 14.15 - name: Use node.js
uses: actions/setup-node@v1 uses: actions/setup-node@v1
with: with:
node-version: 14.15 node-version: 16.13
- name: Build - name: Build
run: | run: |
npm ci && \ npm ci && \

View file

@ -11,10 +11,10 @@ jobs:
steps: steps:
- name: Checkout code - name: Checkout code
uses: actions/checkout@v2 uses: actions/checkout@v2
- name: Use node.js 14.15 - name: Use node.js
uses: actions/setup-node@v1 uses: actions/setup-node@v1
with: with:
node-version: 14.15 node-version: 16.13
- name: Generate release assets - name: Generate release assets
run: npm ci && npm run build ${GITHUB_REF#refs/tags/v} run: npm ci && npm run build ${GITHUB_REF#refs/tags/v}
- name: Publish release with assets - name: Publish release with assets

View file

@ -9,6 +9,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
* [#496](https://github.com/shlinkio/shlink-web-client/issues/496) Allowed to select "all visits" as the default interval for visits. * [#496](https://github.com/shlinkio/shlink-web-client/issues/496) Allowed to select "all visits" as the default interval for visits.
* [#500](https://github.com/shlinkio/shlink-web-client/issues/500) Allowed to set the `forwardQuery` flag when creating/editing short URLs on a Shlink v2.9.0 server. * [#500](https://github.com/shlinkio/shlink-web-client/issues/500) Allowed to set the `forwardQuery` flag when creating/editing short URLs on a Shlink v2.9.0 server.
* [#508](https://github.com/shlinkio/shlink-web-client/issues/508) Added new servers management section. * [#508](https://github.com/shlinkio/shlink-web-client/issues/508) Added new servers management section.
* [#490](https://github.com/shlinkio/shlink-web-client/issues/490) Now a server can be marked as auto-connect, skipping home screen when that happens.
### Changed ### Changed
* Moved ci workflow to external repo and reused * Moved ci workflow to external repo and reused

View file

@ -1,4 +1,4 @@
FROM node:14.17-alpine as node FROM node:16.13-alpine as node
COPY . /shlink-web-client COPY . /shlink-web-client
ARG VERSION="latest" ARG VERSION="latest"
ENV VERSION ${VERSION} ENV VERSION ${VERSION}

View file

@ -3,7 +3,7 @@ version: '3'
services: services:
shlink_web_client_node: shlink_web_client_node:
container_name: shlink_web_client_node container_name: shlink_web_client_node
image: node:14.17-alpine image: node:16.13-alpine
command: /bin/sh -c "cd /home/shlink/www && npm install && npm run start" command: /bin/sh -c "cd /home/shlink/www && npm install && npm run start"
volumes: volumes:
- ./:/home/shlink/www - ./:/home/shlink/www

39399
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -1,5 +1,6 @@
import { useEffect } from 'react';
import { isEmpty, values } from 'ramda'; import { isEmpty, values } from 'ramda';
import { Link } from 'react-router-dom'; import { Link, RouteChildrenProps } from 'react-router-dom';
import { Card, Row } from 'reactstrap'; import { Card, Row } from 'reactstrap';
import { ExternalLink } from 'react-external-link'; import { ExternalLink } from 'react-external-link';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
@ -9,14 +10,21 @@ import { ServersMap } from '../servers/data';
import { ShlinkLogo } from './img/ShlinkLogo'; import { ShlinkLogo } from './img/ShlinkLogo';
import './Home.scss'; import './Home.scss';
export interface HomeProps { export interface HomeProps extends RouteChildrenProps {
servers: ServersMap; servers: ServersMap;
} }
const Home = ({ servers }: HomeProps) => { const Home = ({ servers, history }: HomeProps) => {
const serversList = values(servers); const serversList = values(servers);
const hasServers = !isEmpty(serversList); const hasServers = !isEmpty(serversList);
useEffect(() => {
// Try to redirect to the first server marked as auto-connect
const autoConnectServer = serversList.find(({ autoConnect }) => autoConnect);
autoConnectServer && history.push(`/server/${autoConnectServer.id}`);
}, []);
return ( return (
<div className="home"> <div className="home">
<Card className="home__main-card"> <Card className="home__main-card">

View file

@ -28,6 +28,7 @@ const provideServices = (bottle: Bottle, connect: ConnectDecorator, withRouter:
bottle.serviceFactory('Home', () => Home); bottle.serviceFactory('Home', () => Home);
bottle.decorator('Home', withoutSelectedServer); bottle.decorator('Home', withoutSelectedServer);
bottle.decorator('Home', withRouter);
bottle.decorator('Home', connect([ 'servers' ], [ 'resetSelectedServer' ])); bottle.decorator('Home', connect([ 'servers' ], [ 'resetSelectedServer' ]));
bottle.serviceFactory( bottle.serviceFactory(

View file

@ -1,5 +1,6 @@
import { shallow, ShallowWrapper } from 'enzyme'; import { shallow, ShallowWrapper } from 'enzyme';
import { Mock } from 'ts-mockery'; import { Mock } from 'ts-mockery';
import { RouteChildrenProps } from 'react-router-dom';
import Home, { HomeProps } from '../../src/common/Home'; import Home, { HomeProps } from '../../src/common/Home';
import { ServerWithId } from '../../src/servers/data'; import { ServerWithId } from '../../src/servers/data';
import { ShlinkLogo } from '../../src/common/img/ShlinkLogo'; import { ShlinkLogo } from '../../src/common/img/ShlinkLogo';
@ -7,6 +8,7 @@ import { ShlinkLogo } from '../../src/common/img/ShlinkLogo';
describe('<Home />', () => { describe('<Home />', () => {
let wrapped: ShallowWrapper; let wrapped: ShallowWrapper;
const defaultProps = { const defaultProps = {
...Mock.all<RouteChildrenProps>(),
resetSelectedServer: jest.fn(), resetSelectedServer: jest.fn(),
servers: {}, servers: {},
}; };