forked from sombochea/verdaccio-ui
Compare commits
147 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
584f4c141e | ||
|
|
91d818c478 | ||
|
|
ae6e479f16 | ||
|
|
18ef27eac6 | ||
|
|
eabc0b9f5b | ||
|
|
3779caa4e3 | ||
|
|
543877a077 | ||
|
|
7e6702c34b | ||
|
|
2e50981514 | ||
|
|
f61913c2d3 | ||
|
|
ffc97c373c | ||
|
|
3a889b67ee | ||
|
|
de0f91a6d2 | ||
|
|
195a79a809 | ||
|
|
0a7428edab | ||
|
|
9ad506d569 | ||
|
|
3b52a17623 | ||
|
|
3309e449d1 | ||
|
|
7853ec2acb | ||
|
|
2890e5a27e | ||
|
|
1904179af3 | ||
|
|
bbec54d602 | ||
|
|
67d7188cf5 | ||
|
|
376b84f8c9 | ||
|
|
5a9bd6001a | ||
|
|
ac58730e8c | ||
|
|
97e8448098 | ||
|
|
e7d3c461cd | ||
|
|
003f879a87 | ||
|
|
d81b610e2e | ||
|
|
3d7b230c71 | ||
|
|
ce3b22579f | ||
|
|
e46020f9b0 | ||
|
|
502c0903ab | ||
|
|
542212a479 | ||
|
|
1cb9b56940 | ||
|
|
1446c8e5fb | ||
|
|
155987d837 | ||
|
|
a44e76fded | ||
|
|
2dfa7aa4d6 | ||
|
|
cfb0caf2bb | ||
|
|
62b6edc821 | ||
|
|
9b55b75f8a | ||
|
|
ade58caf41 | ||
|
|
2e9703346c | ||
|
|
ccc2cb3fa6 | ||
|
|
3746a0466f | ||
|
|
dcfda4483f | ||
|
|
d44cc7f662 | ||
|
|
4a526c92bb | ||
|
|
2049022477 | ||
|
|
40a25a2507 | ||
|
|
58cb4c7465 | ||
|
|
e1d8eafb7a | ||
|
|
cb876f936e | ||
|
|
94ca0e146d | ||
|
|
8774fd51c7 | ||
|
|
6f8d891c42 | ||
|
|
240535ddad | ||
|
|
3c6fe5d947 | ||
|
|
f8374084b5 | ||
|
|
8c9cffbc6a | ||
|
|
62431038bb | ||
|
|
12974ea54f | ||
|
|
f47ab2490b | ||
|
|
83b6a9d247 | ||
|
|
5c484bba9a | ||
|
|
9d006ad6f7 | ||
|
|
fd74c52bd1 | ||
|
|
a25fc6ec78 | ||
|
|
dd54aaaf94 | ||
|
|
64c003943c | ||
|
|
115be1bb6e | ||
|
|
9d7b90fc34 | ||
|
|
8ea017d871 | ||
|
|
786da9975f | ||
|
|
684e989fbd | ||
|
|
4dd953e553 | ||
|
|
9343503372 | ||
|
|
ec243b1352 | ||
|
|
2ffb2b5bf1 | ||
|
|
cad5ac91e7 | ||
|
|
ecc4521314 | ||
|
|
795544a14c | ||
|
|
67fff03b87 | ||
|
|
5148fdca66 | ||
|
|
46ae0d21a3 | ||
|
|
9ade2a0ee7 | ||
|
|
e346819035 | ||
|
|
46e5f09dbf | ||
|
|
cca2c3c0d7 | ||
|
|
c814080957 | ||
|
|
157addfd00 | ||
|
|
c6c164de50 | ||
|
|
640e8ca5ee | ||
|
|
0d00ab4490 | ||
|
|
e9b881b979 | ||
|
|
6ab3aa2885 | ||
|
|
50664dc008 | ||
|
|
9e0c9db78c | ||
|
|
3ab3506958 | ||
|
|
78b4c3fac1 | ||
|
|
fdad635072 | ||
|
|
6a421ab22d | ||
|
|
6afc2c0e54 | ||
|
|
542038e03f | ||
|
|
c667bea33b | ||
|
|
bb4d36840f | ||
|
|
60b71611ca | ||
|
|
39867938b6 | ||
|
|
30568bfe13 | ||
|
|
f6e62d95bb | ||
|
|
c57f9dde35 | ||
|
|
0e14146c77 | ||
|
|
b6717497aa | ||
|
|
99e1bb3ea3 | ||
|
|
a49780f5f0 | ||
|
|
0c4ebbffa8 | ||
|
|
b6b0ecdb1e | ||
|
|
13c7aa6d03 | ||
|
|
cf1f47e86c | ||
|
|
b2e420dbd9 | ||
|
|
283464fd13 | ||
|
|
7c254471a6 | ||
|
|
8e3e619eea | ||
|
|
531e7579a4 | ||
|
|
e7d145f547 | ||
|
|
210bcf3ff5 | ||
|
|
55b1402456 | ||
|
|
4746f4070c | ||
|
|
ec8ed1214b | ||
|
|
a0f0c80e2e | ||
|
|
d1ed3e705f | ||
|
|
b683b68a2c | ||
|
|
6eec4f45d9 | ||
|
|
7cab3f289e | ||
|
|
2f28ade710 | ||
|
|
31c11f2b5b | ||
|
|
55f50e9f4d | ||
|
|
e33570b3f0 | ||
|
|
91e603ef21 | ||
|
|
116055c5d1 | ||
|
|
3c54b116c9 | ||
|
|
df4e45cd6c | ||
|
|
df58d463e8 | ||
|
|
313fb33480 | ||
|
|
d468ca7c5f |
@@ -1,31 +1,25 @@
|
||||
version: 2
|
||||
|
||||
aliases:
|
||||
- &repo_path
|
||||
~/ui-theme
|
||||
- &defaults
|
||||
working_directory: ~/ui-theme
|
||||
- &node11_executor
|
||||
working_directory: *repo_path
|
||||
- &node_latest_executor
|
||||
docker:
|
||||
- image: circleci/node:11.10.1
|
||||
- &node8_executor
|
||||
- image: circleci/node:latest
|
||||
- &node_lts_executor
|
||||
docker:
|
||||
- image: circleci/node:8
|
||||
- &node10_executor
|
||||
docker:
|
||||
- image: circleci/node:10
|
||||
- image: circleci/node:lts
|
||||
- &default_executor
|
||||
<<: *node10_executor
|
||||
- &repo_key
|
||||
repo-{{ .Branch }}-{{ .Revision }}
|
||||
- &coverage_key
|
||||
coverage-{{ .Branch }}-{{ .Revision }}
|
||||
- &base_config_key
|
||||
base-config-{{ .Branch }}-{{ .Revision }}
|
||||
<<: *node_latest_executor
|
||||
- &yarn_cache_key
|
||||
yarn-sha-{{ checksum "yarn.lock" }}
|
||||
- &coverage_key
|
||||
coverage-{{ .Branch }}-{{ .Revision }}
|
||||
- &restore_repo
|
||||
restore_cache:
|
||||
keys:
|
||||
- *repo_key
|
||||
attach_workspace:
|
||||
at: *repo_path
|
||||
- &ignore_non_dev_branches
|
||||
filters:
|
||||
tags:
|
||||
@@ -36,7 +30,7 @@ aliases:
|
||||
- &execute_on_release
|
||||
filters:
|
||||
tags:
|
||||
only: /(v)?[0-9]+(\.[0-9]+)*/
|
||||
only: /v?[0-9]+(\.[0-9]+)*([-+\.][a-zA-Z0-9]+)*/
|
||||
branches:
|
||||
ignore:
|
||||
- /.*/
|
||||
@@ -48,21 +42,11 @@ jobs:
|
||||
steps:
|
||||
- *restore_repo
|
||||
- checkout
|
||||
- restore_cache:
|
||||
key: *base_config_key
|
||||
- run:
|
||||
name: 'Base environment setup'
|
||||
command: echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc
|
||||
- save_cache:
|
||||
key: *base_config_key
|
||||
paths:
|
||||
- ~/.npmrc
|
||||
- ~/.gitconfig
|
||||
- restore_cache:
|
||||
key: *yarn_cache_key
|
||||
- run:
|
||||
name: Install Js dependencies
|
||||
command: yarn install --no-progress --registry https://registry.verdaccio.org --no-lockfile
|
||||
name: Install dependencies
|
||||
command: yarn install --frozen-lockfile
|
||||
- run:
|
||||
name: Build project
|
||||
command: yarn run build
|
||||
@@ -72,10 +56,20 @@ jobs:
|
||||
- ~/.yarn
|
||||
- ~/.cache/yarn
|
||||
- node_modules
|
||||
- save_cache:
|
||||
key: *repo_key
|
||||
- persist_to_workspace:
|
||||
root: *repo_path
|
||||
paths:
|
||||
- ~/ui-theme
|
||||
- ./*
|
||||
|
||||
lint:
|
||||
<<: *defaults
|
||||
<<: *default_executor
|
||||
steps:
|
||||
- *restore_repo
|
||||
- run:
|
||||
name: Lint code
|
||||
command: yarn lint
|
||||
|
||||
test_bundlesize:
|
||||
<<: *defaults
|
||||
<<: *default_executor
|
||||
@@ -85,37 +79,28 @@ jobs:
|
||||
name: Test BundleSize
|
||||
command: yarn test:size
|
||||
|
||||
test_node11:
|
||||
test_node_latest:
|
||||
<<: *defaults
|
||||
<<: *node11_executor
|
||||
<<: *node_latest_executor
|
||||
steps:
|
||||
- *restore_repo
|
||||
- run:
|
||||
name: Test with Node 11
|
||||
name: Test with Node (Latest)
|
||||
command: yarn test
|
||||
|
||||
test_node8:
|
||||
<<: *defaults
|
||||
<<: *node8_executor
|
||||
steps:
|
||||
- *restore_repo
|
||||
- run:
|
||||
name: Test with Node 8
|
||||
command: yarn test
|
||||
|
||||
test_node10:
|
||||
<<: *defaults
|
||||
<<: *node10_executor
|
||||
steps:
|
||||
- *restore_repo
|
||||
- run:
|
||||
name: Test with Node 10
|
||||
command: yarn run test
|
||||
- save_cache:
|
||||
key: *coverage_key
|
||||
paths:
|
||||
- coverage
|
||||
|
||||
test_node_lts:
|
||||
<<: *defaults
|
||||
<<: *node_lts_executor
|
||||
steps:
|
||||
- *restore_repo
|
||||
- run:
|
||||
name: Test with Node (LTS)
|
||||
command: yarn test
|
||||
|
||||
coverage:
|
||||
<<: *defaults
|
||||
<<: *default_executor
|
||||
@@ -140,8 +125,9 @@ jobs:
|
||||
<<: *default_executor
|
||||
steps:
|
||||
- *restore_repo
|
||||
- restore_cache:
|
||||
key: *base_config_key
|
||||
- run:
|
||||
name: 'Setup publish credentials'
|
||||
command: echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc
|
||||
- run:
|
||||
name: Publish
|
||||
command: yarn publish
|
||||
@@ -152,29 +138,31 @@ workflows:
|
||||
jobs:
|
||||
- prepare:
|
||||
<<: *ignore_non_dev_branches
|
||||
- test_node11:
|
||||
requires:
|
||||
- prepare
|
||||
<<: *ignore_non_dev_branches
|
||||
- test_node8:
|
||||
requires:
|
||||
- prepare
|
||||
<<: *ignore_non_dev_branches
|
||||
- test_node10:
|
||||
- lint:
|
||||
requires:
|
||||
- prepare
|
||||
<<: *ignore_non_dev_branches
|
||||
- test_bundlesize:
|
||||
requires:
|
||||
- test_node11
|
||||
- test_node8
|
||||
- test_node10
|
||||
- prepare
|
||||
<<: *ignore_non_dev_branches
|
||||
- test_node_latest:
|
||||
requires:
|
||||
- prepare
|
||||
<<: *ignore_non_dev_branches
|
||||
- test_node_lts:
|
||||
requires:
|
||||
- prepare
|
||||
<<: *ignore_non_dev_branches
|
||||
- coverage:
|
||||
requires:
|
||||
- test_bundlesize
|
||||
- test_node_latest
|
||||
<<: *ignore_non_dev_branches
|
||||
- publish_package:
|
||||
requires:
|
||||
- lint
|
||||
- test_bundlesize
|
||||
- test_node_latest
|
||||
- test_node_lts
|
||||
- coverage
|
||||
<<: *execute_on_release
|
||||
|
||||
@@ -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,
|
||||
}
|
||||
}
|
||||
|
||||
67
.github/main.workflow
vendored
67
.github/main.workflow
vendored
@@ -1,67 +0,0 @@
|
||||
################################################
|
||||
# Workflow for a github release when a tag is
|
||||
# pushed
|
||||
################################################
|
||||
workflow "github release" {
|
||||
resolves = [
|
||||
"release.github",
|
||||
"release.lint",
|
||||
]
|
||||
on = "push"
|
||||
}
|
||||
|
||||
action "release.filter" {
|
||||
uses = "actions/bin/filter@master"
|
||||
args = "tag v*"
|
||||
}
|
||||
|
||||
action "release.install" {
|
||||
uses = "docker://node:10"
|
||||
needs = ["release.filter"]
|
||||
args = "yarn install"
|
||||
}
|
||||
|
||||
action "release.build" {
|
||||
uses = "docker://node:10"
|
||||
needs = ["release.install"]
|
||||
args = "yarn run build"
|
||||
}
|
||||
|
||||
action "release.lint" {
|
||||
uses = "docker://node:10"
|
||||
needs = ["release.install"]
|
||||
args = "yarn run lint"
|
||||
}
|
||||
|
||||
action "release.test" {
|
||||
uses = "docker://node:10"
|
||||
needs = ["release.build"]
|
||||
args = "yarn run test"
|
||||
}
|
||||
|
||||
action "release.auth" {
|
||||
needs = ["release.test"]
|
||||
uses = "actions/bin/filter@master"
|
||||
args = ["actor", "octocat", "torvalds"]
|
||||
}
|
||||
|
||||
action "release.npm.publish" {
|
||||
needs = ["release.auth"]
|
||||
uses = "docker://node:10"
|
||||
args = "sh scripts/publish.sh"
|
||||
secrets = [
|
||||
"REGISTRY_AUTH_TOKEN",
|
||||
]
|
||||
env = {
|
||||
REGISTRY_URL = "registry.npmjs.org"
|
||||
}
|
||||
}
|
||||
|
||||
action "release.github" {
|
||||
needs = ["release.npm.publish"]
|
||||
uses = "docker://node:10"
|
||||
args = "sh scripts/github-release.sh"
|
||||
secrets = [
|
||||
"GITHUB_TOKEN",
|
||||
]
|
||||
}
|
||||
28
.github/workflows/main.yml
vendored
Normal file
28
.github/workflows/main.yml
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
name: CI
|
||||
|
||||
on: push
|
||||
|
||||
jobs:
|
||||
build_test_lint:
|
||||
name: Node ${{ matrix.node_version }} and ${{ matrix.os }}
|
||||
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
node_version: [10, 12]
|
||||
os: [ubuntu-latest, windows-latest, macOS-latest]
|
||||
|
||||
runs-on: ${{ matrix.os }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- name: Use Node.js ${{ matrix.node_version }}
|
||||
uses: actions/setup-node@v1
|
||||
with:
|
||||
version: ${{ matrix.node_version }}
|
||||
- name: Install
|
||||
run: yarn install --frozen-lockfile
|
||||
- name: Build
|
||||
run: yarn build
|
||||
- name: Lint
|
||||
run: yarn lint
|
||||
@@ -1,4 +1,5 @@
|
||||
{
|
||||
"endOfLine": "auto",
|
||||
"useTabs": false,
|
||||
"printWidth": 160,
|
||||
"tabWidth": 2,
|
||||
|
||||
40
.secrets-baseline
Normal file
40
.secrets-baseline
Normal file
@@ -0,0 +1,40 @@
|
||||
{
|
||||
"exclude": {
|
||||
"files": null,
|
||||
"lines": null
|
||||
},
|
||||
"generated_at": "2019-09-29T18:19:50Z",
|
||||
"plugins_used": [
|
||||
{
|
||||
"name": "AWSKeyDetector"
|
||||
},
|
||||
{
|
||||
"name": "ArtifactoryDetector"
|
||||
},
|
||||
{
|
||||
"base64_limit": 4.5,
|
||||
"name": "Base64HighEntropyString"
|
||||
},
|
||||
{
|
||||
"name": "BasicAuthDetector"
|
||||
},
|
||||
{
|
||||
"hex_limit": 3,
|
||||
"name": "HexHighEntropyString"
|
||||
},
|
||||
{
|
||||
"name": "KeywordDetector"
|
||||
},
|
||||
{
|
||||
"name": "PrivateKeyDetector"
|
||||
},
|
||||
{
|
||||
"name": "SlackDetector"
|
||||
},
|
||||
{
|
||||
"name": "StripeDetector"
|
||||
}
|
||||
],
|
||||
"results": {},
|
||||
"version": "0.12.4"
|
||||
}
|
||||
@@ -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,
|
||||
|
||||
83
CHANGELOG.md
83
CHANGELOG.md
@@ -1,7 +1,88 @@
|
||||
# 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.3.2](https://github.com/verdaccio/ui/compare/v0.3.1...v0.3.2) (2019-09-30)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* sidebar view on small screens ([#136](https://github.com/verdaccio/ui/issues/136)) ([91d818c](https://github.com/verdaccio/ui/commit/91d818c))
|
||||
|
||||
### [0.3.1](https://github.com/verdaccio/ui/compare/v0.3.0...v0.3.1) (2019-09-29)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **ui:** fix the hover effect on the packageItem's author area ([#137](https://github.com/verdaccio/ui/issues/137)) ([2e50981](https://github.com/verdaccio/ui/commit/2e50981))
|
||||
* correctly load font files - closes [#128](https://github.com/verdaccio/ui/issues/128) ([#134](https://github.com/verdaccio/ui/issues/134)) ([f61913c](https://github.com/verdaccio/ui/commit/f61913c))
|
||||
|
||||
## [0.3.0](https://github.com/verdaccio/ui/compare/v0.2.4...v0.3.0) (2019-09-01)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* add browser features to browse by version ([#125](https://github.com/verdaccio/ui/issues/125)) ([1904179](https://github.com/verdaccio/ui/commit/1904179))
|
||||
|
||||
### [0.2.4](https://github.com/verdaccio/ui/compare/v0.2.3...v0.2.4) (2019-08-31)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* update material-ui@4.x ([#123](https://github.com/verdaccio/ui/issues/123)) ([67d7188](https://github.com/verdaccio/ui/commit/67d7188))
|
||||
|
||||
### [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)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* [@typescript-eslint](https://github.com/typescript-eslint)/explicit-function-return-type ([31c11f2](https://github.com/verdaccio/ui/commit/31c11f2))
|
||||
* [@typescript-eslint](https://github.com/typescript-eslint)/explicit-member-accessibility ([55f50e9](https://github.com/verdaccio/ui/commit/55f50e9))
|
||||
* [@typescript-eslint](https://github.com/typescript-eslint)/no-explicit-any ([2f28ade](https://github.com/verdaccio/ui/commit/2f28ade))
|
||||
* [@typescript-eslint](https://github.com/typescript-eslint)/no-explicit-any ([6eec4f4](https://github.com/verdaccio/ui/commit/6eec4f4))
|
||||
* [@typescript-eslint](https://github.com/typescript-eslint)/no-explicit-any ([ec8ed12](https://github.com/verdaccio/ui/commit/ec8ed12))
|
||||
* [@typescript-eslint](https://github.com/typescript-eslint)/no-explicit-any for file-size.ts ([b683b68](https://github.com/verdaccio/ui/commit/b683b68))
|
||||
* add missing global font-family ([c57f9dd](https://github.com/verdaccio/ui/commit/c57f9dd))
|
||||
* added packageMeta type ([3c54b11](https://github.com/verdaccio/ui/commit/3c54b11))
|
||||
* container breakpoint ([60b7161](https://github.com/verdaccio/ui/commit/60b7161))
|
||||
* incorrect logos styles ([fdad635](https://github.com/verdaccio/ui/commit/fdad635)), closes [#47](https://github.com/verdaccio/ui/issues/47)
|
||||
* logo component styled ([210bcf3](https://github.com/verdaccio/ui/commit/210bcf3))
|
||||
* remove any types and added additional component state interfaces ([116055c](https://github.com/verdaccio/ui/commit/116055c))
|
||||
* remove token from AppState ([78b4c3f](https://github.com/verdaccio/ui/commit/78b4c3f))
|
||||
* remove undefined error ([d1ed3e7](https://github.com/verdaccio/ui/commit/d1ed3e7))
|
||||
* support deprecated license object properties ([b2e420d](https://github.com/verdaccio/ui/commit/b2e420d))
|
||||
* type lint for login ([91e603e](https://github.com/verdaccio/ui/commit/91e603e))
|
||||
* typescript warnings - prefer-rest-params ([e33570b](https://github.com/verdaccio/ui/commit/e33570b))
|
||||
* update snapshot for verdaccio/jsx-no-style ([e7d145f](https://github.com/verdaccio/ui/commit/e7d145f))
|
||||
* updated type to fix unit test ([7cab3f2](https://github.com/verdaccio/ui/commit/7cab3f2))
|
||||
* verdaccio/jsx-no-style ([55b1402](https://github.com/verdaccio/ui/commit/55b1402))
|
||||
|
||||
|
||||
|
||||
<a name="0.2.0"></a>
|
||||
# [0.2.0](https://github.com/verdaccio/ui/compare/v0.1.11...v0.2.0) (2019-06-20)
|
||||
|
||||
|
||||
@@ -26,14 +26,14 @@ We use `>=yarn@1.13.0`, keep on mind we use lock file.
|
||||
|
||||
For development run the following command, it will execute `webpack` and `verdaccio` to
|
||||
|
||||
```
|
||||
```bash
|
||||
yarn dev
|
||||
```
|
||||
The configuration file is located on `tools/_config.yaml`.
|
||||
|
||||
Run linting tooling and test to check your code is clean before commit.
|
||||
|
||||
```
|
||||
```bash
|
||||
yarn lint && yarn test
|
||||
```
|
||||
|
||||
|
||||
21
codecept.conf.js
Normal file
21
codecept.conf.js
Normal 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',
|
||||
};
|
||||
@@ -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)'],
|
||||
// };
|
||||
@@ -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'],
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -39,8 +39,8 @@ const register = (url, method = 'get', options = {}) => {
|
||||
* Bind API methods
|
||||
*/
|
||||
class API {
|
||||
request() {
|
||||
return register.call(null, ...arguments);
|
||||
public request(...rest) {
|
||||
return register.call(null, ...rest);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,6 @@
|
||||
* Mock response for logo api
|
||||
* @returns {promise}
|
||||
*/
|
||||
export default function() {
|
||||
export default function<T>(): Promise<T> {
|
||||
return Promise.resolve('http://localhost/-/static/logo.png');
|
||||
}
|
||||
|
||||
166
package.json
166
package.json
@@ -1,106 +1,115 @@
|
||||
{
|
||||
"name": "@verdaccio/ui-theme",
|
||||
"version": "0.2.0",
|
||||
"version": "0.3.2",
|
||||
"description": "Verdaccio User Interface",
|
||||
"author": {
|
||||
"name": "Verdaccio Core Team"
|
||||
"name": "Verdaccio Core Team",
|
||||
"email": "verdaccio.npm@gmail.com"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/verdaccio/ui"
|
||||
},
|
||||
"homepage": "https://verdaccio.org",
|
||||
"main": "index.js",
|
||||
"devDependencies": {
|
||||
"@commitlint/cli": "8.0.0",
|
||||
"@commitlint/config-conventional": "8.0.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",
|
||||
"@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",
|
||||
"@commitlint/cli": "8.2.0",
|
||||
"@commitlint/config-conventional": "8.2.0",
|
||||
"@material-ui/core": "4.4.3",
|
||||
"@material-ui/icons": "4.4.3",
|
||||
"@octokit/rest": "16.28.7",
|
||||
"@testing-library/react": "9.2.0",
|
||||
"@types/enzyme": "3.10.3",
|
||||
"@types/jest": "24.0.18",
|
||||
"@types/lodash": "4.14.141",
|
||||
"@types/node": "12.7.8",
|
||||
"@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.1.0",
|
||||
"autosuggest-highlight": "3.1.1",
|
||||
"babel-loader": "8.0.6",
|
||||
"bundlesize": "0.17.2",
|
||||
"codecov": "3.5.0",
|
||||
"concurrently": "4.1.0",
|
||||
"cross-env": "5.2.0",
|
||||
"css-loader": "0.28.10",
|
||||
"bundlesize": "0.18.0",
|
||||
"codeceptjs": "2.3.2",
|
||||
"codecov": "3.6.1",
|
||||
"concurrently": "4.1.2",
|
||||
"cross-env": "6.0.0",
|
||||
"detect-secrets": "1.0.4",
|
||||
"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": "2.0.1",
|
||||
"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.7",
|
||||
"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",
|
||||
"lint-staged": "8.2.1",
|
||||
"lockfile-lint": "2.0.1",
|
||||
"localstorage-memory": "1.0.3",
|
||||
"mini-css-extract-plugin": "0.7.0",
|
||||
"node-mocks-http": "1.7.3",
|
||||
"node-sass": "4.12.0",
|
||||
"mini-css-extract-plugin": "0.8.0",
|
||||
"node-mocks-http": "1.8.0",
|
||||
"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",
|
||||
"rimraf": "2.6.3",
|
||||
"sass-loader": "7.1.0",
|
||||
"react-hot-loader": "4.12.11",
|
||||
"react-router": "5.0.1",
|
||||
"react-router-dom": "5.0.1",
|
||||
"resolve-url-loader": "3.1.0",
|
||||
"rimraf": "3.0.0",
|
||||
"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-recommended-scss": "3.3.0",
|
||||
"stylelint-config-styled-components": "0.1.1",
|
||||
"stylelint-processor-styled-components": "1.8.0",
|
||||
"stylelint-scss": "3.8.0",
|
||||
"stylelint-webpack-plugin": "0.10.5",
|
||||
"supertest": "4.0.2",
|
||||
"typeface-roboto": "0.0.54",
|
||||
"typescript": "3.4.5",
|
||||
"url-loader": "1.1.2",
|
||||
"validator": "10.11.0",
|
||||
"verdaccio": "4.0.3",
|
||||
"verdaccio-auth-memory": "0.0.4",
|
||||
"verdaccio-memory": "2.0.0",
|
||||
"webpack": "4.20.2",
|
||||
"webpack-bundle-analyzer": "3.3.2",
|
||||
"webpack-bundle-size-analyzer": "3.0.0",
|
||||
"webpack-cli": "3.2.3",
|
||||
"webpack-dev-server": "3.2.1",
|
||||
"webpack-merge": "4.2.1",
|
||||
"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.2",
|
||||
"verdaccio-auth-memory": "8.1.1",
|
||||
"verdaccio-memory": "8.1.1",
|
||||
"webpack": "4.41.0",
|
||||
"webpack-bundle-analyzer": "3.5.2",
|
||||
"webpack-bundle-size-analyzer": "3.1.0",
|
||||
"webpack-cli": "3.3.9",
|
||||
"webpack-dev-server": "3.8.1",
|
||||
"webpack-merge": "4.2.2",
|
||||
"whatwg-fetch": "3.0.0",
|
||||
"xss": "1.0.6"
|
||||
},
|
||||
@@ -138,12 +147,16 @@
|
||||
"scripts": {
|
||||
"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",
|
||||
"release": "standard-version -a",
|
||||
"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": "npm run lint:js && npm run lint:css && npm run lint:lockfile",
|
||||
"lint:js": "npm run type-check && eslint . --ext .js,.ts,.tsx",
|
||||
"lint:css": "stylelint 'src/**/styles.ts'",
|
||||
"lint:css": "stylelint \"src/**/styles.ts\"",
|
||||
"lint:lockfile": "lockfile-lint --path yarn.lock --type yarn --validate-https --allowed-hosts verdaccio npm yarn",
|
||||
"coverage:publish": "codecov",
|
||||
"pre:webpack": "rimraf static/*",
|
||||
"prepublish": "in-publish && npm run build || not-in-publish",
|
||||
@@ -160,9 +173,26 @@
|
||||
},
|
||||
"husky": {
|
||||
"hooks": {
|
||||
"pre-commit": "commitlint -e $GIT_PARAMS"
|
||||
"pre-commit": "lint-staged",
|
||||
"commit-msg": "commitlint -e $GIT_PARAMS"
|
||||
}
|
||||
},
|
||||
"lint-staged": {
|
||||
"relative": true,
|
||||
"linters": {
|
||||
"*.{js,tsx,ts}": [
|
||||
"eslint .",
|
||||
"prettier --write"
|
||||
],
|
||||
"*": [
|
||||
"detect-secrets-launcher --baseline .secrets-baseline",
|
||||
"git add"
|
||||
]
|
||||
},
|
||||
"ignore": [
|
||||
"*.json"
|
||||
]
|
||||
},
|
||||
"license": "MIT",
|
||||
"commitlint": {
|
||||
"extends": [
|
||||
|
||||
1
partials/storage/.verdaccio-db.json
Normal file
1
partials/storage/.verdaccio-db.json
Normal file
@@ -0,0 +1 @@
|
||||
{"list":["vue","jquery"],"secret":"3bb332943c7086716a35dea44754b43b956ee655af1fe61866fbdaf38486836c"}
|
||||
BIN
partials/storage/jquery/jquery-1.5.1.tgz
Normal file
BIN
partials/storage/jquery/jquery-1.5.1.tgz
Normal file
Binary file not shown.
4983
partials/storage/jquery/package.json
Normal file
4983
partials/storage/jquery/package.json
Normal file
File diff suppressed because it is too large
Load Diff
25174
partials/storage/vue/package.json
Normal file
25174
partials/storage/vue/package.json
Normal file
File diff suppressed because one or more lines are too long
@@ -7,7 +7,7 @@ import { generateTokenWithTimeRange } from '../../jest/unit/components/__mocks__
|
||||
|
||||
jest.mock('../utils/storage', () => {
|
||||
class LocalStorageMock {
|
||||
store: object;
|
||||
private store: object;
|
||||
public constructor() {
|
||||
this.store = {};
|
||||
}
|
||||
@@ -43,7 +43,7 @@ describe('App', () => {
|
||||
expect(wrapper.state().showLoginModal).toBeFalsy();
|
||||
handleToggleLoginModal();
|
||||
expect(wrapper.state('showLoginModal')).toBeTruthy();
|
||||
expect(wrapper.state('error')).toEqual({});
|
||||
expect(wrapper.state('error')).toEqual(undefined);
|
||||
});
|
||||
|
||||
test('isUserAlreadyLoggedIn: token already available in storage', async () => {
|
||||
@@ -71,7 +71,6 @@ describe('App', () => {
|
||||
await handleDoLogin('sam', '1234');
|
||||
const result = {
|
||||
username: 'sam',
|
||||
token: 'TEST_TOKEN',
|
||||
};
|
||||
expect(wrapper.state('isUserLoggedIn')).toBeTruthy();
|
||||
expect(wrapper.state('showLoginModal')).toBeFalsy();
|
||||
|
||||
@@ -10,18 +10,30 @@ import Header from '../components/Header';
|
||||
import { Container, Content } from '../components/Layout';
|
||||
import RouterApp from '../router';
|
||||
import API from '../utils/api';
|
||||
import '../styles/typeface-roboto.scss';
|
||||
import '../styles/main.scss';
|
||||
import 'typeface-roboto/index.css';
|
||||
import '../utils/styles/global';
|
||||
import 'normalize.css';
|
||||
import Footer from '../components/Footer';
|
||||
import { FormError } from 'src/components/Login/Login';
|
||||
|
||||
export const AppContext = React.createContext<null>(null);
|
||||
export const AppContext = React.createContext<{}>({});
|
||||
export const AppContextProvider = AppContext.Provider;
|
||||
export const AppContextConsumer = AppContext.Consumer;
|
||||
|
||||
export default class App extends Component<any, any> {
|
||||
public state = {
|
||||
error: {},
|
||||
export interface AppStateInterface {
|
||||
error?: FormError;
|
||||
logoUrl: string;
|
||||
user: {
|
||||
username?: string;
|
||||
};
|
||||
scope: string;
|
||||
showLoginModal: boolean;
|
||||
isUserLoggedIn: boolean;
|
||||
packages: [];
|
||||
isLoading: boolean;
|
||||
}
|
||||
export default class App extends Component<{}, AppStateInterface> {
|
||||
public state: AppStateInterface = {
|
||||
// @ts-ignore
|
||||
logoUrl: window.VERDACCIO_LOGO,
|
||||
user: {},
|
||||
@@ -49,18 +61,12 @@ export default class App extends Component<any, any> {
|
||||
public render(): React.ReactElement<HTMLDivElement> {
|
||||
const { isLoading, isUserLoggedIn, packages, logoUrl, user, scope } = this.state;
|
||||
|
||||
const context: any = { isUserLoggedIn, packages, logoUrl, user, scope };
|
||||
const context = { isUserLoggedIn, packages, logoUrl, user, scope };
|
||||
|
||||
return (
|
||||
// @ts-ignore
|
||||
<Container isLoading={isLoading}>
|
||||
{isLoading ? (
|
||||
<Loading />
|
||||
) : (
|
||||
<>
|
||||
<AppContextProvider value={context}>{this.renderContent()}</AppContextProvider>
|
||||
</>
|
||||
)}
|
||||
{isLoading ? <Loading /> : <AppContextProvider value={context}>{this.renderContent()}</AppContextProvider>}
|
||||
{this.renderLoginModal()}
|
||||
</Container>
|
||||
);
|
||||
@@ -74,7 +80,7 @@ export default class App extends Component<any, any> {
|
||||
this.handleLogout();
|
||||
} else {
|
||||
this.setState({
|
||||
user: { username, token },
|
||||
user: { username },
|
||||
isUserLoggedIn: true,
|
||||
});
|
||||
}
|
||||
@@ -112,7 +118,6 @@ export default class App extends Component<any, any> {
|
||||
this.setState(prevState => ({
|
||||
// @ts-ignore
|
||||
showLoginModal: !prevState.showLoginModal,
|
||||
error: {},
|
||||
}));
|
||||
};
|
||||
|
||||
@@ -127,7 +132,7 @@ export default class App extends Component<any, any> {
|
||||
if (username && token) {
|
||||
storage.setItem('username', username);
|
||||
storage.setItem('token', token);
|
||||
this.setLoggedUser(username, token);
|
||||
this.setLoggedUser(username);
|
||||
}
|
||||
|
||||
if (error) {
|
||||
@@ -138,11 +143,10 @@ export default class App extends Component<any, any> {
|
||||
}
|
||||
};
|
||||
|
||||
public setLoggedUser = (username, token) => {
|
||||
public setLoggedUser = username => {
|
||||
this.setState({
|
||||
user: {
|
||||
username,
|
||||
token,
|
||||
},
|
||||
isUserLoggedIn: true, // close login modal after successful login
|
||||
showLoginModal: false, // set isUserLoggedIn to true
|
||||
|
||||
38
src/App/AppError.tsx
Normal file
38
src/App/AppError.tsx
Normal 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;
|
||||
}
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
@import './styles/variables';
|
||||
|
||||
.alertError {
|
||||
background-color: $red !important;
|
||||
min-width: inherit !important;
|
||||
}
|
||||
|
||||
.alertErrorMsg {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.alertIcon {
|
||||
opacity: 0.9;
|
||||
margin-right: 8px;
|
||||
}
|
||||
17
src/App/styles.ts
Normal file
17
src/App/styles.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import { css } from 'emotion';
|
||||
import colors from '../utils/styles/colors';
|
||||
|
||||
export const alertError = css({
|
||||
backgroundColor: `${colors.red} !important`,
|
||||
minWidth: 'inherit !important',
|
||||
});
|
||||
|
||||
export const alertErrorMsg = css({
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
});
|
||||
|
||||
export const alertIcon = css({
|
||||
opacity: 0.9,
|
||||
marginRight: '8px',
|
||||
});
|
||||
62
src/components/ActionBar/ActionBar.test.tsx
Normal file
62
src/components/ActionBar/ActionBar.test.tsx
Normal file
@@ -0,0 +1,62 @@
|
||||
import React from 'react';
|
||||
import { mount } from 'enzyme';
|
||||
import { ActionBar } from './ActionBar';
|
||||
|
||||
const mockPackageMeta = jest.fn(() => ({
|
||||
latest: {
|
||||
homepage: 'https://verdaccio.tld',
|
||||
bugs: {
|
||||
url: 'https://verdaccio.tld/bugs',
|
||||
},
|
||||
dist: {
|
||||
tarball: 'https://verdaccio.tld/download',
|
||||
},
|
||||
},
|
||||
}));
|
||||
|
||||
jest.mock('../../pages/Version', () => ({
|
||||
DetailContextConsumer: component => {
|
||||
return component.children({ packageMeta: mockPackageMeta() });
|
||||
},
|
||||
}));
|
||||
|
||||
describe('<ActionBar /> component', () => {
|
||||
beforeEach(() => {
|
||||
jest.resetModules();
|
||||
jest.resetAllMocks();
|
||||
});
|
||||
|
||||
test('should render the component in default state', () => {
|
||||
const wrapper = mount(<ActionBar />);
|
||||
expect(wrapper.html()).toMatchSnapshot();
|
||||
});
|
||||
|
||||
test('when there is no action bar data', () => {
|
||||
// @ts-ignore
|
||||
mockPackageMeta.mockImplementation(() => ({
|
||||
latest: {},
|
||||
}));
|
||||
|
||||
const wrapper = mount(<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', () => {
|
||||
// @ts-ignore
|
||||
mockPackageMeta.mockImplementation(() => ({
|
||||
latest: {
|
||||
dist: {
|
||||
tarball: 'http://localhost:8080/bootstrap/-/bootstrap-4.3.1.tgz',
|
||||
},
|
||||
},
|
||||
}));
|
||||
|
||||
const wrapper = mount(<ActionBar />);
|
||||
expect(wrapper.html()).toMatchSnapshot();
|
||||
|
||||
const button = wrapper.find('button');
|
||||
expect(button).toHaveLength(1);
|
||||
});
|
||||
});
|
||||
@@ -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,21 +40,28 @@ const ACTIONS = {
|
||||
tarball: {
|
||||
icon: <DownloadIcon />,
|
||||
title: 'Download tarball',
|
||||
handler: downloadHandler,
|
||||
},
|
||||
};
|
||||
|
||||
class ActionBar extends Component<any, any> {
|
||||
class ActionBar extends Component {
|
||||
public render(): ReactElement<HTMLElement> {
|
||||
return (
|
||||
<DetailContextConsumer>
|
||||
{context => {
|
||||
const { packageMeta } = context;
|
||||
|
||||
if (!packageMeta) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return this.renderActionBar(context as VersionPageConsumerProps);
|
||||
}}
|
||||
</DetailContextConsumer>
|
||||
);
|
||||
}
|
||||
|
||||
private renderIconsWithLink(link: string, component: any): ReactElement<HTMLElement> {
|
||||
private renderIconsWithLink(link: string, component: JSX.Element): ReactElement<HTMLElement> {
|
||||
return (
|
||||
<a href={link} target={'_blank'}>
|
||||
{component}
|
||||
@@ -44,40 +69,66 @@ class ActionBar extends Component<any, any> {
|
||||
);
|
||||
}
|
||||
|
||||
private renderActionBarListItems = packageMeta => {
|
||||
private renderActionBar = ({ packageMeta }) => {
|
||||
// @ts-ignore
|
||||
const { latest: { bugs: { url: issue } = {}, homepage, dist: { tarball } = {} } = {} } = packageMeta;
|
||||
const { latest } = packageMeta;
|
||||
|
||||
if (!latest) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const { homepage, bugs, dist } = latest;
|
||||
|
||||
const actionsMap = {
|
||||
homepage,
|
||||
issue,
|
||||
tarball,
|
||||
issue: bugs ? bugs.url : null,
|
||||
tarball: dist ? dist.tarball : null,
|
||||
};
|
||||
|
||||
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;
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<>
|
||||
<ActionListItem alignItems={'flex-start'}>{renderList}</ActionListItem>
|
||||
</>
|
||||
);
|
||||
};
|
||||
if (renderList.length > 0) {
|
||||
return (
|
||||
<List>
|
||||
<ActionListItem alignItems={'flex-start'} button={true}>
|
||||
{renderList}
|
||||
</ActionListItem>
|
||||
</List>
|
||||
);
|
||||
}
|
||||
|
||||
private renderActionBar = ({ packageMeta = {} }) => {
|
||||
return <List>{this.renderActionBarListItems(packageMeta)}</List>;
|
||||
return null;
|
||||
};
|
||||
}
|
||||
|
||||
export default ActionBar;
|
||||
export { ActionBar };
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`<ActionBar /> component should render the component in default state 1`] = `""`;
|
||||
|
||||
exports[`<ActionBar /> component when there is a button to download a tarball 1`] = `"<ul class=\\"MuiList-root MuiList-padding\\"><div class=\\"MuiButtonBase-root MuiListItem-root css-9q3x3c eux6shq0 MuiListItem-gutters MuiListItem-button MuiListItem-alignItemsFlexStart\\" tabindex=\\"0\\" role=\\"button\\" aria-disabled=\\"false\\"><button class=\\"MuiButtonBase-root MuiFab-root css-96oxa0 eux6shq1 MuiFab-sizeSmall\\" tabindex=\\"0\\" type=\\"button\\" title=\\"Download tarball\\"><span class=\\"MuiFab-label\\"><svg class=\\"MuiSvgIcon-root\\" focusable=\\"false\\" viewBox=\\"0 0 24 24\\" aria-hidden=\\"true\\" role=\\"presentation\\"><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\\"></span></button><span class=\\"MuiTouchRipple-root\\"></span></div></ul>"`;
|
||||
@@ -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',
|
||||
},
|
||||
});
|
||||
|
||||
@@ -1,11 +1,83 @@
|
||||
import React from 'react';
|
||||
import { shallow } from 'enzyme';
|
||||
import { mount } from 'enzyme';
|
||||
import Authors from './Author';
|
||||
|
||||
import Author from './Author';
|
||||
const mockPackageMeta = jest.fn(() => ({
|
||||
latest: {
|
||||
homepage: 'https://verdaccio.tld',
|
||||
bugs: {
|
||||
url: 'https://verdaccio.tld/bugs',
|
||||
},
|
||||
dist: {
|
||||
tarball: 'https://verdaccio.tld/download',
|
||||
},
|
||||
},
|
||||
}));
|
||||
|
||||
jest.mock('../../pages/Version', () => ({
|
||||
DetailContextConsumer: component => {
|
||||
return component.children({ packageMeta: mockPackageMeta() });
|
||||
},
|
||||
}));
|
||||
|
||||
describe('<Author /> component', () => {
|
||||
beforeEach(() => {
|
||||
jest.resetAllMocks();
|
||||
});
|
||||
|
||||
test('should render the component in default state', () => {
|
||||
const wrapper = shallow(<Author />);
|
||||
const packageMeta = {
|
||||
latest: {
|
||||
name: 'verdaccio',
|
||||
version: '4.0.0',
|
||||
author: {
|
||||
name: 'verdaccio user',
|
||||
email: 'verdaccio.user@verdaccio.org',
|
||||
url: '',
|
||||
avatar: 'https://www.gravatar.com/avatar/000000',
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
// @ts-ignore
|
||||
mockPackageMeta.mockImplementation(() => packageMeta);
|
||||
|
||||
const wrapper = mount(<Authors />);
|
||||
expect(wrapper.html()).toMatchSnapshot();
|
||||
});
|
||||
|
||||
test('should render the component when there is no author information available', () => {
|
||||
const packageMeta = {
|
||||
latest: {
|
||||
name: 'verdaccio',
|
||||
version: '4.0.0',
|
||||
},
|
||||
};
|
||||
|
||||
// @ts-ignore
|
||||
mockPackageMeta.mockImplementation(() => packageMeta);
|
||||
|
||||
const wrapper = mount(<Authors />);
|
||||
expect(wrapper.html()).toEqual('');
|
||||
});
|
||||
|
||||
test('should render the component when there is no author email', () => {
|
||||
const packageMeta = {
|
||||
latest: {
|
||||
name: 'verdaccio',
|
||||
version: '4.0.0',
|
||||
author: {
|
||||
name: 'verdaccio user',
|
||||
url: '',
|
||||
avatar: 'https://www.gravatar.com/avatar/000000',
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
// @ts-ignore
|
||||
mockPackageMeta.mockImplementation(() => packageMeta);
|
||||
|
||||
const wrapper = mount(<Authors />);
|
||||
expect(wrapper.html()).toMatchSnapshot();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,25 +1,30 @@
|
||||
import React, { Component, ReactNode } from 'react';
|
||||
import React, { Component, ReactNode, ReactElement } from 'react';
|
||||
|
||||
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 { Heading, AuthorListItem } from './styles';
|
||||
import { DetailContextConsumer } from '../../pages/Version';
|
||||
import { Heading, AuthorListItem, AuthorListItemText } from './styles';
|
||||
import { isEmail } from '../../utils/url';
|
||||
|
||||
class Authors extends Component<any, any> {
|
||||
render() {
|
||||
class Authors extends Component {
|
||||
public render(): ReactElement<HTMLElement> {
|
||||
return (
|
||||
<DetailContextConsumer>
|
||||
{(context: any) => {
|
||||
return context && context.packageMeta && this.renderAuthor(context.packageMeta);
|
||||
{context => {
|
||||
const { packageMeta } = context;
|
||||
|
||||
if (!packageMeta) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return this.renderAuthor(packageMeta);
|
||||
}}
|
||||
</DetailContextConsumer>
|
||||
);
|
||||
}
|
||||
|
||||
renderLinkForMail(email: string, avatarComponent: ReactNode, packageName: string, version: string) {
|
||||
public renderLinkForMail(email: string, avatarComponent: ReactNode, packageName: string, version: string): ReactElement<HTMLElement> | ReactNode {
|
||||
if (!email || isEmail(email) === false) {
|
||||
return avatarComponent;
|
||||
}
|
||||
@@ -31,8 +36,8 @@ class Authors extends Component<any, any> {
|
||||
);
|
||||
}
|
||||
|
||||
renderAuthor = packageMeta => {
|
||||
const { author, name: packageName, version } = packageMeta.latest;
|
||||
public renderAuthor = ({ latest }) => {
|
||||
const { author, name: packageName, version } = latest;
|
||||
|
||||
if (!author) {
|
||||
return null;
|
||||
@@ -40,10 +45,10 @@ class Authors extends Component<any, any> {
|
||||
|
||||
const avatarComponent = <Avatar alt={author.name} src={author.avatar} />;
|
||||
return (
|
||||
<List subheader={<Heading variant={'subheading'}>{'Author'}</Heading>}>
|
||||
<AuthorListItem>
|
||||
<List subheader={<Heading variant={'subtitle1'}>{'Author'}</Heading>}>
|
||||
<AuthorListItem button={true}>
|
||||
{this.renderLinkForMail(author.email, avatarComponent, packageName, version)}
|
||||
<ListItemText primary={author.name} />
|
||||
<AuthorListItemText primary={author.name} />
|
||||
</AuthorListItem>
|
||||
</List>
|
||||
);
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`<Author /> component should render the component in default state 1`] = `""`;
|
||||
exports[`<Author /> component should render the component in default state 1`] = `"<ul class=\\"MuiList-root MuiList-padding MuiList-subheader\\"><h6 class=\\"MuiTypography-root css-hyrz44 e1xuehjw0 MuiTypography-subtitle1\\">Author</h6><div class=\\"MuiButtonBase-root MuiListItem-root css-xugzlj e1xuehjw1 MuiListItem-gutters MuiListItem-button\\" tabindex=\\"0\\" role=\\"button\\" aria-disabled=\\"false\\"><a href=\\"mailto:verdaccio.user@verdaccio.org?subject=verdaccio@4.0.0\\" target=\\"_top\\"><div class=\\"MuiAvatar-root\\"><img alt=\\"verdaccio user\\" src=\\"https://www.gravatar.com/avatar/000000\\" class=\\"MuiAvatar-img\\"></div></a><div class=\\"MuiListItemText-root css-1vhg3jx e1xuehjw2\\"><span class=\\"MuiTypography-root MuiListItemText-primary MuiTypography-body1\\">verdaccio user</span></div><span class=\\"MuiTouchRipple-root\\"></span></div></ul>"`;
|
||||
|
||||
exports[`<Author /> component should render the component when there is no author email 1`] = `"<ul class=\\"MuiList-root MuiList-padding MuiList-subheader\\"><h6 class=\\"MuiTypography-root css-hyrz44 e1xuehjw0 MuiTypography-subtitle1\\">Author</h6><div class=\\"MuiButtonBase-root MuiListItem-root css-xugzlj e1xuehjw1 MuiListItem-gutters MuiListItem-button\\" tabindex=\\"0\\" role=\\"button\\" aria-disabled=\\"false\\"><div class=\\"MuiAvatar-root\\"><img alt=\\"verdaccio user\\" src=\\"https://www.gravatar.com/avatar/000000\\" class=\\"MuiAvatar-img\\"></div><div class=\\"MuiListItemText-root css-1vhg3jx e1xuehjw2\\"><span class=\\"MuiTypography-root MuiListItemText-primary MuiTypography-body1\\">verdaccio user</span></div><span class=\\"MuiTouchRipple-root\\"></span></div></ul>"`;
|
||||
|
||||
@@ -1,16 +1,27 @@
|
||||
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';
|
||||
import ListItemText from '@material-ui/core/ListItemText';
|
||||
|
||||
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)({
|
||||
'&&': {
|
||||
padding: 0,
|
||||
},
|
||||
'&&:hover': {
|
||||
backgroundColor: 'transparent',
|
||||
},
|
||||
});
|
||||
|
||||
export const AuthorListItemText = styled(ListItemText)({
|
||||
'&&': {
|
||||
padding: '0 10px',
|
||||
margin: 0,
|
||||
},
|
||||
});
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import React, { KeyboardEvent } from 'react';
|
||||
import { css } from 'emotion';
|
||||
import Autosuggest from 'react-autosuggest';
|
||||
import match from 'autosuggest-highlight/match';
|
||||
import parse from 'autosuggest-highlight/parse';
|
||||
@@ -7,8 +8,8 @@ import MenuItem from '@material-ui/core/MenuItem';
|
||||
import { fontWeight } from '../../utils/styles/sizes';
|
||||
import { Wrapper, InputField, SuggestionContainer } from './styles';
|
||||
|
||||
export interface Props {
|
||||
suggestions: any[];
|
||||
interface Props {
|
||||
suggestions: unknown[];
|
||||
suggestionsLoading?: boolean;
|
||||
suggestionsLoaded?: boolean;
|
||||
suggestionsError?: boolean;
|
||||
@@ -16,17 +17,17 @@ export interface Props {
|
||||
color?: string;
|
||||
value?: string;
|
||||
placeholder?: string;
|
||||
startAdornment?: any;
|
||||
startAdornment?: JSX.Element;
|
||||
disableUnderline?: boolean;
|
||||
onChange?: (event: KeyboardEvent<HTMLInputElement>, { newValue, method }: { newValue: string; method: string }) => void;
|
||||
onSuggestionsFetch?: ({ value: string }) => Promise<void>;
|
||||
onCleanSuggestions?: () => void;
|
||||
onClick?: (event: KeyboardEvent<HTMLInputElement>, { suggestionValue, method }: { suggestionValue: any[]; method: string }) => void;
|
||||
onClick?: (event: KeyboardEvent<HTMLInputElement>, { suggestionValue, method }: { suggestionValue: string[]; method: string }) => void;
|
||||
onKeyDown?: (event: KeyboardEvent<HTMLInputElement>) => void;
|
||||
onBlur?: (event: KeyboardEvent<HTMLInputElement>) => void;
|
||||
}
|
||||
|
||||
const renderInputComponent = inputProps => {
|
||||
const renderInputComponent = (inputProps): JSX.Element => {
|
||||
const { ref, startAdornment, disableUnderline, onKeyDown, ...others } = inputProps;
|
||||
return (
|
||||
<InputField
|
||||
@@ -46,19 +47,21 @@ const renderInputComponent = inputProps => {
|
||||
|
||||
const getSuggestionValue = (suggestion): string => suggestion.name;
|
||||
|
||||
const renderSuggestion = (suggestion, { query, isHighlighted }) => {
|
||||
const renderSuggestion = (suggestion, { query, isHighlighted }): JSX.Element => {
|
||||
const matches = match(suggestion.name, query);
|
||||
const parts = parse(suggestion.name, matches);
|
||||
return (
|
||||
<MenuItem component="div" selected={isHighlighted}>
|
||||
<div>
|
||||
{parts.map((part, index) => {
|
||||
return part.highlight ? (
|
||||
<a href={suggestion.link} key={String(index)} style={{ fontWeight: fontWeight.semiBold }}>
|
||||
{part.text}
|
||||
</a>
|
||||
) : (
|
||||
<a href={suggestion.link} key={String(index)} style={{ fontWeight: fontWeight.light }}>
|
||||
const fw = part.highlight ? fontWeight.semiBold : fontWeight.light;
|
||||
return (
|
||||
<a
|
||||
className={css`
|
||||
font-weight: ${fw};
|
||||
`}
|
||||
href={suggestion.link}
|
||||
key={String(index)}>
|
||||
{part.text}
|
||||
</a>
|
||||
);
|
||||
@@ -68,7 +71,7 @@ const renderSuggestion = (suggestion, { query, isHighlighted }) => {
|
||||
);
|
||||
};
|
||||
|
||||
const renderMessage = message => {
|
||||
const renderMessage = (message): JSX.Element => {
|
||||
return (
|
||||
<MenuItem component="div" selected={false}>
|
||||
<div>{message}</div>
|
||||
@@ -98,7 +101,7 @@ const AutoComplete = ({
|
||||
suggestionsLoading = false,
|
||||
suggestionsLoaded = false,
|
||||
suggestionsError = false,
|
||||
}: Props) => {
|
||||
}: Props): JSX.Element => {
|
||||
const autosuggestProps = {
|
||||
renderInputComponent,
|
||||
suggestions,
|
||||
@@ -119,7 +122,7 @@ const AutoComplete = ({
|
||||
};
|
||||
|
||||
// this format avoid arrow function eslint rule
|
||||
function renderSuggestionsContainer({ containerProps, children, query }) {
|
||||
function renderSuggestionsContainer({ containerProps, children, query }): JSX.Element {
|
||||
return (
|
||||
<SuggestionContainer {...containerProps} square={true}>
|
||||
{suggestionsLoaded && children === null && query && renderMessage(SUGGESTIONS_RESPONSE.NO_RESULT)}
|
||||
|
||||
@@ -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',
|
||||
},
|
||||
});
|
||||
|
||||
32
src/components/AvatarTooltip/AvatarTooltip.tsx
Normal file
32
src/components/AvatarTooltip/AvatarTooltip.tsx
Normal 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 };
|
||||
4
src/components/AvatarTooltip/index.ts
Normal file
4
src/components/AvatarTooltip/index.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
import { AvatarTooltip } from './AvatarTooltip';
|
||||
|
||||
export { AvatarTooltip };
|
||||
export default AvatarTooltip;
|
||||
@@ -1,5 +1,5 @@
|
||||
import React from 'react';
|
||||
import { shallow } from 'enzyme';
|
||||
import { mount } from 'enzyme';
|
||||
|
||||
import CopyToClipBoard from './CopyToClipBoard';
|
||||
import { CopyIcon } from './styles';
|
||||
@@ -8,7 +8,7 @@ describe('<CopyToClipBoard /> component', () => {
|
||||
let wrapper;
|
||||
|
||||
beforeEach(() => {
|
||||
wrapper = shallow(<CopyToClipBoard text={'copy text'} />);
|
||||
wrapper = mount(<CopyToClipBoard text={'copy text'} />);
|
||||
});
|
||||
|
||||
test('render the component', () => {
|
||||
|
||||
@@ -12,7 +12,7 @@ interface Props {
|
||||
children?: React.ReactNode;
|
||||
}
|
||||
|
||||
const renderText: React.FC<any> = (text: string, children: React.ReactNode): React.ReactElement<HTMLElement> => {
|
||||
const renderText = (text, children): JSX.Element => {
|
||||
if (children) {
|
||||
return <ClipBoardCopyText>{children}</ClipBoardCopyText>;
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`<CopyToClipBoard /> component render the component 1`] = `"<div class=\\"css-1mta3t8 eb8w2fo0\\"><span class=\\"css-1m8aenu eb8w2fo1\\">copy text</span><button class=\\"MuiButtonBase-root-15 MuiIconButton-root-9 css-56v3u0 eb8w2fo2\\" tabindex=\\"0\\" type=\\"button\\" title=\\"Copy to Clipboard\\"><span class=\\"MuiIconButton-label-14\\"><svg class=\\"MuiSvgIcon-root-18\\" 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>"`;
|
||||
exports[`<CopyToClipBoard /> component render the component 1`] = `"<div class=\\"css-1mta3t8 eb8w2fo0\\"><span class=\\"css-1m8aenu eb8w2fo1\\">copy text</span><button class=\\"MuiButtonBase-root MuiIconButton-root css-0 eb8w2fo2\\" tabindex=\\"0\\" type=\\"button\\" title=\\"Copy to Clipboard\\"><span class=\\"MuiIconButton-label\\"><svg class=\\"MuiSvgIcon-root\\" focusable=\\"false\\" viewBox=\\"0 0 24 24\\" aria-hidden=\\"true\\" role=\\"presentation\\"><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><span class=\\"MuiTouchRipple-root\\"></span></button></div>"`;
|
||||
|
||||
@@ -1,26 +1,22 @@
|
||||
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)({});
|
||||
|
||||
@@ -1,14 +1,25 @@
|
||||
import React, { Component, Fragment, ReactElement } from 'react';
|
||||
import { withRouter } from 'react-router-dom';
|
||||
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';
|
||||
|
||||
class DepDetail extends Component<any, any> {
|
||||
constructor(props: any) {
|
||||
type DepDetailProps = {
|
||||
name: string;
|
||||
version: string;
|
||||
onLoading?: () => void;
|
||||
} & RouteComponentProps;
|
||||
|
||||
interface DepDetailState {
|
||||
name: string;
|
||||
version: string;
|
||||
}
|
||||
|
||||
class DepDetail extends Component<DepDetailProps, DepDetailState> {
|
||||
constructor(props: DepDetailProps) {
|
||||
super(props);
|
||||
const { name, version } = this.props;
|
||||
|
||||
@@ -21,32 +32,32 @@ class DepDetail extends Component<any, any> {
|
||||
public render(): ReactElement<HTMLElement> {
|
||||
const { name, version } = this.state;
|
||||
const tagText = `${name}@${version}`;
|
||||
return <Tag className={'dep-tag'} clickable={true} component={'div'} label={tagText} onClick={this.handleOnClick} />;
|
||||
return <Tag className={'dep-tag'} clickable={true} label={tagText} onClick={this.handleOnClick} />;
|
||||
}
|
||||
|
||||
private handleOnClick = () => {
|
||||
const { name } = this.state;
|
||||
const { onLoading, history } = this.props;
|
||||
|
||||
onLoading();
|
||||
onLoading && onLoading();
|
||||
history.push(`/-/web/detail/${name}`);
|
||||
};
|
||||
}
|
||||
|
||||
const WrapperDependencyDetail = withRouter(DepDetail);
|
||||
|
||||
class DependencyBlock extends Component<any, any> {
|
||||
class DependencyBlock extends Component<{ title: string; dependencies: [] }> {
|
||||
public render(): ReactElement<HTMLElement> {
|
||||
const { dependencies, title } = this.props;
|
||||
const deps = Object.entries(dependencies);
|
||||
const deps = Object.entries(dependencies) as [];
|
||||
|
||||
return (
|
||||
<DetailContextConsumer>
|
||||
{({ enableLoading }: any) => {
|
||||
{({ enableLoading }) => {
|
||||
return (
|
||||
<CardWrap>
|
||||
<CardContent>
|
||||
<Heading variant="subheading">{`${title} (${deps.length})`}</Heading>
|
||||
<Heading variant="subtitle1">{`${title} (${deps.length})`}</Heading>
|
||||
<Tags>{this.renderTags(deps, enableLoading)}</Tags>
|
||||
</CardContent>
|
||||
</CardWrap>
|
||||
@@ -56,15 +67,15 @@ class DependencyBlock extends Component<any, any> {
|
||||
);
|
||||
}
|
||||
|
||||
private renderTags = (deps: any, enableLoading: any) =>
|
||||
private renderTags = (deps: [], enableLoading?: () => void) =>
|
||||
deps.map(dep => {
|
||||
const [name, version] = dep;
|
||||
const [name, version] = dep as [string, string];
|
||||
|
||||
return <WrapperDependencyDetail key={name} name={name} onLoading={enableLoading} version={version} />;
|
||||
});
|
||||
}
|
||||
|
||||
class Dependencies extends Component<any, any> {
|
||||
class Dependencies extends Component {
|
||||
public state = {
|
||||
tabPosition: 0,
|
||||
};
|
||||
@@ -79,7 +90,7 @@ class Dependencies extends Component<any, any> {
|
||||
);
|
||||
}
|
||||
|
||||
private checkDependencyLength(dependency: Record<string, any> = {}): boolean {
|
||||
private checkDependencyLength<T>(dependency: Record<string, T> = {}): boolean {
|
||||
return Object.keys(dependency).length > 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -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',
|
||||
},
|
||||
});
|
||||
|
||||
@@ -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,7 +14,12 @@ interface DetailContainerState {
|
||||
tabPosition: number;
|
||||
}
|
||||
|
||||
class DetailContainer extends Component<any, DetailContainerState> {
|
||||
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,
|
||||
};
|
||||
@@ -29,7 +34,7 @@ class DetailContainer extends Component<any, DetailContainerState> {
|
||||
);
|
||||
}
|
||||
|
||||
private handleChange = (event: any, tabPosition: number) => {
|
||||
private handleChange = (event: React.ChangeEvent<{}>, tabPosition: number) => {
|
||||
event.preventDefault();
|
||||
this.setState({ tabPosition });
|
||||
};
|
||||
@@ -37,10 +42,10 @@ class DetailContainer extends Component<any, 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>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import styled from 'react-emotion';
|
||||
|
||||
export const Content = styled('div')`
|
||||
&& {
|
||||
padding: 15px;
|
||||
}
|
||||
`;
|
||||
export const Content = styled('div')({
|
||||
'&&': {
|
||||
padding: '15px',
|
||||
},
|
||||
});
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
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';
|
||||
import List from '@material-ui/core/List';
|
||||
|
||||
import ActionBar from '../ActionBar/ActionBar';
|
||||
import { ActionBar } from '../ActionBar/ActionBar';
|
||||
import Author from '../Author';
|
||||
import Developers from '../Developers';
|
||||
import Dist from '../Dist/Dist';
|
||||
@@ -12,76 +12,64 @@ 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 renderLatestDescription = (description, version, isLatest: boolean = true) => {
|
||||
return (
|
||||
<span>
|
||||
<div>{description}</div>
|
||||
{version ? <small>{`${isLatest ? 'Latest v' : 'v'}${version}`}</small> : null}
|
||||
</span>
|
||||
);
|
||||
};
|
||||
|
||||
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>
|
||||
);
|
||||
};
|
||||
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, packageVersion, packageMeta) => {
|
||||
const version = packageVersion ? packageVersion : packageMeta.latest.version;
|
||||
const isLatest = typeof packageVersion === 'undefined';
|
||||
|
||||
private renderTitle = (packageName, packageMeta) => {
|
||||
return (
|
||||
<List className="detail-info">
|
||||
<TitleListItem alignItems="flex-start">
|
||||
<TitleListItemText primary={<b>{packageName}</b>} secondary={packageMeta.latest.description} />
|
||||
</TitleListItem>
|
||||
</List>
|
||||
);
|
||||
};
|
||||
return (
|
||||
<List className="detail-info">
|
||||
<TitleListItem alignItems="flex-start" button={true}>
|
||||
<TitleListItemText primary={<b>{packageName}</b>} secondary={renderLatestDescription(packageMeta.latest.description, version, isLatest)} />
|
||||
</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, packageVersion, packageMeta): ReactElement<HTMLElement> {
|
||||
return (
|
||||
<div className={'sidebar-info'}>
|
||||
<Card>
|
||||
<CardContent>
|
||||
{renderTitle(packageName, packageVersion, packageMeta)}
|
||||
{renderActionBar()}
|
||||
{renderCopyCLI()}
|
||||
{renderRepository()}
|
||||
{renderEngine()}
|
||||
{renderDist()}
|
||||
{renderAuthor()}
|
||||
{renderMaintainers()}
|
||||
{renderContributors()}
|
||||
</CardContent>
|
||||
</Card>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
const DetailSidebar = () => {
|
||||
const { packageName, packageMeta, packageVersion } = React.useContext(DetailContext);
|
||||
|
||||
return renderSideBar(packageName, packageVersion, packageMeta);
|
||||
};
|
||||
|
||||
export default DetailSidebar;
|
||||
|
||||
@@ -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',
|
||||
},
|
||||
});
|
||||
|
||||
104
src/components/Developers/Developers.test.tsx
Normal file
104
src/components/Developers/Developers.test.tsx
Normal 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');
|
||||
});
|
||||
});
|
||||
@@ -1,76 +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';
|
||||
type: DevelopersType;
|
||||
visibleMax?: number;
|
||||
}
|
||||
|
||||
class Developers extends Component<Props, any> {
|
||||
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);
|
||||
};
|
||||
|
||||
render() {
|
||||
return (
|
||||
<DetailContextConsumer>
|
||||
{({ packageMeta }: any) => {
|
||||
const { type } = this.props;
|
||||
const developerType = 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;
|
||||
|
||||
handleLoadMore = () => {
|
||||
this.setState(prev => ({ visibleDevs: prev.visibleDevs + 6 }));
|
||||
return <AvatarTooltip avatar={avatar} email={email} name={name} packageName={packageName} version={version} />;
|
||||
};
|
||||
|
||||
renderDevelopers = (developers, packageMeta) => {
|
||||
const { type } = this.props;
|
||||
const { visibleDevs } = this.state;
|
||||
const renderDevelopers = (developers, packageMeta) => {
|
||||
const listVisibleDevelopers = developers.slice(0, visibleDevs);
|
||||
|
||||
return (
|
||||
<>
|
||||
<Heading variant={'subheading'}>{type}</Heading>
|
||||
<Fragment>
|
||||
<Heading variant={'subtitle1'}>{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>
|
||||
);
|
||||
};
|
||||
|
||||
renderLinkForMail(email, avatarComponent, packageName, version) {
|
||||
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;
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
487
src/components/Developers/__snapshots__/Developers.test.tsx.snap
Normal file
487
src/components/Developers/__snapshots__/Developers.test.tsx.snap
Normal file
@@ -0,0 +1,487 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`test Developers should render the component for contributors with items 1`] = `
|
||||
<Developers
|
||||
type="contributors"
|
||||
>
|
||||
<Styled(WithStyles(ForwardRef(Typography)))
|
||||
variant="subtitle1"
|
||||
>
|
||||
<WithStyles(ForwardRef(Typography))
|
||||
className="css-18tsvng emotion-0"
|
||||
variant="subtitle1"
|
||||
>
|
||||
<ForwardRef(Typography)
|
||||
className="css-18tsvng emotion-0"
|
||||
classes={
|
||||
Object {
|
||||
"alignCenter": "MuiTypography-alignCenter",
|
||||
"alignJustify": "MuiTypography-alignJustify",
|
||||
"alignLeft": "MuiTypography-alignLeft",
|
||||
"alignRight": "MuiTypography-alignRight",
|
||||
"body1": "MuiTypography-body1",
|
||||
"body2": "MuiTypography-body2",
|
||||
"button": "MuiTypography-button",
|
||||
"caption": "MuiTypography-caption",
|
||||
"colorError": "MuiTypography-colorError",
|
||||
"colorInherit": "MuiTypography-colorInherit",
|
||||
"colorPrimary": "MuiTypography-colorPrimary",
|
||||
"colorSecondary": "MuiTypography-colorSecondary",
|
||||
"colorTextPrimary": "MuiTypography-colorTextPrimary",
|
||||
"colorTextSecondary": "MuiTypography-colorTextSecondary",
|
||||
"displayBlock": "MuiTypography-displayBlock",
|
||||
"displayInline": "MuiTypography-displayInline",
|
||||
"gutterBottom": "MuiTypography-gutterBottom",
|
||||
"h1": "MuiTypography-h1",
|
||||
"h2": "MuiTypography-h2",
|
||||
"h3": "MuiTypography-h3",
|
||||
"h4": "MuiTypography-h4",
|
||||
"h5": "MuiTypography-h5",
|
||||
"h6": "MuiTypography-h6",
|
||||
"noWrap": "MuiTypography-noWrap",
|
||||
"overline": "MuiTypography-overline",
|
||||
"paragraph": "MuiTypography-paragraph",
|
||||
"root": "MuiTypography-root",
|
||||
"srOnly": "MuiTypography-srOnly",
|
||||
"subtitle1": "MuiTypography-subtitle1",
|
||||
"subtitle2": "MuiTypography-subtitle2",
|
||||
}
|
||||
}
|
||||
variant="subtitle1"
|
||||
>
|
||||
<h6
|
||||
className="MuiTypography-root css-18tsvng emotion-0 MuiTypography-subtitle1"
|
||||
>
|
||||
contributors
|
||||
</h6>
|
||||
</ForwardRef(Typography)>
|
||||
</WithStyles(ForwardRef(Typography))>
|
||||
</Styled(WithStyles(ForwardRef(Typography)))>
|
||||
<Styled(div)>
|
||||
<div
|
||||
className="css-mkcn9c emotion-5"
|
||||
>
|
||||
<Styled(span)
|
||||
key="dave.methvin@gmail.com"
|
||||
>
|
||||
<span
|
||||
className="css-dvxtzn emotion-3"
|
||||
>
|
||||
<AvatarTooltip
|
||||
email="dave.methvin@gmail.com"
|
||||
name="dmethvin"
|
||||
version="1.0.0"
|
||||
>
|
||||
<WithStyles(ForwardRef(Tooltip))
|
||||
title="dmethvin"
|
||||
>
|
||||
<ForwardRef(Tooltip)
|
||||
classes={
|
||||
Object {
|
||||
"popper": "MuiTooltip-popper",
|
||||
"popperInteractive": "MuiTooltip-popperInteractive",
|
||||
"tooltip": "MuiTooltip-tooltip",
|
||||
"tooltipPlacementBottom": "MuiTooltip-tooltipPlacementBottom",
|
||||
"tooltipPlacementLeft": "MuiTooltip-tooltipPlacementLeft",
|
||||
"tooltipPlacementRight": "MuiTooltip-tooltipPlacementRight",
|
||||
"tooltipPlacementTop": "MuiTooltip-tooltipPlacementTop",
|
||||
"touch": "MuiTooltip-touch",
|
||||
}
|
||||
}
|
||||
title="dmethvin"
|
||||
>
|
||||
<a
|
||||
aria-describedby={null}
|
||||
className=""
|
||||
href="mailto:dave.methvin@gmail.com?subject=undefined@1.0.0"
|
||||
onBlur={[Function]}
|
||||
onFocus={[Function]}
|
||||
onMouseLeave={[Function]}
|
||||
onMouseOver={[Function]}
|
||||
onTouchEnd={[Function]}
|
||||
onTouchStart={[Function]}
|
||||
target="_top"
|
||||
title="dmethvin"
|
||||
>
|
||||
<WithStyles(ForwardRef(Avatar))
|
||||
aria-label="dmethvin"
|
||||
>
|
||||
<ForwardRef(Avatar)
|
||||
aria-label="dmethvin"
|
||||
classes={
|
||||
Object {
|
||||
"colorDefault": "MuiAvatar-colorDefault",
|
||||
"img": "MuiAvatar-img",
|
||||
"root": "MuiAvatar-root",
|
||||
}
|
||||
}
|
||||
>
|
||||
<div
|
||||
aria-label="dmethvin"
|
||||
className="MuiAvatar-root MuiAvatar-colorDefault"
|
||||
/>
|
||||
</ForwardRef(Avatar)>
|
||||
</WithStyles(ForwardRef(Avatar))>
|
||||
</a>
|
||||
<ForwardRef(Popper)
|
||||
anchorEl={
|
||||
<a
|
||||
class=""
|
||||
href="mailto:dave.methvin@gmail.com?subject=undefined@1.0.0"
|
||||
target="_top"
|
||||
title="dmethvin"
|
||||
>
|
||||
<div
|
||||
aria-label="dmethvin"
|
||||
class="MuiAvatar-root MuiAvatar-colorDefault"
|
||||
/>
|
||||
</a>
|
||||
}
|
||||
className="MuiTooltip-popper"
|
||||
id={null}
|
||||
open={false}
|
||||
placement="bottom"
|
||||
transition={true}
|
||||
/>
|
||||
</ForwardRef(Tooltip)>
|
||||
</WithStyles(ForwardRef(Tooltip))>
|
||||
</AvatarTooltip>
|
||||
</span>
|
||||
</Styled(span)>
|
||||
<Styled(span)
|
||||
key="m.goleb@gmail.com"
|
||||
>
|
||||
<span
|
||||
className="css-dvxtzn emotion-3"
|
||||
>
|
||||
<AvatarTooltip
|
||||
email="m.goleb@gmail.com"
|
||||
name="mgol"
|
||||
version="1.0.0"
|
||||
>
|
||||
<WithStyles(ForwardRef(Tooltip))
|
||||
title="mgol"
|
||||
>
|
||||
<ForwardRef(Tooltip)
|
||||
classes={
|
||||
Object {
|
||||
"popper": "MuiTooltip-popper",
|
||||
"popperInteractive": "MuiTooltip-popperInteractive",
|
||||
"tooltip": "MuiTooltip-tooltip",
|
||||
"tooltipPlacementBottom": "MuiTooltip-tooltipPlacementBottom",
|
||||
"tooltipPlacementLeft": "MuiTooltip-tooltipPlacementLeft",
|
||||
"tooltipPlacementRight": "MuiTooltip-tooltipPlacementRight",
|
||||
"tooltipPlacementTop": "MuiTooltip-tooltipPlacementTop",
|
||||
"touch": "MuiTooltip-touch",
|
||||
}
|
||||
}
|
||||
title="mgol"
|
||||
>
|
||||
<a
|
||||
aria-describedby={null}
|
||||
className=""
|
||||
href="mailto:m.goleb@gmail.com?subject=undefined@1.0.0"
|
||||
onBlur={[Function]}
|
||||
onFocus={[Function]}
|
||||
onMouseLeave={[Function]}
|
||||
onMouseOver={[Function]}
|
||||
onTouchEnd={[Function]}
|
||||
onTouchStart={[Function]}
|
||||
target="_top"
|
||||
title="mgol"
|
||||
>
|
||||
<WithStyles(ForwardRef(Avatar))
|
||||
aria-label="mgol"
|
||||
>
|
||||
<ForwardRef(Avatar)
|
||||
aria-label="mgol"
|
||||
classes={
|
||||
Object {
|
||||
"colorDefault": "MuiAvatar-colorDefault",
|
||||
"img": "MuiAvatar-img",
|
||||
"root": "MuiAvatar-root",
|
||||
}
|
||||
}
|
||||
>
|
||||
<div
|
||||
aria-label="mgol"
|
||||
className="MuiAvatar-root MuiAvatar-colorDefault"
|
||||
/>
|
||||
</ForwardRef(Avatar)>
|
||||
</WithStyles(ForwardRef(Avatar))>
|
||||
</a>
|
||||
<ForwardRef(Popper)
|
||||
anchorEl={
|
||||
<a
|
||||
class=""
|
||||
href="mailto:m.goleb@gmail.com?subject=undefined@1.0.0"
|
||||
target="_top"
|
||||
title="mgol"
|
||||
>
|
||||
<div
|
||||
aria-label="mgol"
|
||||
class="MuiAvatar-root MuiAvatar-colorDefault"
|
||||
/>
|
||||
</a>
|
||||
}
|
||||
className="MuiTooltip-popper"
|
||||
id={null}
|
||||
open={false}
|
||||
placement="bottom"
|
||||
transition={true}
|
||||
/>
|
||||
</ForwardRef(Tooltip)>
|
||||
</WithStyles(ForwardRef(Tooltip))>
|
||||
</AvatarTooltip>
|
||||
</span>
|
||||
</Styled(span)>
|
||||
</div>
|
||||
</Styled(div)>
|
||||
</Developers>
|
||||
`;
|
||||
|
||||
exports[`test Developers should render the component for maintainers with items 1`] = `
|
||||
<Developers
|
||||
type="maintainers"
|
||||
>
|
||||
<Styled(WithStyles(ForwardRef(Typography)))
|
||||
variant="subtitle1"
|
||||
>
|
||||
<WithStyles(ForwardRef(Typography))
|
||||
className="css-18tsvng emotion-0"
|
||||
variant="subtitle1"
|
||||
>
|
||||
<ForwardRef(Typography)
|
||||
className="css-18tsvng emotion-0"
|
||||
classes={
|
||||
Object {
|
||||
"alignCenter": "MuiTypography-alignCenter",
|
||||
"alignJustify": "MuiTypography-alignJustify",
|
||||
"alignLeft": "MuiTypography-alignLeft",
|
||||
"alignRight": "MuiTypography-alignRight",
|
||||
"body1": "MuiTypography-body1",
|
||||
"body2": "MuiTypography-body2",
|
||||
"button": "MuiTypography-button",
|
||||
"caption": "MuiTypography-caption",
|
||||
"colorError": "MuiTypography-colorError",
|
||||
"colorInherit": "MuiTypography-colorInherit",
|
||||
"colorPrimary": "MuiTypography-colorPrimary",
|
||||
"colorSecondary": "MuiTypography-colorSecondary",
|
||||
"colorTextPrimary": "MuiTypography-colorTextPrimary",
|
||||
"colorTextSecondary": "MuiTypography-colorTextSecondary",
|
||||
"displayBlock": "MuiTypography-displayBlock",
|
||||
"displayInline": "MuiTypography-displayInline",
|
||||
"gutterBottom": "MuiTypography-gutterBottom",
|
||||
"h1": "MuiTypography-h1",
|
||||
"h2": "MuiTypography-h2",
|
||||
"h3": "MuiTypography-h3",
|
||||
"h4": "MuiTypography-h4",
|
||||
"h5": "MuiTypography-h5",
|
||||
"h6": "MuiTypography-h6",
|
||||
"noWrap": "MuiTypography-noWrap",
|
||||
"overline": "MuiTypography-overline",
|
||||
"paragraph": "MuiTypography-paragraph",
|
||||
"root": "MuiTypography-root",
|
||||
"srOnly": "MuiTypography-srOnly",
|
||||
"subtitle1": "MuiTypography-subtitle1",
|
||||
"subtitle2": "MuiTypography-subtitle2",
|
||||
}
|
||||
}
|
||||
variant="subtitle1"
|
||||
>
|
||||
<h6
|
||||
className="MuiTypography-root css-18tsvng emotion-0 MuiTypography-subtitle1"
|
||||
>
|
||||
maintainers
|
||||
</h6>
|
||||
</ForwardRef(Typography)>
|
||||
</WithStyles(ForwardRef(Typography))>
|
||||
</Styled(WithStyles(ForwardRef(Typography)))>
|
||||
<Styled(div)>
|
||||
<div
|
||||
className="css-mkcn9c emotion-5"
|
||||
>
|
||||
<Styled(span)
|
||||
key="dave.methvin@gmail.com"
|
||||
>
|
||||
<span
|
||||
className="css-dvxtzn emotion-3"
|
||||
>
|
||||
<AvatarTooltip
|
||||
email="dave.methvin@gmail.com"
|
||||
name="dmethvin"
|
||||
version="1.0.0"
|
||||
>
|
||||
<WithStyles(ForwardRef(Tooltip))
|
||||
title="dmethvin"
|
||||
>
|
||||
<ForwardRef(Tooltip)
|
||||
classes={
|
||||
Object {
|
||||
"popper": "MuiTooltip-popper",
|
||||
"popperInteractive": "MuiTooltip-popperInteractive",
|
||||
"tooltip": "MuiTooltip-tooltip",
|
||||
"tooltipPlacementBottom": "MuiTooltip-tooltipPlacementBottom",
|
||||
"tooltipPlacementLeft": "MuiTooltip-tooltipPlacementLeft",
|
||||
"tooltipPlacementRight": "MuiTooltip-tooltipPlacementRight",
|
||||
"tooltipPlacementTop": "MuiTooltip-tooltipPlacementTop",
|
||||
"touch": "MuiTooltip-touch",
|
||||
}
|
||||
}
|
||||
title="dmethvin"
|
||||
>
|
||||
<a
|
||||
aria-describedby={null}
|
||||
className=""
|
||||
href="mailto:dave.methvin@gmail.com?subject=undefined@1.0.0"
|
||||
onBlur={[Function]}
|
||||
onFocus={[Function]}
|
||||
onMouseLeave={[Function]}
|
||||
onMouseOver={[Function]}
|
||||
onTouchEnd={[Function]}
|
||||
onTouchStart={[Function]}
|
||||
target="_top"
|
||||
title="dmethvin"
|
||||
>
|
||||
<WithStyles(ForwardRef(Avatar))
|
||||
aria-label="dmethvin"
|
||||
>
|
||||
<ForwardRef(Avatar)
|
||||
aria-label="dmethvin"
|
||||
classes={
|
||||
Object {
|
||||
"colorDefault": "MuiAvatar-colorDefault",
|
||||
"img": "MuiAvatar-img",
|
||||
"root": "MuiAvatar-root",
|
||||
}
|
||||
}
|
||||
>
|
||||
<div
|
||||
aria-label="dmethvin"
|
||||
className="MuiAvatar-root MuiAvatar-colorDefault"
|
||||
/>
|
||||
</ForwardRef(Avatar)>
|
||||
</WithStyles(ForwardRef(Avatar))>
|
||||
</a>
|
||||
<ForwardRef(Popper)
|
||||
anchorEl={
|
||||
<a
|
||||
class=""
|
||||
href="mailto:dave.methvin@gmail.com?subject=undefined@1.0.0"
|
||||
target="_top"
|
||||
title="dmethvin"
|
||||
>
|
||||
<div
|
||||
aria-label="dmethvin"
|
||||
class="MuiAvatar-root MuiAvatar-colorDefault"
|
||||
/>
|
||||
</a>
|
||||
}
|
||||
className="MuiTooltip-popper"
|
||||
id={null}
|
||||
open={false}
|
||||
placement="bottom"
|
||||
transition={true}
|
||||
/>
|
||||
</ForwardRef(Tooltip)>
|
||||
</WithStyles(ForwardRef(Tooltip))>
|
||||
</AvatarTooltip>
|
||||
</span>
|
||||
</Styled(span)>
|
||||
<Styled(span)
|
||||
key="m.goleb@gmail.com"
|
||||
>
|
||||
<span
|
||||
className="css-dvxtzn emotion-3"
|
||||
>
|
||||
<AvatarTooltip
|
||||
email="m.goleb@gmail.com"
|
||||
name="mgol"
|
||||
version="1.0.0"
|
||||
>
|
||||
<WithStyles(ForwardRef(Tooltip))
|
||||
title="mgol"
|
||||
>
|
||||
<ForwardRef(Tooltip)
|
||||
classes={
|
||||
Object {
|
||||
"popper": "MuiTooltip-popper",
|
||||
"popperInteractive": "MuiTooltip-popperInteractive",
|
||||
"tooltip": "MuiTooltip-tooltip",
|
||||
"tooltipPlacementBottom": "MuiTooltip-tooltipPlacementBottom",
|
||||
"tooltipPlacementLeft": "MuiTooltip-tooltipPlacementLeft",
|
||||
"tooltipPlacementRight": "MuiTooltip-tooltipPlacementRight",
|
||||
"tooltipPlacementTop": "MuiTooltip-tooltipPlacementTop",
|
||||
"touch": "MuiTooltip-touch",
|
||||
}
|
||||
}
|
||||
title="mgol"
|
||||
>
|
||||
<a
|
||||
aria-describedby={null}
|
||||
className=""
|
||||
href="mailto:m.goleb@gmail.com?subject=undefined@1.0.0"
|
||||
onBlur={[Function]}
|
||||
onFocus={[Function]}
|
||||
onMouseLeave={[Function]}
|
||||
onMouseOver={[Function]}
|
||||
onTouchEnd={[Function]}
|
||||
onTouchStart={[Function]}
|
||||
target="_top"
|
||||
title="mgol"
|
||||
>
|
||||
<WithStyles(ForwardRef(Avatar))
|
||||
aria-label="mgol"
|
||||
>
|
||||
<ForwardRef(Avatar)
|
||||
aria-label="mgol"
|
||||
classes={
|
||||
Object {
|
||||
"colorDefault": "MuiAvatar-colorDefault",
|
||||
"img": "MuiAvatar-img",
|
||||
"root": "MuiAvatar-root",
|
||||
}
|
||||
}
|
||||
>
|
||||
<div
|
||||
aria-label="mgol"
|
||||
className="MuiAvatar-root MuiAvatar-colorDefault"
|
||||
/>
|
||||
</ForwardRef(Avatar)>
|
||||
</WithStyles(ForwardRef(Avatar))>
|
||||
</a>
|
||||
<ForwardRef(Popper)
|
||||
anchorEl={
|
||||
<a
|
||||
class=""
|
||||
href="mailto:m.goleb@gmail.com?subject=undefined@1.0.0"
|
||||
target="_top"
|
||||
title="mgol"
|
||||
>
|
||||
<div
|
||||
aria-label="mgol"
|
||||
class="MuiAvatar-root MuiAvatar-colorDefault"
|
||||
/>
|
||||
</a>
|
||||
}
|
||||
className="MuiTooltip-popper"
|
||||
id={null}
|
||||
open={false}
|
||||
placement="bottom"
|
||||
transition={true}
|
||||
/>
|
||||
</ForwardRef(Tooltip)>
|
||||
</WithStyles(ForwardRef(Tooltip))>
|
||||
</AvatarTooltip>
|
||||
</span>
|
||||
</Styled(span)>
|
||||
</div>
|
||||
</Styled(div)>
|
||||
</Developers>
|
||||
`;
|
||||
|
||||
exports[`test Developers should render the component with no items 1`] = `
|
||||
<Developers
|
||||
type="maintainers"
|
||||
/>
|
||||
`;
|
||||
@@ -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,
|
||||
},
|
||||
});
|
||||
|
||||
90
src/components/Dist/Dist.test.tsx
Normal file
90
src/components/Dist/Dist.test.tsx
Normal file
@@ -0,0 +1,90 @@
|
||||
import React from 'react';
|
||||
import { mount } from 'enzyme';
|
||||
import Dist from './Dist';
|
||||
|
||||
const mockPackageMeta = jest.fn(() => ({
|
||||
latest: {
|
||||
homepage: 'https://verdaccio.tld',
|
||||
bugs: {
|
||||
url: 'https://verdaccio.tld/bugs',
|
||||
},
|
||||
dist: {
|
||||
tarball: 'https://verdaccio.tld/download',
|
||||
},
|
||||
},
|
||||
}));
|
||||
|
||||
jest.mock('../../pages/Version', () => ({
|
||||
DetailContextConsumer: component => {
|
||||
return component.children({ packageMeta: mockPackageMeta() });
|
||||
},
|
||||
}));
|
||||
|
||||
describe('<Dist /> component', () => {
|
||||
beforeEach(() => {
|
||||
jest.resetModules();
|
||||
});
|
||||
|
||||
test('should render the component in default state', () => {
|
||||
const packageMeta = {
|
||||
latest: {
|
||||
name: 'verdaccio',
|
||||
version: '4.0.0',
|
||||
dist: {
|
||||
fileCount: 7,
|
||||
unpackedSize: 10,
|
||||
},
|
||||
license: '',
|
||||
},
|
||||
};
|
||||
|
||||
// @ts-ignore
|
||||
mockPackageMeta.mockImplementation(() => packageMeta);
|
||||
|
||||
const wrapper = mount(<Dist />);
|
||||
expect(wrapper.html()).toMatchSnapshot();
|
||||
});
|
||||
|
||||
test('should render the component with license as string', () => {
|
||||
const packageMeta = {
|
||||
latest: {
|
||||
name: 'verdaccio',
|
||||
version: '4.0.0',
|
||||
dist: {
|
||||
fileCount: 7,
|
||||
unpackedSize: 10,
|
||||
},
|
||||
license: 'MIT',
|
||||
},
|
||||
};
|
||||
|
||||
// @ts-ignore
|
||||
mockPackageMeta.mockImplementation(() => packageMeta);
|
||||
|
||||
const wrapper = mount(<Dist />);
|
||||
expect(wrapper.html()).toMatchSnapshot();
|
||||
});
|
||||
|
||||
test('should render the component with license as object', () => {
|
||||
const packageMeta = {
|
||||
latest: {
|
||||
name: 'verdaccio',
|
||||
version: '4.0.0',
|
||||
dist: {
|
||||
fileCount: 7,
|
||||
unpackedSize: 10,
|
||||
},
|
||||
license: {
|
||||
type: 'MIT',
|
||||
url: 'https://www.opensource.org/licenses/mit-license.php',
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
// @ts-ignore
|
||||
mockPackageMeta.mockImplementation(() => packageMeta);
|
||||
|
||||
const wrapper = mount(<Dist />);
|
||||
expect(wrapper.html()).toMatchSnapshot();
|
||||
});
|
||||
});
|
||||
@@ -2,53 +2,52 @@ import React, { Component } from 'react';
|
||||
|
||||
import List from '@material-ui/core/List';
|
||||
|
||||
import { DetailContextConsumer } 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';
|
||||
import { formatLicense } from '../../utils/package';
|
||||
|
||||
class Dist extends Component<any, any> {
|
||||
render() {
|
||||
class Dist extends Component {
|
||||
public render(): JSX.Element {
|
||||
return (
|
||||
<DetailContextConsumer>
|
||||
{(context: any) => {
|
||||
return this.renderDist(context);
|
||||
{(context: Partial<VersionPageConsumerProps>) => {
|
||||
return context && context.packageMeta && this.renderDist(context.packageMeta);
|
||||
}}
|
||||
</DetailContextConsumer>
|
||||
);
|
||||
}
|
||||
|
||||
renderChips(dist: any, license: string) {
|
||||
private renderChips(dist, license: PackageMetaInterface['latest']['license']): (JSX.Element | undefined)[] {
|
||||
const distDict = {
|
||||
'file-count': dist.fileCount,
|
||||
size: dist.unpackedSize && fileSizeSI(dist.unpackedSize),
|
||||
license,
|
||||
};
|
||||
|
||||
const chipsList = Object.keys(distDict).reduce((componentList, title, key) => {
|
||||
// @ts-ignore
|
||||
const value = distDict[title];
|
||||
if (value) {
|
||||
const label = (
|
||||
<span>
|
||||
{/* eslint-disable-next-line */}
|
||||
<b>{title.split('-').join(' ')}</b>:{value}
|
||||
</span>
|
||||
);
|
||||
// @ts-ignore is not assignable to parameter of type 'never'
|
||||
componentList.push(<DistChips key={key} label={label} />);
|
||||
}
|
||||
return componentList;
|
||||
}, []);
|
||||
const chipsList = Object.keys(distDict).map((dist, key) => {
|
||||
if (!distDict[dist]) return;
|
||||
|
||||
const value = dist === 'license' ? formatLicense(distDict[dist]) : distDict[dist];
|
||||
const label = (
|
||||
<>
|
||||
{/* eslint-disable-next-line */}
|
||||
<b>{dist.replace('-', ' ')}</b>: {value}
|
||||
</>
|
||||
);
|
||||
return <DistChips key={key} label={label} />;
|
||||
});
|
||||
|
||||
return chipsList;
|
||||
}
|
||||
|
||||
renderDist = ({ packageMeta }: any) => {
|
||||
const { dist = {}, license } = packageMeta.latest;
|
||||
private renderDist = (packageMeta: PackageMetaInterface) => {
|
||||
const { dist, license } = packageMeta && packageMeta.latest;
|
||||
|
||||
return (
|
||||
<List subheader={<Heading variant="subheading">{'Latest Distribution'}</Heading>}>
|
||||
<DistListItem>{this.renderChips(dist, license)}</DistListItem>
|
||||
<List subheader={<Heading variant="subtitle1">{'Latest Distribution'}</Heading>}>
|
||||
<DistListItem button={true}>{this.renderChips(dist, license)}</DistListItem>
|
||||
</List>
|
||||
);
|
||||
};
|
||||
|
||||
7
src/components/Dist/__snapshots__/Dist.test.tsx.snap
Normal file
7
src/components/Dist/__snapshots__/Dist.test.tsx.snap
Normal file
@@ -0,0 +1,7 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`<Dist /> component should render the component in default state 1`] = `"<ul class=\\"MuiList-root MuiList-padding MuiList-subheader\\"><h6 class=\\"MuiTypography-root css-hyrz44 estxrtg0 MuiTypography-subtitle1\\">Latest Distribution</h6><div class=\\"MuiButtonBase-root MuiListItem-root css-z8a2h0 estxrtg1 MuiListItem-gutters MuiListItem-button\\" tabindex=\\"0\\" role=\\"button\\" aria-disabled=\\"false\\"><div class=\\"MuiChip-root css-1le6jk6 estxrtg2\\"><span class=\\"MuiChip-label\\"><b>file count</b>: 7</span></div><div class=\\"MuiChip-root css-1le6jk6 estxrtg2\\"><span class=\\"MuiChip-label\\"><b>size</b>: 10.00 Bytes</span></div><span class=\\"MuiTouchRipple-root\\"></span></div></ul>"`;
|
||||
|
||||
exports[`<Dist /> component should render the component with license as object 1`] = `"<ul class=\\"MuiList-root MuiList-padding MuiList-subheader\\"><h6 class=\\"MuiTypography-root css-hyrz44 estxrtg0 MuiTypography-subtitle1\\">Latest Distribution</h6><div class=\\"MuiButtonBase-root MuiListItem-root css-z8a2h0 estxrtg1 MuiListItem-gutters MuiListItem-button\\" tabindex=\\"0\\" role=\\"button\\" aria-disabled=\\"false\\"><div class=\\"MuiChip-root css-1le6jk6 estxrtg2\\"><span class=\\"MuiChip-label\\"><b>file count</b>: 7</span></div><div class=\\"MuiChip-root css-1le6jk6 estxrtg2\\"><span class=\\"MuiChip-label\\"><b>size</b>: 10.00 Bytes</span></div><div class=\\"MuiChip-root css-1le6jk6 estxrtg2\\"><span class=\\"MuiChip-label\\"><b>license</b>: MIT</span></div><span class=\\"MuiTouchRipple-root\\"></span></div></ul>"`;
|
||||
|
||||
exports[`<Dist /> component should render the component with license as string 1`] = `"<ul class=\\"MuiList-root MuiList-padding MuiList-subheader\\"><h6 class=\\"MuiTypography-root css-hyrz44 estxrtg0 MuiTypography-subtitle1\\">Latest Distribution</h6><div class=\\"MuiButtonBase-root MuiListItem-root css-z8a2h0 estxrtg1 MuiListItem-gutters MuiListItem-button\\" tabindex=\\"0\\" role=\\"button\\" aria-disabled=\\"false\\"><div class=\\"MuiChip-root css-1le6jk6 estxrtg2\\"><span class=\\"MuiChip-label\\"><b>file count</b>: 7</span></div><div class=\\"MuiChip-root css-1le6jk6 estxrtg2\\"><span class=\\"MuiChip-label\\"><b>size</b>: 10.00 Bytes</span></div><div class=\\"MuiChip-root css-1le6jk6 estxrtg2\\"><span class=\\"MuiChip-label\\"><b>license</b>: MIT</span></div><span class=\\"MuiTouchRipple-root\\"></span></div></ul>"`;
|
||||
@@ -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,
|
||||
},
|
||||
});
|
||||
|
||||
73
src/components/Engines/Engines.test.tsx
Normal file
73
src/components/Engines/Engines.test.tsx
Normal file
@@ -0,0 +1,73 @@
|
||||
import React from 'react';
|
||||
import { mount } from 'enzyme';
|
||||
import Engine from './Engines';
|
||||
|
||||
jest.mock('./img/node.png', () => '');
|
||||
jest.mock('../Install/img/npm.svg', () => '');
|
||||
|
||||
const mockPackageMeta = jest.fn(() => ({
|
||||
latest: {
|
||||
homepage: 'https://verdaccio.tld',
|
||||
bugs: {
|
||||
url: 'https://verdaccio.tld/bugs',
|
||||
},
|
||||
dist: {
|
||||
tarball: 'https://verdaccio.tld/download',
|
||||
},
|
||||
},
|
||||
}));
|
||||
|
||||
jest.mock('../../pages/Version', () => ({
|
||||
DetailContextConsumer: component => {
|
||||
return component.children({ packageMeta: mockPackageMeta() });
|
||||
},
|
||||
}));
|
||||
|
||||
describe('<Engines /> component', () => {
|
||||
beforeEach(() => {
|
||||
jest.resetAllMocks();
|
||||
});
|
||||
|
||||
test('should render the component in default state', () => {
|
||||
const packageMeta = {
|
||||
latest: {
|
||||
engines: {
|
||||
node: '>= 0.1.98',
|
||||
npm: '>3',
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
// @ts-ignore
|
||||
mockPackageMeta.mockImplementation(() => packageMeta);
|
||||
|
||||
const wrapper = mount(<Engine />);
|
||||
expect(wrapper.html()).toMatchSnapshot();
|
||||
});
|
||||
|
||||
test('should render the component when there is no engine key in package meta', () => {
|
||||
const packageMeta = {
|
||||
latest: {},
|
||||
};
|
||||
|
||||
// @ts-ignore
|
||||
mockPackageMeta.mockImplementation(() => packageMeta);
|
||||
|
||||
const wrapper = mount(<Engine />);
|
||||
expect(wrapper.html()).toEqual('');
|
||||
});
|
||||
|
||||
test('should render the component when there is no keys in engine in package meta', () => {
|
||||
const packageMeta = {
|
||||
latest: {
|
||||
engines: {},
|
||||
},
|
||||
};
|
||||
|
||||
// @ts-ignore
|
||||
mockPackageMeta.mockImplementation(() => packageMeta);
|
||||
|
||||
const wrapper = mount(<Engine />);
|
||||
expect(wrapper.html()).toEqual('');
|
||||
});
|
||||
});
|
||||
@@ -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';
|
||||
@@ -60,8 +60,8 @@ class Engine extends Component {
|
||||
|
||||
private renderListItems = (heading, text) => {
|
||||
return (
|
||||
<List subheader={<Heading variant={'subheading'}>{text.split('-').join(' ')}</Heading>}>
|
||||
<EngineListItem>
|
||||
<List subheader={<Heading variant={'subtitle1'}>{text.split('-').join(' ')}</Heading>}>
|
||||
<EngineListItem button={true}>
|
||||
{ICONS[text]}
|
||||
<ListItemText primary={heading} />
|
||||
</EngineListItem>
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`<Engines /> component should render the component in default state 1`] = `"<div class=\\"MuiGrid-root MuiGrid-container\\"><div class=\\"MuiGrid-root MuiGrid-item MuiGrid-grid-xs-6\\"><ul class=\\"MuiList-root MuiList-padding MuiList-subheader\\"><h6 class=\\"MuiTypography-root css-hyrz44 et66bt70 MuiTypography-subtitle1\\">node JS</h6><div class=\\"MuiButtonBase-root MuiListItem-root css-dt93b2 et66bt71 MuiListItem-gutters MuiListItem-button\\" tabindex=\\"0\\" role=\\"button\\" aria-disabled=\\"false\\"><div class=\\"MuiAvatar-root MuiAvatar-colorDefault\\"></div><div class=\\"MuiListItemText-root\\"><span class=\\"MuiTypography-root MuiListItemText-primary MuiTypography-body1\\">>= 0.1.98</span></div><span class=\\"MuiTouchRipple-root\\"></span></div></ul></div><div class=\\"MuiGrid-root MuiGrid-item MuiGrid-grid-xs-6\\"><ul class=\\"MuiList-root MuiList-padding MuiList-subheader\\"><h6 class=\\"MuiTypography-root css-hyrz44 et66bt70 MuiTypography-subtitle1\\">NPM version</h6><div class=\\"MuiButtonBase-root MuiListItem-root css-dt93b2 et66bt71 MuiListItem-gutters MuiListItem-button\\" tabindex=\\"0\\" role=\\"button\\" aria-disabled=\\"false\\"><div class=\\"MuiAvatar-root MuiAvatar-colorDefault\\"></div><div class=\\"MuiListItemText-root\\"><span class=\\"MuiTypography-root MuiListItemText-primary MuiTypography-body1\\">>3</span></div><span class=\\"MuiTouchRipple-root\\"></span></div></ul></div></div>"`;
|
||||
@@ -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,
|
||||
},
|
||||
});
|
||||
|
||||
@@ -3,7 +3,7 @@ import React from 'react';
|
||||
import { Wrapper, Left, Right, Earth, Flags, Love, Flag, Logo, Inner, ToolTip } from './styles';
|
||||
import { goToVerdaccioWebsite } from '../../utils/windows';
|
||||
|
||||
const renderTooltip = () => (
|
||||
const renderTooltip = (): JSX.Element => (
|
||||
<ToolTip>
|
||||
<Earth name="earth" size="md" />
|
||||
<Flags>
|
||||
@@ -22,7 +22,7 @@ const ON_LABEL = 'on';
|
||||
const HEARTH_EMOJI = '♥';
|
||||
|
||||
// @ts-ignore
|
||||
const renderRight = (version = window.VERDACCIO_VERSION) => {
|
||||
const renderRight = (version = window.VERDACCIO_VERSION): JSX.Element => {
|
||||
return (
|
||||
<Right>
|
||||
{POWERED_LABEL}
|
||||
@@ -32,7 +32,7 @@ const renderRight = (version = window.VERDACCIO_VERSION) => {
|
||||
);
|
||||
};
|
||||
|
||||
const renderLeft = () => (
|
||||
const renderLeft = (): JSX.Element => (
|
||||
<Left>
|
||||
{MADEWITH_LABEL}
|
||||
<Love>{HEARTH_EMOJI}</Love>
|
||||
|
||||
@@ -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>"`;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import React, { SyntheticEvent, Component, Fragment, ReactElement } from 'react';
|
||||
import { Link } from 'react-router-dom';
|
||||
import { css } from 'emotion';
|
||||
|
||||
import Button from '@material-ui/core/Button';
|
||||
import IconButton from '@material-ui/core/IconButton';
|
||||
@@ -22,7 +23,7 @@ import RegistryInfoContent from '../RegistryInfoContent/RegistryInfoContent';
|
||||
import { Greetings, NavBar, InnerNavBar, MobileNavBar, InnerMobileNavBar, LeftSide, RightSide, IconSearchButton, SearchWrapper } from './styles';
|
||||
|
||||
interface Props {
|
||||
logo: string;
|
||||
logo?: string;
|
||||
username?: string;
|
||||
onLogout: () => void;
|
||||
onToggleLoginModal: () => void;
|
||||
@@ -31,7 +32,7 @@ interface Props {
|
||||
}
|
||||
|
||||
interface State {
|
||||
anchorEl?: any;
|
||||
anchorEl?: null | Element | ((element: Element) => Element);
|
||||
openInfoDialog: boolean;
|
||||
registryUrl: string;
|
||||
showMobileNavBar: boolean;
|
||||
@@ -141,7 +142,11 @@ class Header extends Component<Props, State> {
|
||||
const { withoutSearch = false } = this.props;
|
||||
return (
|
||||
<LeftSide>
|
||||
<Link style={{ marginRight: '1em' }} to={'/'}>
|
||||
<Link
|
||||
className={css`
|
||||
margin-right: 1em;
|
||||
`}
|
||||
to={'/'}>
|
||||
{this.renderLogo()}
|
||||
</Link>
|
||||
{!withoutSearch && (
|
||||
|
||||
@@ -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 style=\\"margin-right:1em\\" 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 MuiPaper-elevation4 MuiAppBar-root MuiAppBar-positionStatic css-rfunvc e1jf5lit8 MuiAppBar-colorPrimary\\"><div class=\\"MuiToolbar-root MuiToolbar-regular css-1pwdmmq e1jf5lit0 MuiToolbar-gutters\\"><div class=\\"MuiToolbar-root MuiToolbar-regular css-1vacr9s e1jf5lit3 MuiToolbar-gutters\\"><a class=\\"css-1dk30lc\\" href=\\"/\\"><div class=\\"css-1sifsqk em793ed0\\"></div></a></div><div class=\\"MuiToolbar-root MuiToolbar-regular css-m61s5i e1jf5lit2 MuiToolbar-gutters\\"><a href=\\"https://verdaccio.org/docs/en/installation\\" target=\\"_blank\\" class=\\"MuiButtonBase-root MuiIconButton-root MuiIconButton-colorInherit\\" tabindex=\\"0\\" role=\\"button\\" aria-disabled=\\"false\\" title=\\"Documentation\\"><span class=\\"MuiIconButton-label\\"><svg class=\\"MuiSvgIcon-root\\" 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 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 MuiIconButton-root MuiIconButton-colorInherit\\" tabindex=\\"0\\" type=\\"button\\" id=\\"header--button-registryInfo\\" title=\\"Registry Information\\"><span class=\\"MuiIconButton-label\\"><svg class=\\"MuiSvgIcon-root\\" 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 2zm1 15h-2v-6h2v6zm0-8h-2V7h2v2z\\"></path></svg></span></button><button class=\\"MuiButtonBase-root MuiIconButton-root MuiIconButton-colorInherit\\" tabindex=\\"0\\" type=\\"button\\" id=\\"header--button-account\\"><span class=\\"MuiIconButton-label\\"><svg class=\\"MuiSvgIcon-root\\" 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></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 style=\\"margin-right:1em\\" 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 MuiPaper-elevation4 MuiAppBar-root MuiAppBar-positionStatic css-rfunvc e1jf5lit8 MuiAppBar-colorPrimary\\"><div class=\\"MuiToolbar-root MuiToolbar-regular css-1pwdmmq e1jf5lit0 MuiToolbar-gutters\\"><div class=\\"MuiToolbar-root MuiToolbar-regular css-1vacr9s e1jf5lit3 MuiToolbar-gutters\\"><a class=\\"css-1dk30lc\\" href=\\"/\\"><div class=\\"css-1sifsqk em793ed0\\"></div></a></div><div class=\\"MuiToolbar-root MuiToolbar-regular css-m61s5i e1jf5lit2 MuiToolbar-gutters\\"><a href=\\"https://verdaccio.org/docs/en/installation\\" target=\\"_blank\\" class=\\"MuiButtonBase-root MuiIconButton-root MuiIconButton-colorInherit\\" tabindex=\\"0\\" role=\\"button\\" aria-disabled=\\"false\\" title=\\"Documentation\\"><span class=\\"MuiIconButton-label\\"><svg class=\\"MuiSvgIcon-root\\" 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 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 MuiIconButton-root MuiIconButton-colorInherit\\" tabindex=\\"0\\" type=\\"button\\" id=\\"header--button-registryInfo\\" title=\\"Registry Information\\"><span class=\\"MuiIconButton-label\\"><svg class=\\"MuiSvgIcon-root\\" 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 2zm1 15h-2v-6h2v6zm0-8h-2V7h2v2z\\"></path></svg></span></button><button class=\\"MuiButtonBase-root MuiButton-root MuiButton-text MuiButton-colorInherit\\" tabindex=\\"0\\" type=\\"button\\" id=\\"header--button-login\\"><span class=\\"MuiButton-label\\">Login</span></button></div></div></header></div>"`;
|
||||
|
||||
@@ -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)`
|
||||
&& {
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import React from 'react';
|
||||
import { shallow } from 'enzyme';
|
||||
import { mount } from 'enzyme';
|
||||
import Help from './Help';
|
||||
|
||||
describe('<Help /> component', () => {
|
||||
test('should render the component in default state', () => {
|
||||
const wrapper = shallow(<Help />);
|
||||
const wrapper = mount(<Help />);
|
||||
expect(wrapper.html()).toMatchSnapshot();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -12,7 +12,7 @@ import { CardStyled as Card, HelpTitle } from './styles';
|
||||
function renderHeadingClipboardSegments(title: string, text: string): React.ReactNode {
|
||||
return (
|
||||
<Fragment>
|
||||
<Typography variant={'body2'}>{title}</Typography>
|
||||
<Typography variant={'body1'}>{title}</Typography>
|
||||
<CopyToClipBoard text={text} />
|
||||
</Fragment>
|
||||
);
|
||||
@@ -24,7 +24,7 @@ const Help: React.FC = () => {
|
||||
return (
|
||||
<Card id="help-card">
|
||||
<CardContent>
|
||||
<Typography component="h2" gutterBottom={true} id="help-card__title" variant="headline">
|
||||
<Typography component="h2" gutterBottom={true} id="help-card__title" variant="h5">
|
||||
{'No Package Published Yet.'}
|
||||
</Typography>
|
||||
<HelpTitle color="textSecondary" gutterBottom={true}>
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`<Help /> component should render the component in default state 1`] = `"<div class=\\"MuiPaper-root-2 MuiPaper-elevation1-5 MuiPaper-rounded-3 MuiCard-root-1 css-ryznli e1wgaou60\\" id=\\"help-card\\"><div class=\\"MuiCardContent-root-29\\"><h2 class=\\"MuiTypography-root-30 MuiTypography-headline-35 MuiTypography-gutterBottom-57\\" id=\\"help-card__title\\">No Package Published Yet.</h2><p class=\\"MuiTypography-root-30 MuiTypography-body1-39 MuiTypography-colorTextSecondary-63 MuiTypography-gutterBottom-57 css-zg2fwz e1wgaou61\\">To publish your first package just:</p><p class=\\"MuiTypography-root-30 MuiTypography-body2-38\\">1. Login</p><div class=\\"css-1mta3t8 eb8w2fo0\\"><span class=\\"css-1m8aenu eb8w2fo1\\">npm adduser --registry http://localhost</span><button class=\\"MuiButtonBase-root-80 MuiIconButton-root-74 css-56v3u0 eb8w2fo2\\" tabindex=\\"0\\" type=\\"button\\" title=\\"Copy to Clipboard\\"><span class=\\"MuiIconButton-label-79\\"><svg class=\\"MuiSvgIcon-root-83\\" 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><p class=\\"MuiTypography-root-30 MuiTypography-body2-38\\">2. Publish</p><div class=\\"css-1mta3t8 eb8w2fo0\\"><span class=\\"css-1m8aenu eb8w2fo1\\">npm publish --registry http://localhost</span><button class=\\"MuiButtonBase-root-80 MuiIconButton-root-74 css-56v3u0 eb8w2fo2\\" tabindex=\\"0\\" type=\\"button\\" title=\\"Copy to Clipboard\\"><span class=\\"MuiIconButton-label-79\\"><svg class=\\"MuiSvgIcon-root-83\\" 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><p class=\\"MuiTypography-root-30 MuiTypography-body2-38\\">3. Refresh this page.</p></div><div class=\\"MuiCardActions-root-92\\"><a class=\\"MuiButtonBase-root-80 MuiButton-root-95 MuiButton-text-97 MuiButton-textPrimary-98 MuiButton-flat-100 MuiButton-flatPrimary-101 MuiButton-sizeSmall-118 MuiCardActions-action-94\\" tabindex=\\"0\\" role=\\"button\\" href=\\"https://verdaccio.org/docs/en/installation\\" target=\\"_blank\\"><span class=\\"MuiButton-label-96\\">Learn More</span></a></div></div>"`;
|
||||
exports[`<Help /> component should render the component in default state 1`] = `"<div class=\\"MuiPaper-root MuiPaper-elevation1 MuiCard-root css-ryznli e1wgaou60 MuiPaper-rounded\\" id=\\"help-card\\"><div class=\\"MuiCardContent-root\\"><h2 class=\\"MuiTypography-root MuiTypography-h5 MuiTypography-gutterBottom\\" id=\\"help-card__title\\">No Package Published Yet.</h2><p class=\\"MuiTypography-root css-zg2fwz e1wgaou61 MuiTypography-body1 MuiTypography-colorTextSecondary MuiTypography-gutterBottom\\">To publish your first package just:</p><p class=\\"MuiTypography-root MuiTypography-body1\\">1. Login</p><div class=\\"css-1mta3t8 eb8w2fo0\\"><span class=\\"css-1m8aenu eb8w2fo1\\">npm adduser --registry http://localhost</span><button class=\\"MuiButtonBase-root MuiIconButton-root css-0 eb8w2fo2\\" tabindex=\\"0\\" type=\\"button\\" title=\\"Copy to Clipboard\\"><span class=\\"MuiIconButton-label\\"><svg class=\\"MuiSvgIcon-root\\" focusable=\\"false\\" viewBox=\\"0 0 24 24\\" aria-hidden=\\"true\\" role=\\"presentation\\"><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><span class=\\"MuiTouchRipple-root\\"></span></button></div><p class=\\"MuiTypography-root MuiTypography-body1\\">2. Publish</p><div class=\\"css-1mta3t8 eb8w2fo0\\"><span class=\\"css-1m8aenu eb8w2fo1\\">npm publish --registry http://localhost</span><button class=\\"MuiButtonBase-root MuiIconButton-root css-0 eb8w2fo2\\" tabindex=\\"0\\" type=\\"button\\" title=\\"Copy to Clipboard\\"><span class=\\"MuiIconButton-label\\"><svg class=\\"MuiSvgIcon-root\\" focusable=\\"false\\" viewBox=\\"0 0 24 24\\" aria-hidden=\\"true\\" role=\\"presentation\\"><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><span class=\\"MuiTouchRipple-root\\"></span></button></div><p class=\\"MuiTypography-root MuiTypography-body2\\">3. Refresh this page.</p></div><div class=\\"MuiCardActions-root MuiCardActions-spacing\\"><a class=\\"MuiButtonBase-root MuiButton-root MuiButton-text MuiButton-textPrimary MuiButton-sizeSmall\\" tabindex=\\"0\\" aria-disabled=\\"false\\" href=\\"https://verdaccio.org/docs/en/installation\\" target=\\"_blank\\"><span class=\\"MuiButton-label\\">Learn More</span><span class=\\"MuiTouchRipple-root\\"></span></a></div></div>"`;
|
||||
|
||||
@@ -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',
|
||||
},
|
||||
});
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import React, { MouseEvent } from 'react';
|
||||
import capitalize from 'lodash/capitalize';
|
||||
import { Breakpoint } from '@material-ui/core/styles/createBreakpoints';
|
||||
|
||||
import { Svg, Img, ImgWrapper } from './styles';
|
||||
|
||||
@@ -57,10 +58,10 @@ export interface Props {
|
||||
name: keyof IconsMap;
|
||||
className?: string;
|
||||
onClick?: (event: MouseEvent<SVGElement | HTMLSpanElement>) => void;
|
||||
size?: 'sm' | 'md';
|
||||
size?: Breakpoint;
|
||||
pointer?: boolean;
|
||||
img?: boolean;
|
||||
modifiers?: any;
|
||||
modifiers?: null | undefined;
|
||||
}
|
||||
|
||||
const Icon: React.FC<Props> = ({ className, name, size = 'sm', img = false, pointer = false, ...props }) => {
|
||||
|
||||
@@ -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>"`;
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
import styled, { css } from 'react-emotion';
|
||||
import { Breakpoint } from '@material-ui/core/styles/createBreakpoints';
|
||||
import { StyledOtherComponent } from 'create-emotion-styled';
|
||||
import { DetailedHTMLProps, HTMLAttributes } from 'react';
|
||||
|
||||
const getSize = (size?: 'md' | 'sm') => {
|
||||
const getSize = (size: Breakpoint): string => {
|
||||
switch (size) {
|
||||
case 'md':
|
||||
return `
|
||||
@@ -15,10 +18,10 @@ const getSize = (size?: 'md' | 'sm') => {
|
||||
}
|
||||
};
|
||||
|
||||
const commonStyle = ({ size = 'sm', pointer, modifiers }: any) => css`
|
||||
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};
|
||||
}
|
||||
@@ -30,15 +33,24 @@ export const Svg = styled('svg')`
|
||||
}
|
||||
`;
|
||||
|
||||
export const ImgWrapper = styled('span')`
|
||||
export const ImgWrapper: StyledOtherComponent<
|
||||
{
|
||||
size?: Breakpoint;
|
||||
pointer: boolean;
|
||||
modifiers?: null | undefined;
|
||||
name?: string | unknown;
|
||||
},
|
||||
DetailedHTMLProps<HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>,
|
||||
{}
|
||||
> = styled('span')`
|
||||
&& {
|
||||
${commonStyle};
|
||||
}
|
||||
`;
|
||||
|
||||
export const Img = styled('img')`
|
||||
&& {
|
||||
width: 100%;
|
||||
height: auto;
|
||||
}
|
||||
`;
|
||||
export const Img = styled('img')({
|
||||
'&&': {
|
||||
width: '100%',
|
||||
height: 'auto',
|
||||
},
|
||||
});
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import React from 'react';
|
||||
import { shallow } from 'enzyme';
|
||||
import { mount } from 'enzyme';
|
||||
|
||||
import Install from './Install';
|
||||
|
||||
describe('<Install /> component', () => {
|
||||
test('should render the component in default state', () => {
|
||||
const wrapper = shallow(<Install />);
|
||||
const wrapper = mount(<Install />);
|
||||
expect(wrapper.html()).toMatchSnapshot();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
import List from '@material-ui/core/List';
|
||||
import ListItemText from '@material-ui/core/ListItemText';
|
||||
import React, { Component } from 'react';
|
||||
|
||||
// @ts-ignore
|
||||
import { DetailContextConsumer } from '../../pages/version/Version';
|
||||
import { DetailContextConsumer, VersionPageConsumerProps } from '../../pages/Version';
|
||||
|
||||
import CopyToClipBoard from '../CopyToClipBoard';
|
||||
|
||||
// logos of package managers
|
||||
@@ -11,23 +10,23 @@ import npm from './img/npm.svg';
|
||||
import pnpm from './img/pnpm.svg';
|
||||
import yarn from './img/yarn.svg';
|
||||
|
||||
import { Heading, InstallItem, PackageMangerAvatar } from './styles';
|
||||
import { Heading, InstallItem, PackageMangerAvatar, InstallListItemText } from './styles';
|
||||
|
||||
class Install extends Component {
|
||||
public render() {
|
||||
public render(): JSX.Element {
|
||||
return (
|
||||
<DetailContextConsumer>
|
||||
{(context: any) => {
|
||||
{(context: Partial<VersionPageConsumerProps>) => {
|
||||
return context && context.packageName && this.renderCopyCLI(context);
|
||||
}}
|
||||
</DetailContextConsumer>
|
||||
);
|
||||
}
|
||||
|
||||
public renderCopyCLI = ({ packageName }: { packageName: string }) => {
|
||||
public renderCopyCLI = ({ packageName = '' }: Partial<VersionPageConsumerProps>) => {
|
||||
return (
|
||||
<>
|
||||
<List subheader={<Heading variant={'subheading'}>{'Installation'}</Heading>}>{this.renderListItems(packageName)}</List>
|
||||
<List subheader={<Heading variant={'subtitle1'}>{'Installation'}</Heading>}>{this.renderListItems(packageName)}</List>
|
||||
</>
|
||||
);
|
||||
};
|
||||
@@ -35,17 +34,17 @@ class Install extends Component {
|
||||
public renderListItems = (packageName: string) => {
|
||||
return (
|
||||
<>
|
||||
<InstallItem>
|
||||
<InstallItem button={true}>
|
||||
<PackageMangerAvatar alt={'npm logo'} src={npm} />
|
||||
<ListItemText primary={<CopyToClipBoard text={`npm install ${packageName}`} />} secondary={'Install using NPM'} />
|
||||
<InstallListItemText primary={<CopyToClipBoard text={`npm install ${packageName}`} />} secondary={'Install using NPM'} />
|
||||
</InstallItem>
|
||||
<InstallItem>
|
||||
<InstallItem button={true}>
|
||||
<PackageMangerAvatar alt={'yarn logo'} src={yarn} />
|
||||
<ListItemText primary={<CopyToClipBoard text={`yarn add ${packageName}`} />} secondary={'Install using Yarn'} />
|
||||
<InstallListItemText primary={<CopyToClipBoard text={`yarn add ${packageName}`} />} secondary={'Install using Yarn'} />
|
||||
</InstallItem>
|
||||
<InstallItem>
|
||||
<InstallItem button={true}>
|
||||
<PackageMangerAvatar alt={'pnpm logo'} src={pnpm} />
|
||||
<ListItemText primary={<CopyToClipBoard text={`pnpm install ${packageName}`} />} secondary={'Install using PNPM'} />
|
||||
<InstallListItemText primary={<CopyToClipBoard text={`pnpm install ${packageName}`} />} secondary={'Install using PNPM'} />
|
||||
</InstallItem>
|
||||
</>
|
||||
);
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`<Install /> component should render the component in default state 1`] = `""`;
|
||||
exports[`<Install /> component should render the component in default state 1`] = `null`;
|
||||
|
||||
@@ -1,23 +1,36 @@
|
||||
import Avatar from '@material-ui/core/Avatar';
|
||||
import ListItem from '@material-ui/core/ListItem';
|
||||
import ListItemText from '@material-ui/core/ListItemText';
|
||||
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,
|
||||
},
|
||||
'&&:hover': {
|
||||
backgroundColor: 'transparent',
|
||||
},
|
||||
});
|
||||
|
||||
export const PackageMangerAvatar = styled(Avatar)`
|
||||
&& {
|
||||
border-radius: 0px;
|
||||
}
|
||||
`;
|
||||
export const InstallListItemText = styled(ListItemText)({
|
||||
'&&': {
|
||||
padding: '0 10px',
|
||||
margin: 0,
|
||||
},
|
||||
});
|
||||
|
||||
export const PackageMangerAvatar = styled(Avatar)({
|
||||
'&&': {
|
||||
borderRadius: '0px',
|
||||
padding: '0',
|
||||
},
|
||||
});
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import React from 'react';
|
||||
import { shallow } from 'enzyme';
|
||||
import { mount } from 'enzyme';
|
||||
|
||||
import Label from './Label';
|
||||
|
||||
@@ -8,7 +8,7 @@ describe('<Label /> component', () => {
|
||||
text: 'test',
|
||||
};
|
||||
test('should render the component in default state', () => {
|
||||
const wrapper = shallow(<Label text={props.text} />);
|
||||
const wrapper = mount(<Label text={props.text} />);
|
||||
expect(wrapper.html()).toMatchSnapshot();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -6,7 +6,7 @@ interface Props {
|
||||
text: string;
|
||||
capitalize?: boolean;
|
||||
weight?: string;
|
||||
modifiers?: any;
|
||||
modifiers?: null | undefined;
|
||||
}
|
||||
|
||||
const Wrapper = styled('div')`
|
||||
|
||||
@@ -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')`
|
||||
&& {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import React from 'react';
|
||||
import { shallow } from 'enzyme';
|
||||
import { mount } from 'enzyme';
|
||||
|
||||
import Link from './Link';
|
||||
|
||||
@@ -8,7 +8,7 @@ describe('<Link /> component', () => {
|
||||
to: 'https://github.com/verdaccio/ui',
|
||||
};
|
||||
test('should render the component in default state', () => {
|
||||
const wrapper = shallow(<Link blank={true} to={props.to} />);
|
||||
const wrapper = mount(<Link blank={true} to={props.to} />);
|
||||
expect(wrapper.html()).toMatchSnapshot();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
import React from 'react';
|
||||
|
||||
import Logo from '../Logo';
|
||||
import Logo, { Size } from '../Logo';
|
||||
import Spinner from '../Spinner';
|
||||
|
||||
import { Wrapper, Badge } from './styles';
|
||||
|
||||
const Loading: React.FC = () => (
|
||||
<Wrapper>
|
||||
<Wrapper data-testid="loading">
|
||||
<Badge>
|
||||
<Logo />
|
||||
<Logo size={Size.Big} />
|
||||
</Badge>
|
||||
<Spinner />
|
||||
</Wrapper>
|
||||
|
||||
@@ -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-1tnu3ib 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 css-15gl0ho e1ag4h8b1 MuiCircularProgress-colorPrimary MuiCircularProgress-indeterminate\\" style=\\"width:50px;height:50px\\" role=\\"progressbar\\"><svg class=\\"MuiCircularProgress-svg\\" viewBox=\\"22 22 44 44\\"><circle class=\\"MuiCircularProgress-circle MuiCircularProgress-circleIndeterminate\\" cx=\\"44\\" cy=\\"44\\" r=\\"20.2\\" fill=\\"none\\" stroke-width=\\"3.6\\"></circle></svg></div></div></div>"`;
|
||||
|
||||
@@ -63,7 +63,6 @@ describe('<LoginModal />', () => {
|
||||
test('setCredentials - should set username and password in state', () => {
|
||||
const props = {
|
||||
visibility: true,
|
||||
error: {},
|
||||
onCancel: () => {},
|
||||
onSubmit: () => {},
|
||||
};
|
||||
@@ -80,7 +79,6 @@ describe('<LoginModal />', () => {
|
||||
test('validateCredentials: should validate credentials', async () => {
|
||||
const props = {
|
||||
visibility: true,
|
||||
error: {},
|
||||
onCancel: () => {},
|
||||
onSubmit: jest.fn(),
|
||||
};
|
||||
@@ -89,7 +87,7 @@ describe('<LoginModal />', () => {
|
||||
const instance = wrapper.instance();
|
||||
|
||||
instance.submitCredentials = jest.fn();
|
||||
const { validateCredentials, setCredentials, submitCredentials } = instance;
|
||||
const { handleValidateCredentials, setCredentials, submitCredentials } = instance;
|
||||
|
||||
expect(setCredentials('username', eventUsername)).toBeUndefined();
|
||||
expect(wrapper.state('form').username.value).toEqual('xyz');
|
||||
@@ -97,7 +95,7 @@ describe('<LoginModal />', () => {
|
||||
expect(setCredentials('password', eventPassword)).toBeUndefined();
|
||||
expect(wrapper.state('form').password.value).toEqual('1234');
|
||||
|
||||
validateCredentials(event);
|
||||
handleValidateCredentials(event);
|
||||
expect(event.preventDefault).toHaveBeenCalled();
|
||||
expect(wrapper.state('form').username.pristine).toEqual(false);
|
||||
expect(wrapper.state('form').password.pristine).toEqual(false);
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import React, { Component } from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import Button from '@material-ui/core/Button';
|
||||
import DialogTitle from '@material-ui/core/DialogTitle';
|
||||
import Dialog from '@material-ui/core/Dialog';
|
||||
@@ -11,26 +10,39 @@ import InputLabel from '@material-ui/core/InputLabel';
|
||||
import Input from '@material-ui/core/Input';
|
||||
import FormControl from '@material-ui/core/FormControl';
|
||||
import FormHelperText from '@material-ui/core/FormHelperText';
|
||||
import { css } from 'emotion';
|
||||
|
||||
// @ts-ignore
|
||||
import classes from './login.scss';
|
||||
import * as classes from './styles';
|
||||
|
||||
export default class LoginModal extends Component<any, any> {
|
||||
static propTypes = {
|
||||
visibility: PropTypes.bool,
|
||||
error: PropTypes.object,
|
||||
onCancel: PropTypes.func,
|
||||
onSubmit: PropTypes.func,
|
||||
interface FormFields {
|
||||
required: boolean;
|
||||
pristine: boolean;
|
||||
helperText: string;
|
||||
value: string;
|
||||
}
|
||||
export interface FormError {
|
||||
type: string;
|
||||
title: string;
|
||||
description: string;
|
||||
}
|
||||
|
||||
interface LoginModalProps {
|
||||
visibility: boolean;
|
||||
error?: FormError;
|
||||
onCancel: () => void;
|
||||
onSubmit: (username: string, password: string) => void;
|
||||
}
|
||||
|
||||
interface LoginModalState {
|
||||
form: {
|
||||
username: Partial<FormFields>;
|
||||
password: Partial<FormFields>;
|
||||
};
|
||||
error?: FormError;
|
||||
}
|
||||
|
||||
static defaultProps = {
|
||||
error: {},
|
||||
onCancel: () => {},
|
||||
onSubmit: () => {},
|
||||
visibility: true,
|
||||
};
|
||||
|
||||
constructor(props) {
|
||||
export default class LoginModal extends Component<Partial<LoginModalProps>, LoginModalState> {
|
||||
constructor(props: LoginModalProps) {
|
||||
super(props);
|
||||
this.state = {
|
||||
form: {
|
||||
@@ -51,11 +63,28 @@ export default class LoginModal extends Component<any, any> {
|
||||
};
|
||||
}
|
||||
|
||||
public render(): JSX.Element {
|
||||
const { visibility = true, onCancel = () => null, error } = this.props as LoginModalProps;
|
||||
return (
|
||||
<Dialog fullWidth={true} id={'login--form-container'} maxWidth={'xs'} onClose={onCancel} open={visibility}>
|
||||
<form noValidate={true} onSubmit={this.handleValidateCredentials}>
|
||||
<DialogTitle>{'Login'}</DialogTitle>
|
||||
<DialogContent>
|
||||
{error && this.renderLoginError(error)}
|
||||
{this.renderNameField()}
|
||||
{this.renderPasswordField()}
|
||||
</DialogContent>
|
||||
{this.renderActions()}
|
||||
</form>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* set login modal's username and password to current state
|
||||
* Required to login
|
||||
*/
|
||||
setCredentials = (name, e) => {
|
||||
public setCredentials = (name, e) => {
|
||||
const { form } = this.state;
|
||||
this.setState({
|
||||
form: {
|
||||
@@ -69,15 +98,15 @@ export default class LoginModal extends Component<any, any> {
|
||||
});
|
||||
};
|
||||
|
||||
setUsername = event => {
|
||||
public handleUsernameChange = event => {
|
||||
this.setCredentials('username', event);
|
||||
};
|
||||
|
||||
setPassword = event => {
|
||||
public handlePasswordChange = event => {
|
||||
this.setCredentials('password', event);
|
||||
};
|
||||
|
||||
validateCredentials = event => {
|
||||
public handleValidateCredentials = event => {
|
||||
const { form } = this.state;
|
||||
// prevents default submit behavior
|
||||
event.preventDefault();
|
||||
@@ -89,7 +118,7 @@ export default class LoginModal extends Component<any, any> {
|
||||
...acc,
|
||||
...{ [key]: { ...form[key], pristine: false } },
|
||||
}),
|
||||
{}
|
||||
{ username: {}, password: {} }
|
||||
),
|
||||
},
|
||||
() => {
|
||||
@@ -100,10 +129,14 @@ export default class LoginModal extends Component<any, any> {
|
||||
);
|
||||
};
|
||||
|
||||
submitCredentials = async () => {
|
||||
public submitCredentials = async () => {
|
||||
const { form } = this.state;
|
||||
const username = (form.username && form.username.value) || '';
|
||||
const password = (form.password && form.password.value) || '';
|
||||
const { onSubmit } = this.props;
|
||||
await onSubmit(form.username.value, form.password.value);
|
||||
if (onSubmit) {
|
||||
await onSubmit(username, password);
|
||||
}
|
||||
// let's wait for API response and then set
|
||||
// username and password filed to empty state
|
||||
this.setState({
|
||||
@@ -112,12 +145,12 @@ export default class LoginModal extends Component<any, any> {
|
||||
...acc,
|
||||
...{ [key]: { ...form[key], value: '', pristine: true } },
|
||||
}),
|
||||
{}
|
||||
{ username: {}, password: {} }
|
||||
),
|
||||
});
|
||||
};
|
||||
|
||||
renderErrorMessage(title, description) {
|
||||
public renderErrorMessage(title, description): JSX.Element {
|
||||
return (
|
||||
<span>
|
||||
<div>
|
||||
@@ -128,7 +161,7 @@ export default class LoginModal extends Component<any, any> {
|
||||
);
|
||||
}
|
||||
|
||||
renderMessage(title, description) {
|
||||
public renderMessage(title, description): JSX.Element {
|
||||
return (
|
||||
<div className={classes.loginErrorMsg} id={'client-snackbar'}>
|
||||
<ErrorIcon className={classes.loginIcon} />
|
||||
@@ -137,37 +170,43 @@ export default class LoginModal extends Component<any, any> {
|
||||
);
|
||||
}
|
||||
|
||||
renderLoginError({ type, title, description }) {
|
||||
public renderLoginError({ type, title, description }: FormError): JSX.Element | false {
|
||||
return type === 'error' && <SnackbarContent className={classes.loginError} message={this.renderMessage(title, description)} />;
|
||||
}
|
||||
|
||||
renderNameField = () => {
|
||||
public renderNameField = () => {
|
||||
const {
|
||||
form: { username },
|
||||
} = this.state;
|
||||
return (
|
||||
<FormControl error={!username.value && !username.pristine} fullWidth={true} required={username.required}>
|
||||
<InputLabel htmlFor={'username'}>{'Username'}</InputLabel>
|
||||
<Input id={'login--form-username'} onChange={this.setUsername} placeholder={'Your username'} value={username.value} />
|
||||
<Input id={'login--form-username'} onChange={this.handleUsernameChange} placeholder={'Your username'} value={username.value} />
|
||||
{!username.value && !username.pristine && <FormHelperText id={'username-error'}>{username.helperText}</FormHelperText>}
|
||||
</FormControl>
|
||||
);
|
||||
};
|
||||
|
||||
renderPasswordField = () => {
|
||||
public renderPasswordField = () => {
|
||||
const {
|
||||
form: { password },
|
||||
} = this.state;
|
||||
return (
|
||||
<FormControl error={!password.value && !password.pristine} fullWidth={true} required={password.required} style={{ marginTop: '8px' }}>
|
||||
<FormControl
|
||||
className={css`
|
||||
margin-top: 8px;
|
||||
`}
|
||||
error={!password.value && !password.pristine}
|
||||
fullWidth={true}
|
||||
required={password.required}>
|
||||
<InputLabel htmlFor={'password'}>{'Password'}</InputLabel>
|
||||
<Input id={'login--form-password'} onChange={this.setPassword} placeholder={'Your strong password'} type={'password'} value={password.value} />
|
||||
<Input id={'login--form-password'} onChange={this.handlePasswordChange} placeholder={'Your strong password'} type={'password'} value={password.value} />
|
||||
{!password.value && !password.pristine && <FormHelperText id={'password-error'}>{password.helperText}</FormHelperText>}
|
||||
</FormControl>
|
||||
);
|
||||
};
|
||||
|
||||
renderActions = () => {
|
||||
public renderActions = () => {
|
||||
const {
|
||||
form: { username, password },
|
||||
} = this.state;
|
||||
@@ -183,21 +222,4 @@ export default class LoginModal extends Component<any, any> {
|
||||
</DialogActions>
|
||||
);
|
||||
};
|
||||
|
||||
render() {
|
||||
const { visibility, onCancel, error } = this.props;
|
||||
return (
|
||||
<Dialog fullWidth={true} id={'login--form-container'} maxWidth={'xs'} onClose={onCancel} open={visibility}>
|
||||
<form noValidate={true} onSubmit={this.validateCredentials}>
|
||||
<DialogTitle>{'Login'}</DialogTitle>
|
||||
<DialogContent>
|
||||
{this.renderLoginError(error)}
|
||||
{this.renderNameField()}
|
||||
{this.renderPasswordField()}
|
||||
</DialogContent>
|
||||
{this.renderActions()}
|
||||
</form>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`<LoginModal /> should load the component in default state 1`] = `"<div role=\\"dialog\\" class=\\"MuiModal-root-15 MuiDialog-root-1\\" id=\\"login--form-container\\"><div class=\\"MuiBackdrop-root-17\\" aria-hidden=\\"true\\" style=\\"opacity: 1; webkit-transition: opacity 225ms cubic-bezier(0.4, 0, 0.2, 1) 0ms; transition: opacity 225ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;\\"></div><div class=\\"MuiDialog-container-4 MuiDialog-scrollPaper-2\\" role=\\"document\\" style=\\"opacity: 1; webkit-transition: opacity 225ms cubic-bezier(0.4, 0, 0.2, 1) 0ms; transition: opacity 225ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;\\" tabindex=\\"-1\\"><div class=\\"MuiPaper-root-19 MuiPaper-elevation24-45 MuiPaper-rounded-20 MuiDialog-paper-5 MuiDialog-paperScrollPaper-6 MuiDialog-paperWidthXs-8 MuiDialog-paperFullWidth-13\\"><form novalidate=\\"\\"><div class=\\"MuiDialogTitle-root-46\\"><h2 class=\\"MuiTypography-root-47 MuiTypography-title-53\\">Login</h2></div><div class=\\"MuiDialogContent-root-83\\"><div class=\\"MuiFormControl-root-84 MuiFormControl-fullWidth-87\\"><label class=\\"MuiFormLabel-root-99 MuiFormLabel-required-104 MuiInputLabel-required-92 MuiInputLabel-root-88 MuiInputLabel-formControl-93 MuiInputLabel-animated-96\\" data-shrink=\\"false\\" for=\\"username\\">Username<span class=\\"MuiFormLabel-asterisk-105\\"> *</span></label><div class=\\"MuiInputBase-root-119 MuiInput-root-106 MuiInput-underline-110 MuiInputBase-formControl-120 MuiInput-formControl-107\\"><input aria-invalid=\\"false\\" class=\\"MuiInputBase-input-129 MuiInput-input-114\\" id=\\"login--form-username\\" placeholder=\\"Your username\\" required=\\"\\" type=\\"text\\" value=\\"\\"></div></div><div class=\\"MuiFormControl-root-84 MuiFormControl-fullWidth-87\\" style=\\"margin-top: 8px;\\"><label class=\\"MuiFormLabel-root-99 MuiFormLabel-required-104 MuiInputLabel-required-92 MuiInputLabel-root-88 MuiInputLabel-formControl-93 MuiInputLabel-animated-96\\" data-shrink=\\"false\\" for=\\"password\\">Password<span class=\\"MuiFormLabel-asterisk-105\\"> *</span></label><div class=\\"MuiInputBase-root-119 MuiInput-root-106 MuiInput-underline-110 MuiInputBase-formControl-120 MuiInput-formControl-107\\"><input aria-invalid=\\"false\\" class=\\"MuiInputBase-input-129 MuiInput-input-114 MuiInputBase-inputType-132 MuiInput-inputType-117\\" id=\\"login--form-password\\" placeholder=\\"Your strong password\\" required=\\"\\" type=\\"password\\" value=\\"\\"></div></div></div><div class=\\"MuiDialogActions-root-136 dialog-footer\\"><button class=\\"MuiButtonBase-root-164 MuiButton-root-138 MuiButton-text-140 MuiButton-flat-143 MuiButton-colorInherit-159 MuiDialogActions-action-137\\" tabindex=\\"0\\" type=\\"button\\" id=\\"login--form-cancel\\"><span class=\\"MuiButton-label-139\\">Cancel</span><span class=\\"MuiTouchRipple-root-167\\"></span></button><button class=\\"MuiButtonBase-root-164 MuiButtonBase-disabled-165 MuiButton-root-138 MuiButton-text-140 MuiButton-flat-143 MuiButton-disabled-158 MuiButton-colorInherit-159 MuiDialogActions-action-137\\" tabindex=\\"-1\\" type=\\"submit\\" disabled=\\"\\" id=\\"login--form-submit\\"><span class=\\"MuiButton-label-139\\">Login</span></button></div></form></div></div></div>"`;
|
||||
exports[`<LoginModal /> should load the component in default state 1`] = `"<div role=\\"presentation\\" class=\\"MuiDialog-root\\" id=\\"login--form-container\\" style=\\"position: fixed; z-index: 1300; right: 0px; bottom: 0px; top: 0px; left: 0px;\\"><div class=\\"MuiBackdrop-root\\" aria-hidden=\\"true\\" style=\\"opacity: 1; webkit-transition: opacity 225ms cubic-bezier(0.4, 0, 0.2, 1) 0ms; transition: opacity 225ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;\\"></div><div tabindex=\\"0\\" data-test=\\"sentinelStart\\"></div><div class=\\"MuiDialog-container MuiDialog-scrollPaper\\" style=\\"opacity: 1; webkit-transition: opacity 225ms cubic-bezier(0.4, 0, 0.2, 1) 0ms; transition: opacity 225ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;\\" role=\\"document\\" tabindex=\\"-1\\"><div class=\\"MuiPaper-root MuiPaper-elevation24 MuiDialog-paper MuiDialog-paperScrollPaper MuiDialog-paperWidthXs MuiDialog-paperFullWidth MuiPaper-rounded\\" role=\\"dialog\\"><form novalidate=\\"\\"><div class=\\"MuiDialogTitle-root\\"><h2 class=\\"MuiTypography-root MuiTypography-h6\\">Login</h2></div><div class=\\"MuiDialogContent-root\\"><div class=\\"MuiFormControl-root MuiFormControl-fullWidth\\"><label class=\\"MuiFormLabel-root MuiInputLabel-root MuiInputLabel-formControl MuiInputLabel-animated Mui-required Mui-required\\" data-shrink=\\"false\\" for=\\"username\\">Username<span class=\\"MuiFormLabel-asterisk MuiInputLabel-asterisk\\"> *</span></label><div class=\\"MuiInputBase-root MuiInput-root MuiInput-underline MuiInputBase-formControl MuiInput-formControl\\"><input aria-invalid=\\"false\\" class=\\"MuiInputBase-input MuiInput-input\\" id=\\"login--form-username\\" placeholder=\\"Your username\\" required=\\"\\" type=\\"text\\" value=\\"\\"></div></div><div class=\\"MuiFormControl-root css-164r41r MuiFormControl-fullWidth\\"><label class=\\"MuiFormLabel-root MuiInputLabel-root MuiInputLabel-formControl MuiInputLabel-animated Mui-required Mui-required\\" data-shrink=\\"false\\" for=\\"password\\">Password<span class=\\"MuiFormLabel-asterisk MuiInputLabel-asterisk\\"> *</span></label><div class=\\"MuiInputBase-root MuiInput-root MuiInput-underline MuiInputBase-formControl MuiInput-formControl\\"><input aria-invalid=\\"false\\" class=\\"MuiInputBase-input MuiInput-input\\" id=\\"login--form-password\\" placeholder=\\"Your strong password\\" required=\\"\\" type=\\"password\\" value=\\"\\"></div></div></div><div class=\\"MuiDialogActions-root dialog-footer MuiDialogActions-spacing\\"><button class=\\"MuiButtonBase-root MuiButton-root MuiButton-text MuiButton-colorInherit\\" tabindex=\\"0\\" type=\\"button\\" id=\\"login--form-cancel\\"><span class=\\"MuiButton-label\\">Cancel</span><span class=\\"MuiTouchRipple-root\\"></span></button><button class=\\"MuiButtonBase-root MuiButton-root MuiButton-text Mui-disabled MuiButton-colorInherit Mui-disabled\\" tabindex=\\"-1\\" type=\\"submit\\" disabled=\\"\\" id=\\"login--form-submit\\"><span class=\\"MuiButton-label\\">Login</span></button></div></form></div></div><div tabindex=\\"0\\" data-test=\\"sentinelEnd\\"></div></div>"`;
|
||||
|
||||
exports[`<LoginModal /> should load the component with props 1`] = `"<div role=\\"dialog\\" class=\\"MuiModal-root-15 MuiDialog-root-1\\" id=\\"login--form-container\\"><div class=\\"MuiBackdrop-root-17\\" aria-hidden=\\"true\\" style=\\"opacity: 1; webkit-transition: opacity 225ms cubic-bezier(0.4, 0, 0.2, 1) 0ms; transition: opacity 225ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;\\"></div><div class=\\"MuiDialog-container-4 MuiDialog-scrollPaper-2\\" role=\\"document\\" style=\\"opacity: 1; webkit-transition: opacity 225ms cubic-bezier(0.4, 0, 0.2, 1) 0ms; transition: opacity 225ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;\\" tabindex=\\"-1\\"><div class=\\"MuiPaper-root-19 MuiPaper-elevation24-45 MuiPaper-rounded-20 MuiDialog-paper-5 MuiDialog-paperScrollPaper-6 MuiDialog-paperWidthXs-8 MuiDialog-paperFullWidth-13\\"><form novalidate=\\"\\"><div class=\\"MuiDialogTitle-root-46\\"><h2 class=\\"MuiTypography-root-47 MuiTypography-title-53\\">Login</h2></div><div class=\\"MuiDialogContent-root-83\\"><div class=\\"MuiTypography-root-47 MuiTypography-body1-56 MuiPaper-root-19 MuiPaper-elevation6-27 MuiSnackbarContent-root-174 loginError\\" role=\\"alertdialog\\"><div class=\\"MuiSnackbarContent-message-175\\"><div class=\\"loginErrorMsg\\" id=\\"client-snackbar\\"><svg class=\\"MuiSvgIcon-root-177 loginIcon\\" 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-2h2v2zm0-4h-2V7h2v6z\\"></path></svg><span><div><strong>Error Title</strong></div><div>Error Description</div></span></div></div></div><div class=\\"MuiFormControl-root-84 MuiFormControl-fullWidth-87\\"><label class=\\"MuiFormLabel-root-99 MuiFormLabel-required-104 MuiInputLabel-required-92 MuiInputLabel-root-88 MuiInputLabel-formControl-93 MuiInputLabel-animated-96\\" data-shrink=\\"false\\" for=\\"username\\">Username<span class=\\"MuiFormLabel-asterisk-105\\"> *</span></label><div class=\\"MuiInputBase-root-119 MuiInput-root-106 MuiInput-underline-110 MuiInputBase-formControl-120 MuiInput-formControl-107\\"><input aria-invalid=\\"false\\" class=\\"MuiInputBase-input-129 MuiInput-input-114\\" id=\\"login--form-username\\" placeholder=\\"Your username\\" required=\\"\\" type=\\"text\\" value=\\"\\"></div></div><div class=\\"MuiFormControl-root-84 MuiFormControl-fullWidth-87\\" style=\\"margin-top: 8px;\\"><label class=\\"MuiFormLabel-root-99 MuiFormLabel-required-104 MuiInputLabel-required-92 MuiInputLabel-root-88 MuiInputLabel-formControl-93 MuiInputLabel-animated-96\\" data-shrink=\\"false\\" for=\\"password\\">Password<span class=\\"MuiFormLabel-asterisk-105\\"> *</span></label><div class=\\"MuiInputBase-root-119 MuiInput-root-106 MuiInput-underline-110 MuiInputBase-formControl-120 MuiInput-formControl-107\\"><input aria-invalid=\\"false\\" class=\\"MuiInputBase-input-129 MuiInput-input-114 MuiInputBase-inputType-132 MuiInput-inputType-117\\" id=\\"login--form-password\\" placeholder=\\"Your strong password\\" required=\\"\\" type=\\"password\\" value=\\"\\"></div></div></div><div class=\\"MuiDialogActions-root-136 dialog-footer\\"><button class=\\"MuiButtonBase-root-164 MuiButton-root-138 MuiButton-text-140 MuiButton-flat-143 MuiButton-colorInherit-159 MuiDialogActions-action-137\\" tabindex=\\"0\\" type=\\"button\\" id=\\"login--form-cancel\\"><span class=\\"MuiButton-label-139\\">Cancel</span><span class=\\"MuiTouchRipple-root-167\\"></span></button><button class=\\"MuiButtonBase-root-164 MuiButtonBase-disabled-165 MuiButton-root-138 MuiButton-text-140 MuiButton-flat-143 MuiButton-disabled-158 MuiButton-colorInherit-159 MuiDialogActions-action-137\\" tabindex=\\"-1\\" type=\\"submit\\" disabled=\\"\\" id=\\"login--form-submit\\"><span class=\\"MuiButton-label-139\\">Login</span></button></div></form></div></div></div>"`;
|
||||
exports[`<LoginModal /> should load the component with props 1`] = `"<div role=\\"presentation\\" class=\\"MuiDialog-root\\" id=\\"login--form-container\\" style=\\"position: fixed; z-index: 1300; right: 0px; bottom: 0px; top: 0px; left: 0px;\\"><div class=\\"MuiBackdrop-root\\" aria-hidden=\\"true\\" style=\\"opacity: 1; webkit-transition: opacity 225ms cubic-bezier(0.4, 0, 0.2, 1) 0ms; transition: opacity 225ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;\\"></div><div tabindex=\\"0\\" data-test=\\"sentinelStart\\"></div><div class=\\"MuiDialog-container MuiDialog-scrollPaper\\" style=\\"opacity: 1; webkit-transition: opacity 225ms cubic-bezier(0.4, 0, 0.2, 1) 0ms; transition: opacity 225ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;\\" role=\\"document\\" tabindex=\\"-1\\"><div class=\\"MuiPaper-root MuiPaper-elevation24 MuiDialog-paper MuiDialog-paperScrollPaper MuiDialog-paperWidthXs MuiDialog-paperFullWidth MuiPaper-rounded\\" role=\\"dialog\\"><form novalidate=\\"\\"><div class=\\"MuiDialogTitle-root\\"><h2 class=\\"MuiTypography-root MuiTypography-h6\\">Login</h2></div><div class=\\"MuiDialogContent-root\\"><div class=\\"MuiTypography-root MuiPaper-root MuiPaper-elevation6 MuiSnackbarContent-root css-11e09xf MuiTypography-body2\\" role=\\"alertdialog\\"><div class=\\"MuiSnackbarContent-message\\"><div class=\\"css-70qvj9\\" id=\\"client-snackbar\\"><svg class=\\"MuiSvgIcon-root css-1mbwbu9\\" 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 2zm1 15h-2v-2h2v2zm0-4h-2V7h2v6z\\"></path></svg><span><div><strong>Error Title</strong></div><div>Error Description</div></span></div></div></div><div class=\\"MuiFormControl-root MuiFormControl-fullWidth\\"><label class=\\"MuiFormLabel-root MuiInputLabel-root MuiInputLabel-formControl MuiInputLabel-animated Mui-required Mui-required\\" data-shrink=\\"false\\" for=\\"username\\">Username<span class=\\"MuiFormLabel-asterisk MuiInputLabel-asterisk\\"> *</span></label><div class=\\"MuiInputBase-root MuiInput-root MuiInput-underline MuiInputBase-formControl MuiInput-formControl\\"><input aria-invalid=\\"false\\" class=\\"MuiInputBase-input MuiInput-input\\" id=\\"login--form-username\\" placeholder=\\"Your username\\" required=\\"\\" type=\\"text\\" value=\\"\\"></div></div><div class=\\"MuiFormControl-root css-164r41r MuiFormControl-fullWidth\\"><label class=\\"MuiFormLabel-root MuiInputLabel-root MuiInputLabel-formControl MuiInputLabel-animated Mui-required Mui-required\\" data-shrink=\\"false\\" for=\\"password\\">Password<span class=\\"MuiFormLabel-asterisk MuiInputLabel-asterisk\\"> *</span></label><div class=\\"MuiInputBase-root MuiInput-root MuiInput-underline MuiInputBase-formControl MuiInput-formControl\\"><input aria-invalid=\\"false\\" class=\\"MuiInputBase-input MuiInput-input\\" id=\\"login--form-password\\" placeholder=\\"Your strong password\\" required=\\"\\" type=\\"password\\" value=\\"\\"></div></div></div><div class=\\"MuiDialogActions-root dialog-footer MuiDialogActions-spacing\\"><button class=\\"MuiButtonBase-root MuiButton-root MuiButton-text MuiButton-colorInherit\\" tabindex=\\"0\\" type=\\"button\\" id=\\"login--form-cancel\\"><span class=\\"MuiButton-label\\">Cancel</span><span class=\\"MuiTouchRipple-root\\"></span></button><button class=\\"MuiButtonBase-root MuiButton-root MuiButton-text Mui-disabled MuiButton-colorInherit Mui-disabled\\" tabindex=\\"-1\\" type=\\"submit\\" disabled=\\"\\" id=\\"login--form-submit\\"><span class=\\"MuiButton-label\\">Login</span></button></div></form></div></div><div tabindex=\\"0\\" data-test=\\"sentinelEnd\\"></div></div>"`;
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
@import '../../styles/variables';
|
||||
|
||||
.loginDialog {
|
||||
min-width: 300px;
|
||||
}
|
||||
|
||||
.loginError {
|
||||
background-color: $red !important;
|
||||
min-width: inherit !important;
|
||||
margin-bottom: 10px !important;
|
||||
}
|
||||
|
||||
.loginErrorMsg {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.loginIcon {
|
||||
opacity: 0.9;
|
||||
margin-right: 8px;
|
||||
}
|
||||
|
||||
22
src/components/Login/styles.ts
Normal file
22
src/components/Login/styles.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import { css } from 'emotion';
|
||||
import colors from '../../utils/styles/colors';
|
||||
|
||||
export const loginDialog = css({
|
||||
minWidth: '300px',
|
||||
});
|
||||
|
||||
export const loginError = css({
|
||||
backgroundColor: `${colors.red} !important`,
|
||||
minWidth: 'inherit !important',
|
||||
marginBottom: '10px !important',
|
||||
});
|
||||
|
||||
export const loginErrorMsg = css({
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
});
|
||||
|
||||
export const loginIcon = css({
|
||||
opacity: 0.9,
|
||||
marginRight: '8px',
|
||||
});
|
||||
@@ -3,7 +3,16 @@ import React from 'react';
|
||||
import styled from 'react-emotion';
|
||||
import logo from './img/logo.svg';
|
||||
|
||||
const StyledLogo = styled.div`
|
||||
export enum Size {
|
||||
Small = '40px',
|
||||
Big = '90px',
|
||||
}
|
||||
|
||||
interface Props {
|
||||
size?: Size;
|
||||
}
|
||||
|
||||
const StyledLogo = styled('div')<Props>`
|
||||
&& {
|
||||
display: inline-block;
|
||||
vertical-align: middle;
|
||||
@@ -12,11 +21,12 @@ const StyledLogo = styled.div`
|
||||
background-size: contain;
|
||||
background-image: url(${logo});
|
||||
background-repeat: no-repeat;
|
||||
width: 40px;
|
||||
height: 40px;`;
|
||||
|
||||
const Logo: React.FC = () => {
|
||||
return <StyledLogo />;
|
||||
width: ${({ size }) => size};
|
||||
height: ${({ size }) => size};
|
||||
}
|
||||
`;
|
||||
const Logo: React.FC<Props> = ({ size = Size.Small }) => {
|
||||
return <StyledLogo size={size} />;
|
||||
};
|
||||
|
||||
export default Logo;
|
||||
|
||||
@@ -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>"`;
|
||||
|
||||
@@ -1 +1 @@
|
||||
export { default } from './Logo';
|
||||
export { default, Size } from './Logo';
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`<NoItem /> component should load the component in default state 1`] = `"<h6 class=\\"MuiTypography-root-1 MuiTypography-subtitle1-19 MuiTypography-gutterBottom-28\\">test</h6>"`;
|
||||
exports[`<NoItem /> component should load the component in default state 1`] = `"<h6 class=\\"MuiTypography-root MuiTypography-subtitle1 MuiTypography-gutterBottom\\">test</h6>"`;
|
||||
|
||||
exports[`<NoItem /> component should set html from props 1`] = `"<h6 class=\\"MuiTypography-root-1 MuiTypography-subtitle1-19 MuiTypography-gutterBottom-28\\">This is a test string</h6>"`;
|
||||
exports[`<NoItem /> component should set html from props 1`] = `"<h6 class=\\"MuiTypography-root MuiTypography-subtitle1 MuiTypography-gutterBottom\\">This is a test string</h6>"`;
|
||||
|
||||
@@ -1,45 +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: any; history: any };
|
||||
export type NotFoundProps = RouteComponentProps & { width: Breakpoint; history };
|
||||
|
||||
const HOME_LABEL = 'Home';
|
||||
|
||||
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 handleGoTo = (to: string) => () => {
|
||||
history.push(to);
|
||||
};
|
||||
const handleGomHome = useCallback(() => {
|
||||
history.push('/');
|
||||
}, [history]);
|
||||
|
||||
const handleGoBack = () => () => {
|
||||
history.goBack();
|
||||
};
|
||||
|
||||
const renderList = () => (
|
||||
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 = () => (
|
||||
<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'}>
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`<NotFound /> component should load the component in default state 1`] = `<withRouter(WithTheme(WithWidth(NotFound))) />`;
|
||||
exports[`<NotFound /> component should load the component in default state 1`] = `<withRouter(WithWidth(NotFound)) />`;
|
||||
|
||||
@@ -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',
|
||||
});
|
||||
|
||||
@@ -8,7 +8,7 @@ import { WrapperLink, Description, OverviewItem } from './styles';
|
||||
* Generates one month back date from current time
|
||||
* @return {object} date object
|
||||
*/
|
||||
const dateOneMonthAgo = () => new Date(1544377770747);
|
||||
const dateOneMonthAgo = (): Date => new Date(1544377770747);
|
||||
|
||||
describe('<Package /> component', () => {
|
||||
test.skip('should load the component', () => {
|
||||
|
||||
@@ -6,10 +6,28 @@ import HomeIcon from '@material-ui/icons/Home';
|
||||
import ListItem from '@material-ui/core/ListItem';
|
||||
import Tooltip from '@material-ui/core/Tooltip';
|
||||
|
||||
import { PackageMetaInterface } from 'types/packageMeta';
|
||||
import Tag from '../Tag';
|
||||
import fileSizeSI from '../../utils/file-size';
|
||||
import { formatDate, formatDateDistance } from '../../utils/package';
|
||||
|
||||
import {
|
||||
Author,
|
||||
Avatar,
|
||||
Description,
|
||||
Details,
|
||||
GridRightAligned,
|
||||
Icon,
|
||||
IconButton,
|
||||
OverviewItem,
|
||||
PackageList,
|
||||
PackageListItemText,
|
||||
PackageTitle,
|
||||
Published,
|
||||
TagContainer,
|
||||
Text,
|
||||
WrapperLink,
|
||||
} from './styles';
|
||||
import { isURL } from '../../utils/url';
|
||||
interface Author {
|
||||
name: string;
|
||||
avatar?: string;
|
||||
@@ -23,40 +41,20 @@ interface Dist {
|
||||
unpackedSize: number;
|
||||
}
|
||||
|
||||
interface Props {
|
||||
export interface PackageInterface {
|
||||
name: string;
|
||||
version: string;
|
||||
time: string;
|
||||
time?: number | string;
|
||||
author: Author;
|
||||
description?: string;
|
||||
keywords?: string[];
|
||||
license?: string | null;
|
||||
license?: PackageMetaInterface['latest']['license'];
|
||||
homepage?: string;
|
||||
bugs?: Bugs;
|
||||
dist?: Dist;
|
||||
}
|
||||
|
||||
import {
|
||||
Author,
|
||||
Avatar,
|
||||
Description,
|
||||
Details,
|
||||
GridRightAligned,
|
||||
Icon,
|
||||
IconButton,
|
||||
OverviewItem,
|
||||
PackageList,
|
||||
PackageListItem,
|
||||
PackageListItemText,
|
||||
PackageTitle,
|
||||
Published,
|
||||
TagContainer,
|
||||
Text,
|
||||
WrapperLink,
|
||||
} from './styles';
|
||||
import { isURL } from '../../utils/url';
|
||||
|
||||
const Package: React.FC<Props> = ({
|
||||
const Package: React.FC<PackageInterface> = ({
|
||||
author: { name: authorName, avatar: authorAvatar },
|
||||
bugs,
|
||||
description,
|
||||
@@ -175,13 +173,13 @@ const Package: React.FC<Props> = ({
|
||||
return (
|
||||
<PackageList className={'package'}>
|
||||
<ListItem alignItems={'flex-start'}>{renderPackageListItemText()}</ListItem>
|
||||
<PackageListItem alignItems={'flex-start'}>
|
||||
<ListItem alignItems={'flex-start'}>
|
||||
{renderAuthorInfo()}
|
||||
{renderVersionInfo()}
|
||||
{renderPublishedInfo()}
|
||||
{renderFileSize()}
|
||||
{renderLicenseInfo()}
|
||||
</PackageListItem>
|
||||
</ListItem>
|
||||
</PackageList>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -3,7 +3,6 @@ import { Link } from 'react-router-dom';
|
||||
|
||||
import Grid from '@material-ui/core/Grid';
|
||||
import List from '@material-ui/core/List';
|
||||
import ListItem from '@material-ui/core/ListItem';
|
||||
import ListItemText from '@material-ui/core/ListItemText';
|
||||
import MuiIconButton from '@material-ui/core/IconButton';
|
||||
import Photo from '@material-ui/core/Avatar';
|
||||
@@ -13,6 +12,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 +34,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 +106,35 @@ 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;
|
||||
'> :last-child': {
|
||||
paddingTop: 0,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
svg {
|
||||
font-size: 16px;
|
||||
}
|
||||
}
|
||||
`;
|
||||
export const IconButton = styled(MuiIconButton)({
|
||||
'&&': {
|
||||
padding: '6px',
|
||||
|
||||
svg: {
|
||||
fontSize: '16px',
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
export const TagContainer = styled('span')`
|
||||
&& {
|
||||
@@ -143,20 +147,14 @@ export const TagContainer = styled('span')`
|
||||
}
|
||||
`;
|
||||
|
||||
export const PackageListItem = styled(ListItem)`
|
||||
&& {
|
||||
padding-top: 0;
|
||||
}
|
||||
`;
|
||||
export const PackageListItemText = styled(ListItemText)({
|
||||
'&&': {
|
||||
paddingRight: 0,
|
||||
},
|
||||
});
|
||||
|
||||
export const PackageListItemText = styled(ListItemText)`
|
||||
&& {
|
||||
padding-right: 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,
|
||||
});
|
||||
|
||||
@@ -1,25 +1,20 @@
|
||||
import React, { Fragment } from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import React, { Fragment, ReactElement } from 'react';
|
||||
|
||||
import Divider from '@material-ui/core/Divider';
|
||||
|
||||
import Package from '../Package';
|
||||
import Help from '../Help';
|
||||
import { formatLicense } from '../../utils/package';
|
||||
import { PackageInterface } from '../Package/Package';
|
||||
|
||||
// @ts-ignore
|
||||
import classes from './packageList.scss';
|
||||
import * as classes from './styles';
|
||||
|
||||
interface Props {
|
||||
packages: any;
|
||||
packages: PackageInterface[];
|
||||
}
|
||||
|
||||
export default class PackageList extends React.Component<Props, {}> {
|
||||
static propTypes = {
|
||||
packages: PropTypes.array,
|
||||
};
|
||||
|
||||
render() {
|
||||
public render(): ReactElement<HTMLElement> {
|
||||
return (
|
||||
<div className={'package-list-items'}>
|
||||
<div className={classes.pkgContainer}>{this.hasPackages() ? this.renderPackages() : <Help />}</div>
|
||||
@@ -27,20 +22,19 @@ export default class PackageList extends React.Component<Props, {}> {
|
||||
);
|
||||
}
|
||||
|
||||
hasPackages() {
|
||||
private hasPackages(): boolean {
|
||||
const { packages } = this.props;
|
||||
return packages.length > 0;
|
||||
}
|
||||
|
||||
renderPackages = () => {
|
||||
private renderPackages = () => {
|
||||
return <>{this.renderList()}</>;
|
||||
};
|
||||
|
||||
renderList = () => {
|
||||
private renderList = () => {
|
||||
const { packages } = this.props;
|
||||
return packages.map((pkg, i) => {
|
||||
const { name, version, description, time, keywords, dist, homepage, bugs } = pkg;
|
||||
const author = pkg.author;
|
||||
const { name, version, description, time, keywords, dist, homepage, bugs, author } = pkg;
|
||||
// TODO: move format license to API side.
|
||||
const license = formatLicense(pkg.license);
|
||||
return (
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user