Compare commits

...

76 Commits

Author SHA1 Message Date
Juan Picado @jotadeveloper
376b84f8c9 chore(release): 0.2.3 2019-08-25 17:55:59 +02:00
Juan Picado @jotadeveloper
5a9bd6001a fix: remove ToReplaceByVerdaccio #108 (#122)
* fix: remove ToReplaceByVerdaccio #108

it populates CSS url() props with ToReplaceByVerdaccio which cannot be replaced anyway, this PR remove that string.

https://github.com/verdaccio/ui/issues/108

* chore: remove comment
2019-08-25 08:53:30 -07:00
Juan Picado @jotadeveloper
ac58730e8c fix: missing headers on search endpoint with token (#121)
Headers should be part of the options if we override options.

https://github.com/verdaccio/ui/issues/118
2019-08-25 08:39:15 -07:00
Juan Picado @jotadeveloper
97e8448098 fix: refactoring version page / fix issue not found page #100 (#117)
* chore: refactoring version page

* refactor: migrate version page to hooks

* refactor: Version page better imports

* fix: #100 render not found on click item

* test: add test for version page

* chore: update mocks

* test: add scenario for not found package

* chore: fix wrong mock path

* chore: update mock

* chore: add todo list
2019-08-25 14:34:27 +02:00
Juan Picado @jotadeveloper
e7d3c461cd Merge pull request #120 from verdaccio/adds-unit-test-for-version-component
chore: adds unit test for version component
2019-08-25 07:11:09 +02:00
Ayush Sharma
003f879a87 chore: adds unit test for version component 2019-08-24 16:57:51 +02:00
Juan Picado @jotadeveloper
d81b610e2e Merge pull request #115 from verdaccio/hooks-first-step
hooks first step
2019-08-15 21:48:07 +02:00
Juan Picado @jotadeveloper
3d7b230c71 chore: add note 2019-08-12 07:54:14 +02:00
Juan Picado @jotadeveloper
ce3b22579f chore: update snapshots 2019-08-12 07:45:16 +02:00
Juan Picado @jotadeveloper
e46020f9b0 refactor: Developers component
Using React hooks
2019-08-12 07:06:10 +02:00
Juan Picado @jotadeveloper
502c0903ab chore: add react hooks eslint conf 2019-08-11 07:24:54 +02:00
Juan Picado @jotadeveloper
542212a479 Merge pull request #114 from verdaccio/update-stack
chore: update stack
2019-08-10 22:30:47 +02:00
Juan Picado @jotadeveloper
1cb9b56940 Merge branch 'master' into update-stack 2019-08-10 22:25:04 +02:00
Juan Picado @jotadeveloper
1446c8e5fb Merge pull request #112 from ThisIsMissEm/master
fix(api): correctly handle responses with missing content-type header
2019-08-10 22:22:19 +02:00
Juan Picado @jotadeveloper
155987d837 chore: update css-loader 2019-08-10 22:01:02 +02:00
Juan Picado @jotadeveloper
a44e76fded chore: update webpack 2019-08-10 21:52:25 +02:00
Juan Picado @jotadeveloper
2dfa7aa4d6 Merge remote-tracking branch 'origin/master' into update-stack 2019-08-10 21:41:10 +02:00
Juan Picado @jotadeveloper
cfb0caf2bb Merge branch 'master' into master 2019-08-10 21:39:16 +02:00
Juan Picado @jotadeveloper
62b6edc821 Update nodejs.yml 2019-08-10 21:38:21 +02:00
Juan Picado @jotadeveloper
9b55b75f8a Update nodejs.yml 2019-08-10 21:29:56 +02:00
Juan Picado @jotadeveloper
ade58caf41 Update nodejs.yml 2019-08-10 21:25:03 +02:00
Juan Picado @jotadeveloper
2e9703346c Update nodejs.yml 2019-08-10 21:19:03 +02:00
Juan Picado @jotadeveloper
ccc2cb3fa6 chore: update dependencies 2019-08-10 20:32:35 +02:00
Juan Picado @jotadeveloper
3746a0466f chore: trying github ci 2019-08-10 13:54:27 +02:00
Juan Picado @jotadeveloper
dcfda4483f Merge pull request #113 from griffithtp/fix/107_refactor-suggest-styles
Fix/107 refactor suggest styles
2019-08-09 05:56:33 +02:00
Griffithtp
d44cc7f662 refactor: update all reusable fontWeights 2019-08-08 22:08:37 +01:00
Griffithtp
4a526c92bb refactor: add reusable styles properties 2019-08-08 22:03:54 +01:00
Emelia Smith
2049022477 fix(api): correctly handle responses with missing content-type header
Also prevents non .tgz requests from being handled as tgz requests — the previous if condition was incorrect
2019-08-08 14:26:30 +02:00
Juan Picado @jotadeveloper
40a25a2507 refactor: update dependencies
development keys deps updated
add eslint-plugin-codeceptjs to fix eslint issues for acceptant test
2019-08-04 11:40:45 +02:00
Juan Picado @jotadeveloper
58cb4c7465 Merge branch '4.x-master' of github.com:verdaccio/ui into 4.x-master 2019-08-04 11:17:41 +02:00
Juan Picado @jotadeveloper
e1d8eafb7a Merge pull request #44 from DanielRuf/test/bdd-acceptance-testing-setup
test: BDD / acceptance tests
2019-08-04 11:17:04 +02:00
Juan Picado @jotadeveloper
cb876f936e Merge branch '4.x-master' into test/bdd-acceptance-testing-setup 2019-08-04 11:10:56 +02:00
Juan Picado @jotadeveloper
94ca0e146d Merge pull request #96 from verdaccio/4.x-adds-unit-tests-for-repository-component
chore: adds unit tests for <Repository /> component
2019-08-04 11:06:59 +02:00
Juan Picado @jotadeveloper
8774fd51c7 Merge branch '4.x-master' into 4.x-adds-unit-tests-for-repository-component 2019-08-04 10:24:09 +02:00
Juan Picado @jotadeveloper
6f8d891c42 chore: improve local dev displaying 2 packages by default
vue and jquery as examples
2019-08-04 10:17:43 +02:00
Juan Picado @jotadeveloper
240535ddad chore(release): 0.2.2 2019-07-29 16:33:18 +02:00
Juan Picado @jotadeveloper
3c6fe5d947 Merge pull request #110 from verdaccio/issue-token
fix: download protected tarballs
2019-07-29 16:32:27 +02:00
Juan Picado @jotadeveloper
f8374084b5 test: add scenario for handleResponseType tgz 2019-07-29 08:42:37 +02:00
Juan Picado @jotadeveloper
8c9cffbc6a test: add scenario for action bar
Wether the metadata has a tarball distribution file
2019-07-29 00:12:14 +02:00
Juan Picado @jotadeveloper
62431038bb chore: improve types and checks 2019-07-28 17:51:46 +02:00
Juan Picado @jotadeveloper
12974ea54f test: add unit test for extractFileName 2019-07-28 16:44:31 +02:00
Juan Picado @jotadeveloper
f47ab2490b refactor: add download file method 2019-07-28 14:12:18 +02:00
Juan Picado @jotadeveloper
83b6a9d247 chore: update snapshots for actionbar 2019-07-28 11:59:58 +02:00
Juan Picado @jotadeveloper
5c484bba9a fix: proxy webpack setting
- it allows download tarballls in the same origin
- update webpack dev server
- add scenario for blob
2019-07-28 11:53:23 +02:00
Juan Picado @jotadeveloper
9d006ad6f7 chore: first try to download files with fetch 2019-07-28 11:53:23 +02:00
Juan Picado @jotadeveloper
fd74c52bd1 fix: token were not being send it 2019-07-28 11:53:22 +02:00
Juan Picado @jotadeveloper
a25fc6ec78 chore: upgrade dependencies
it upgrade non key dependencies
2019-07-28 00:10:53 +02:00
Juan Picado @jotadeveloper
dd54aaaf94 Merge branch '4.x-master' into 4.x-adds-unit-tests-for-repository-component 2019-07-28 00:03:42 +02:00
Juan Picado @jotadeveloper
64c003943c Merge pull request #104 from verdaccio/97-unify-emotion-css-definition-format
Part of 97 - Unify Emotion CSS format
2019-07-16 16:30:30 +02:00
Sergio Herrera Guzmán
115be1bb6e refactor: move cascaded CSS from templates to JS objects 2019-07-16 16:15:56 +02:00
Juan Picado @jotadeveloper
9d7b90fc34 Merge branch '4.x-master' into 4.x-adds-unit-tests-for-repository-component 2019-07-16 15:57:05 +02:00
Sergio Herrera Guzmán
8ea017d871 refactor: move basic CSS from templates to JS objects 2019-07-16 14:59:54 +02:00
Sergio Herrera Guzmán
786da9975f chore: disable stylelint on files with no CSS templates 2019-07-16 14:59:54 +02:00
Juan Picado @jotadeveloper
684e989fbd Merge pull request #103 from verdaccio/fix-commitlint
chore: execute commitlint on commit-msg and not pre-commit
2019-07-15 14:58:04 +02:00
Juan Picado @jotadeveloper
4dd953e553 Merge branch '4.x-master' into fix-commitlint 2019-07-15 14:57:03 +02:00
Juan Picado @jotadeveloper
9343503372 Merge pull request #106 from verdaccio/bugfix-css-logo
fix: css repetition is not closed in Logo component
2019-07-15 14:50:25 +02:00
Sergio Herrera Guzmán
ec243b1352 fix: css repetition is not closed in Logo component 2019-07-15 14:43:44 +02:00
Sergio Herrera Guzmán
2ffb2b5bf1 chore: execute commitlint on commit-msg and not pre-commit 2019-07-14 18:08:48 +02:00
Juan Picado @jotadeveloper
cad5ac91e7 Merge pull request #101 from griffithtp/fix/76_download-button-hidden-for-localhost
fix: 76 download button hidden for localhost
2019-07-14 14:27:44 +02:00
Griffithtp
ecc4521314 refactor: remove getBaseNamePath() and history.ts 2019-07-14 12:50:47 +01:00
Griffithtp
795544a14c test: add unit test for url utils 2019-07-13 15:46:08 +01:00
Daniel Ruf
67fff03b87 Merge branch '4.x-master' into fix/76_download-button-hidden-for-localhost 2019-07-13 14:01:29 +02:00
Griffithtp
5148fdca66 refactor: add @types/validator 2019-07-13 07:53:23 +01:00
Juan Picado @jotadeveloper
46ae0d21a3 Merge pull request #98 from verdaccio/dependabot/npm_and_yarn/lodash.merge-4.6.2
chore(deps): bump lodash.merge from 4.6.1 to 4.6.2
2019-07-11 22:20:51 +02:00
Juan Picado @jotadeveloper
9ade2a0ee7 Merge branch '4.x-master' into dependabot/npm_and_yarn/lodash.merge-4.6.2 2019-07-11 22:20:46 +02:00
Juan Picado @jotadeveloper
e346819035 Merge pull request #99 from verdaccio/dependabot/npm_and_yarn/lodash.template-4.5.0
chore(deps): bump lodash.template from 4.4.0 to 4.5.0
2019-07-11 22:20:30 +02:00
dependabot[bot]
46e5f09dbf chore(deps): bump lodash.template from 4.4.0 to 4.5.0
Bumps [lodash.template](https://github.com/lodash/lodash) from 4.4.0 to 4.5.0.
- [Release notes](https://github.com/lodash/lodash/releases)
- [Commits](https://github.com/lodash/lodash/compare/4.4.0...4.5.0)

Signed-off-by: dependabot[bot] <support@github.com>
2019-07-11 07:17:47 +00:00
Griffithtp
cca2c3c0d7 fix: localhost domain download tarball button 2019-07-10 23:51:25 +01:00
dependabot[bot]
c814080957 chore(deps): bump lodash.merge from 4.6.1 to 4.6.2
Bumps [lodash.merge](https://github.com/lodash/lodash) from 4.6.1 to 4.6.2.
- [Release notes](https://github.com/lodash/lodash/releases)
- [Commits](https://github.com/lodash/lodash/commits)

Signed-off-by: dependabot[bot] <support@github.com>
2019-07-10 22:51:21 +00:00
Ayush Sharma
157addfd00 Merge branch '4.x-master' into 4.x-adds-unit-tests-for-repository-component 2019-07-10 22:13:41 +02:00
Juan Picado @jotadeveloper
6ab3aa2885 Merge branch '4.x-master' into 4.x-adds-unit-tests-for-repository-component 2019-07-10 07:30:39 +02:00
Ayush Sharma
9e0c9db78c chore: adds unit tests for <Repository /> component 2019-07-09 23:48:46 +02:00
Juan Picado @jotadeveloper
df4e45cd6c Merge branch '4.x-master' into test/bdd-acceptance-testing-setup 2019-05-08 22:07:24 +02:00
Juan Picado @jotadeveloper
df58d463e8 Merge branch '4.x-master' into test/bdd-acceptance-testing-setup 2019-05-04 12:15:18 +02:00
Juan Picado @jotadeveloper
313fb33480 Merge branch '4.x-master' into test/bdd-acceptance-testing-setup 2019-05-03 08:05:06 +02:00
Daniel Ruf
d468ca7c5f test: BDD / acceptance tests
Implement acceptance testing using codeceptjs and puppeteer.
2019-05-02 11:15:33 +02:00
108 changed files with 61947 additions and 3303 deletions

View File

@@ -12,7 +12,9 @@
"jest",
"prettier",
"verdaccio",
"jsx-a11y"
"jsx-a11y",
"codeceptjs",
"react-hooks"
],
"settings": {
"react": {
@@ -106,6 +108,8 @@
2,
"always"
],
"react-hooks/rules-of-hooks": "error",
"react-hooks/exhaustive-deps": "warn",
"verdaccio/jsx-no-style": ["warn"],
"verdaccio/jsx-spread": ["warn"],
"jest/expect-expect": 0,
@@ -119,6 +123,7 @@
},
"env": {
"browser": true,
"jest/globals": true
"jest/globals": true,
"codeceptjs/codeceptjs": true,
}
}

28
.github/workflows/nodejs.yml vendored Normal file
View File

@@ -0,0 +1,28 @@
name: Node CI
on: [push]
jobs:
ci:
name: Test on node ${{ matrix.node_version }} and ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
node_version: [8, 10, 12]
os: [ubuntu-latest, windows-latest, macOS-latest]
steps:
- uses: actions/checkout@v1
- name: Use Node.js ${{ matrix.node_version }}
uses: actions/setup-node@v1
with:
version: ${{ matrix.node_version }}
- name: Use Yarn 1.17.2
run: |
npm install -g yarn@1.17.2
- name: yarn build
run: |
yarn install
yarn lint
yarn build

1
.nvmrc Normal file
View File

@@ -0,0 +1 @@
stable

View File

@@ -26,6 +26,7 @@
"no-descending-specificity": [true, { "severity": "warning" }],
"no-duplicate-at-import-rules": true,
"no-duplicate-selectors": true,
"no-empty-source": null,
"no-extra-semicolons": true,
"no-invalid-double-slash-comments": true,
"property-no-unknown": true,

View File

@@ -1,2 +1 @@
save-prefix ""
registry "http://registry.npmjs.org/"

View File

@@ -1,7 +1,30 @@
# Change Log
# Changelog
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
### [0.2.3](https://github.com/verdaccio/ui/compare/v0.2.2...v0.2.3) (2019-08-25)
### Bug Fixes
* missing headers on search endpoint with token ([#121](https://github.com/verdaccio/ui/issues/121)) ([ac58730](https://github.com/verdaccio/ui/commit/ac58730))
* refactoring version page / fix issue not found page [#100](https://github.com/verdaccio/ui/issues/100) ([#117](https://github.com/verdaccio/ui/issues/117)) ([97e8448](https://github.com/verdaccio/ui/commit/97e8448))
* remove ToReplaceByVerdaccio [#108](https://github.com/verdaccio/ui/issues/108) ([#122](https://github.com/verdaccio/ui/issues/122)) ([5a9bd60](https://github.com/verdaccio/ui/commit/5a9bd60))
* **api:** correctly handle responses with missing content-type header ([2049022](https://github.com/verdaccio/ui/commit/2049022))
<a name="0.2.2"></a>
## [0.2.2](https://github.com/verdaccio/ui/compare/v0.2.1...v0.2.2) (2019-07-29)
### Bug Fixes
* css repetition is not closed in Logo component ([ec243b1](https://github.com/verdaccio/ui/commit/ec243b1))
* localhost domain download tarball button ([cca2c3c](https://github.com/verdaccio/ui/commit/cca2c3c))
* proxy webpack setting ([5c484bb](https://github.com/verdaccio/ui/commit/5c484bb))
* token were not being send it ([fd74c52](https://github.com/verdaccio/ui/commit/fd74c52))
<a name="0.2.1"></a>
## [0.2.1](https://github.com/verdaccio/ui/compare/v0.2.0...v0.2.1) (2019-07-10)

21
codecept.conf.js Normal file
View File

@@ -0,0 +1,21 @@
exports.config = {
tests: './test/acceptance/*_test.js',
output: './test/acceptance/output',
helpers: {
Puppeteer: {
url: 'http://localhost:8080',
// "show": true,
chrome: {
// headless: false
},
},
},
include: {
I: './test/acceptance/steps_file.js',
},
smartWait: 30000,
bootstrap: null,
plugins: {},
mocha: {},
name: '@verdaccio/ui-theme',
};

View File

@@ -1,36 +0,0 @@
module.exports = {
name: 'verdaccio-ui-jest',
verbose: true,
collectCoverage: true,
testEnvironment: 'jest-environment-jsdom-global',
moduleFileExtensions: ['js', 'ts', 'tsx'],
testURL: 'http://localhost',
rootDir: '..',
setupFiles: ['<rootDir>/test/setup.js'],
transformIgnorePatterns: ['<rootDir>/node_modules/(?!react-syntax-highlighter)'],
modulePathIgnorePatterns: ['<rootDir>/coverage', '<rootDir>/scripts', '<rootDir>/.circleci', '<rootDir>/tools', '<rootDir>/build', '<rootDir>/.vscode/'],
snapshotSerializers: ['enzyme-to-json/serializer', 'jest-emotion'],
moduleNameMapper: {
'\\.(s?css)$': '<rootDir>/node_modules/identity-obj-proxy',
'github-markdown-css': '<rootDir>/node_modules/identity-obj-proxy',
'\\.(png)$': '<rootDir>/node_modules/identity-obj-proxy',
'\\.(svg)$': '<rootDir>/test/unit/empty.ts',
},
};
// module.exports = {
// name: 'verdaccio-unit-jest',
// verbose: true,
// collectCoverage: true,
// testEnvironment: 'jest-environment-jsdom-global',
// testURL: 'http://localhost',
// testRegex: '../src/components/CopyToClipBoard/CopyToClipBoard.test.tsx',
// setupFiles: ['./setup.ts'],
// // Some unit tests rely on data folders that look like packages. This confuses jest-hast-map
// // when it tries to scan for package.json files.
// modulePathIgnorePatterns: ['<rootDir>/coverage', '<rootDir>/scripts', '<rootDir>/.circleci', '<rootDir>/tools', '<rootDir>/build', '<rootDir>/.vscode/'],
// // testPathIgnorePatterns: ['__snapshots__', '<rootDir>/build'],
// snapshotSerializers: ['enzyme-to-json/serializer', 'jest-emotion'],
// // coveragePathIgnorePatterns: ['node_modules', 'fixtures', '<rootDir>/src/api/debug', '<rootDir>/test'],
// // transformIgnorePatterns: ['<rootDir>/node_modules/(?!react-syntax-highlighter)'],
// };

View File

@@ -3,6 +3,7 @@ const { defaults } = require('jest-config');
module.exports = {
name: 'verdaccio-ui-jest',
verbose: true,
automock: false,
collectCoverage: true,
testEnvironment: 'jest-environment-jsdom-global',
moduleFileExtensions: [...defaults.moduleFileExtensions, 'ts', 'tsx'],

View File

@@ -5,6 +5,7 @@
import 'raf/polyfill';
import { configure } from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
import { GlobalWithFetchMock } from 'jest-fetch-mock';
// @ts-ignore : Only a void function can be called with the 'new' keyword
configure({ adapter: new Adapter() });
@@ -14,6 +15,10 @@ global.__APP_VERSION__ = '1.0.0';
// @ts-ignore : Property '__VERDACCIO_BASENAME_UI_OPTIONS' does not exist on type 'Global'.
global.__VERDACCIO_BASENAME_UI_OPTIONS = {};
const customGlobal: GlobalWithFetchMock = global as GlobalWithFetchMock;
customGlobal.fetch = require('jest-fetch-mock');
customGlobal.fetchMock = customGlobal.fetch;
// mocking few DOM methods
// @ts-ignore : Property 'document' does not exist on type 'Global'.
if (global.document) {

View File

@@ -1,6 +1,6 @@
{
"name": "@verdaccio/ui-theme",
"version": "0.2.1",
"version": "0.2.3",
"description": "Verdaccio User Interface",
"author": {
"name": "Verdaccio Core Team"
@@ -11,91 +11,100 @@
},
"main": "index.js",
"devDependencies": {
"@commitlint/cli": "8.0.0",
"@commitlint/config-conventional": "8.0.0",
"@commitlint/cli": "8.1.0",
"@commitlint/config-conventional": "8.1.0",
"@material-ui/core": "3.9.3",
"@material-ui/icons": "3.0.2",
"@octokit/rest": "16.23.2",
"@types/enzyme": "3.9.3",
"@types/lodash": "4.14.134",
"@octokit/rest": "16.28.7",
"@testing-library/react": "9.1.3",
"@types/enzyme": "3.10.3",
"@types/jest": "24.0.18",
"@types/lodash": "4.14.137",
"@types/material-ui": "0.21.6",
"@types/node": "12.0.8",
"@types/react": "16.8.16",
"@types/react-dom": "16.8.4",
"@types/react-router-dom": "4.3.2",
"@verdaccio/babel-preset": "0.2.1",
"@verdaccio/eslint-config": "0.0.1",
"@verdaccio/types": "6.1.0",
"@types/node": "12.7.2",
"@types/react": "16.9.2",
"@types/react-dom": "16.9.0",
"@types/react-router-dom": "4.3.5",
"@types/validator": "10.11.3",
"@verdaccio/babel-preset": "2.0.0",
"@verdaccio/eslint-config": "2.0.0",
"@verdaccio/types": "8.0.0",
"autosuggest-highlight": "3.1.1",
"babel-loader": "8.0.6",
"bundlesize": "0.17.2",
"bundlesize": "0.18.0",
"codeceptjs": "2.2.1",
"codecov": "3.5.0",
"concurrently": "4.1.0",
"concurrently": "4.1.2",
"cross-env": "5.2.0",
"css-loader": "0.28.10",
"css-loader": "3.2.0",
"date-fns": "1.30.1",
"emotion": "9.2.12",
"enzyme": "3.10.0",
"enzyme-adapter-react-16": "1.14.0",
"enzyme-to-json": "3.3.5",
"enzyme-to-json": "3.4.0",
"eslint": "5.16.0",
"eslint-plugin-jsx-a11y": "6.2.1",
"eslint-plugin-codeceptjs": "1.1.0",
"eslint-plugin-jsx-a11y": "6.2.3",
"eslint-plugin-prettier": "3.1.0",
"eslint-plugin-react": "7.13.0",
"eslint-plugin-verdaccio": "0.0.5",
"file-loader": "2.0.0",
"eslint-plugin-react": "7.14.3",
"eslint-plugin-react-hooks": "1.7.0",
"eslint-plugin-verdaccio": "2.0.0",
"file-loader": "4.2.0",
"friendly-errors-webpack-plugin": "1.7.0",
"get-stdin": "6.0.0",
"github-markdown-css": "2.10.0",
"github-markdown-css": "3.0.1",
"html-webpack-plugin": "3.2.0",
"husky": "2.4.1",
"husky": "3.0.3",
"identity-obj-proxy": "3.0.0",
"in-publish": "2.0.0",
"jest": "24.8.0",
"jest-emotion": "10.0.11",
"jest-environment-jsdom": "24.8.0",
"jest": "24.9.0",
"jest-emotion": "10.0.14",
"jest-environment-jsdom": "24.9.0",
"jest-environment-jsdom-global": "1.2.0",
"jest-environment-node": "24.8.0",
"jest-environment-node": "24.9.0",
"jest-fetch-mock": "2.1.2",
"js-base64": "2.5.1",
"js-yaml": "3.13.1",
"localstorage-memory": "1.0.3",
"mini-css-extract-plugin": "0.7.0",
"node-mocks-http": "1.7.3",
"mini-css-extract-plugin": "0.8.0",
"node-mocks-http": "1.7.6",
"normalize.css": "8.0.1",
"optimize-css-assets-webpack-plugin": "5.0.1",
"optimize-css-assets-webpack-plugin": "5.0.3",
"ora": "3.4.0",
"prettier": "1.18.2",
"prop-types": "15.7.2",
"puppeteer": "1.17.0",
"react": "16.8.3",
"react-autosuggest": "9.4.2",
"react-dom": "16.8.3",
"react": "16.9.0",
"react-autosuggest": "9.4.3",
"react-dom": "16.9.0",
"react-emotion": "9.2.12",
"react-hot-loader": "4.7.1",
"react-router": "4.3.1",
"react-router-dom": "4.3.1",
"resolve-url-loader": "3.0.1",
"react-hot-loader": "4.12.11",
"react-router": "5.0.1",
"react-router-dom": "5.0.1",
"resolve-url-loader": "3.1.0",
"rimraf": "2.6.3",
"source-map-loader": "0.2.4",
"standard-version": "4.4.0",
"style-loader": "0.23.1",
"standard-version": "7.0.0",
"style-loader": "1.0.0",
"stylelint": "10.1.0",
"stylelint-config-recommended": "2.2.0",
"stylelint-config-styled-components": "0.1.1",
"stylelint-processor-styled-components": "1.8.0",
"stylelint-webpack-plugin": "0.10.5",
"supertest": "4.0.2",
"typeface-roboto": "0.0.54",
"typescript": "3.5.2",
"url-loader": "1.1.2",
"validator": "10.11.0",
"verdaccio": "4.0.3",
"verdaccio-auth-memory": "0.0.4",
"typeface-roboto": "0.0.75",
"typescript": "3.5.3",
"uglifyjs-webpack-plugin": "2.2.0",
"url-loader": "2.1.0",
"validator": "11.1.0",
"verdaccio": "4.2.1",
"verdaccio-auth-memory": "1.1.5",
"verdaccio-memory": "2.0.0",
"webpack": "4.20.2",
"webpack-bundle-analyzer": "3.3.2",
"webpack": "4.39.2",
"webpack-bundle-analyzer": "3.4.1",
"webpack-bundle-size-analyzer": "3.0.0",
"webpack-cli": "3.2.3",
"webpack-dev-server": "3.2.1",
"webpack-cli": "3.3.7",
"webpack-dev-server": "3.8.0",
"webpack-merge": "4.2.1",
"whatwg-fetch": "3.0.0",
"xss": "1.0.6"
@@ -135,7 +144,10 @@
"type-check": "tsc --noEmit",
"type-check:watch": "npm run type-check -- --watch",
"release": "standard-version -a -s",
"test": "cross-env NODE_ENV=test BABEL_ENV=test TZ=UTC jest --config ./jest/jest.config.js --maxWorkers 2",
"test:clean": "npx jest --clearCache",
"test:acceptance": "codeceptjs run --steps",
"test:acceptance:server": "concurrently --kill-others \"npm run verdaccio:server\" \"npm run test:acceptance\"",
"test": "cross-env NODE_ENV=test BABEL_ENV=test TZ=UTC jest --config ./jest/jest.config.js --maxWorkers 2 --passWithNoTests",
"test:size": "bundlesize",
"lint": "npm run lint:js && npm run lint:css",
"lint:js": "npm run type-check && eslint . --ext .js,.ts,.tsx",
@@ -156,7 +168,7 @@
},
"husky": {
"hooks": {
"pre-commit": "commitlint -e $GIT_PARAMS"
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
}
},
"license": "MIT",

View File

@@ -0,0 +1 @@
{"list":["vue","jquery"],"secret":"3bb332943c7086716a35dea44754b43b956ee655af1fe61866fbdaf38486836c"}

Binary file not shown.

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

38
src/App/AppError.tsx Normal file
View File

@@ -0,0 +1,38 @@
import React, { Component } from 'react';
export interface ErrorProps {
children: any;
}
export interface ErrorAppState {
hasError: boolean;
error: any;
info: any;
}
export default class ErrorBoundary extends Component<ErrorProps, ErrorAppState> {
constructor(props) {
super(props);
this.state = { hasError: false, error: null, info: null };
}
componentDidCatch(error, info) {
this.setState({ hasError: true, error, info });
}
render() {
const { hasError, error, info } = this.state;
const { children } = this.props;
if (hasError) {
return (
<>
<h1>{'Something went wrong.'}</h1>
<p>{`error: ${error}`}</p>
<p>{`info: ${JSON.stringify(info)}`}</p>
</>
);
}
return children;
}
}

View File

@@ -1,15 +1,15 @@
import { css } from 'emotion';
import colors from '../utils/styles/colors';
export const alertError = css`
background-color: ${colors.red} !important;
min-width: inherit !important;
`;
export const alertError = css({
backgroundColor: `${colors.red} !important`,
minWidth: 'inherit !important',
});
export const alertErrorMsg = css`
display: flex;
align-items: center;
`;
export const alertErrorMsg = css({
display: 'flex',
alignItems: 'center',
});
export const alertIcon = css({
opacity: 0.9,

View File

@@ -1,5 +1,5 @@
import React from 'react';
import { shallow } from 'enzyme';
import { mount, shallow } from 'enzyme';
describe('<ActionBar /> component', () => {
beforeEach(() => {
@@ -19,7 +19,7 @@ describe('<ActionBar /> component', () => {
},
};
jest.doMock('../../pages/version/Version', () => ({
jest.doMock('../../pages/Version', () => ({
DetailContextConsumer: component => {
return component.children({ packageMeta });
},
@@ -35,7 +35,7 @@ describe('<ActionBar /> component', () => {
latest: {},
};
jest.doMock('../../pages/version/Version', () => ({
jest.doMock('../../pages/Version', () => ({
DetailContextConsumer: component => {
return component.children({ packageMeta });
},
@@ -43,6 +43,31 @@ describe('<ActionBar /> component', () => {
const ActionBar = require('./ActionBar').default;
const wrapper = shallow(<ActionBar />);
// FIXME: this only renders the DetailContextConsumer, thus
// the wrapper will be always empty
expect(wrapper.html()).toEqual('');
});
test('when there is a button to download a tarball', () => {
const packageMeta = {
latest: {
dist: {
tarball: 'http://localhost:8080/bootstrap/-/bootstrap-4.3.1.tgz',
},
},
};
jest.doMock('../../pages/Version', () => ({
DetailContextConsumer: component => {
return component.children({ packageMeta });
},
}));
const ActionBar = require('./ActionBar').default;
const wrapper = mount(<ActionBar />);
expect(wrapper.html()).toMatchSnapshot();
const button = wrapper.find('button');
expect(button).toHaveLength(1);
});
});

View File

@@ -6,9 +6,27 @@ import HomeIcon from '@material-ui/icons/Home';
import List from '@material-ui/core/List';
import Tooltip from '@material-ui/core/Tooltip';
import { DetailContextConsumer, VersionPageConsumerProps } from '../../pages/version/Version';
import { DetailContextConsumer, VersionPageConsumerProps } from '../../pages/Version';
import { Fab, ActionListItem } from './styles';
import { isURL } from '../../utils/url';
import { isURL, extractFileName, downloadFile } from '../../utils/url';
import api from '../../utils/api';
export interface Action {
icon: string;
title: string;
handler?: Function;
}
export async function downloadHandler(link: string): Promise<void> {
const fileStream: Blob = await api.request(link, 'GET', {
headers: {
['accept']: 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3',
},
credentials: 'include',
});
const fileName = extractFileName(link);
downloadFile(fileStream, fileName);
}
const ACTIONS = {
homepage: {
@@ -22,6 +40,7 @@ const ACTIONS = {
tarball: {
icon: <DownloadIcon />,
title: 'Download tarball',
handler: downloadHandler,
},
};
@@ -54,16 +73,34 @@ class ActionBar extends Component {
tarball,
};
const renderList = Object.keys(actionsMap).reduce((component, value, key) => {
const renderList = Object.keys(actionsMap).reduce((component: React.ReactElement[], value, key) => {
const link = actionsMap[value];
if (link && isURL(link)) {
const fab = <Fab size={'small'}>{ACTIONS[value]['icon']}</Fab>;
component.push(
// @ts-ignore
<Tooltip key={key} title={ACTIONS[value]['title']}>
<>{this.renderIconsWithLink(link, fab)}</>
</Tooltip>
);
const actionItem: Action = ACTIONS[value];
if (actionItem.handler) {
const fab = (
<Tooltip key={key} title={actionItem['title']}>
<Fab
/* eslint-disable react/jsx-no-bind */
onClick={() => {
/* eslint-disable @typescript-eslint/no-non-null-assertion */
actionItem.handler!(link);
}}
size={'small'}>
{actionItem['icon']}
</Fab>
</Tooltip>
);
component.push(fab);
} else {
const fab = <Fab size={'small'}>{actionItem['icon']}</Fab>;
component.push(
// @ts-ignore
<Tooltip key={key} title={actionItem['title']}>
<>{this.renderIconsWithLink(link, fab)}</>
</Tooltip>
);
}
}
return component;
}, []);

View File

@@ -1,3 +1,5 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`<ActionBar /> component should render the component in default state 1`] = `"<ul class=\\"MuiList-root-1 MuiList-padding-2\\"><li class=\\"MuiListItem-root-5 MuiListItem-default-8 MuiListItem-gutters-13 MuiListItem-alignItemsFlexStart-10 css-9q3x3c eux6shq0\\"><a href=\\"https://verdaccio.tld\\" target=\\"_blank\\"><button class=\\"MuiButtonBase-root-35 MuiFab-root-25 MuiFab-sizeSmall-33 css-96oxa0 eux6shq1\\" tabindex=\\"0\\" type=\\"button\\"><span class=\\"MuiFab-label-26\\"><svg class=\\"MuiSvgIcon-root-38\\" focusable=\\"false\\" viewBox=\\"0 0 24 24\\" aria-hidden=\\"true\\" role=\\"presentation\\"><path d=\\"M10 20v-6h4v6h5v-8h3L12 3 2 12h3v8z\\"></path><path fill=\\"none\\" d=\\"M0 0h24v24H0z\\"></path></svg></span></button></a><a href=\\"https://verdaccio.tld/bugs\\" target=\\"_blank\\"><button class=\\"MuiButtonBase-root-35 MuiFab-root-25 MuiFab-sizeSmall-33 css-96oxa0 eux6shq1\\" tabindex=\\"0\\" type=\\"button\\"><span class=\\"MuiFab-label-26\\"><svg class=\\"MuiSvgIcon-root-38\\" focusable=\\"false\\" viewBox=\\"0 0 24 24\\" aria-hidden=\\"true\\" role=\\"presentation\\"><path fill=\\"none\\" d=\\"M0 0h24v24H0z\\"></path><path d=\\"M20 8h-2.81c-.45-.78-1.07-1.45-1.82-1.96L17 4.41 15.59 3l-2.17 2.17C12.96 5.06 12.49 5 12 5c-.49 0-.96.06-1.41.17L8.41 3 7 4.41l1.62 1.63C7.88 6.55 7.26 7.22 6.81 8H4v2h2.09c-.05.33-.09.66-.09 1v1H4v2h2v1c0 .34.04.67.09 1H4v2h2.81c1.04 1.79 2.97 3 5.19 3s4.15-1.21 5.19-3H20v-2h-2.09c.05-.33.09-.66.09-1v-1h2v-2h-2v-1c0-.34-.04-.67-.09-1H20V8zm-6 8h-4v-2h4v2zm0-4h-4v-2h4v2z\\"></path></svg></span></button></a><a href=\\"https://verdaccio.tld/download\\" target=\\"_blank\\"><button class=\\"MuiButtonBase-root-35 MuiFab-root-25 MuiFab-sizeSmall-33 css-96oxa0 eux6shq1\\" tabindex=\\"0\\" type=\\"button\\"><span class=\\"MuiFab-label-26\\"><svg class=\\"MuiSvgIcon-root-38\\" focusable=\\"false\\" viewBox=\\"0 0 24 24\\" aria-hidden=\\"true\\" role=\\"presentation\\"><path fill=\\"none\\" d=\\"M0 0h24v24H0z\\"></path><path d=\\"M19.35 10.04C18.67 6.59 15.64 4 12 4 9.11 4 6.6 5.64 5.35 8.04 2.34 8.36 0 10.91 0 14c0 3.31 2.69 6 6 6h13c2.76 0 5-2.24 5-5 0-2.64-2.05-4.78-4.65-4.96zM17 13l-5 5-5-5h3V9h4v4h3z\\"></path></svg></span></button></a></li></ul>"`;
exports[`<ActionBar /> component should render the component in default state 1`] = `"<ul class=\\"MuiList-root-1 MuiList-padding-2\\"><li class=\\"MuiListItem-root-5 MuiListItem-default-8 MuiListItem-gutters-13 MuiListItem-alignItemsFlexStart-10 css-9q3x3c eux6shq0\\"><a href=\\"https://verdaccio.tld\\" target=\\"_blank\\"><button class=\\"MuiButtonBase-root-35 MuiFab-root-25 MuiFab-sizeSmall-33 css-96oxa0 eux6shq1\\" tabindex=\\"0\\" type=\\"button\\"><span class=\\"MuiFab-label-26\\"><svg class=\\"MuiSvgIcon-root-38\\" focusable=\\"false\\" viewBox=\\"0 0 24 24\\" aria-hidden=\\"true\\" role=\\"presentation\\"><path d=\\"M10 20v-6h4v6h5v-8h3L12 3 2 12h3v8z\\"></path><path fill=\\"none\\" d=\\"M0 0h24v24H0z\\"></path></svg></span></button></a><a href=\\"https://verdaccio.tld/bugs\\" target=\\"_blank\\"><button class=\\"MuiButtonBase-root-35 MuiFab-root-25 MuiFab-sizeSmall-33 css-96oxa0 eux6shq1\\" tabindex=\\"0\\" type=\\"button\\"><span class=\\"MuiFab-label-26\\"><svg class=\\"MuiSvgIcon-root-38\\" focusable=\\"false\\" viewBox=\\"0 0 24 24\\" aria-hidden=\\"true\\" role=\\"presentation\\"><path fill=\\"none\\" d=\\"M0 0h24v24H0z\\"></path><path d=\\"M20 8h-2.81c-.45-.78-1.07-1.45-1.82-1.96L17 4.41 15.59 3l-2.17 2.17C12.96 5.06 12.49 5 12 5c-.49 0-.96.06-1.41.17L8.41 3 7 4.41l1.62 1.63C7.88 6.55 7.26 7.22 6.81 8H4v2h2.09c-.05.33-.09.66-.09 1v1H4v2h2v1c0 .34.04.67.09 1H4v2h2.81c1.04 1.79 2.97 3 5.19 3s4.15-1.21 5.19-3H20v-2h-2.09c.05-.33.09-.66.09-1v-1h2v-2h-2v-1c0-.34-.04-.67-.09-1H20V8zm-6 8h-4v-2h4v2zm0-4h-4v-2h4v2z\\"></path></svg></span></button></a><button class=\\"MuiButtonBase-root-35 MuiFab-root-25 MuiFab-sizeSmall-33 css-96oxa0 eux6shq1\\" tabindex=\\"0\\" type=\\"button\\" title=\\"Download tarball\\"><span class=\\"MuiFab-label-26\\"><svg class=\\"MuiSvgIcon-root-38\\" focusable=\\"false\\" viewBox=\\"0 0 24 24\\" aria-hidden=\\"true\\" role=\\"presentation\\"><path fill=\\"none\\" d=\\"M0 0h24v24H0z\\"></path><path d=\\"M19.35 10.04C18.67 6.59 15.64 4 12 4 9.11 4 6.6 5.64 5.35 8.04 2.34 8.36 0 10.91 0 14c0 3.31 2.69 6 6 6h13c2.76 0 5-2.24 5-5 0-2.64-2.05-4.78-4.65-4.96zM17 13l-5 5-5-5h3V9h4v4h3z\\"></path></svg></span></button></li></ul>"`;
exports[`<ActionBar /> component when there is a button to download a tarball 1`] = `"<ul class=\\"MuiList-root-47 MuiList-padding-48\\"><li class=\\"MuiListItem-root-51 MuiListItem-default-54 MuiListItem-gutters-59 MuiListItem-alignItemsFlexStart-56 css-9q3x3c eux6shq0\\"><button class=\\"MuiButtonBase-root-81 MuiFab-root-71 MuiFab-sizeSmall-79 css-96oxa0 eux6shq1\\" tabindex=\\"0\\" type=\\"button\\" title=\\"Download tarball\\"><span class=\\"MuiFab-label-72\\"><svg class=\\"MuiSvgIcon-root-84\\" focusable=\\"false\\" viewBox=\\"0 0 24 24\\" aria-hidden=\\"true\\" role=\\"presentation\\"><path fill=\\"none\\" d=\\"M0 0h24v24H0z\\"></path><path d=\\"M19.35 10.04C18.67 6.59 15.64 4 12 4 9.11 4 6.6 5.64 5.35 8.04 2.34 8.36 0 10.91 0 14c0 3.31 2.69 6 6 6h13c2.76 0 5-2.24 5-5 0-2.64-2.05-4.78-4.65-4.96zM17 13l-5 5-5-5h3V9h4v4h3z\\"></path></svg></span><span class=\\"MuiTouchRipple-root-93\\"></span></button></li></ul>"`;

View File

@@ -4,18 +4,18 @@ import ListItem from '@material-ui/core/ListItem';
import colors from '../../utils/styles/colors';
export const ActionListItem = styled(ListItem)`
&& {
padding-top: 0;
padding-left: 0;
padding-right: 0;
}
`;
export const ActionListItem = styled(ListItem)({
'&&': {
paddingTop: 0,
paddingLeft: 0,
paddingRight: 0,
},
});
export const Fab = styled(MuiFab)`
&& {
background-color: ${colors.primary};
color: ${colors.white};
margin-right: 10px;
}
`;
export const Fab = styled(MuiFab)({
'&&': {
backgroundColor: colors.primary,
color: colors.white,
marginRight: '10px',
},
});

View File

@@ -20,7 +20,7 @@ describe('<Author /> component', () => {
},
};
jest.doMock('../../pages/version/Version', () => ({
jest.doMock('../../pages/Version', () => ({
DetailContextConsumer: component => {
return component.children({ packageMeta });
},
@@ -39,7 +39,7 @@ describe('<Author /> component', () => {
},
};
jest.doMock('../../pages/version/Version', () => ({
jest.doMock('../../pages/Version', () => ({
DetailContextConsumer: component => {
return component.children({ packageMeta });
},
@@ -63,7 +63,7 @@ describe('<Author /> component', () => {
},
};
jest.doMock('../../pages/version/Version', () => ({
jest.doMock('../../pages/Version', () => ({
DetailContextConsumer: component => {
return component.children({ packageMeta });
},

View File

@@ -4,7 +4,7 @@ import Avatar from '@material-ui/core/Avatar';
import List from '@material-ui/core/List';
import ListItemText from '@material-ui/core/ListItemText';
import { DetailContextConsumer } from '../../pages/version/Version';
import { DetailContextConsumer } from '../../pages/Version';
import { Heading, AuthorListItem } from './styles';
import { isEmail } from '../../utils/url';

View File

@@ -1,16 +1,17 @@
import styled from 'react-emotion';
import ListItem from '@material-ui/core/ListItem';
import Typography from '@material-ui/core/Typography';
import { fontWeight } from '../../utils/styles/sizes';
export const Heading = styled(Typography)`
&& {
font-weight: 700;
text-transform: capitalize;
}
`;
export const AuthorListItem = styled(ListItem)`
&& {
padding-left: 0;
padding-right: 0;
}
`;
export const Heading = styled(Typography)({
'&&': {
fontWeight: fontWeight.bold,
textTransform: 'capitalize',
},
});
export const AuthorListItem = styled(ListItem)({
'&&': {
paddingLeft: 0,
paddingRight: 0,
},
});

View File

@@ -8,14 +8,14 @@ export interface InputFieldProps {
color: string;
}
export const Wrapper = styled('div')`
&& {
width: 100%;
height: 32px;
position: relative;
z-index: 1;
}
`;
export const Wrapper = styled('div')({
'&&': {
width: '100%',
height: '32px',
position: 'relative',
zIndex: 1,
},
});
export const InputField: React.FC<InputFieldProps> = ({ color, ...others }) => (
<TextField
@@ -51,9 +51,9 @@ export const InputField: React.FC<InputFieldProps> = ({ color, ...others }) => (
/>
);
export const SuggestionContainer = styled(Paper)`
&& {
max-height: 500px;
overflow-y: auto;
}
`;
export const SuggestionContainer = styled(Paper)({
'&&': {
maxHeight: '500px',
overflowY: 'auto',
},
});

View File

@@ -0,0 +1,32 @@
import React, { FC } from 'react';
import Avatar from '@material-ui/core/Avatar';
import Tooltip from '@material-ui/core/Tooltip';
import { isEmail } from '../../utils/url';
export interface AvatarDeveloper {
name: string;
packageName: string;
version: string;
avatar: string;
email: string;
}
const AvatarTooltip: FC<AvatarDeveloper> = ({ name, packageName, version, avatar, email }) => {
const avatarComponent = <Avatar aria-label={name} src={avatar} />;
function renderLinkForMail(email, avatarComponent, packageName, version): JSX.Element {
if (!email || isEmail(email) === false) {
return avatarComponent;
}
return (
<a href={`mailto:${email}?subject=${packageName}@${version}`} target={'_top'}>
{avatarComponent}
</a>
);
}
return <Tooltip title={name}>{renderLinkForMail(email, avatarComponent, packageName, version)}</Tooltip>;
};
export { AvatarTooltip };

View File

@@ -0,0 +1,4 @@
import { AvatarTooltip } from './AvatarTooltip';
export { AvatarTooltip };
export default AvatarTooltip;

View File

@@ -1,26 +1,26 @@
import IconButton from '@material-ui/core/IconButton';
import styled from 'react-emotion';
export const ClipBoardCopy = styled('div')`
&& {
display: flex;
align-items: center;
justify-content: space-between;
}
`;
export const ClipBoardCopy = styled('div')({
'&&': {
display: 'flex',
alignItems: 'center',
justifyContent: 'space-between',
},
});
export const ClipBoardCopyText = styled('span')`
&& {
display: inline-block;
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
height: 21px;
}
`;
export const ClipBoardCopyText = styled('span')({
'&&': {
display: 'inline-block',
textOverflow: 'ellipsis',
overflow: 'hidden',
whiteSpace: 'nowrap',
height: '21px',
},
});
export const CopyIcon = styled(IconButton)`
&& {
margin: 0 0 0 10px;
}
`;
export const CopyIcon = styled(IconButton)({
'&&': {
margin: '0 0 0 10px',
},
});

View File

@@ -2,7 +2,7 @@ import React, { Component, Fragment, ReactElement } from 'react';
import { withRouter, RouteComponentProps } from 'react-router-dom';
import CardContent from '@material-ui/core/CardContent';
import { DetailContextConsumer, VersionPageConsumerProps } from '../../pages/version/Version';
import { DetailContextConsumer, VersionPageConsumerProps } from '../../pages/Version';
import { CardWrap, Heading, Tags, Tag } from './styles';
import NoItems from '../NoItems';

View File

@@ -2,31 +2,32 @@ import styled from 'react-emotion';
import Card from '@material-ui/core/Card';
import Typography from '@material-ui/core/Typography';
import Chip from '@material-ui/core/Chip';
import { fontWeight } from '../../utils/styles/sizes';
export const CardWrap = styled(Card)`
&& {
margin: 0 0 16px;
}
`;
export const CardWrap = styled(Card)({
'&&': {
margin: '0 0 16px',
},
});
export const Heading = styled(Typography)`
&& {
font-weight: 700;
text-transform: capitalize;
}
`;
export const Heading = styled(Typography)({
'&&': {
fontWeight: fontWeight.bold,
textTransform: 'capitalize',
},
});
export const Tags = styled('div')`
&& {
display: flex;
justify-content: start;
flex-wrap: wrap;
margin: 0 -5px;
}
`;
export const Tags = styled('div')({
'&&': {
display: 'flex',
justifyContent: 'start',
flexWrap: 'wrap',
margin: '0 -5px',
},
});
export const Tag = styled(Chip)`
&& {
margin: 5px;
}
`;
export const Tag = styled(Chip)({
'&&': {
margin: '5px',
},
});

View File

@@ -1,6 +1,6 @@
import React, { Component, ReactElement, Fragment } from 'react';
import { DetailContextConsumer, VersionPageConsumerProps } from '../../pages/version/Version';
import { DetailContextConsumer, VersionPageConsumerProps } from '../../pages/Version';
import Readme from '../Readme';
import Versions from '../Versions';
import { preventXSS } from '../../utils/sec-utils';
@@ -14,6 +14,11 @@ interface DetailContainerState {
tabPosition: number;
}
export const README_LABEL = 'Readme';
export const DEPS_LABEL = 'Dependencies';
export const VERSION_LABEL = 'Versions';
export const UPLINKS_LABEL = 'Uplinks';
class DetailContainer<P> extends Component<P, DetailContainerState> {
public state = {
tabPosition: 0,
@@ -37,10 +42,10 @@ class DetailContainer<P> extends Component<P, DetailContainerState> {
private renderListTabs(tabPosition: number): React.ReactElement<HTMLElement> {
return (
<Tabs indicatorColor={'primary'} onChange={this.handleChange} textColor={'primary'} value={tabPosition} variant={'fullWidth'}>
<Tab id={'readme-tab'} label={'Readme'} />
<Tab id={'dependencies-tab'} label={'Dependencies'} />
<Tab id={'versions-tab'} label={'Versions'} />
<Tab id={'uplinks-tab'} label={'Uplinks'} />
<Tab data-testid={'readme-tab'} id={'readme-tab'} label={README_LABEL} />
<Tab data-testid={'dependencies-tab'} id={'dependencies-tab'} label={DEPS_LABEL} />
<Tab data-testid={'versions-tab'} id={'versions-tab'} label={VERSION_LABEL} />
<Tab data-testid={'uplinks-tab'} id={'uplinks-tab'} label={UPLINKS_LABEL} />
</Tabs>
);
}

View File

@@ -1,7 +1,7 @@
import styled from 'react-emotion';
export const Content = styled('div')`
&& {
padding: 15px;
}
`;
export const Content = styled('div')({
'&&': {
padding: '15px',
},
});

View File

@@ -1,4 +1,4 @@
import React, { Component, ReactElement } from 'react';
import React, { ReactElement } from 'react';
import Card from '@material-ui/core/Card';
import CardContent from '@material-ui/core/CardContent';
@@ -12,76 +12,52 @@ import Engine from '../Engines/Engines';
import Install from '../Install';
import Repository from '../Repository/Repository';
import { DetailContextConsumer, VersionPageConsumerProps } from '../../pages/version/Version';
import { DetailContext } from '../../pages/Version';
import { TitleListItem, TitleListItemText } from './styles';
class DetailSidebar extends Component {
public render(): ReactElement<HTMLElement> {
return <DetailContextConsumer>{context => this.renderSideBar(context as VersionPageConsumerProps)}</DetailContextConsumer>;
}
const renderCopyCLI = () => <Install />;
const renderMaintainers = () => <Developers type="maintainers" />;
const renderContributors = () => <Developers type="contributors" />;
const renderRepository = () => <Repository />;
const renderAuthor = () => <Author />;
const renderEngine = () => <Engine />;
const renderDist = () => <Dist />;
const renderActionBar = () => <ActionBar />;
const renderTitle = (packageName, packageMeta) => {
return (
<List className="detail-info">
<TitleListItem alignItems="flex-start">
<TitleListItemText primary={<b>{packageName}</b>} secondary={packageMeta.latest.description} />
</TitleListItem>
</List>
);
};
private renderSideBar = ({ packageName, packageMeta }): ReactElement<HTMLElement> => {
return (
<div className={'sidebar-info'}>
<Card>
<CardContent>
{this.renderTitle(packageName, packageMeta)}
{this.renderActionBar()}
{this.renderCopyCLI()}
{this.renderRepository()}
{this.renderEngine()}
{this.renderDist()}
{this.renderAuthor()}
{this.renderMaintainers()}
{this.renderContributors()}
</CardContent>
</Card>
</div>
);
};
private renderTitle = (packageName, packageMeta) => {
return (
<List className="detail-info">
<TitleListItem alignItems="flex-start">
<TitleListItemText primary={<b>{packageName}</b>} secondary={packageMeta.latest.description} />
</TitleListItem>
</List>
);
};
private renderCopyCLI = () => {
return <Install />;
};
private renderMaintainers = () => {
return <Developers type="maintainers" />;
};
private renderContributors = () => {
return <Developers type="contributors" />;
};
private renderRepository = () => {
return <Repository />;
};
private renderAuthor = () => {
return <Author />;
};
private renderEngine = () => {
return <Engine />;
};
private renderDist = () => {
return <Dist />;
};
private renderActionBar = () => {
return <ActionBar />;
};
function renderSideBar(packageName, packageMeta): ReactElement<HTMLElement> {
return (
<div className={'sidebar-info'}>
<Card>
<CardContent>
{renderTitle(packageName, packageMeta)}
{renderActionBar()}
{renderCopyCLI()}
{renderRepository()}
{renderEngine()}
{renderDist()}
{renderAuthor()}
{renderMaintainers()}
{renderContributors()}
</CardContent>
</Card>
</div>
);
}
const DetailSidebar = () => {
const { packageName, packageMeta } = React.useContext(DetailContext);
return renderSideBar(packageName, packageMeta);
};
export default DetailSidebar;

View File

@@ -5,26 +5,26 @@ import ListItemText from '@material-ui/core/ListItemText';
import colors from '../../utils/styles/colors';
export const TitleListItem = styled(ListItem)`
&& {
padding-left: 0;
padding-right: 0;
padding-bottom: 0;
}
`;
export const TitleListItem = styled(ListItem)({
'&&': {
paddingLeft: 0,
paddingRight: 0,
paddingBottom: 0,
},
});
export const TitleListItemText = styled(ListItemText)`
&& {
padding-left: 0;
padding-right: 0;
padding-top: 8px;
}
`;
export const TitleListItemText = styled(ListItemText)({
'&&': {
paddingLeft: 0,
paddingRight: 0,
paddingTop: '8px',
},
});
export const TitleAvatar = styled(Avatar)`
&& {
color: ${colors.greySuperLight};
background-color: ${colors.primary};
text-transform: capitalize;
}
`;
export const TitleAvatar = styled(Avatar)({
'&&': {
color: colors.greySuperLight,
backgroundColor: colors.primary,
textTransform: 'capitalize',
},
});

View File

@@ -0,0 +1,104 @@
import React from 'react';
import { mount } from 'enzyme';
import Developers, { DevelopersType } from './Developers';
import { Fab } from './styles';
import { DetailContextProvider } from '../../pages/Version';
describe('test Developers', () => {
const packageMeta = {
latest: {
packageName: 'foo',
version: '1.0.0',
maintainers: [
{
name: 'dmethvin',
email: 'dave.methvin@gmail.com',
},
{
name: 'mgol',
email: 'm.goleb@gmail.com',
},
],
contributors: [
{
name: 'dmethvin',
email: 'dave.methvin@gmail.com',
},
{
name: 'mgol',
email: 'm.goleb@gmail.com',
},
],
},
};
test('should render the component with no items', () => {
const type: DevelopersType = 'maintainers';
const packageMeta = {
latest: {},
};
const wrapper = mount(
// @ts-ignore
<DetailContextProvider value={{ packageMeta }}>
<Developers type={type} />
</DetailContextProvider>
);
expect(wrapper).toMatchSnapshot();
});
test('should render the component for maintainers with items', () => {
const type: DevelopersType = 'maintainers';
const wrapper = mount(
// @ts-ignore
<DetailContextProvider value={{ packageMeta }}>
<Developers type={type} />
</DetailContextProvider>
);
expect(wrapper).toMatchSnapshot();
});
test('should render the component for contributors with items', () => {
const type: DevelopersType = 'contributors';
const wrapper = mount(
// @ts-ignore
<DetailContextProvider value={{ packageMeta }}>
<Developers type={type} />
</DetailContextProvider>
);
expect(wrapper).toMatchSnapshot();
});
test('should test onClick the component avatar', () => {
const type: DevelopersType = 'contributors';
const packageMeta = {
latest: {
packageName: 'foo',
version: '1.0.0',
contributors: [
{
name: 'dmethvin',
email: 'dave.methvin@gmail.com',
},
{
name: 'dmethvin2',
email: 'dave2.methvin@gmail.com',
},
],
},
};
const wrapper = mount(
// @ts-ignore
<DetailContextProvider value={{ packageMeta }}>
<Developers type={type} visibleMax={1} />
</DetailContextProvider>
);
const item2 = wrapper.find(Fab);
// TODO: I am not sure here how to verify the method inside the component was called.
item2.simulate('click');
});
});

View File

@@ -1,79 +1,59 @@
import React, { Component } from 'react';
import Avatar from '@material-ui/core/Avatar';
import React, { FC, Fragment } from 'react';
import Add from '@material-ui/icons/Add';
import Tooltip from '@material-ui/core/Tooltip';
import { DetailContextConsumer } from '../../pages/version/Version';
import { DetailContext } from '../../pages/Version';
import { AvatarTooltip } from '../AvatarTooltip';
import { Details, Heading, Content, Fab } from './styles';
import { isEmail } from '../../utils/url';
export type DevelopersType = 'contributors' | 'maintainers';
interface Props {
type: 'contributors' | 'maintainers';
}
interface State {
visibleDevs: number;
type: DevelopersType;
visibleMax?: number;
}
class Developers extends Component<Props, State> {
public state = {
visibleDevs: 6,
export const VISIBLE_MAX = 6;
const Developers: FC<Props> = ({ type, visibleMax }) => {
const [visibleDevs, setVisibleDevs] = React.useState<number>(visibleMax || VISIBLE_MAX);
const { packageMeta } = React.useContext(DetailContext);
const handleLoadMore = () => {
setVisibleDevs(visibleDevs + VISIBLE_MAX);
};
public render(): JSX.Element {
return (
<DetailContextConsumer>
{({ packageMeta }) => {
const { type } = this.props;
const developerType = packageMeta && packageMeta.latest[type];
if (!developerType || developerType.length === 0) return null;
return this.renderDevelopers(developerType, packageMeta);
}}
</DetailContextConsumer>
);
}
const renderDeveloperDetails = ({ name, avatar, email }, packageMeta) => {
const { name: packageName, version } = packageMeta.latest;
public handleLoadMore = () => {
this.setState(prev => ({ visibleDevs: prev.visibleDevs + 6 }));
return <AvatarTooltip avatar={avatar} email={email} name={name} packageName={packageName} version={version} />;
};
private renderDevelopers = (developers, packageMeta) => {
const { type } = this.props;
const { visibleDevs } = this.state;
const renderDevelopers = (developers, packageMeta) => {
const listVisibleDevelopers = developers.slice(0, visibleDevs);
return (
<>
<Fragment>
<Heading variant={'subheading'}>{type}</Heading>
<Content>
{developers.slice(0, visibleDevs).map(developer => (
<Details key={developer.email}>{this.renderDeveloperDetails(developer, packageMeta)}</Details>
{listVisibleDevelopers.map(developer => (
<Details key={developer.email}>{renderDeveloperDetails(developer, packageMeta)}</Details>
))}
{visibleDevs < developers.length && (
<Fab onClick={this.handleLoadMore} size="small">
<Fab onClick={handleLoadMore} size="small">
<Add />
</Fab>
)}
</Content>
</>
</Fragment>
);
};
private renderLinkForMail(email, avatarComponent, packageName, version): JSX.Element {
if (!email || isEmail(email) === false) {
return avatarComponent;
}
return (
<a href={`mailto:${email}?subject=${packageName}@${version}`} target={'_top'}>
{avatarComponent}
</a>
);
const developerList = packageMeta && packageMeta.latest[type];
if (!developerList || developerList.length === 0) {
return null;
}
private renderDeveloperDetails = ({ name, avatar, email }, packageMeta) => {
const { name: packageName, version } = packageMeta.latest;
const avatarComponent = <Avatar aria-label={name} src={avatar} />;
return <Tooltip title={name}>{this.renderLinkForMail(email, avatarComponent, packageName, version)}</Tooltip>;
};
}
return renderDevelopers(developerList, packageMeta);
};
export default Developers;

File diff suppressed because it is too large Load Diff

View File

@@ -1,34 +1,36 @@
import styled from 'react-emotion';
import Typography from '@material-ui/core/Typography';
import { default as MuiFab } from '@material-ui/core/Fab';
import colors from '../../utils/styles/colors';
import { fontWeight } from '../../utils/styles/sizes';
export const Details = styled('span')`
display: flex;
flex-direction: column;
align-items: center;
`;
export const Details = styled('span')({
display: 'flex',
flexDirection: 'column',
alignItems: 'center',
});
export const Content = styled('div')`
margin: 10px 0 10px 0;
display: flex;
flex-wrap: wrap;
> * {
margin: 5px;
}
`;
export const Content = styled('div')({
margin: '10px 0 10px 0',
display: 'flex',
flexWrap: 'wrap',
'> *': {
margin: '5px',
},
});
export const Heading = styled(Typography)`
&& {
font-weight: 700;
margin-bottom: 10px;
text-transform: capitalize;
}
`;
export const Heading = styled(Typography)({
'&&': {
fontWeight: fontWeight.bold,
marginBottom: '10px',
textTransform: 'capitalize',
},
});
export const Fab = styled(MuiFab)`
&& {
background-color: ${colors.primary};
color: ${colors.white};
}
`;
export const Fab = styled(MuiFab)({
'&&': {
backgroundColor: colors.primary,
color: colors.white,
},
});

View File

@@ -18,7 +18,7 @@ describe('<Dist /> component', () => {
license: '',
},
};
jest.doMock('../../pages/version/Version', () => ({
jest.doMock('../../pages/Version', () => ({
DetailContextConsumer: component => {
return component.children({ packageMeta });
},
@@ -41,7 +41,7 @@ describe('<Dist /> component', () => {
license: 'MIT',
},
};
jest.doMock('../../pages/version/Version', () => ({
jest.doMock('../../pages/Version', () => ({
DetailContextConsumer: component => {
return component.children({ packageMeta });
},
@@ -67,7 +67,7 @@ describe('<Dist /> component', () => {
},
},
};
jest.doMock('../../pages/version/Version', () => ({
jest.doMock('../../pages/Version', () => ({
DetailContextConsumer: component => {
return component.children({ packageMeta });
},

View File

@@ -2,7 +2,7 @@ import React, { Component } from 'react';
import List from '@material-ui/core/List';
import { DetailContextConsumer, VersionPageConsumerProps } from '../../pages/version/Version';
import { VersionPageConsumerProps, DetailContextConsumer } from '../../pages/Version';
import { Heading, DistListItem, DistChips } from './styles';
import fileSizeSI from '../../utils/file-size';
import { PackageMetaInterface } from 'types/packageMeta';

View File

@@ -5,31 +5,32 @@ import ListItem from '@material-ui/core/ListItem';
import Typography from '@material-ui/core/Typography';
import colors from '../../utils/styles/colors';
import { fontWeight } from '../../utils/styles/sizes';
export const Heading = styled(Typography)`
&& {
font-weight: 700;
text-transform: capitalize;
}
`;
export const Heading = styled(Typography)({
'&&': {
fontWeight: fontWeight.bold,
textTransform: 'capitalize',
},
});
export const DistListItem = styled(ListItem)`
&& {
padding-left: 0;
padding-right: 0;
}
`;
export const DistListItem = styled(ListItem)({
'&&': {
paddingLeft: 0,
paddingRight: 0,
},
});
export const DistChips = styled(Chip)`
&& {
margin-right: 5px;
text-transform: capitalize;
}
`;
export const DistChips = styled(Chip)({
'&&': {
marginRight: '5px',
textTransform: 'capitalize',
},
});
export const DownloadButton = styled(MuiFab)`
&& {
background-color: ${colors.primary};
color: ${colors.white};
}
`;
export const DownloadButton = styled(MuiFab)({
'&&': {
backgroundColor: colors.primary,
color: colors.white,
},
});

View File

@@ -19,7 +19,7 @@ describe('<Engines /> component', () => {
},
};
jest.doMock('../../pages/version/Version', () => ({
jest.doMock('../../pages/Version', () => ({
DetailContextConsumer: component => {
return component.children({ packageMeta });
},
@@ -35,7 +35,7 @@ describe('<Engines /> component', () => {
latest: {},
};
jest.doMock('../../pages/version/Version', () => ({
jest.doMock('../../pages/Version', () => ({
DetailContextConsumer: component => {
return component.children({ packageMeta });
},
@@ -53,7 +53,7 @@ describe('<Engines /> component', () => {
},
};
jest.doMock('../../pages/version/Version', () => ({
jest.doMock('../../pages/Version', () => ({
DetailContextConsumer: component => {
return component.children({ packageMeta });
},

View File

@@ -5,7 +5,7 @@ import Grid from '@material-ui/core/Grid';
import List from '@material-ui/core/List';
import ListItemText from '@material-ui/core/ListItemText';
import { DetailContextConsumer, VersionPageConsumerProps } from '../../pages/version/Version';
import { VersionPageConsumerProps, DetailContextConsumer } from '../../pages/Version';
import { Heading, EngineListItem } from './styles';
// @ts-ignore
import node from './img/node.png';

View File

@@ -1,16 +1,17 @@
import styled from 'react-emotion';
import ListItem from '@material-ui/core/ListItem';
import Typography from '@material-ui/core/Typography';
import { fontWeight } from '../../utils/styles/sizes';
export const Heading = styled(Typography)`
&& {
font-weight: 700;
text-transform: capitalize;
}
`;
export const Heading = styled(Typography)({
'&&': {
fontWeight: fontWeight.bold,
textTransform: 'capitalize',
},
});
export const EngineListItem = styled(ListItem)`
&& {
padding-left: 0;
}
`;
export const EngineListItem = styled(ListItem)({
'&&': {
paddingLeft: 0,
},
});

View File

@@ -1,3 +1,3 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`<Footer /> component should load the initial state of Footer component 1`] = `"<div class=\\"css-i0nj2g ezbsl480\\"><div class=\\"css-hzfs9b ezbsl481\\"><div class=\\"css-d8nsp7 ezbsl482\\"> Made with<span class=\\"css-1so4oe0 ezbsl487\\">♥</span>on<span class=\\"css-1ie354y ezbsl484\\"><svg class=\\"ezbsl485 css-1kgp95j ek145dl0\\"><title>Earth</title><use xlink:href=\\"[object Object]#earth\\"></use></svg><span class=\\"css-8631ip ezbsl486\\"><svg class=\\"ezbsl488 css-f1ndto ek145dl0\\"><title>Spain</title><use xlink:href=\\"[object Object]#spain\\"></use></svg><svg class=\\"ezbsl488 css-f1ndto ek145dl0\\"><title>Nicaragua</title><use xlink:href=\\"[object Object]#nicaragua\\"></use></svg><svg class=\\"ezbsl488 css-f1ndto ek145dl0\\"><title>India</title><use xlink:href=\\"[object Object]#india\\"></use></svg><svg class=\\"ezbsl488 css-f1ndto ek145dl0\\"><title>Brazil</title><use xlink:href=\\"[object Object]#brazil\\"></use></svg><svg class=\\"ezbsl488 css-f1ndto ek145dl0\\"><title>China</title><use xlink:href=\\"[object Object]#china\\"></use></svg><svg class=\\"ezbsl488 css-f1ndto ek145dl0\\"><title>Austria</title><use xlink:href=\\"[object Object]#austria\\"></use></svg></span></span></div><div class=\\"css-1wbzdyy ezbsl483\\">Powered by<span class=\\"ezbsl488 css-i15wza ek145dl1\\" name=\\"verdaccio\\" title=\\"Verdaccio\\"><img alt=\\"Verdaccio\\" src=\\"[object Object]\\" class=\\"css-1ncdhax ek145dl2\\"></span>/ v.1.0.0</div></div></div>"`;
exports[`<Footer /> component should load the initial state of Footer component 1`] = `"<div class=\\"css-i0nj2g ezbsl480\\"><div class=\\"css-hzfs9b ezbsl481\\"><div class=\\"css-d8nsp7 ezbsl482\\"> Made with<span class=\\"css-1so4oe0 ezbsl487\\">♥</span>on<span class=\\"css-1ie354y ezbsl484\\"><svg class=\\"ezbsl485 css-tsfgle ek145dl0\\"><title>Earth</title><use xlink:href=\\"[object Object]#earth\\"></use></svg><span class=\\"css-8631ip ezbsl486\\"><svg class=\\"ezbsl488 css-13b76ay ek145dl0\\"><title>Spain</title><use xlink:href=\\"[object Object]#spain\\"></use></svg><svg class=\\"ezbsl488 css-13b76ay ek145dl0\\"><title>Nicaragua</title><use xlink:href=\\"[object Object]#nicaragua\\"></use></svg><svg class=\\"ezbsl488 css-13b76ay ek145dl0\\"><title>India</title><use xlink:href=\\"[object Object]#india\\"></use></svg><svg class=\\"ezbsl488 css-13b76ay ek145dl0\\"><title>Brazil</title><use xlink:href=\\"[object Object]#brazil\\"></use></svg><svg class=\\"ezbsl488 css-13b76ay ek145dl0\\"><title>China</title><use xlink:href=\\"[object Object]#china\\"></use></svg><svg class=\\"ezbsl488 css-13b76ay ek145dl0\\"><title>Austria</title><use xlink:href=\\"[object Object]#austria\\"></use></svg></span></span></div><div class=\\"css-1wbzdyy ezbsl483\\">Powered by<span class=\\"ezbsl488 css-i15wza ek145dl1\\" name=\\"verdaccio\\" title=\\"Verdaccio\\"><img alt=\\"Verdaccio\\" src=\\"[object Object]\\" class=\\"css-1ncdhax ek145dl2\\"></span>/ v.1.0.0</div></div></div>"`;

View File

@@ -3,15 +3,15 @@ import mq from '../../utils/styles/media';
import Icon from '../Icon/Icon';
import colors from '../../utils/styles/colors';
export const Wrapper = styled('div')`
&& {
background: ${colors.snow};
border-top: 1px solid ${colors.greyGainsboro};
color: ${colors.nobel01};
font-size: 14px;
padding: 20px;
}
`;
export const Wrapper = styled('div')({
'&&': {
background: colors.snow,
borderTop: `1px solid ${colors.greyGainsboro}`,
color: colors.nobel01,
fontSize: '14px',
padding: '20px',
},
});
export const Inner = styled('div')`
&& {
@@ -50,24 +50,24 @@ export const Left = styled('div')`
}
`;
export const Right = styled(Left)`
&& {
display: flex;
}
`;
export const Right = styled(Left)({
'&&': {
display: 'flex',
},
});
export const ToolTip = styled('span')`
&& {
position: relative;
height: 18px;
}
`;
export const ToolTip = styled('span')({
'&&': {
position: 'relative',
height: '18px',
},
});
export const Earth = styled(Icon)`
&& {
padding: 0 10px;
}
`;
export const Earth = styled(Icon)({
'&&': {
padding: '0 10px',
},
});
export const Flags = styled('span')`
&& {
@@ -96,17 +96,17 @@ export const Flags = styled('span')`
}
`;
export const Love = styled('span')`
&& {
color: ${colors.love};
padding: 0 5px;
}
`;
export const Love = styled('span')({
'&&': {
color: colors.love,
padding: '0 5px',
},
});
export const Flag = styled(Icon)`
&& {
padding: 0 5px;
}
`;
export const Flag = styled(Icon)({
'&&': {
padding: '0 5px',
},
});
export const Logo = Flag;

View File

@@ -1,5 +1,5 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`<Header /> component with logged in state should load the component in logged in state 1`] = `"<div><header class=\\"MuiPaper-root-10 MuiPaper-elevation4-16 MuiAppBar-root-1 MuiAppBar-positionStatic-5 MuiAppBar-colorPrimary-8 css-rfunvc e1jf5lit8\\"><div class=\\"MuiToolbar-root-37 MuiToolbar-regular-39 MuiToolbar-gutters-38 css-1pwdmmq e1jf5lit0\\"><div class=\\"MuiToolbar-root-37 MuiToolbar-regular-39 MuiToolbar-gutters-38 css-1vacr9s e1jf5lit3\\"><a class=\\"css-1dk30lc\\" href=\\"/\\"><div class=\\"css-1tnu3ib em793ed0\\"></div></a></div><div class=\\"MuiToolbar-root-37 MuiToolbar-regular-39 MuiToolbar-gutters-38 css-m61s5i e1jf5lit2\\"><a href=\\"https://verdaccio.org/docs/en/installation\\" target=\\"_blank\\" class=\\"MuiButtonBase-root-55 MuiIconButton-root-49 MuiIconButton-colorInherit-50\\" tabindex=\\"0\\" role=\\"button\\" title=\\"Documentation\\"><span class=\\"MuiIconButton-label-54\\"><svg class=\\"MuiSvgIcon-root-58\\" focusable=\\"false\\" viewBox=\\"0 0 24 24\\" aria-hidden=\\"true\\" role=\\"presentation\\"><path fill=\\"none\\" d=\\"M0 0h24v24H0z\\"></path><path d=\\"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 17h-2v-2h2v2zm2.07-7.75l-.9.92C13.45 12.9 13 13.5 13 15h-2v-.5c0-1.1.45-2.1 1.17-2.83l1.24-1.26c.37-.36.59-.86.59-1.41 0-1.1-.9-2-2-2s-2 .9-2 2H8c0-2.21 1.79-4 4-4s4 1.79 4 4c0 .88-.36 1.68-.93 2.25z\\"></path></svg></span></a><button class=\\"MuiButtonBase-root-55 MuiIconButton-root-49 MuiIconButton-colorInherit-50\\" tabindex=\\"0\\" type=\\"button\\" id=\\"header--button-registryInfo\\" title=\\"Registry Information\\"><span class=\\"MuiIconButton-label-54\\"><svg class=\\"MuiSvgIcon-root-58\\" focusable=\\"false\\" viewBox=\\"0 0 24 24\\" aria-hidden=\\"true\\" role=\\"presentation\\"><path fill=\\"none\\" d=\\"M0 0h24v24H0z\\"></path><path d=\\"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-6h2v6zm0-8h-2V7h2v2z\\"></path></svg></span></button><button class=\\"MuiButtonBase-root-55 MuiIconButton-root-49 MuiIconButton-colorInherit-50\\" tabindex=\\"0\\" type=\\"button\\" id=\\"header--button-account\\"><span class=\\"MuiIconButton-label-54\\"><svg class=\\"MuiSvgIcon-root-58\\" focusable=\\"false\\" viewBox=\\"0 0 24 24\\" aria-hidden=\\"true\\" role=\\"presentation\\"><path d=\\"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 3c1.66 0 3 1.34 3 3s-1.34 3-3 3-3-1.34-3-3 1.34-3 3-3zm0 14.2c-2.5 0-4.71-1.28-6-3.22.03-1.99 4-3.08 6-3.08 1.99 0 5.97 1.09 6 3.08-1.29 1.94-3.5 3.22-6 3.22z\\"></path><path fill=\\"none\\" d=\\"M0 0h24v24H0z\\"></path></svg></span></button></div></div></header></div>"`;
exports[`<Header /> component with logged in state should load the component in logged in state 1`] = `"<div><header class=\\"MuiPaper-root-10 MuiPaper-elevation4-16 MuiAppBar-root-1 MuiAppBar-positionStatic-5 MuiAppBar-colorPrimary-8 css-rfunvc e1jf5lit8\\"><div class=\\"MuiToolbar-root-37 MuiToolbar-regular-39 MuiToolbar-gutters-38 css-1pwdmmq e1jf5lit0\\"><div class=\\"MuiToolbar-root-37 MuiToolbar-regular-39 MuiToolbar-gutters-38 css-1vacr9s e1jf5lit3\\"><a class=\\"css-1dk30lc\\" href=\\"/\\"><div class=\\"css-1sifsqk em793ed0\\"></div></a></div><div class=\\"MuiToolbar-root-37 MuiToolbar-regular-39 MuiToolbar-gutters-38 css-m61s5i e1jf5lit2\\"><a href=\\"https://verdaccio.org/docs/en/installation\\" target=\\"_blank\\" class=\\"MuiButtonBase-root-55 MuiIconButton-root-49 MuiIconButton-colorInherit-50\\" tabindex=\\"0\\" role=\\"button\\" title=\\"Documentation\\"><span class=\\"MuiIconButton-label-54\\"><svg class=\\"MuiSvgIcon-root-58\\" focusable=\\"false\\" viewBox=\\"0 0 24 24\\" aria-hidden=\\"true\\" role=\\"presentation\\"><path fill=\\"none\\" d=\\"M0 0h24v24H0z\\"></path><path d=\\"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 17h-2v-2h2v2zm2.07-7.75l-.9.92C13.45 12.9 13 13.5 13 15h-2v-.5c0-1.1.45-2.1 1.17-2.83l1.24-1.26c.37-.36.59-.86.59-1.41 0-1.1-.9-2-2-2s-2 .9-2 2H8c0-2.21 1.79-4 4-4s4 1.79 4 4c0 .88-.36 1.68-.93 2.25z\\"></path></svg></span></a><button class=\\"MuiButtonBase-root-55 MuiIconButton-root-49 MuiIconButton-colorInherit-50\\" tabindex=\\"0\\" type=\\"button\\" id=\\"header--button-registryInfo\\" title=\\"Registry Information\\"><span class=\\"MuiIconButton-label-54\\"><svg class=\\"MuiSvgIcon-root-58\\" focusable=\\"false\\" viewBox=\\"0 0 24 24\\" aria-hidden=\\"true\\" role=\\"presentation\\"><path fill=\\"none\\" d=\\"M0 0h24v24H0z\\"></path><path d=\\"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-6h2v6zm0-8h-2V7h2v2z\\"></path></svg></span></button><button class=\\"MuiButtonBase-root-55 MuiIconButton-root-49 MuiIconButton-colorInherit-50\\" tabindex=\\"0\\" type=\\"button\\" id=\\"header--button-account\\"><span class=\\"MuiIconButton-label-54\\"><svg class=\\"MuiSvgIcon-root-58\\" focusable=\\"false\\" viewBox=\\"0 0 24 24\\" aria-hidden=\\"true\\" role=\\"presentation\\"><path d=\\"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 3c1.66 0 3 1.34 3 3s-1.34 3-3 3-3-1.34-3-3 1.34-3 3-3zm0 14.2c-2.5 0-4.71-1.28-6-3.22.03-1.99 4-3.08 6-3.08 1.99 0 5.97 1.09 6 3.08-1.29 1.94-3.5 3.22-6 3.22z\\"></path><path fill=\\"none\\" d=\\"M0 0h24v24H0z\\"></path></svg></span></button></div></div></header></div>"`;
exports[`<Header /> component with logged out state should load the component in logged out state 1`] = `"<div><header class=\\"MuiPaper-root-10 MuiPaper-elevation4-16 MuiAppBar-root-1 MuiAppBar-positionStatic-5 MuiAppBar-colorPrimary-8 css-rfunvc e1jf5lit8\\"><div class=\\"MuiToolbar-root-37 MuiToolbar-regular-39 MuiToolbar-gutters-38 css-1pwdmmq e1jf5lit0\\"><div class=\\"MuiToolbar-root-37 MuiToolbar-regular-39 MuiToolbar-gutters-38 css-1vacr9s e1jf5lit3\\"><a class=\\"css-1dk30lc\\" href=\\"/\\"><div class=\\"css-1tnu3ib em793ed0\\"></div></a></div><div class=\\"MuiToolbar-root-37 MuiToolbar-regular-39 MuiToolbar-gutters-38 css-m61s5i e1jf5lit2\\"><a href=\\"https://verdaccio.org/docs/en/installation\\" target=\\"_blank\\" class=\\"MuiButtonBase-root-55 MuiIconButton-root-49 MuiIconButton-colorInherit-50\\" tabindex=\\"0\\" role=\\"button\\" title=\\"Documentation\\"><span class=\\"MuiIconButton-label-54\\"><svg class=\\"MuiSvgIcon-root-58\\" focusable=\\"false\\" viewBox=\\"0 0 24 24\\" aria-hidden=\\"true\\" role=\\"presentation\\"><path fill=\\"none\\" d=\\"M0 0h24v24H0z\\"></path><path d=\\"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 17h-2v-2h2v2zm2.07-7.75l-.9.92C13.45 12.9 13 13.5 13 15h-2v-.5c0-1.1.45-2.1 1.17-2.83l1.24-1.26c.37-.36.59-.86.59-1.41 0-1.1-.9-2-2-2s-2 .9-2 2H8c0-2.21 1.79-4 4-4s4 1.79 4 4c0 .88-.36 1.68-.93 2.25z\\"></path></svg></span></a><button class=\\"MuiButtonBase-root-55 MuiIconButton-root-49 MuiIconButton-colorInherit-50\\" tabindex=\\"0\\" type=\\"button\\" id=\\"header--button-registryInfo\\" title=\\"Registry Information\\"><span class=\\"MuiIconButton-label-54\\"><svg class=\\"MuiSvgIcon-root-58\\" focusable=\\"false\\" viewBox=\\"0 0 24 24\\" aria-hidden=\\"true\\" role=\\"presentation\\"><path fill=\\"none\\" d=\\"M0 0h24v24H0z\\"></path><path d=\\"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-6h2v6zm0-8h-2V7h2v2z\\"></path></svg></span></button><button class=\\"MuiButtonBase-root-55 MuiButton-root-85 MuiButton-text-87 MuiButton-flat-90 MuiButton-colorInherit-106\\" tabindex=\\"0\\" type=\\"button\\" id=\\"header--button-login\\"><span class=\\"MuiButton-label-86\\">Login</span></button></div></div></header></div>"`;
exports[`<Header /> component with logged out state should load the component in logged out state 1`] = `"<div><header class=\\"MuiPaper-root-10 MuiPaper-elevation4-16 MuiAppBar-root-1 MuiAppBar-positionStatic-5 MuiAppBar-colorPrimary-8 css-rfunvc e1jf5lit8\\"><div class=\\"MuiToolbar-root-37 MuiToolbar-regular-39 MuiToolbar-gutters-38 css-1pwdmmq e1jf5lit0\\"><div class=\\"MuiToolbar-root-37 MuiToolbar-regular-39 MuiToolbar-gutters-38 css-1vacr9s e1jf5lit3\\"><a class=\\"css-1dk30lc\\" href=\\"/\\"><div class=\\"css-1sifsqk em793ed0\\"></div></a></div><div class=\\"MuiToolbar-root-37 MuiToolbar-regular-39 MuiToolbar-gutters-38 css-m61s5i e1jf5lit2\\"><a href=\\"https://verdaccio.org/docs/en/installation\\" target=\\"_blank\\" class=\\"MuiButtonBase-root-55 MuiIconButton-root-49 MuiIconButton-colorInherit-50\\" tabindex=\\"0\\" role=\\"button\\" title=\\"Documentation\\"><span class=\\"MuiIconButton-label-54\\"><svg class=\\"MuiSvgIcon-root-58\\" focusable=\\"false\\" viewBox=\\"0 0 24 24\\" aria-hidden=\\"true\\" role=\\"presentation\\"><path fill=\\"none\\" d=\\"M0 0h24v24H0z\\"></path><path d=\\"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 17h-2v-2h2v2zm2.07-7.75l-.9.92C13.45 12.9 13 13.5 13 15h-2v-.5c0-1.1.45-2.1 1.17-2.83l1.24-1.26c.37-.36.59-.86.59-1.41 0-1.1-.9-2-2-2s-2 .9-2 2H8c0-2.21 1.79-4 4-4s4 1.79 4 4c0 .88-.36 1.68-.93 2.25z\\"></path></svg></span></a><button class=\\"MuiButtonBase-root-55 MuiIconButton-root-49 MuiIconButton-colorInherit-50\\" tabindex=\\"0\\" type=\\"button\\" id=\\"header--button-registryInfo\\" title=\\"Registry Information\\"><span class=\\"MuiIconButton-label-54\\"><svg class=\\"MuiSvgIcon-root-58\\" focusable=\\"false\\" viewBox=\\"0 0 24 24\\" aria-hidden=\\"true\\" role=\\"presentation\\"><path fill=\\"none\\" d=\\"M0 0h24v24H0z\\"></path><path d=\\"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-6h2v6zm0-8h-2V7h2v2z\\"></path></svg></span></button><button class=\\"MuiButtonBase-root-55 MuiButton-root-85 MuiButton-text-87 MuiButton-flat-90 MuiButton-colorInherit-106\\" tabindex=\\"0\\" type=\\"button\\" id=\\"header--button-login\\"><span class=\\"MuiButton-label-86\\">Login</span></button></div></div></header></div>"`;

View File

@@ -6,67 +6,67 @@ import IconButton from '@material-ui/core/IconButton';
import colors from '../../utils/styles/colors';
import mq from '../../utils/styles/media';
export const InnerNavBar = styled(Toolbar)`
&& {
justify-content: space-between;
align-items: center;
padding: 0 15px;
}
`;
export const InnerNavBar = styled(Toolbar)({
'&&': {
justifyContent: 'space-between',
alignItems: 'center',
padding: '0 15px',
},
});
export const Greetings = styled('span')`
&& {
margin: 0 5px 0 0;
}
`;
export const Greetings = styled('span')({
'&&': {
margin: '0 5px 0 0',
},
});
export const RightSide = styled(Toolbar)`
&& {
display: flex;
padding: 0;
}
`;
export const RightSide = styled(Toolbar)({
'&&': {
display: 'flex',
padding: 0,
},
});
export const LeftSide = styled(RightSide)`
&& {
flex: 1;
}
`;
export const LeftSide = styled(RightSide)({
'&&': {
flex: 1,
},
});
export const MobileNavBar = styled('div')`
&& {
align-items: center;
display: flex;
border-bottom: 1px solid ${colors.greyLight};
padding: 8px;
position: relative;
}
`;
export const MobileNavBar = styled('div')({
'&&': {
alignItems: 'center',
display: 'flex',
borderBottom: `1px solid ${colors.greyLight}`,
padding: '8px',
position: 'relative',
},
});
export const InnerMobileNavBar = styled('div')`
&& {
border-radius: 4px;
background-color: ${colors.greyLight};
color: ${colors.white};
width: 100%;
padding: 0px 5px;
margin: 0 10px 0 0;
}
`;
export const InnerMobileNavBar = styled('div')({
'&&': {
borderRadius: '4px',
backgroundColor: colors.greyLight,
color: colors.white,
width: '100%',
padding: '0 5px',
margin: '0 10px 0 0',
},
});
export const IconSearchButton = styled(IconButton)`
&& {
display: block;
}
`;
export const IconSearchButton = styled(IconButton)({
'&&': {
display: 'block',
},
});
export const SearchWrapper = styled('div')`
&& {
display: none;
max-width: 393px;
width: 100%;
}
`;
export const SearchWrapper = styled('div')({
'&&': {
display: 'none',
maxWidth: '393px',
width: '100%',
},
});
export const NavBar = styled(AppBar)`
&& {

View File

@@ -2,15 +2,15 @@ import Card from '@material-ui/core/Card';
import Typography from '@material-ui/core/Typography';
import styled from 'react-emotion';
export const CardStyled = styled(Card)`
&& {
width: 600px;
margin: auto;
}
`;
export const CardStyled = styled(Card)({
'&&': {
width: '600px',
margin: 'auto',
},
});
export const HelpTitle = styled(Typography)`
&& {
margin-bottom: 20px;
}
`;
export const HelpTitle = styled(Typography)({
'&&': {
marginBottom: '20px',
},
});

View File

@@ -1,3 +1,3 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`<Icon /> component should render the component in default state 1`] = `"<svg class=\\"css-3skwlp ek145dl0\\"><title>Austria</title><use xlink:href=\\"[object Object]#austria\\"></use></svg>"`;
exports[`<Icon /> component should render the component in default state 1`] = `"<svg class=\\"css-snirlv ek145dl0\\"><title>Austria</title><use xlink:href=\\"[object Object]#austria\\"></use></svg>"`;

View File

@@ -21,7 +21,7 @@ const getSize = (size: Breakpoint): string => {
const commonStyle = ({ size = 'sm' as Breakpoint, pointer, modifiers = null }): string => css`
&& {
display: inline-block;
cursor: ${pointer ? 'pointer' : 'default'};
cursor: ${pointer ? 'pointer' : 'Developers'};
${getSize(size)};
${modifiers && modifiers};
}
@@ -48,9 +48,9 @@ export const ImgWrapper: StyledOtherComponent<
}
`;
export const Img = styled('img')`
&& {
width: 100%;
height: auto;
}
`;
export const Img = styled('img')({
'&&': {
width: '100%',
height: 'auto',
},
});

View File

@@ -2,8 +2,8 @@ import List from '@material-ui/core/List';
import ListItemText from '@material-ui/core/ListItemText';
import React, { Component } from 'react';
// @ts-ignore
import { DetailContextConsumer, VersionPageConsumerProps } from '../../pages/version/Version';
import { DetailContextConsumer, VersionPageConsumerProps } from '../../pages/Version';
import CopyToClipBoard from '../CopyToClipBoard';
// logos of package managers

View File

@@ -2,22 +2,23 @@ import Avatar from '@material-ui/core/Avatar';
import ListItem from '@material-ui/core/ListItem';
import Typography from '@material-ui/core/Typography';
import styled from 'react-emotion';
import { fontWeight } from '../../utils/styles/sizes';
export const Heading = styled(Typography)`
&& {
font-weight: 700;
text-transform: capitalize;
}
`;
export const Heading = styled(Typography)({
'&&': {
fontWeight: fontWeight.bold,
textTransform: 'capitalize',
},
});
export const InstallItem = styled(ListItem)`
&& {
padding: 0;
}
`;
export const InstallItem = styled(ListItem)({
'&&': {
padding: 0,
},
});
export const PackageMangerAvatar = styled(Avatar)`
&& {
border-radius: 0px;
}
`;
export const PackageMangerAvatar = styled(Avatar)({
'&&': {
borderRadius: '0px',
},
});

View File

@@ -1,14 +1,15 @@
import styled, { css } from 'react-emotion';
import colors from '../../utils/styles/colors';
export const Content = styled('div')`
&& {
background-color: #ffffff;
flex: 1;
display: flex;
position: relative;
flex-direction: column;
}
`;
export const Content = styled('div')({
'&&': {
backgroundColor: colors.white,
flex: 1,
display: 'flex',
position: 'relative',
flexDirection: 'column',
},
});
export const Container = styled('div')`
&& {

View File

@@ -6,7 +6,7 @@ import Spinner from '../Spinner';
import { Wrapper, Badge } from './styles';
const Loading: React.FC = () => (
<Wrapper>
<Wrapper data-testid="loading">
<Badge>
<Logo size={Size.Big} />
</Badge>

View File

@@ -1,3 +1,3 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`<Loading /> component should render the component in default state 1`] = `"<div class=\\"css-1221txa eimgwje0\\"><div class=\\"css-bxochs eimgwje1\\"><div class=\\"css-kt1gx0 em793ed0\\"></div></div><div class=\\"css-vqrgi e1ag4h8b0\\"><div class=\\"MuiCircularProgress-root-1 MuiCircularProgress-colorPrimary-4 MuiCircularProgress-indeterminate-3 css-15gl0ho e1ag4h8b1\\" style=\\"width:50px;height:50px\\" role=\\"progressbar\\"><svg class=\\"MuiCircularProgress-svg-6\\" viewBox=\\"22 22 44 44\\"><circle class=\\"MuiCircularProgress-circle-7 MuiCircularProgress-circleIndeterminate-9\\" cx=\\"44\\" cy=\\"44\\" r=\\"20.2\\" fill=\\"none\\" stroke-width=\\"3.6\\"></circle></svg></div></div></div>"`;
exports[`<Loading /> component should render the component in default state 1`] = `"<div data-testid=\\"loading\\" class=\\"css-1221txa eimgwje0\\"><div class=\\"css-bxochs eimgwje1\\"><div class=\\"css-ge0nak em793ed0\\"></div></div><div class=\\"css-vqrgi e1ag4h8b0\\"><div class=\\"MuiCircularProgress-root-1 MuiCircularProgress-colorPrimary-4 MuiCircularProgress-indeterminate-3 css-15gl0ho e1ag4h8b1\\" style=\\"width:50px;height:50px\\" role=\\"progressbar\\"><svg class=\\"MuiCircularProgress-svg-6\\" viewBox=\\"22 22 44 44\\"><circle class=\\"MuiCircularProgress-circle-7 MuiCircularProgress-circleIndeterminate-9\\" cx=\\"44\\" cy=\\"44\\" r=\\"20.2\\" fill=\\"none\\" stroke-width=\\"3.6\\"></circle></svg></div></div></div>"`;

View File

@@ -5,16 +5,16 @@ export const loginDialog = css({
minWidth: '300px',
});
export const loginError = css`
background-color: ${colors.red} !important;
min-width: inherit !important;
margin-bottom: 10px !important;
`;
export const loginError = css({
backgroundColor: `${colors.red} !important`,
minWidth: 'inherit !important',
marginBottom: '10px !important',
});
export const loginErrorMsg = css`
display: flex;
align-items: center;
`;
export const loginErrorMsg = css({
display: 'flex',
alignItems: 'center',
});
export const loginIcon = css({
opacity: 0.9,

View File

@@ -23,6 +23,7 @@ const StyledLogo = styled('div')<Props>`
background-repeat: no-repeat;
width: ${({ size }) => size};
height: ${({ size }) => size};
}
`;
const Logo: React.FC<Props> = ({ size = Size.Small }) => {
return <StyledLogo size={size} />;

View File

@@ -1,3 +1,3 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`<Logo /> component should render the component in default state 1`] = `"<div class=\\"css-1tnu3ib em793ed0\\"></div>"`;
exports[`<Logo /> component should render the component in default state 1`] = `"<div class=\\"css-1sifsqk em793ed0\\"></div>"`;

View File

@@ -1,46 +1,43 @@
import ListItem from '@material-ui/core/ListItem';
import Typography from '@material-ui/core/Typography';
import withWidth, { isWidthUp } from '@material-ui/core/withWidth';
import React from 'react';
import React, { useCallback } from 'react';
import { RouteComponentProps, withRouter } from 'react-router-dom';
import PackageImg from './img/package.svg';
import { Card, EmptyPackage, Heading, Inner, List, Wrapper } from './styles';
import { Breakpoint } from '@material-ui/core/styles/createBreakpoints';
export const NOT_FOUND_TEXT = "Sorry, we couldn't find it...";
export const NOT_FOUND_TEXT = `Sorry, we couldn't find it...`;
export const LABEL_NOT_FOUND = `The page you're looking for doesn't exist.`;
export const LABEL_FOOTER_NOT_FOUND = 'Perhaps these links will help find what you are looking for:';
export type NotFoundProps = RouteComponentProps & { width: Breakpoint; history };
const NotFound: React.FC<NotFoundProps> = ({ history, width }) => {
const handleGoTo = (to: string): (() => void | undefined) => () => {
history.push(to);
};
const HOME_LABEL = 'Home';
const handleGoBack = (): ((e: React.MouseEvent<HTMLElement, MouseEvent>) => void | undefined) => () => {
history.goBack();
};
const renderSubTitle = (): JSX.Element => (
<Typography variant="subtitle1">
<div>{LABEL_NOT_FOUND}</div>
<div>{LABEL_FOOTER_NOT_FOUND}</div>
</Typography>
);
const NotFound: React.FC<NotFoundProps> = ({ history, width }) => {
const handleGomHome = useCallback(() => {
history.push('/');
}, [history]);
const renderList = (): JSX.Element => (
<List>
<ListItem button={true} divider={true} onClick={handleGoTo('/')}>
{'Home'}
</ListItem>
<ListItem button={true} divider={true} onClick={handleGoBack()}>
{'Back'}
<ListItem button={true} divider={true} onClick={handleGomHome}>
{HOME_LABEL}
</ListItem>
</List>
);
const renderSubTitle = (): JSX.Element => (
<Typography variant="subtitle1">
<div>{"The page you're looking for doesn't exist."}</div>
<div>{'Perhaps these links will help find what you are looking for:'}</div>
</Typography>
);
return (
<Wrapper>
<Wrapper data-testid="404">
<Inner>
<EmptyPackage alt="404 - Page not found" src={PackageImg} />
<Heading className="not-found-text" variant={isWidthUp('sm', width) ? 'h2' : 'h4'}>

View File

@@ -3,39 +3,39 @@ import { default as MuiList } from '@material-ui/core/List';
import Typography from '@material-ui/core/Typography';
import styled from 'react-emotion';
export const Wrapper = styled('div')`
display: flex;
align-items: center;
flex-direction: column;
justify-content: center;
flex: 1;
padding: 16px;
`;
export const Wrapper = styled('div')({
display: 'flex',
alignItems: 'center',
flexDirection: 'column',
justifyContent: 'center',
flex: 1,
padding: '16px',
});
export const Inner = styled('div')`
max-width: 650px;
display: flex;
flex-direction: column;
`;
export const Inner = styled('div')({
maxWidth: '650px',
display: 'flex',
flexDirection: 'column',
});
export const EmptyPackage = styled('img')`
width: 150px;
margin: 0 auto;
`;
export const EmptyPackage = styled('img')({
width: '150px',
margin: '0 auto',
});
export const Heading = styled(Typography)`
&& {
color: #4b5e40;
}
`;
export const Heading = styled(Typography)({
'&&': {
color: '#4b5e40',
},
});
export const List = styled(MuiList)`
&& {
padding: 0;
color: #4b5e40;
}
`;
export const List = styled(MuiList)({
'&&': {
padding: 0,
color: '#4b5e40',
},
});
export const Card = styled(MuiCard)`
margin-top: 24px;
`;
export const Card = styled(MuiCard)({
marginTop: '24px',
});

View File

@@ -13,6 +13,7 @@ import { breakpoints } from '../../utils/styles/media';
import Ico from '../Icon';
import Label from '../Label';
import colors from '../../utils/styles/colors';
import { fontWeight } from '../../utils/styles/sizes';
export const OverviewItem = styled('span')`
&& {
@@ -34,57 +35,57 @@ export const OverviewItem = styled('span')`
}
`;
export const Icon = styled(Ico)`
&& {
margin: 2px 10px 0px 0;
fill: ${colors.greyLight2};
}
`;
export const Icon = styled(Ico)({
'&&': {
margin: '2px 10px 0 0',
fill: colors.greyLight2,
},
});
export const Published = styled('span')`
&& {
color: ${colors.greyLight2};
margin: 0px 5px 0px 0px;
}
`;
export const Published = styled('span')({
'&&': {
color: colors.greyLight2,
margin: '0 5px 0 0',
},
});
// @ts-ignore
export const Text = styled(Label)`
&& {
font-size: 12px;
font-weight: 500;
color: ${colors.greyLight2};
}
`;
export const Text = styled(Label)({
'&&': {
fontSize: '12px',
fontWeight: fontWeight.semiBold,
color: colors.greyLight2,
},
});
export const Details = styled('span')`
&& {
margin-left: 5px;
line-height: 1.5;
display: flex;
flex-direction: column;
}
`;
export const Details = styled('span')({
'&&': {
marginLeft: '5px',
lineHeight: 1.5,
display: 'flex',
flexDirection: 'column',
},
});
export const Author = styled('div')`
&& {
display: flex;
align-items: center;
}
`;
export const Author = styled('div')({
'&&': {
display: 'flex',
alignItems: 'center',
},
});
export const Avatar = styled(Photo)`
&& {
width: 20px;
height: 20px;
}
`;
export const Avatar = styled(Photo)({
'&&': {
width: '20px',
height: '20px',
},
});
export const WrapperLink = styled(Link)`
&& {
text-decoration: none;
}
`;
export const WrapperLink = styled(Link)({
'&&': {
textDecoration: 'none',
},
});
export const PackageTitle = styled('span')`
&& {
@@ -106,31 +107,31 @@ export const PackageTitle = styled('span')`
}
`;
export const GridRightAligned = styled(Grid)`
&& {
text-align: right;
}
`;
export const GridRightAligned = styled(Grid)({
'&&': {
textAlign: 'right',
},
});
export const PackageList = styled(List)`
&& {
padding: 12px 0 12px 0;
export const PackageList = styled(List)({
'&&': {
padding: '12px 0 12px 0',
&:hover {
background-color: ${colors.greyLight3};
}
}
`;
'&:hover': {
backgroundColor: colors.greyLight3,
},
},
});
export const IconButton = styled(MuiIconButton)`
&& {
padding: 6px;
export const IconButton = styled(MuiIconButton)({
'&&': {
padding: '6px',
svg {
font-size: 16px;
}
}
`;
svg: {
fontSize: '16px',
},
},
});
export const TagContainer = styled('span')`
&& {
@@ -143,20 +144,20 @@ export const TagContainer = styled('span')`
}
`;
export const PackageListItem = styled(ListItem)`
&& {
padding-top: 0;
}
`;
export const PackageListItem = styled(ListItem)({
'&&': {
paddingTop: 0,
},
});
export const PackageListItemText = styled(ListItemText)`
&& {
padding-right: 0;
}
`;
export const PackageListItemText = styled(ListItemText)({
'&&': {
paddingRight: 0,
},
});
export const Description = styled(Typography)`
color: ${colors.greyDark2};
font-size: 14px;
padding-right: 0;
`;
export const Description = styled(Typography)({
color: colors.greyDark2,
fontSize: '14px',
paddingRight: 0,
});

View File

@@ -1,7 +1,7 @@
import styled from 'react-emotion';
export const CommandContainer = styled('div')`
&& {
padding-top: 20px;
}
`;
export const CommandContainer = styled('div')({
'&&': {
paddingTop: '20px',
},
});

View File

@@ -4,16 +4,16 @@ import DialogContent from '@material-ui/core/DialogContent';
import colors from '../../utils/styles/colors';
import { fontSize } from '../../utils/styles/sizes';
export const Title = styled(DialogTitle)`
&& {
background-color: ${colors.primary};
color: ${colors.white};
font-size: ${fontSize.lg};
}
`;
export const Title = styled(DialogTitle)({
'&&': {
backgroundColor: colors.primary,
color: colors.white,
fontSize: fontSize.lg,
},
});
export const Content = styled(DialogContent)`
&& {
padding: 0 24px;
}
`;
export const Content = styled(DialogContent)({
'&&': {
padding: '0 24px',
},
});

View File

@@ -1,11 +1,68 @@
import React from 'react';
import { shallow } from 'enzyme';
import Repository from './Repository';
jest.mock('./img/git.png', () => '');
describe('<Repository /> component', () => {
beforeEach(() => {
jest.resetModules();
});
test('should render the component in default state', () => {
const packageMeta = {
latest: {
repository: {
type: 'git',
url: 'git+https://github.com/verdaccio/ui.git',
},
},
};
jest.doMock('../../pages/Version', () => ({
DetailContextConsumer: component => {
return component.children({ packageMeta });
},
}));
const Repository = require('./Repository').default;
const wrapper = shallow(<Repository />);
expect(wrapper.html()).toMatchSnapshot();
});
test('should render the component in with no repository data', () => {
const packageMeta = {
latest: {},
};
jest.doMock('../../pages/Version', () => ({
DetailContextConsumer: component => {
return component.children({ packageMeta });
},
}));
const Repository = require('./Repository').default;
const wrapper = shallow(<Repository />);
expect(wrapper.html()).toEqual('');
});
test('should render the component in with invalid url', () => {
const packageMeta = {
latest: {
repository: {
type: 'git',
url: 'git://github.com/verdaccio/ui.git',
},
},
};
jest.doMock('../../pages/Version', () => ({
DetailContextConsumer: component => {
return component.children({ packageMeta });
},
}));
const Repository = require('./Repository').default;
const wrapper = shallow(<Repository />);
expect(wrapper.html()).toEqual('');
});
});

View File

@@ -5,7 +5,7 @@ import Avatar from '@material-ui/core/Avatar';
import List from '@material-ui/core/List';
import ListItemText from '@material-ui/core/ListItemText';
import { DetailContextConsumer } from '../../pages/version/Version';
import { DetailContextConsumer } from '../../pages/Version';
import CopyToClipBoard from '../CopyToClipBoard';
import { Heading, GithubLink, RepositoryListItem } from './styles';

View File

@@ -1,3 +1,3 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`<Repository /> component should render the component in default state 1`] = `""`;
exports[`<Repository /> component should render the component in default state 1`] = `"<ul class=\\"MuiList-root-1 MuiList-dense-3 MuiList-padding-2 MuiList-subheader-4\\"><h3 class=\\"MuiTypography-root-5 MuiTypography-subheading-12 css-hyrz44 e1wmjxnh0\\">Repository</h3><li class=\\"MuiListItem-root-41 MuiListItem-default-44 MuiListItem-dense-45 MuiListItem-gutters-49 css-z8a2h0 e1wmjxnh4\\"><div class=\\"MuiAvatar-root-53 MuiAvatar-colorDefault-54\\"></div><div class=\\"MuiListItemText-root-56 MuiListItemText-dense-58\\"><span class=\\"MuiTypography-root-5 MuiTypography-subheading-12 MuiListItemText-primary-59 MuiListItemText-textDense-61\\"><div class=\\"css-1mta3t8 eb8w2fo0\\"><span class=\\"css-1m8aenu eb8w2fo1\\"><a href=\\"git+https://github.com/verdaccio/ui.git\\" target=\\"_blank\\" class=\\"css-15gl0ho e1wmjxnh2\\">git+https://github.com/verdaccio/ui.git</a></span><button class=\\"MuiButtonBase-root-76 MuiIconButton-root-70 css-56v3u0 eb8w2fo2\\" tabindex=\\"0\\" type=\\"button\\" title=\\"Copy to Clipboard\\"><span class=\\"MuiIconButton-label-75\\"><svg class=\\"MuiSvgIcon-root-79\\" focusable=\\"false\\" viewBox=\\"0 0 24 24\\" aria-hidden=\\"true\\" role=\\"presentation\\"><path fill=\\"none\\" d=\\"M0 0h24v24H0z\\"></path><path d=\\"M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm-1 4l6 6v10c0 1.1-.9 2-2 2H7.99C6.89 23 6 22.1 6 21l.01-14c0-1.1.89-2 1.99-2h7zm-1 7h5.5L14 6.5V12z\\"></path></svg></span></button></div></span></div></li></ul>"`;

View File

@@ -5,37 +5,38 @@ import Typography from '@material-ui/core/Typography';
import Github from '../../icons/GitHub';
import colors from '../../utils/styles/colors';
import { fontWeight } from '../../utils/styles/sizes';
export const Heading = styled(Typography)`
&& {
font-weight: 700;
text-transform: capitalize;
}
`;
export const Heading = styled(Typography)({
'&&': {
fontWeight: fontWeight.bold,
textTransform: 'capitalize',
},
});
export const GridRepo = styled(Grid)`
&& {
align-items: center;
}
`;
export const GridRepo = styled(Grid)({
'&&': {
alignItems: 'center',
},
});
export const GithubLink = styled('a')`
&& {
color: ${colors.primary};
}
`;
export const GithubLink = styled('a')({
'&&': {
color: colors.primary,
},
});
export const GithubLogo = styled(Github)`
&& {
font-size: 40px;
color: ${colors.primary};
background-color: ${colors.greySuperLight};
}
`;
export const GithubLogo = styled(Github)({
'&&': {
fontSize: '40px',
color: colors.primary,
backgroundColor: colors.greySuperLight,
},
});
export const RepositoryListItem = styled(ListItem)`
&& {
padding-left: 0;
padding-right: 0;
}
`;
export const RepositoryListItem = styled(ListItem)({
'&&': {
paddingLeft: 0,
paddingRight: 0,
},
});

View File

@@ -5,7 +5,7 @@ import { BrowserRouter } from 'react-router-dom';
import Search from './Search';
const SEARCH_FILE_PATH = './Search';
const API_FILE_PATH = '../../utils/api';
const API_FILE_PATH = '../../utils/calls';
const URL_FILE_PATH = '../../utils/url';
// Global mocks
@@ -165,8 +165,7 @@ describe('<Search /> component test', () => {
const suggestions = [{ name: 'verdaccio' }, { name: 'verdaccio-htpasswd' }];
jest.doMock(API_FILE_PATH, () => ({
request(url: string) {
expect(url).toEqual('search/verdaccio');
callSearch(url: string) {
return Promise.resolve(apiResponse);
},
}));
@@ -194,7 +193,7 @@ describe('<Search /> component test', () => {
test('handleFetchPackages: when browser cancel a request', async () => {
const apiResponse = { name: 'AbortError' };
jest.doMock(API_FILE_PATH, () => ({ request: jest.fn(() => Promise.reject(apiResponse)) }));
jest.doMock(API_FILE_PATH, () => ({ callSearch: jest.fn(() => Promise.reject(apiResponse)) }));
const Search = require(SEARCH_FILE_PATH).Search;
@@ -219,8 +218,7 @@ describe('<Search /> component test', () => {
const apiResponse = { name: 'BAD_REQUEST' };
jest.doMock(API_FILE_PATH, () => ({
request(url) {
expect(url).toEqual('search/verdaccio');
callSearch(url) {
return Promise.reject(apiResponse);
},
}));

View File

@@ -6,9 +6,9 @@ import { default as IconSearch } from '@material-ui/icons/Search';
import InputAdornment from '@material-ui/core/InputAdornment';
import debounce from 'lodash/debounce';
import API from '../../utils/api';
import AutoComplete from '../AutoComplete';
import colors from '../../utils/styles/colors';
import { callSearch } from '../../utils/calls';
export interface State {
search: string;
@@ -148,7 +148,7 @@ export class Search extends Component<RouteComponentProps<{}>, State> {
const signal = controller.signal;
// Keep track of search requests.
this.requestList.push(controller);
const suggestions = await API.request(`search/${encodeURIComponent(value)}`, 'GET', { signal });
const suggestions = await callSearch(value, signal);
// @ts-ignore
this.setState({
suggestions,

View File

@@ -20,8 +20,8 @@ export const Wrapper = styled('div')`
}
`;
export const Circular = styled(CircularProgress)`
&& {
color: ${colors.primary};
}
`;
export const Circular = styled(CircularProgress)({
'&&': {
color: colors.primary,
},
});

View File

@@ -1,13 +1,13 @@
import styled from 'react-emotion';
export const Wrapper = styled('span')`
&& {
vertical-align: middle;
line-height: 22px;
border-radius: 2px;
color: #485a3e;
background-color: #f3f4f2;
padding: 0.22rem 0.4rem;
margin: 8px 8px 0 0;
}
`;
export const Wrapper = styled('span')({
'&&': {
verticalAlign: 'middle',
lineHeight: '22px',
borderRadius: '2px',
color: '#485a3e',
backgroundColor: '#f3f4f2',
padding: '0.22rem 0.4rem',
margin: '8px 8px 0 0',
},
});

View File

@@ -2,7 +2,7 @@ import React, { ReactElement } from 'react';
import List from '@material-ui/core/List';
import ListItem from '@material-ui/core/ListItem';
import { DetailContextConsumer } from '../../pages/version/Version';
import { DetailContextConsumer } from '../../pages/Version';
import NoItems from '../NoItems';
import { formatDateDistance } from '../../utils/package';

View File

@@ -1,24 +1,25 @@
import styled from 'react-emotion';
import Typography from '@material-ui/core/Typography';
import { default as MuiListItemText } from '@material-ui/core/ListItemText';
import { fontWeight } from '../../utils/styles/sizes';
export const Heading = styled(Typography)`
&& {
font-weight: 700;
}
`;
export const Heading = styled(Typography)({
'&&': {
fontWeight: fontWeight.bold,
},
});
export const Spacer = styled('div')`
flex: 1 1 auto;
border-bottom: 1px dotted rgba(0, 0, 0, 0.2);
white-space: nowrap;
height: 0.5em;
`;
export const Spacer = styled('div')({
flex: '1 1 auto',
borderBottom: '1px dotted rgba(0, 0, 0, 0.2)',
whiteSpace: 'nowrap',
height: '0.5em',
});
export const ListItemText = styled(MuiListItemText)`
&& {
flex: none;
color: black;
opacity: 0.6;
}
`;
export const ListItemText = styled(MuiListItemText)({
'&&': {
flex: 'none',
color: 'black',
opacity: 0.6,
},
});

View File

@@ -1,11 +1,42 @@
import React from 'react';
import { shallow } from 'enzyme';
import Versions from './Versions';
describe('<Version /> component', () => {
beforeEach(() => {
jest.resetModules();
});
describe('<Versions /> component', () => {
test('should render the component in default state', () => {
const wrapper = shallow(<Versions />);
const packageMeta = {
versions: {
'1.0.0': {
version: '1.0.0',
},
'2.0.0': {
version: '2.0.0',
},
'3.0.0': {
version: '3.0.0',
},
},
time: {
'1.0.0': '2016-08-26T22:36:41.762Z',
'2.0.0': '2017-08-26T22:36:41.762Z',
'3.0.0': '2018-02-07T06:43:22.801Z',
},
'dist-tags': {
latest: '3.0.0',
},
};
jest.doMock('../../pages/Version', () => ({
DetailContextConsumer: component => {
return component.children({ packageMeta });
},
}));
const Version = require('./Versions').default;
const wrapper = shallow(<Version />);
expect(wrapper.html()).toMatchSnapshot();
});
});

View File

@@ -1,10 +1,11 @@
import { DetailContextConsumer } from '../../pages/version/Version';
import { formatDateDistance } from '../../utils/package';
import { Heading, Spacer, ListItemText } from './styles';
import React, { ReactElement } from 'react';
import List from '@material-ui/core/List';
import ListItem from '@material-ui/core/ListItem';
import React, { ReactElement } from 'react';
import { DetailContextConsumer } from '../../pages/Version';
import { formatDateDistance } from '../../utils/package';
import { DIST_TAGS } from '../../../lib/constants';
import { Heading, Spacer, ListItemText } from './styles';
const NOT_AVAILABLE = 'Not available';

View File

@@ -1,3 +1,3 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`<Versions /> component should render the component in default state 1`] = `""`;
exports[`<Version /> component should render the component in default state 1`] = `"<h3 class=\\"MuiTypography-root-1 MuiTypography-subheading-8 css-1ikpjfo e1h4if9v0\\">Current Tags</h3><ul class=\\"MuiList-root-37 MuiList-padding-38\\"><li class=\\"MuiListItem-root-41 MuiListItem-default-44 MuiListItem-gutters-49 version-item\\"><div class=\\"MuiListItemText-root-53 css-5tz9yo e1h4if9v2\\"><span class=\\"MuiTypography-root-1 MuiTypography-subheading-8 MuiListItemText-primary-56\\">latest</span></div><div class=\\"css-1l1cv61 e1h4if9v1\\"></div><div class=\\"MuiListItemText-root-53 css-5tz9yo e1h4if9v2\\"><span class=\\"MuiTypography-root-1 MuiTypography-subheading-8 MuiListItemText-primary-56\\">3.0.0</span></div></li></ul><h3 class=\\"MuiTypography-root-1 MuiTypography-subheading-8 css-1ikpjfo e1h4if9v0\\">Version History</h3><ul class=\\"MuiList-root-37 MuiList-padding-38\\"><li class=\\"MuiListItem-root-41 MuiListItem-default-44 MuiListItem-gutters-49 version-item\\"><div class=\\"MuiListItemText-root-53 css-5tz9yo e1h4if9v2\\"><span class=\\"MuiTypography-root-1 MuiTypography-subheading-8 MuiListItemText-primary-56\\">3.0.0</span></div><div class=\\"css-1l1cv61 e1h4if9v1\\"></div><div class=\\"MuiListItemText-root-53 css-5tz9yo e1h4if9v2\\"><span class=\\"MuiTypography-root-1 MuiTypography-subheading-8 MuiListItemText-primary-56\\">over 1 year ago</span></div></li><li class=\\"MuiListItem-root-41 MuiListItem-default-44 MuiListItem-gutters-49 version-item\\"><div class=\\"MuiListItemText-root-53 css-5tz9yo e1h4if9v2\\"><span class=\\"MuiTypography-root-1 MuiTypography-subheading-8 MuiListItemText-primary-56\\">2.0.0</span></div><div class=\\"css-1l1cv61 e1h4if9v1\\"></div><div class=\\"MuiListItemText-root-53 css-5tz9yo e1h4if9v2\\"><span class=\\"MuiTypography-root-1 MuiTypography-subheading-8 MuiListItemText-primary-56\\">almost 2 years ago</span></div></li><li class=\\"MuiListItem-root-41 MuiListItem-default-44 MuiListItem-gutters-49 version-item\\"><div class=\\"MuiListItemText-root-53 css-5tz9yo e1h4if9v2\\"><span class=\\"MuiTypography-root-1 MuiTypography-subheading-8 MuiListItemText-primary-56\\">1.0.0</span></div><div class=\\"css-1l1cv61 e1h4if9v1\\"></div><div class=\\"MuiListItemText-root-53 css-5tz9yo e1h4if9v2\\"><span class=\\"MuiTypography-root-1 MuiTypography-subheading-8 MuiListItemText-primary-56\\">almost 3 years ago</span></div></li></ul>"`;

View File

@@ -1,24 +1,25 @@
import styled from 'react-emotion';
import Typography from '@material-ui/core/Typography';
import { default as MuiListItemText } from '@material-ui/core/ListItemText';
import { fontWeight } from '../../utils/styles/sizes';
export const Heading = styled(Typography)`
&& {
font-weight: 700;
}
`;
export const Heading = styled(Typography)({
'&&': {
fontWeight: fontWeight.bold,
},
});
export const Spacer = styled('div')`
flex: 1 1 auto;
border-bottom: 1px dotted rgba(0, 0, 0, 0.2);
white-space: nowrap;
height: 0.5em;
`;
export const Spacer = styled('div')({
flex: '1 1 auto',
borderBottom: '1px dotted rgba(0, 0, 0, 0.2)',
whiteSpace: 'nowrap',
height: '0.5em',
});
export const ListItemText = styled(MuiListItemText)`
&& {
flex: none;
color: black;
opacity: 0.6;
}
`;
export const ListItemText = styled(MuiListItemText)({
'&&': {
flex: 'none',
color: 'black',
opacity: 0.6,
},
});

View File

@@ -1,8 +0,0 @@
import { createBrowserHistory } from 'history';
import { getBaseNamePath } from './utils/url';
const history = createBrowserHistory({
basename: getBaseNamePath(),
});
export default history;

View File

@@ -0,0 +1,27 @@
import React, { FC, ReactElement } from 'react';
import Grid from '@material-ui/core/Grid';
import DetailContainer from '../../components/DetailContainer';
import DetailSidebar from '../../components/DetailSidebar';
function renderDetail(): ReactElement<HTMLElement> {
return <DetailContainer />;
}
function renderSidebar(): ReactElement<HTMLElement> {
return <DetailSidebar />;
}
const Layout: FC<{}> = () => {
return (
<Grid className={'container content'} container={true} data-testid="version-layout" spacing={0}>
<Grid item={true} xs={8}>
{renderDetail()}
</Grid>
<Grid item={true} xs={4}>
{renderSidebar()}
</Grid>
</Grid>
);
};
export { Layout };

View File

@@ -0,0 +1,97 @@
import React from 'react';
import { render, cleanup } from '@testing-library/react';
import { MemoryRouter } from 'react-router';
import vueMetadata from '../../../test/fixtures/metadata/vue.json';
import Version from './Version';
import { waitForElement } from '@testing-library/dom';
import ErrorBoundary from '../../App/AppError';
import { LABEL_NOT_FOUND } from '../../components/NotFound/NotFound';
// :-) we mock this otherways fails on render, some weird issue on material-ui
jest.mock('@material-ui/core/Avatar');
describe('test Version page', () => {
beforeAll(() => {
// FIXME: a better way to mock this
// @ts-ignore
global.window.VERDACCIO_API_URL = 'http://test';
});
afterEach(() => {
cleanup();
});
beforeEach(() => {
jest.resetAllMocks();
// @ts-ignore
fetch.resetMocks();
});
test('should render the version page', async () => {
const readmeText = 'test';
// @ts-ignore
fetch.mockResponses(
[[JSON.stringify(vueMetadata)], { status: 200, headers: { 'content-type': 'application/json' } }],
[[`<p align="center">${readmeText}</p>`], { status: 200, headers: { 'content-type': 'text/html' } }]
);
const { getByTestId, getByText } = render(
<ErrorBoundary>
<MemoryRouter>
<Version match={{ params: { ['package']: 'vue' } }}></Version>
</MemoryRouter>
</ErrorBoundary>
);
// first it display loading
const hasLoading = getByTestId('loading');
expect(hasLoading).toBeTruthy();
// we wait fetch response (mocked above)
await waitForElement(() => getByTestId('version-layout'));
// check whether readme was loaded
const hasReadme = getByText(readmeText);
expect(hasReadme).toBeTruthy();
});
test('should render 404 page if the resources are not found', async () => {
// @ts-ignore
fetch.mockResponses(
[[JSON.stringify({})], { status: 404, headers: { 'content-type': 'application/json' } }],
[[``], { status: 404, headers: { 'content-type': 'text/html' } }]
);
const { getByTestId, getByText } = render(
<ErrorBoundary>
<MemoryRouter>
<Version match={{ params: { ['package']: 'vue' } }}></Version>
</MemoryRouter>
</ErrorBoundary>
);
// first it display loading
const hasLoading = getByTestId('loading');
expect(hasLoading).toBeTruthy();
// we wait fetch response (mocked above)
await waitForElement(() => getByTestId('404'));
// check whether readme was loaded
const hasReadme = getByText(LABEL_NOT_FOUND);
expect(hasReadme).toBeTruthy();
});
// Wanna contribute? Here we some scenarios we need to test
test.todo('should test click on tabs');
test.todo('should check what is rendered int he sidebar is correct');
test.todo('should test click back home on 404');
test.todo('should test click on elements in the sidebar');
test.todo('should test other not consider scenarios');
});

View File

@@ -0,0 +1,69 @@
import React, { useEffect, useState } from 'react';
import { callDetailPage, callReadme } from '../../utils/calls';
import { buildScopePackage } from '../../utils/package';
import Loading from '../../components/Loading/Loading';
import NotFound from '../../components/NotFound';
import { Layout } from './Layout';
import { DetailContextProvider } from './context';
import { StateInterface } from './types';
export function getRouterPackageName(params): string {
const packageName = params.package;
const { scope } = params;
if (scope) {
return buildScopePackage(scope, packageName);
}
return packageName;
}
const Version = ({ match: { params } }) => {
const pkgName = getRouterPackageName(params);
const [readMe, setReadme] = useState();
const [packageName, setPackageName] = useState(pkgName);
const [packageMeta, setPackageMeta] = useState();
const [isLoading, setIsLoading] = useState(true);
const [notFound, setNotFound] = useState(false);
useEffect(() => {
(async () => {
try {
const packageMeta = (await callDetailPage(packageName)) as Partial<StateInterface>;
const readMe = (await callReadme(packageName)) as Partial<StateInterface>;
setReadme(readMe);
setPackageMeta(packageMeta);
setIsLoading(false);
} catch (error) {
setNotFound(true);
setIsLoading(false);
}
})();
}, [packageName]);
useEffect(() => {
document.title = `Verdaccio - ${packageName}`;
}, [packageName]);
useEffect(() => {
const pkgName = getRouterPackageName(params);
setPackageName(pkgName);
}, [params]);
const isNotFound = notFound || typeof packageMeta === 'undefined' || typeof packageName === 'undefined' || typeof readMe === 'undefined';
const renderContent = (): React.ReactElement<HTMLElement> => {
if (isLoading) {
return <Loading />;
} else if (isNotFound) {
return <NotFound />;
} else {
return <Layout />;
}
};
return <DetailContextProvider value={{ packageMeta, readMe, packageName, enableLoading: setIsLoading }}>{renderContent()}</DetailContextProvider>;
};
export default Version;

View File

@@ -0,0 +1,7 @@
import React, { Consumer, Provider } from 'react';
import { DetailContextProps, VersionPageConsumerProps } from './types';
export const DetailContext = React.createContext<Partial<DetailContextProps>>({});
export const DetailContextProvider: Provider<Partial<VersionPageConsumerProps>> = DetailContext.Provider;
export const DetailContextConsumer: Consumer<Partial<VersionPageConsumerProps>> = DetailContext.Consumer;

View File

@@ -0,0 +1,3 @@
export { DetailContextProps, VersionPageConsumerProps } from './types';
export { DetailContext, DetailContextConsumer, DetailContextProvider } from './context';
export { default } from './Version';

View File

@@ -3,10 +3,10 @@ import DialogTitle from '@material-ui/core/DialogTitle';
import colors from '../../utils/styles/colors';
import { fontSize } from '../../utils/styles/sizes';
export const Title = styled(DialogTitle)`
&& {
background-color: ${colors.primary};
color: ${colors.white};
font-size: ${fontSize.lg};
}
`;
export const Title = styled(DialogTitle)({
'&&': {
backgroundColor: colors.primary,
color: colors.white,
fontSize: fontSize.lg,
},
});

View File

@@ -0,0 +1,28 @@
import { PackageMetaInterface } from '../../../types/packageMeta';
export interface DetailContextProps {
packageMeta: PackageMetaInterface;
readMe: string;
packageName: string;
enableLoading: () => void;
}
export interface VersionPageConsumerProps {
packageMeta: PackageMetaInterface;
readMe: string;
packageName: string;
// FIXME: looking for the appropiated type here
enableLoading: any;
}
export interface PropsInterface {
match: boolean;
}
export interface StateInterface {
readMe: string;
packageName: string;
packageMeta?: PackageMetaInterface;
isLoading: boolean;
notFound: boolean;
}

View File

@@ -1,160 +0,0 @@
import React, { Component, ReactElement, Consumer, Provider } from 'react';
import Grid from '@material-ui/core/Grid';
import Loading from '../../components/Loading/Loading';
import DetailContainer from '../../components/DetailContainer/DetailContainer';
import DetailSidebar from '../../components/DetailSidebar/DetailSidebar';
import { callDetailPage } from '../../utils/calls';
import { getRouterPackageName } from '../../utils/package';
import NotFound from '../../components/NotFound';
import { PackageMetaInterface } from '../../../types/packageMeta';
export interface DetailContextProps {
packageMeta: PackageMetaInterface;
readMe: string;
packageName: string;
enableLoading: () => void;
}
export const DetailContext = React.createContext<Partial<DetailContextProps>>({});
export interface VersionPageConsumerProps {
packageMeta: PackageMetaInterface;
readMe: string;
packageName: string;
enableLoading: () => void;
}
export const DetailContextProvider: Provider<Partial<VersionPageConsumerProps>> = DetailContext.Provider;
export const DetailContextConsumer: Consumer<Partial<VersionPageConsumerProps>> = DetailContext.Consumer;
interface PropsInterface {
match: boolean;
}
interface StateInterface {
readMe: string;
packageName: string;
packageMeta: PackageMetaInterface | null;
isLoading: boolean;
notFound: boolean;
}
class VersionPage extends Component<PropsInterface, Partial<StateInterface>> {
constructor(props) {
super(props);
this.state = {
readMe: '',
packageName: getRouterPackageName(props.match),
packageMeta: null,
isLoading: true,
notFound: false,
};
}
public static getDerivedStateFromProps(nextProps, prevState): { packageName?: string; isLoading: boolean; notFound?: boolean } | null {
const { match } = nextProps;
const packageName = getRouterPackageName(match);
if (packageName !== prevState.packageName) {
try {
return {
packageName,
isLoading: false,
};
} catch (err) {
return {
notFound: true,
isLoading: false,
};
}
} else {
return null;
}
}
public async componentDidMount(): Promise<void> {
await this.loadPackageInfo();
}
/* eslint no-unused-vars: 0 */
public async componentDidUpdate(nextProps, prevState: StateInterface): Promise<void> {
const { packageName } = this.state;
if (packageName !== prevState.packageName) {
const { readMe, packageMeta } = (await callDetailPage(packageName)) as Partial<StateInterface>;
this.setState({
readMe,
packageMeta,
packageName,
notFound: false,
isLoading: false,
});
}
}
public render(): ReactElement<HTMLElement> {
const { isLoading, packageMeta, readMe, packageName } = this.state;
if (isLoading) {
return <Loading />;
} else if (!packageMeta) {
return <NotFound />;
} else {
return (
<DetailContextProvider value={{ packageMeta, readMe, packageName, enableLoading: this.enableLoading }}>
<Grid className={'container content'} container={true} spacing={0}>
<Grid item={true} xs={8}>
{this.renderDetail()}
</Grid>
<Grid item={true} xs={4}>
{this.renderSidebar()}
</Grid>
</Grid>
</DetailContextProvider>
);
}
}
public async loadPackageInfo(): Promise<void> {
const { packageName } = this.state;
// FIXME: use utility
document.title = `Verdaccio - ${packageName}`;
this.setState({
readMe: '',
});
try {
const { readMe, packageMeta } = (await callDetailPage(packageName)) as Partial<StateInterface>;
this.setState({
readMe,
packageMeta,
packageName,
notFound: false,
isLoading: false,
});
} catch (err) {
this.setState({
notFound: true,
packageName,
isLoading: false,
});
}
}
public enableLoading = () => {
this.setState({
isLoading: true,
});
};
public renderDetail(): ReactElement<HTMLElement> {
return <DetailContainer />;
}
public renderSidebar(): ReactElement<HTMLElement> {
return <DetailSidebar />;
}
}
export default VersionPage;

View File

@@ -1 +0,0 @@
export { default, DetailContextProps } from './Version';

View File

@@ -2,14 +2,18 @@
import React, { Component, ReactElement } from 'react';
import { Router, Route, Switch } from 'react-router-dom';
import { createBrowserHistory } from 'history';
import { AppContextConsumer, AppStateInterface } from './App/App';
import { asyncComponent } from './utils/asyncComponent';
import history from './history';
import Header from './components/Header';
const history = createBrowserHistory({
basename: window.__VERDACCIO_BASENAME_UI_OPTIONS && window.__VERDACCIO_BASENAME_UI_OPTIONS.url_prefix,
});
const NotFound = asyncComponent(() => import('./components/NotFound'));
const VersionPackage = asyncComponent(() => import('./pages/version/Version'));
const VersionPackage = asyncComponent(() => import('./pages/Version'));
const HomePage = asyncComponent(() => import('./pages/home'));
interface RouterAppProps {

44
src/utils/api.test.ts Normal file
View File

@@ -0,0 +1,44 @@
/* eslint-disable @typescript-eslint/no-object-literal-type-assertion */
import { handleResponseType } from '../../src/utils/api';
describe('api', () => {
// no the best mock, but I'd look for a mock library to work with fetch in the future
// @ts-ignore
const headers: Headers = {
// @ts-ignore
get: () => [],
};
describe('handleResponseType', () => {
test('should handle missing Content-Type', async () => {
const response: Response = {
url: 'http://localhost:8080/-/packages',
ok: false,
// @ts-ignore
headers: {
get: () => null,
} as Headers,
} as Response;
const handled = await handleResponseType(response);
// Should this actually return [false, null] ?
expect(handled).toBeUndefined();
});
test('should test tgz scenario', async () => {
const blob = new Blob(['foo']);
const blobPromise = Promise.resolve<Blob>(blob);
const response: Response = {
url: 'http://localhost:8080/bootstrap/-/bootstrap-4.3.1.tgz',
blob: () => blobPromise,
ok: true,
headers,
} as Response;
const handled = await handleResponseType(response);
expect(handled).toEqual([true, blob]);
});
});
});

View File

@@ -6,35 +6,40 @@ import '../../types';
* @param {object} response
* @returns {promise}
*/
function handleResponseType(response: Response): Promise<[boolean, Blob | string]> | Promise<void> {
export function handleResponseType(response: Response): Promise<[boolean, Blob | string]> | Promise<void> {
if (response.headers) {
const contentType = response.headers.get('Content-Type') as string;
if (contentType.includes('application/pdf')) {
const contentType = response.headers.get('Content-Type');
if (contentType && contentType.includes('application/pdf')) {
return Promise.all([response.ok, response.blob()]);
}
if (contentType.includes('application/json')) {
if (contentType && contentType.includes('application/json')) {
return Promise.all([response.ok, response.json()]);
}
// it includes all text types
if (contentType.includes('text/')) {
if (contentType && contentType.includes('text/')) {
return Promise.all([response.ok, response.text()]);
}
// unfortunatelly on download files there is no header available
if (response.url && response.url.endsWith('.tgz') === true) {
return Promise.all([response.ok, response.blob()]);
}
}
return Promise.resolve();
}
class API {
public request<T>(url: string, method = 'GET', options?: RequestInit): Promise<T> {
public request<T>(url: string, method = 'GET', options: RequestInit = { headers: {} }): Promise<T> {
if (!window.VERDACCIO_API_URL) {
throw new Error('VERDACCIO_API_URL is not defined!');
}
const token = storage.getItem('token');
const headers = new Headers(options && options.headers);
if (token && options && options.headers) {
headers.set('Authorization', `Bearer ${token}`);
options.headers = Object.assign(options.headers, headers);
if (token && options.headers && typeof options.headers['Authorization'] === 'undefined') {
options.headers = Object.assign({}, options.headers, {
['Authorization']: `Bearer ${token}`,
});
}
if (!['http://', 'https://', '//'].some(prefix => url.startsWith(prefix))) {
@@ -50,11 +55,11 @@ class API {
})
// @ts-ignore
.then(handleResponseType)
.then(([responseOk, body]) => {
if (responseOk) {
resolve(body);
.then(response => {
if (response[0]) {
resolve(response[1]);
} else {
reject(body);
reject(new Error('something went wrong'));
}
})
.catch(error => {

View File

@@ -1,14 +1,18 @@
import API from './api';
import { PackageMetaInterface } from 'types/packageMeta';
export interface DetailPage {
readMe: string | {};
packageMeta: PackageMetaInterface | {};
export async function callReadme(packageName): Promise<string | {}> {
return await API.request<string | {}>(`package/readme/${packageName}`, 'GET');
}
export async function callDetailPage(packageName): Promise<DetailPage> {
const readMe = await API.request<string | {}>(`package/readme/${packageName}`, 'GET');
export async function callDetailPage(packageName): Promise<PackageMetaInterface | {}> {
const packageMeta = await API.request<PackageMetaInterface | {}>(`sidebar/${packageName}`, 'GET');
return { readMe, packageMeta };
return packageMeta;
}
export function callSearch(value: string, signal: any) {
// https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API#Browser_compatibility
// FUTURE: signal is not well supported for IE and Samsung Browser
return API.request(`search/${encodeURIComponent(value)}`, 'GET', { signal, headers: {} });
}

View File

@@ -56,14 +56,8 @@ export function formatDateDistance(lastUpdate): string {
return distanceInWordsToNow(new Date(lastUpdate));
}
export function getRouterPackageName(match): string {
const packageName = match.params.package;
const scope = match.params.scope;
if (scope) {
return `@${scope}/${packageName}`;
}
return packageName;
export function buildScopePackage(scope: string, packageName: string) {
return `@${scope}/${packageName}`;
}
/**

36
src/utils/url.test.ts Normal file
View File

@@ -0,0 +1,36 @@
import { isURL, isEmail, getRegistryURL, extractFileName } from './url';
describe('utils', () => {
describe('url', () => {
test('isURL() - should return true for localhost', () => {
expect(isURL('http://localhost:8080/bootstrap/-/bootstrap-4.3.1.tgz')).toBeTruthy();
});
test('isURL() - should return false when protocol is missing', () => {
expect(isURL('localhost:8080/bootstrap/-/bootstrap-4.3.1.tgz')).toBeFalsy();
});
test('isEmail() - should return true if valid', () => {
expect(isEmail('email@domain.com')).toBeTruthy();
});
test('isEmail() - should return false if invalid', () => {
expect(isEmail('')).toBeFalsy();
});
test('getRegistryURL() - should keep slash if location is a sub directory', () => {
history.pushState({}, 'page title', '/-/web/detail');
expect(getRegistryURL()).toBe('http://localhost/-/web/detail');
history.pushState({}, 'page title', '/');
});
test('getRegistryURL() - should not add slash if location is not a sub directory', () => {
expect(getRegistryURL()).toBe('http://localhost');
});
});
describe('extractFileName', () => {
test('should return the file name', () => {
expect(extractFileName('http://localhost:4872/juan_test_webpack1/-/test-10.0.0.tgz')).toBe('test-10.0.0.tgz');
});
});
});

View File

@@ -2,10 +2,11 @@ import isURLValidator from 'validator/lib/isURL';
import isEmailValidator from 'validator/lib/isEmail';
import '../../types';
export function isURL(url): boolean {
export function isURL(url: string): boolean {
return isURLValidator(url || '', {
protocols: ['http', 'https', 'git+https'],
require_protocol: true,
require_tld: false,
});
}
@@ -18,10 +19,19 @@ export function getRegistryURL(): string {
return `${location.origin}${location.pathname === '/' ? '' : location.pathname}`;
}
export function getBaseNamePath(): string {
return window.__VERDACCIO_BASENAME_UI_OPTIONS && window.__VERDACCIO_BASENAME_UI_OPTIONS.url_prefix;
export function extractFileName(url: string): string {
return url.substring(url.lastIndexOf('/') + 1);
}
export function getRootPath(): string {
return window.__VERDACCIO_BASENAME_UI_OPTIONS && window.__VERDACCIO_BASENAME_UI_OPTIONS.base;
export function downloadFile(fileStream: Blob, fileName: string): void {
const file = new File([fileStream], fileName, { type: 'application/octet-stream', lastModified: Date.now() });
const objectURL = URL.createObjectURL(file);
const fileLink = document.createElement('a');
fileLink.href = objectURL;
fileLink.download = fileName;
fileLink.click();
// firefox requires remove the object url
setTimeout(() => {
URL.revokeObjectURL(objectURL);
}, 150);
}

View File

@@ -0,0 +1,6 @@
{
"rules": {
"new-cap": 0,
"prettier/prettier": 0
}
}

1
test/acceptance/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
output

View File

@@ -0,0 +1,9 @@
Feature('Menu');
Scenario('check if we find the npm commands to set the registry', (I) => {
I.amOnPage('http://localhost:8080');
I.waitForElement('#header--button-registryInfo', 5);
I.click('#header--button-registryInfo');
I.waitForElement('#registryInfo--dialog-container');
I.see('npm set registry http://localhost:8080');
});

View File

@@ -0,0 +1,10 @@
Feature('SearchResult');
Scenario('check if we get the "no results found" text', (I) => {
I.amOnPage('http://localhost:8080');
I.seeElement('header .react-autosuggest__input input');
I.fillField('header .react-autosuggest__input input', 'test');
I.waitForElement('header .react-autosuggest__suggestions-container');
I.wait(1);
I.see('No results found.', 'header .react-autosuggest__suggestions-container');
});

View File

@@ -0,0 +1,8 @@
// in this file you can append custom step methods to 'I' object
module.exports = function() {
return actor({
// Define custom steps here, use 'this' to access default methods of I.
// It is recommended to place a general 'login' function here.
});
};

Some files were not shown because too many files have changed in this diff Show More