From 4869435acaa7e9973871a8d134768aae6856bac4 Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Wed, 30 Dec 2020 20:10:37 +0100 Subject: [PATCH 1/4] Changed linting order --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 7606cd82..223ed929 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "repository": "https://github.com/shlinkio/shlink-web-client", "license": "MIT", "scripts": { - "lint": "npm run lint:js && npm run lint:css", + "lint": "npm run lint:css && npm run lint:js", "lint:js": "eslint --ext .js,.ts,.tsx src test scripts config", "lint:js:fix": "npm run lint:js -- --fix", "lint:css": "stylelint src/*.scss src/**/*.scss", From fe81bfccef4b4aaec86ee0bd28fd41dfad6ef3af Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Wed, 30 Dec 2020 20:52:05 +0100 Subject: [PATCH 2/4] Fixed importing servers in android due to wrong mime type --- src/servers/services/ServersImporter.ts | 10 ++++++++-- test/servers/services/ServersImporter.test.ts | 8 ++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/servers/services/ServersImporter.ts b/src/servers/services/ServersImporter.ts index 62de8f53..03c1ca25 100644 --- a/src/servers/services/ServersImporter.ts +++ b/src/servers/services/ServersImporter.ts @@ -1,13 +1,19 @@ import { CsvJson } from 'csvjson'; import { ServerData } from '../data'; -const CSV_MIME_TYPE = 'text/csv'; + +interface CsvFile extends File { + type: 'text/csv' | 'text/comma-separated-values' | 'application/csv'; +} + +const CSV_MIME_TYPES = [ 'text/csv', 'text/comma-separated-values', 'application/csv' ]; +const isCsv = (file?: File | null): file is CsvFile => !!file && CSV_MIME_TYPES.includes(file.type); export default class ServersImporter { public constructor(private readonly csvjson: CsvJson, private readonly fileReaderFactory: () => FileReader) {} public readonly importServersFromFile = async (file?: File | null): Promise => { - if (!file || file.type !== CSV_MIME_TYPE) { + if (!isCsv(file)) { throw new Error('No file provided or file is not a CSV'); } diff --git a/test/servers/services/ServersImporter.test.ts b/test/servers/services/ServersImporter.test.ts index 28c4e390..f6749ca6 100644 --- a/test/servers/services/ServersImporter.test.ts +++ b/test/servers/services/ServersImporter.test.ts @@ -29,8 +29,12 @@ describe('ServersImporter', () => { ); }); - it('reads file when a CSV is provided', async () => { - await importer.importServersFromFile(Mock.of({ type: 'text/csv' })); + it.each([ + [ 'text/csv' ], + [ 'text/comma-separated-values' ], + [ 'application/csv' ], + ])('reads file when a CSV is provided', async (type) => { + await importer.importServersFromFile(Mock.of({ type })); expect(readAsText).toHaveBeenCalledTimes(1); expect(toObject).toHaveBeenCalledTimes(1); From d08a69954aeb4c873d6e1f2081d28ae4d39974bd Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Wed, 30 Dec 2020 20:53:14 +0100 Subject: [PATCH 3/4] Updated changelog --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6b931691..da1228f8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org). -## [Unreleased] +## [3.0.1] - 2020-12-30 ### Added * *Nothing* @@ -22,6 +22,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), * [#366](https://github.com/shlinkio/shlink-web-client/issues/366) Fixed text in visits menu jumping to next line in some tablet resolutions. * [#367](https://github.com/shlinkio/shlink-web-client/issues/367) Removed conflicting overflow in visits table for mobile devices. * [#365](https://github.com/shlinkio/shlink-web-client/issues/365) Fixed weird rendering of short URLs list in tablets. +* [#372](https://github.com/shlinkio/shlink-web-client/issues/372) Fixed importing servers in Android devices. ## [3.0.0] - 2020-12-22 From e577eb48d6c7db69c2e8ab8d7b770ce320bb7f67 Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Wed, 30 Dec 2020 20:58:36 +0100 Subject: [PATCH 4/4] Changed env for github workflows from ubuntu-latest to ubuntu-20.04 --- .github/workflows/ci.yml | 8 ++++---- .github/workflows/docker-image-build.yml | 2 +- .github/workflows/publish-release.yml | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f2e68544..ef02e953 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,7 +9,7 @@ on: jobs: lint: continue-on-error: true - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 steps: - name: Checkout code uses: actions/checkout@v2 @@ -21,7 +21,7 @@ jobs: - run: npm run lint unit-tests: - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 steps: - name: Checkout code uses: actions/checkout@v2 @@ -38,7 +38,7 @@ jobs: mutation-tests: continue-on-error: true - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 steps: - name: Checkout code uses: actions/checkout@v2 @@ -52,7 +52,7 @@ jobs: - run: npm run mutate -- --mutate=$(git diff origin/main --name-only | grep -E 'src\/(.*).(ts|tsx)$' | paste -sd ",") build-docker-image: - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 steps: - name: Checkout code uses: actions/checkout@v2 diff --git a/.github/workflows/docker-image-build.yml b/.github/workflows/docker-image-build.yml index 50a0d4ba..36ff3809 100644 --- a/.github/workflows/docker-image-build.yml +++ b/.github/workflows/docker-image-build.yml @@ -9,7 +9,7 @@ on: jobs: build: - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 steps: - name: Checkout code uses: actions/checkout@v2 diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml index 5f857f89..fac8fded 100644 --- a/.github/workflows/publish-release.yml +++ b/.github/workflows/publish-release.yml @@ -7,7 +7,7 @@ on: jobs: build: - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 steps: - name: Checkout code uses: actions/checkout@v2