forked from sombochea/verdaccio-ui
Compare commits
99 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2a2784ba39 | ||
|
|
6d553ea607 | ||
|
|
95f173d29a | ||
|
|
531295a6d0 | ||
|
|
a38b93e127 | ||
|
|
52ed8ad67b | ||
|
|
ae0222cf65 | ||
|
|
2bc49f3ab7 | ||
|
|
ade548a7da | ||
|
|
6dfcd70025 | ||
|
|
4498aad4bf | ||
|
|
5d6ad3d783 | ||
|
|
5c06ace14a | ||
|
|
8c66dbc4d7 | ||
|
|
302f4dbd89 | ||
|
|
ff791a35f7 | ||
|
|
f5c77ff43c | ||
|
|
d69fc1b260 | ||
|
|
16b12ddc76 | ||
|
|
dd532955de | ||
|
|
0d581718ab | ||
|
|
7de6983d1e | ||
|
|
48c03fe472 | ||
|
|
1abc15603e | ||
|
|
6f87be68be | ||
|
|
cfb29ce325 | ||
|
|
245247cbed | ||
|
|
e0e7c07bce | ||
|
|
d1b3e6e3b5 | ||
|
|
0c4fb7da13 | ||
|
|
a8deeb9b9d | ||
|
|
82d7107de7 | ||
|
|
d2c1130efd | ||
|
|
fdbdb6303b | ||
|
|
7529c02e58 | ||
|
|
8b86ded434 | ||
|
|
3b4d823845 | ||
|
|
7548c89401 | ||
|
|
af8ed8b3e3 | ||
|
|
d0d4139dd3 | ||
|
|
3888736e45 | ||
|
|
752e2b963d | ||
|
|
99621b6baf | ||
|
|
e0642a9d0d | ||
|
|
68b7171de4 | ||
|
|
d1ce82854a | ||
|
|
ae73772a37 | ||
|
|
950f6defca | ||
|
|
0ca89dcbe7 | ||
|
|
f4da5e692d | ||
|
|
6f52838531 | ||
|
|
a8eb1f36fc | ||
|
|
1fb0bf96d1 | ||
|
|
f6eb74736a | ||
|
|
35d691c1e0 | ||
|
|
b35baa069f | ||
|
|
7a8b158188 | ||
|
|
852f6eeb22 | ||
|
|
b1804d7644 | ||
|
|
32f4389b73 | ||
|
|
3166673875 | ||
|
|
626bcce5cb | ||
|
|
909a8d9fb8 | ||
|
|
9eb698f7e1 | ||
|
|
43a9628ec4 | ||
|
|
d2f1f1c06a | ||
|
|
a365ec548a | ||
|
|
f1f8f8ae3f | ||
|
|
583ddd555a | ||
|
|
7bd9eb7a07 | ||
|
|
61a400fbd8 | ||
|
|
f84fd79c5b | ||
|
|
28c982a7da | ||
|
|
f8e3013b59 | ||
|
|
1d705da38c | ||
|
|
1a74c08b5d | ||
|
|
f8a1f2cbb8 | ||
|
|
74576bda12 | ||
|
|
cf050f234d | ||
|
|
e14729006a | ||
|
|
584f4c141e | ||
|
|
91d818c478 | ||
|
|
ae6e479f16 | ||
|
|
18ef27eac6 | ||
|
|
eabc0b9f5b | ||
|
|
3779caa4e3 | ||
|
|
543877a077 | ||
|
|
7e6702c34b | ||
|
|
2e50981514 | ||
|
|
f61913c2d3 | ||
|
|
ffc97c373c | ||
|
|
3a889b67ee | ||
|
|
de0f91a6d2 | ||
|
|
195a79a809 | ||
|
|
0a7428edab | ||
|
|
9ad506d569 | ||
|
|
3b52a17623 | ||
|
|
3309e449d1 | ||
|
|
7853ec2acb |
4
.babelrc
4
.babelrc
@@ -1,5 +1,3 @@
|
||||
{
|
||||
"presets": [
|
||||
["@verdaccio", { "typescript": true }]
|
||||
]
|
||||
"presets": [["@verdaccio"]]
|
||||
}
|
||||
|
||||
@@ -1,31 +1,28 @@
|
||||
version: 2
|
||||
|
||||
aliases:
|
||||
- &repo_path
|
||||
~/ui-theme
|
||||
- &defaults
|
||||
working_directory: ~/ui-theme
|
||||
- &node11_executor
|
||||
working_directory: *repo_path
|
||||
- &node_latest_browser
|
||||
docker:
|
||||
- image: circleci/node:11.10.1
|
||||
- &node8_executor
|
||||
- image: circleci/node:latest-browsers
|
||||
- &node_latest_executor
|
||||
docker:
|
||||
- image: circleci/node:8
|
||||
- &node10_executor
|
||||
- image: circleci/node:latest
|
||||
- &node_lts_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 +33,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,34 +45,28 @@ 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: Lint code
|
||||
command: yarn lint
|
||||
- run:
|
||||
name: Build project
|
||||
command: yarn run build
|
||||
command: yarn build
|
||||
- save_cache:
|
||||
key: *yarn_cache_key
|
||||
paths:
|
||||
- ~/.yarn
|
||||
- ~/.cache/yarn
|
||||
- node_modules
|
||||
- save_cache:
|
||||
key: *repo_key
|
||||
- persist_to_workspace:
|
||||
root: *repo_path
|
||||
paths:
|
||||
- ~/ui-theme
|
||||
- ./*
|
||||
|
||||
test_bundlesize:
|
||||
<<: *defaults
|
||||
<<: *default_executor
|
||||
@@ -85,37 +76,37 @@ 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_e2e:
|
||||
<<: *defaults
|
||||
<<: *node_latest_browser
|
||||
steps:
|
||||
- *restore_repo
|
||||
- run:
|
||||
name: Test E2E Node (LTS)
|
||||
command: yarn test:e2e
|
||||
|
||||
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 +131,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 +144,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:
|
||||
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
|
||||
- test_e2e:
|
||||
requires:
|
||||
- prepare
|
||||
<<: *ignore_non_dev_branches
|
||||
- coverage:
|
||||
requires:
|
||||
- test_bundlesize
|
||||
- test_node_latest
|
||||
<<: *ignore_non_dev_branches
|
||||
- publish_package:
|
||||
requires:
|
||||
- test_bundlesize
|
||||
- test_node_latest
|
||||
- test_node_lts
|
||||
- test_e2e
|
||||
- coverage
|
||||
<<: *execute_on_release
|
||||
|
||||
@@ -3,6 +3,7 @@ coverage/
|
||||
static/
|
||||
.github/
|
||||
.circleci/
|
||||
build
|
||||
*.md
|
||||
*.lock
|
||||
*.yaml
|
||||
@@ -10,3 +11,4 @@ Dockerfile
|
||||
*.html
|
||||
*.scss
|
||||
*.png
|
||||
doc
|
||||
|
||||
@@ -5,7 +5,8 @@
|
||||
"plugin:jest/recommended",
|
||||
"plugin:prettier/recommended",
|
||||
"plugin:verdaccio/recommended",
|
||||
"plugin:jsx-a11y/recommended"
|
||||
"plugin:jsx-a11y/recommended",
|
||||
"plugin:import/typescript"
|
||||
],
|
||||
"plugins": [
|
||||
"react",
|
||||
@@ -14,19 +15,22 @@
|
||||
"verdaccio",
|
||||
"jsx-a11y",
|
||||
"codeceptjs",
|
||||
"react-hooks"
|
||||
"react-hooks",
|
||||
"import"
|
||||
],
|
||||
"settings": {
|
||||
"react": {
|
||||
"version": "detect"
|
||||
}
|
||||
},
|
||||
"parser": "@typescript-eslint/parser",
|
||||
"parserOptions": {
|
||||
"ecmaFeatures": {
|
||||
"jsx": true
|
||||
}
|
||||
},
|
||||
"rules": {
|
||||
"import/order": ["error", {"newlines-between": "always"}],
|
||||
"babel/no-invalid-this": 0,
|
||||
"no-invalid-this": 0,
|
||||
"no-console": ["error", { "allow": ["warn", "error"] }],
|
||||
|
||||
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, pull_request]
|
||||
|
||||
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:
|
||||
node-version: ${{ matrix.node_version }}
|
||||
- name: Install
|
||||
run: yarn install --frozen-lockfile
|
||||
- name: Build
|
||||
run: yarn build
|
||||
- name: Lint
|
||||
run: yarn lint
|
||||
28
.github/workflows/nodejs.yml
vendored
28
.github/workflows/nodejs.yml
vendored
@@ -1,28 +0,0 @@
|
||||
name: Node CI
|
||||
|
||||
on: [push]
|
||||
|
||||
jobs:
|
||||
ci:
|
||||
name: Test on node ${{ matrix.node_version }} and ${{ matrix.os }}
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
node_version: [8, 10, 12]
|
||||
os: [ubuntu-latest, windows-latest, macOS-latest]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- name: Use Node.js ${{ matrix.node_version }}
|
||||
uses: actions/setup-node@v1
|
||||
with:
|
||||
version: ${{ matrix.node_version }}
|
||||
|
||||
- name: Use Yarn 1.17.2
|
||||
run: |
|
||||
npm install -g yarn@1.17.2
|
||||
- name: yarn build
|
||||
run: |
|
||||
yarn install
|
||||
yarn lint
|
||||
yarn build
|
||||
2
.gitignore
vendored
2
.gitignore
vendored
@@ -2,6 +2,8 @@ npm-debug.log
|
||||
verdaccio-*.tgz
|
||||
.DS_Store
|
||||
build/
|
||||
doc
|
||||
|
||||
###
|
||||
node_modules
|
||||
package-lock.json
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
3
.vscode/settings.json
vendored
3
.vscode/settings.json
vendored
@@ -5,5 +5,6 @@
|
||||
"javascriptreact",
|
||||
"typescript",
|
||||
"typescriptreact"
|
||||
]
|
||||
],
|
||||
"typescript.tsdk": "node_modules/typescript/lib"
|
||||
}
|
||||
82
CHANGELOG.md
82
CHANGELOG.md
@@ -2,6 +2,88 @@
|
||||
|
||||
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.4](https://github.com/verdaccio/ui/compare/v0.3.3...v0.3.4) (2019-10-26)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* adds no uplink spec ([#213](https://github.com/verdaccio/ui/issues/213)) ([ade548a](https://github.com/verdaccio/ui/commit/ade548a))
|
||||
* api typings ([#210](https://github.com/verdaccio/ui/issues/210)) ([5d6ad3d](https://github.com/verdaccio/ui/commit/5d6ad3d))
|
||||
* PackageList component is converted to functional ([#219](https://github.com/verdaccio/ui/issues/219)) [#116](https://github.com/verdaccio/ui/issues/116) ([ae0222c](https://github.com/verdaccio/ui/commit/ae0222c))
|
||||
* routes - Replaced class by func. comp ([#159](https://github.com/verdaccio/ui/issues/159)) ([5c06ace](https://github.com/verdaccio/ui/commit/5c06ace))
|
||||
* version Page - Replaces class by func. ([#171](https://github.com/verdaccio/ui/issues/171)) ([f5c77ff](https://github.com/verdaccio/ui/commit/f5c77ff))
|
||||
* **162:** added forwardRef Card ([#216](https://github.com/verdaccio/ui/issues/216)) ([2bc49f3](https://github.com/verdaccio/ui/commit/2bc49f3))
|
||||
* **installlistitem:** changed the wrong icon ([#211](https://github.com/verdaccio/ui/issues/211)) ([4498aad](https://github.com/verdaccio/ui/commit/4498aad))
|
||||
|
||||
### [0.3.3](https://github.com/verdaccio/ui/compare/v0.3.2...v0.3.3) (2019-10-16)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **deps:** remove types from dependencies ([#201](https://github.com/verdaccio/ui/issues/201)) ([48c03fe](https://github.com/verdaccio/ui/commit/48c03fe))
|
||||
* add new window property to interface definition ([b35baa0](https://github.com/verdaccio/ui/commit/b35baa0))
|
||||
* added typings for react-autosuggest ([#200](https://github.com/verdaccio/ui/issues/200)) ([cfb29ce](https://github.com/verdaccio/ui/commit/cfb29ce))
|
||||
* better type inference for MediaQuery ([#180](https://github.com/verdaccio/ui/issues/180)) ([e0e7c07](https://github.com/verdaccio/ui/commit/e0e7c07))
|
||||
* changes font size for items of the register-info component ([#196](https://github.com/verdaccio/ui/issues/196)) ([6f87be6](https://github.com/verdaccio/ui/commit/6f87be6)), closes [#193](https://github.com/verdaccio/ui/issues/193)
|
||||
* convert Dist component to hooks ([#156](https://github.com/verdaccio/ui/issues/156)) ([f1f8f8a](https://github.com/verdaccio/ui/commit/f1f8f8a))
|
||||
* detailContainer Component - Replaced class by func. comp ([#130](https://github.com/verdaccio/ui/issues/130)) ([f84fd79](https://github.com/verdaccio/ui/commit/f84fd79))
|
||||
* dist-tags attribute [#175](https://github.com/verdaccio/ui/issues/175) ([#178](https://github.com/verdaccio/ui/issues/178)) ([752e2b9](https://github.com/verdaccio/ui/commit/752e2b9))
|
||||
* fix DependencyBlock props interface ([35d691c](https://github.com/verdaccio/ui/commit/35d691c))
|
||||
* fixed import ([#176](https://github.com/verdaccio/ui/issues/176)) ([d0d4139](https://github.com/verdaccio/ui/commit/d0d4139))
|
||||
* fixed imports & func's name ([#182](https://github.com/verdaccio/ui/issues/182)) ([3888736](https://github.com/verdaccio/ui/commit/3888736))
|
||||
* Header Component - Replaced class by func. comp ([#142](https://github.com/verdaccio/ui/issues/142)) ([d1ce828](https://github.com/verdaccio/ui/commit/d1ce828))
|
||||
* improve jest mock typings ([852f6ee](https://github.com/verdaccio/ui/commit/852f6ee))
|
||||
* improved typing ([#174](https://github.com/verdaccio/ui/issues/174)) ([e0642a9](https://github.com/verdaccio/ui/commit/e0642a9))
|
||||
* incorrect Tooltip import in avatar component ([#160](https://github.com/verdaccio/ui/issues/160)) ([43a9628](https://github.com/verdaccio/ui/commit/43a9628))
|
||||
* install Component - Replaced class by func. comp ([#152](https://github.com/verdaccio/ui/issues/152)) ([9eb698f](https://github.com/verdaccio/ui/commit/9eb698f))
|
||||
* introduced forwardRef ([#163](https://github.com/verdaccio/ui/issues/163)) ([626bcce](https://github.com/verdaccio/ui/commit/626bcce))
|
||||
* introduced forwardRef ([#164](https://github.com/verdaccio/ui/issues/164)) ([909a8d9](https://github.com/verdaccio/ui/commit/909a8d9))
|
||||
* introduced ForwardRef ([#177](https://github.com/verdaccio/ui/issues/177)) ([af8ed8b](https://github.com/verdaccio/ui/commit/af8ed8b))
|
||||
* introduced forwardRef ([#181](https://github.com/verdaccio/ui/issues/181)) ([0c4fb7d](https://github.com/verdaccio/ui/commit/0c4fb7d))
|
||||
* introduced forwardRef ([#185](https://github.com/verdaccio/ui/issues/185)) ([7548c89](https://github.com/verdaccio/ui/commit/7548c89))
|
||||
* introduced SvgIcon ([#184](https://github.com/verdaccio/ui/issues/184)) ([8b86ded](https://github.com/verdaccio/ui/commit/8b86ded))
|
||||
* linter error fixed ([#143](https://github.com/verdaccio/ui/issues/143)) ([74576bd](https://github.com/verdaccio/ui/commit/74576bd))
|
||||
* listItem Component - Introduced ForwardRef ([#183](https://github.com/verdaccio/ui/issues/183)) ([82d7107](https://github.com/verdaccio/ui/commit/82d7107))
|
||||
* lock file was corrupted ([7bd9eb7](https://github.com/verdaccio/ui/commit/7bd9eb7))
|
||||
* media query ts ignore ([6f52838](https://github.com/verdaccio/ui/commit/6f52838))
|
||||
* remove ts ignore from some components ([b1804d7](https://github.com/verdaccio/ui/commit/b1804d7))
|
||||
* remove unnecessary ts ignore ([7a8b158](https://github.com/verdaccio/ui/commit/7a8b158))
|
||||
* remove unnecessary ts ignore ([32f4389](https://github.com/verdaccio/ui/commit/32f4389))
|
||||
* removed tsignore for AppContext ([#188](https://github.com/verdaccio/ui/issues/188)) ([d2c1130](https://github.com/verdaccio/ui/commit/d2c1130))
|
||||
* typography Component - Introduced ForwardRef ([#179](https://github.com/verdaccio/ui/issues/179)) ([a8deeb9](https://github.com/verdaccio/ui/commit/a8deeb9))
|
||||
* **api:** remove unnecessary ts ignore ([a8eb1f3](https://github.com/verdaccio/ui/commit/a8eb1f3))
|
||||
* **App:** ts ignore ([f6eb747](https://github.com/verdaccio/ui/commit/f6eb747))
|
||||
* **Developers:** remove compilation warnings ([f4da5e6](https://github.com/verdaccio/ui/commit/f4da5e6))
|
||||
* **Footer:** remove unnecessary ts ignore ([1fb0bf9](https://github.com/verdaccio/ui/commit/1fb0bf9))
|
||||
* some warnings in console ([#155](https://github.com/verdaccio/ui/issues/155)) ([583ddd5](https://github.com/verdaccio/ui/commit/583ddd5))
|
||||
* spinner typings ([3166673](https://github.com/verdaccio/ui/commit/3166673))
|
||||
* tarball download not working on Firefox and Edge ([#144](https://github.com/verdaccio/ui/issues/144)) ([f8e3013](https://github.com/verdaccio/ui/commit/f8e3013))
|
||||
* warning about modules with names differing in casing ([#148](https://github.com/verdaccio/ui/issues/148)) ([e147290](https://github.com/verdaccio/ui/commit/e147290))
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* new not found component ([#170](https://github.com/verdaccio/ui/issues/170)) ([fdbdb63](https://github.com/verdaccio/ui/commit/fdbdb63))
|
||||
* **eslint-config:** add order rule in import ([ae73772](https://github.com/verdaccio/ui/commit/ae73772))
|
||||
* upgraded typescript to 3.6.3 ([#145](https://github.com/verdaccio/ui/issues/145)) ([f8a1f2c](https://github.com/verdaccio/ui/commit/f8a1f2c))
|
||||
* use React.lazy for loading components ([#158](https://github.com/verdaccio/ui/issues/158)) ([a365ec5](https://github.com/verdaccio/ui/commit/a365ec5))
|
||||
* version Component - Replaced classes by func. comp ([#129](https://github.com/verdaccio/ui/issues/129)) ([1d705da](https://github.com/verdaccio/ui/commit/1d705da))
|
||||
|
||||
### [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)
|
||||
|
||||
|
||||
|
||||
24
README.md
24
README.md
@@ -26,21 +26,39 @@ 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.
|
||||
|
||||
```
|
||||
> ⚠️ The development mode just emulate interaction of the UI development with a real verdaccio server, but it is not the real integration. UI is just a theme plugin dependency in the [Verdaccio project](https://github.com/verdaccio/verdaccio).
|
||||
|
||||
### Before commit
|
||||
|
||||
Don't forget run the following commands before commit and push your code, it will save you time.
|
||||
|
||||
```bash
|
||||
yarn lint && yarn test
|
||||
```
|
||||
|
||||
#### Commits
|
||||
|
||||
Remember we follow the [the Conventional Commits specification](https://www.conventionalcommits.org/en/v1.0.0-beta.4/).
|
||||
|
||||
🤓 Feel free to participate in code reviews, let us know if you want to participate in this plugin.
|
||||
|
||||
### End to End Testing
|
||||
|
||||
Additionally, we recommend run E2E testing before push and verify your changes do not break anything. These command will run in our CI anyway.
|
||||
|
||||
```bash
|
||||
yarn build && yarn test:e2e
|
||||
```
|
||||
|
||||
> `yarn build` will build with webpack the production files.
|
||||
|
||||
|
||||
## Open Collective Sponsors
|
||||
|
||||
@@ -65,7 +83,7 @@ Thank you to all our backers! 🙏 [[Become a backer](https://opencollective.com
|
||||
|
||||
## Contributors
|
||||
|
||||
This project exists thanks to all the people who contribute. [[Contribute](CONTRIBUTING.md)].
|
||||
This project exists thanks to all the people who contribute.
|
||||
|
||||
[](../../graphs/contributors)
|
||||
|
||||
|
||||
29
codecov.yml
Normal file
29
codecov.yml
Normal file
@@ -0,0 +1,29 @@
|
||||
codecov:
|
||||
require_ci_to_pass: yes
|
||||
|
||||
coverage:
|
||||
precision: 2
|
||||
round: down
|
||||
range: "80...85"
|
||||
|
||||
status:
|
||||
project:
|
||||
default:
|
||||
target: auto
|
||||
threshold: 1%
|
||||
base: auto
|
||||
patch: no
|
||||
changes: no
|
||||
|
||||
parsers:
|
||||
gcov:
|
||||
branch_detection:
|
||||
conditional: yes
|
||||
loop: yes
|
||||
method: no
|
||||
macro: no
|
||||
|
||||
comment:
|
||||
layout: "diff,flags,tree"
|
||||
behavior: default
|
||||
require_changes: no
|
||||
@@ -11,7 +11,15 @@ module.exports = {
|
||||
rootDir: '..',
|
||||
setupFiles: ['<rootDir>/jest/setup.ts'],
|
||||
transformIgnorePatterns: ['<rootDir>/node_modules/(?!react-syntax-highlighter)'],
|
||||
modulePathIgnorePatterns: ['<rootDir>/coverage', '<rootDir>/scripts', '<rootDir>/.circleci', '<rootDir>/tools', '<rootDir>/build', '<rootDir>/.vscode/'],
|
||||
modulePathIgnorePatterns: [
|
||||
'<rootDir>/coverage',
|
||||
'<rootDir>/scripts',
|
||||
'<rootDir>/.circleci',
|
||||
'<rootDir>/tools',
|
||||
'<rootDir>/build',
|
||||
'<rootDir>/.vscode/',
|
||||
'<rootDir>/test/e2e/',
|
||||
],
|
||||
snapshotSerializers: ['enzyme-to-json/serializer', 'jest-emotion'],
|
||||
moduleNameMapper: {
|
||||
'\\.(s?css)$': '<rootDir>/node_modules/identity-obj-proxy',
|
||||
|
||||
@@ -15,6 +15,11 @@ export function generateTokenWithTimeRange(limit = 0) {
|
||||
|
||||
export function generateTokenWithExpirationAsString() {
|
||||
const payload = { username: 'verdaccio', exp: 'I am not a number' };
|
||||
return `xxxxxx.${Base64.encode(JSON.stringify(payload))}.xxxxxx`;
|
||||
}
|
||||
|
||||
export function generateInvalidToken() {
|
||||
const payload = `invalidtoken`;
|
||||
return `xxxxxx.${Base64.encode(payload)}.xxxxxx`;
|
||||
}
|
||||
|
||||
|
||||
123
package.json
123
package.json
@@ -1,49 +1,59 @@
|
||||
{
|
||||
"name": "@verdaccio/ui-theme",
|
||||
"version": "0.3.0",
|
||||
"version": "0.3.4",
|
||||
"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.1.0",
|
||||
"@commitlint/config-conventional": "8.1.0",
|
||||
"@material-ui/core": "4.3.3",
|
||||
"@material-ui/icons": "4.2.1",
|
||||
"@material-ui/styles": "4.3.3",
|
||||
"@octokit/rest": "16.28.7",
|
||||
"@testing-library/react": "9.1.3",
|
||||
"@commitlint/cli": "8.2.0",
|
||||
"@commitlint/config-conventional": "8.2.0",
|
||||
"@material-ui/core": "4.5.1",
|
||||
"@material-ui/icons": "4.5.1",
|
||||
"@octokit/rest": "16.34.0",
|
||||
"@testing-library/react": "9.3.0",
|
||||
"@types/autosuggest-highlight": "3.1.0",
|
||||
"@types/enzyme": "3.10.3",
|
||||
"@types/jest": "24.0.18",
|
||||
"@types/lodash": "4.14.138",
|
||||
"@types/node": "12.7.3",
|
||||
"@types/react": "16.9.2",
|
||||
"@types/react-dom": "16.9.0",
|
||||
"@types/react-router-dom": "4.3.5",
|
||||
"@types/jest": "24.0.20",
|
||||
"@types/js-base64": "2.3.1",
|
||||
"@types/lodash": "4.14.144",
|
||||
"@types/node": "12.11.7",
|
||||
"@types/react": "16.9.11",
|
||||
"@types/react-autosuggest": "9.3.13",
|
||||
"@types/react-dom": "16.9.3",
|
||||
"@types/react-router-dom": "5.1.0",
|
||||
"@types/request": "2.48.3",
|
||||
"@types/validator": "10.11.3",
|
||||
"@verdaccio/babel-preset": "2.0.0",
|
||||
"@types/webpack-env": "1.14.1",
|
||||
"@typescript-eslint/parser": "2.4.0",
|
||||
"@verdaccio/babel-preset": "8.2.0",
|
||||
"@verdaccio/commons-api": "8.2.0",
|
||||
"@verdaccio/eslint-config": "2.0.0",
|
||||
"@verdaccio/types": "8.0.0",
|
||||
"@verdaccio/types": "8.1.0",
|
||||
"autosuggest-highlight": "3.1.1",
|
||||
"babel-loader": "8.0.6",
|
||||
"bundlesize": "0.18.0",
|
||||
"codeceptjs": "2.2.1",
|
||||
"codecov": "3.5.0",
|
||||
"concurrently": "4.1.2",
|
||||
"cross-env": "5.2.0",
|
||||
"codeceptjs": "2.3.5",
|
||||
"codecov": "3.6.1",
|
||||
"concurrently": "5.0.0",
|
||||
"cross-env": "6.0.3",
|
||||
"css-loader": "3.2.0",
|
||||
"date-fns": "1.30.1",
|
||||
"detect-secrets": "1.0.4",
|
||||
"emotion": "9.2.12",
|
||||
"enzyme": "3.10.0",
|
||||
"enzyme-adapter-react-16": "1.14.0",
|
||||
"enzyme-to-json": "3.4.0",
|
||||
"eslint": "5.16.0",
|
||||
"enzyme-adapter-react-16": "1.15.1",
|
||||
"enzyme-to-json": "3.4.3",
|
||||
"eslint": "6.5.1",
|
||||
"eslint-plugin-codeceptjs": "1.1.0",
|
||||
"eslint-plugin-import": "2.18.2",
|
||||
"eslint-plugin-jsx-a11y": "6.2.3",
|
||||
"eslint-plugin-prettier": "3.1.0",
|
||||
"eslint-plugin-react": "7.14.3",
|
||||
@@ -51,14 +61,14 @@
|
||||
"eslint-plugin-verdaccio": "2.0.0",
|
||||
"file-loader": "4.2.0",
|
||||
"friendly-errors-webpack-plugin": "1.7.0",
|
||||
"get-stdin": "6.0.0",
|
||||
"get-stdin": "7.0.0",
|
||||
"github-markdown-css": "3.0.1",
|
||||
"html-webpack-plugin": "3.2.0",
|
||||
"husky": "3.0.4",
|
||||
"husky": "3.0.9",
|
||||
"identity-obj-proxy": "3.0.0",
|
||||
"in-publish": "2.0.0",
|
||||
"jest": "24.9.0",
|
||||
"jest-emotion": "10.0.14",
|
||||
"jest-emotion": "10.0.17",
|
||||
"jest-environment-jsdom": "24.9.0",
|
||||
"jest-environment-jsdom-global": "1.2.0",
|
||||
"jest-environment-node": "24.9.0",
|
||||
@@ -67,45 +77,48 @@
|
||||
"js-yaml": "3.13.1",
|
||||
"lint-staged": "8.2.1",
|
||||
"localstorage-memory": "1.0.3",
|
||||
"lockfile-lint": "2.1.6",
|
||||
"lodash": "^4.17.15",
|
||||
"mini-css-extract-plugin": "0.8.0",
|
||||
"node-mocks-http": "1.7.6",
|
||||
"node-mocks-http": "1.8.0",
|
||||
"normalize.css": "8.0.1",
|
||||
"optimize-css-assets-webpack-plugin": "5.0.3",
|
||||
"ora": "3.4.0",
|
||||
"ora": "4.0.2",
|
||||
"prettier": "1.18.2",
|
||||
"prop-types": "15.7.2",
|
||||
"puppeteer": "1.17.0",
|
||||
"react": "16.9.0",
|
||||
"puppeteer": "1.8.0",
|
||||
"react": "16.11.0",
|
||||
"react-autosuggest": "9.4.3",
|
||||
"react-dom": "16.9.0",
|
||||
"react-dom": "16.11.0",
|
||||
"react-emotion": "9.2.12",
|
||||
"react-hot-loader": "4.12.11",
|
||||
"react-router": "5.0.1",
|
||||
"react-router-dom": "5.0.1",
|
||||
"react-hot-loader": "4.12.15",
|
||||
"react-router-dom": "5.1.2",
|
||||
"request": "2.88.0",
|
||||
"resolve-url-loader": "3.1.0",
|
||||
"rimraf": "2.6.3",
|
||||
"rimraf": "3.0.0",
|
||||
"source-map-loader": "0.2.4",
|
||||
"standard-version": "7.0.0",
|
||||
"style-loader": "1.0.0",
|
||||
"stylelint": "10.1.0",
|
||||
"stylelint-config-recommended": "2.2.0",
|
||||
"stylelint": "11.1.1",
|
||||
"stylelint-config-recommended": "3.0.0",
|
||||
"stylelint-config-styled-components": "0.1.1",
|
||||
"stylelint-processor-styled-components": "1.8.0",
|
||||
"stylelint-webpack-plugin": "0.10.5",
|
||||
"stylelint-webpack-plugin": "1.0.3",
|
||||
"supertest": "4.0.2",
|
||||
"typeface-roboto": "0.0.75",
|
||||
"typescript": "3.5.3",
|
||||
"typescript": "3.7.1-rc",
|
||||
"uglifyjs-webpack-plugin": "2.2.0",
|
||||
"url-loader": "2.1.0",
|
||||
"url-loader": "2.2.0",
|
||||
"validator": "11.1.0",
|
||||
"verdaccio": "4.2.2",
|
||||
"verdaccio-auth-memory": "8.0.0",
|
||||
"verdaccio-memory": "8.0.0",
|
||||
"webpack": "4.39.3",
|
||||
"webpack-bundle-analyzer": "3.4.1",
|
||||
"webpack-bundle-size-analyzer": "3.0.0",
|
||||
"webpack-cli": "3.3.7",
|
||||
"webpack-dev-server": "3.8.0",
|
||||
"verdaccio": "4.3.4",
|
||||
"verdaccio-auth-memory": "8.2.0",
|
||||
"verdaccio-memory": "8.2.0",
|
||||
"wait-on": "3.3.0",
|
||||
"webpack": "4.41.2",
|
||||
"webpack-bundle-analyzer": "3.6.0",
|
||||
"webpack-bundle-size-analyzer": "3.1.0",
|
||||
"webpack-cli": "3.3.9",
|
||||
"webpack-dev-server": "3.9.0",
|
||||
"webpack-merge": "4.2.2",
|
||||
"whatwg-fetch": "3.0.0",
|
||||
"xss": "1.0.6"
|
||||
@@ -142,17 +155,20 @@
|
||||
}
|
||||
],
|
||||
"scripts": {
|
||||
"type-check": "tsc --noEmit",
|
||||
"type-check": "tsc --noEmit --pretty",
|
||||
"type-check:watch": "npm run type-check -- --watch",
|
||||
"type-check-strict:watch": "tsc --project ./tsconfig.strict.json --noEmit --pretty --watch",
|
||||
"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:e2e": "cross-env BABEL_ENV=test jest --config ./test/jest.config.e2e.js",
|
||||
"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",
|
||||
@@ -177,10 +193,11 @@
|
||||
"relative": true,
|
||||
"linters": {
|
||||
"*.{js,tsx,ts}": [
|
||||
"eslint",
|
||||
"eslint .",
|
||||
"prettier --write"
|
||||
],
|
||||
"*": [
|
||||
"detect-secrets-launcher --baseline .secrets-baseline",
|
||||
"git add"
|
||||
]
|
||||
},
|
||||
|
||||
@@ -1,26 +1,28 @@
|
||||
import React from 'react';
|
||||
import { mount } from 'enzyme';
|
||||
import storage from '../utils/storage';
|
||||
import App from './App';
|
||||
import { mount, ReactWrapper } from 'enzyme';
|
||||
|
||||
import storage from '../utils/storage';
|
||||
import { generateTokenWithTimeRange } from '../../jest/unit/components/__mocks__/token';
|
||||
|
||||
import App from './App';
|
||||
import { AppProps } from './AppContext';
|
||||
|
||||
jest.mock('../utils/storage', () => {
|
||||
class LocalStorageMock {
|
||||
private store: object;
|
||||
private store: Record<string, string>;
|
||||
public constructor() {
|
||||
this.store = {};
|
||||
}
|
||||
public clear(): void {
|
||||
this.store = {};
|
||||
}
|
||||
public getItem(key): unknown {
|
||||
public getItem(key: string): unknown {
|
||||
return this.store[key] || null;
|
||||
}
|
||||
public setItem(key, value): void {
|
||||
public setItem(key: string, value: string): void {
|
||||
this.store[key] = value.toString();
|
||||
}
|
||||
public removeItem(key): void {
|
||||
public removeItem(key: string): void {
|
||||
delete this.store[key];
|
||||
}
|
||||
}
|
||||
@@ -32,7 +34,7 @@ jest.mock('../utils/api', () => ({
|
||||
}));
|
||||
|
||||
describe('App', () => {
|
||||
let wrapper;
|
||||
let wrapper: ReactWrapper<{}, AppProps, App>;
|
||||
|
||||
beforeEach(() => {
|
||||
wrapper = mount(<App />);
|
||||
|
||||
@@ -1,44 +1,26 @@
|
||||
import React, { Component, ReactElement } from 'react';
|
||||
import isNil from 'lodash/isNil';
|
||||
import 'normalize.css';
|
||||
import 'typeface-roboto/index.css';
|
||||
|
||||
import storage from '../utils/storage';
|
||||
import { makeLogin, isTokenExpire } from '../utils/login';
|
||||
|
||||
import Loading from '../components/Loading';
|
||||
import LoginModal from '../components/Login';
|
||||
import Header from '../components/Header';
|
||||
import { Container, Content } from '../components/Layout';
|
||||
import RouterApp from '../router';
|
||||
import API from '../utils/api';
|
||||
import '../styles/typeface-roboto.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<{}>({});
|
||||
export const AppContextProvider = AppContext.Provider;
|
||||
export const AppContextConsumer = AppContext.Consumer;
|
||||
import AppRoute from './AppRoute';
|
||||
import { AppProps, AppContextProvider } from './AppContext';
|
||||
|
||||
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
|
||||
export default class App extends Component<{}, AppProps> {
|
||||
public state: AppProps = {
|
||||
logoUrl: window.VERDACCIO_LOGO,
|
||||
user: {},
|
||||
// @ts-ignore
|
||||
scope: window.VERDACCIO_SCOPE ? `${window.VERDACCIO_SCOPE}:` : '',
|
||||
scope: window.VERDACCIO_SCOPE || '',
|
||||
showLoginModal: false,
|
||||
isUserLoggedIn: false,
|
||||
packages: [],
|
||||
@@ -51,7 +33,7 @@ export default class App extends Component<{}, AppStateInterface> {
|
||||
}
|
||||
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
public componentDidUpdate(_, prevState): void {
|
||||
public componentDidUpdate(_: AppProps, prevState: AppProps): void {
|
||||
const { isUserLoggedIn } = this.state;
|
||||
if (prevState.isUserLoggedIn !== isUserLoggedIn) {
|
||||
this.loadOnHandler();
|
||||
@@ -64,7 +46,6 @@ export default class App extends Component<{}, AppStateInterface> {
|
||||
const context = { isUserLoggedIn, packages, logoUrl, user, scope };
|
||||
|
||||
return (
|
||||
// @ts-ignore
|
||||
<Container isLoading={isLoading}>
|
||||
{isLoading ? <Loading /> : <AppContextProvider value={context}>{this.renderContent()}</AppContextProvider>}
|
||||
{this.renderLoginModal()}
|
||||
@@ -75,7 +56,7 @@ export default class App extends Component<{}, AppStateInterface> {
|
||||
public isUserAlreadyLoggedIn = () => {
|
||||
// checks for token validity
|
||||
const token = storage.getItem('token');
|
||||
const username = storage.getItem('username');
|
||||
const username: string = storage.getItem('username') as string;
|
||||
if (isTokenExpire(token) || isNil(username)) {
|
||||
this.handleLogout();
|
||||
} else {
|
||||
@@ -88,11 +69,10 @@ export default class App extends Component<{}, AppStateInterface> {
|
||||
|
||||
public loadOnHandler = async () => {
|
||||
try {
|
||||
// @ts-ignore
|
||||
this.req = await API.request('packages', 'GET');
|
||||
const packages = await API.request<any[]>('packages', 'GET');
|
||||
// @ts-ignore: FIX THIS TYPE: Type 'any[]' is not assignable to type '[]'
|
||||
this.setState({
|
||||
// @ts-ignore
|
||||
packages: this.req,
|
||||
packages,
|
||||
isLoading: false,
|
||||
});
|
||||
} catch (error) {
|
||||
@@ -105,7 +85,7 @@ export default class App extends Component<{}, AppStateInterface> {
|
||||
}
|
||||
};
|
||||
|
||||
public setLoading = isLoading =>
|
||||
public setLoading = (isLoading: boolean) =>
|
||||
this.setState({
|
||||
isLoading,
|
||||
});
|
||||
@@ -116,7 +96,6 @@ export default class App extends Component<{}, AppStateInterface> {
|
||||
*/
|
||||
public handleToggleLoginModal = () => {
|
||||
this.setState(prevState => ({
|
||||
// @ts-ignore
|
||||
showLoginModal: !prevState.showLoginModal,
|
||||
}));
|
||||
};
|
||||
@@ -125,8 +104,7 @@ export default class App extends Component<{}, AppStateInterface> {
|
||||
* handles login
|
||||
* Required by: <Header />
|
||||
*/
|
||||
public handleDoLogin = async (usernameValue, passwordValue) => {
|
||||
// @ts-ignore
|
||||
public handleDoLogin = async (usernameValue: string, passwordValue: string) => {
|
||||
const { username, token, error } = await makeLogin(usernameValue, passwordValue);
|
||||
|
||||
if (username && token) {
|
||||
@@ -143,7 +121,7 @@ export default class App extends Component<{}, AppStateInterface> {
|
||||
}
|
||||
};
|
||||
|
||||
public setLoggedUser = username => {
|
||||
public setLoggedUser = (username: string) => {
|
||||
this.setState({
|
||||
user: {
|
||||
username,
|
||||
@@ -175,9 +153,7 @@ export default class App extends Component<{}, AppStateInterface> {
|
||||
return (
|
||||
<>
|
||||
<Content>
|
||||
<RouterApp onLogout={this.handleLogout} onToggleLoginModal={this.handleToggleLoginModal}>
|
||||
{this.renderHeader()}
|
||||
</RouterApp>
|
||||
<AppRoute>{this.renderHeader()}</AppRoute>
|
||||
</Content>
|
||||
<Footer />
|
||||
</>
|
||||
@@ -187,7 +163,6 @@ export default class App extends Component<{}, AppStateInterface> {
|
||||
public renderHeader = (): ReactElement<HTMLElement> => {
|
||||
const {
|
||||
logoUrl,
|
||||
// @ts-ignore
|
||||
user: { username },
|
||||
scope,
|
||||
} = this.state;
|
||||
|
||||
20
src/App/AppContext.tsx
Normal file
20
src/App/AppContext.tsx
Normal file
@@ -0,0 +1,20 @@
|
||||
import { createContext } from 'react';
|
||||
|
||||
import { FormError } from '../components/Login/Login';
|
||||
|
||||
export interface AppProps {
|
||||
error?: FormError;
|
||||
logoUrl: string;
|
||||
user: {
|
||||
username?: string;
|
||||
};
|
||||
scope: string;
|
||||
showLoginModal: boolean;
|
||||
isUserLoggedIn: boolean;
|
||||
packages: [];
|
||||
isLoading: boolean;
|
||||
}
|
||||
|
||||
export const AppContext = createContext<Partial<AppProps>>({});
|
||||
export const AppContextProvider = AppContext.Provider;
|
||||
export const AppContextConsumer = AppContext.Consumer;
|
||||
@@ -6,21 +6,21 @@ export interface ErrorProps {
|
||||
|
||||
export interface ErrorAppState {
|
||||
hasError: boolean;
|
||||
error: any;
|
||||
info: any;
|
||||
error: Error | null;
|
||||
info: object | null;
|
||||
}
|
||||
|
||||
export default class ErrorBoundary extends Component<ErrorProps, ErrorAppState> {
|
||||
constructor(props) {
|
||||
constructor(props: ErrorProps) {
|
||||
super(props);
|
||||
this.state = { hasError: false, error: null, info: null };
|
||||
}
|
||||
|
||||
componentDidCatch(error, info) {
|
||||
public componentDidCatch(error: Error, info: object) {
|
||||
this.setState({ hasError: true, error, info });
|
||||
}
|
||||
|
||||
render() {
|
||||
public render(): JSX.Element {
|
||||
const { hasError, error, info } = this.state;
|
||||
const { children } = this.props;
|
||||
|
||||
|
||||
68
src/App/AppRoute.tsx
Normal file
68
src/App/AppRoute.tsx
Normal file
@@ -0,0 +1,68 @@
|
||||
import React, { lazy, useContext, Suspense } from 'react';
|
||||
import { Route as ReactRouterDomRoute, Switch, Router } from 'react-router-dom';
|
||||
import { createBrowserHistory } from 'history';
|
||||
|
||||
import Loading from '../components/Loading';
|
||||
|
||||
import { AppContext } from './AppContext';
|
||||
|
||||
const NotFound = lazy(() => import('../components/NotFound'));
|
||||
const VersionContextProvider = lazy(() => import('../pages/Version/VersionContextProvider'));
|
||||
const VersionPage = lazy(() => import('../pages/Version'));
|
||||
const HomePage = lazy(() => import('../pages/home'));
|
||||
|
||||
enum Route {
|
||||
ROOT = '/',
|
||||
SCOPE_PACKAGE = '/-/web/detail/@:scope/:package',
|
||||
SCOPE_PACKAGE_VERSION = '/-/web/detail/@:scope/:package/v/:version',
|
||||
PACKAGE = '/-/web/detail/:package',
|
||||
PACKAGE_VERSION = '/-/web/detail/:package/v/:version',
|
||||
}
|
||||
|
||||
const history = createBrowserHistory({
|
||||
basename: window.__VERDACCIO_BASENAME_UI_OPTIONS && window.__VERDACCIO_BASENAME_UI_OPTIONS.url_prefix,
|
||||
});
|
||||
|
||||
/* eslint react/jsx-max-depth: 0 */
|
||||
const AppRoute: React.FC = ({ children }) => {
|
||||
const appContext = useContext(AppContext);
|
||||
const { isUserLoggedIn, packages } = appContext;
|
||||
|
||||
return (
|
||||
<Router history={history}>
|
||||
<Suspense fallback={<Loading />}>
|
||||
{children}
|
||||
<Switch>
|
||||
<ReactRouterDomRoute exact={true} path={Route.ROOT}>
|
||||
<HomePage isUserLoggedIn={!!isUserLoggedIn} packages={packages || []} />
|
||||
</ReactRouterDomRoute>
|
||||
<ReactRouterDomRoute exact={true} path={Route.PACKAGE}>
|
||||
<VersionContextProvider>
|
||||
<VersionPage />
|
||||
</VersionContextProvider>
|
||||
</ReactRouterDomRoute>
|
||||
<ReactRouterDomRoute exact={true} path={Route.PACKAGE_VERSION}>
|
||||
<VersionContextProvider>
|
||||
<VersionPage />
|
||||
</VersionContextProvider>
|
||||
</ReactRouterDomRoute>
|
||||
<ReactRouterDomRoute exact={true} path={Route.SCOPE_PACKAGE_VERSION}>
|
||||
<VersionContextProvider>
|
||||
<VersionPage />
|
||||
</VersionContextProvider>
|
||||
</ReactRouterDomRoute>
|
||||
<ReactRouterDomRoute exact={true} path={Route.SCOPE_PACKAGE}>
|
||||
<VersionContextProvider>
|
||||
<VersionPage />
|
||||
</VersionContextProvider>
|
||||
</ReactRouterDomRoute>
|
||||
<ReactRouterDomRoute>
|
||||
<NotFound />
|
||||
</ReactRouterDomRoute>
|
||||
</Switch>
|
||||
</Suspense>
|
||||
</Router>
|
||||
);
|
||||
};
|
||||
|
||||
export default AppRoute;
|
||||
@@ -1,4 +1,5 @@
|
||||
import { css } from 'emotion';
|
||||
|
||||
import colors from '../utils/styles/colors';
|
||||
|
||||
export const alertError = css({
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
import React from 'react';
|
||||
import { mount } from 'enzyme';
|
||||
|
||||
import api from '../../utils/api';
|
||||
|
||||
import { ActionBar } from './ActionBar';
|
||||
|
||||
const mockPackageMeta = jest.fn(() => ({
|
||||
const mockPackageMeta: jest.Mock = jest.fn(() => ({
|
||||
latest: {
|
||||
homepage: 'https://verdaccio.tld',
|
||||
bugs: {
|
||||
@@ -32,7 +35,6 @@ describe('<ActionBar /> component', () => {
|
||||
});
|
||||
|
||||
test('when there is no action bar data', () => {
|
||||
// @ts-ignore
|
||||
mockPackageMeta.mockImplementation(() => ({
|
||||
latest: {},
|
||||
}));
|
||||
@@ -43,8 +45,13 @@ describe('<ActionBar /> component', () => {
|
||||
expect(wrapper.html()).toEqual('');
|
||||
});
|
||||
|
||||
test('when there is no latest property in package meta', () => {
|
||||
mockPackageMeta.mockImplementation(() => ({}));
|
||||
const wrapper = mount(<ActionBar />);
|
||||
expect(wrapper.html()).toEqual('');
|
||||
});
|
||||
|
||||
test('when there is a button to download a tarball', () => {
|
||||
// @ts-ignore
|
||||
mockPackageMeta.mockImplementation(() => ({
|
||||
latest: {
|
||||
dist: {
|
||||
@@ -58,5 +65,25 @@ describe('<ActionBar /> component', () => {
|
||||
|
||||
const button = wrapper.find('button');
|
||||
expect(button).toHaveLength(1);
|
||||
|
||||
const spy = jest.spyOn(api, 'request');
|
||||
button.simulate('click');
|
||||
expect(spy).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
test('when there is a button to open an issue', () => {
|
||||
mockPackageMeta.mockImplementation(() => ({
|
||||
latest: {
|
||||
bugs: {
|
||||
url: 'https://verdaccio.tld/bugs',
|
||||
},
|
||||
},
|
||||
}));
|
||||
|
||||
const wrapper = mount(<ActionBar />);
|
||||
expect(wrapper.html()).toMatchSnapshot();
|
||||
|
||||
const button = wrapper.find('button');
|
||||
expect(button).toHaveLength(1);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
import React, { Component, ReactElement } from 'react';
|
||||
|
||||
import BugReportIcon from '@material-ui/icons/BugReport';
|
||||
import DownloadIcon from '@material-ui/icons/CloudDownload';
|
||||
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';
|
||||
import { Fab, ActionListItem } from './styles';
|
||||
import { isURL, extractFileName, downloadFile } from '../../utils/url';
|
||||
import api from '../../utils/api';
|
||||
import Tooltip from '../../muiComponents/Tooltip';
|
||||
import List from '../../muiComponents/List';
|
||||
|
||||
import { Fab, ActionListItem } from './styles';
|
||||
|
||||
export interface Action {
|
||||
icon: string;
|
||||
@@ -70,7 +70,6 @@ class ActionBar extends Component {
|
||||
}
|
||||
|
||||
private renderActionBar = ({ packageMeta }) => {
|
||||
// @ts-ignore
|
||||
const { latest } = packageMeta;
|
||||
|
||||
if (!latest) {
|
||||
@@ -107,7 +106,6 @@ class ActionBar extends Component {
|
||||
} else {
|
||||
const fab = <Fab size={'small'}>{actionItem['icon']}</Fab>;
|
||||
component.push(
|
||||
// @ts-ignore
|
||||
<Tooltip key={key} title={actionItem['title']}>
|
||||
<>{this.renderIconsWithLink(link, fab)}</>
|
||||
</Tooltip>
|
||||
|
||||
@@ -2,4 +2,6 @@
|
||||
|
||||
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>"`;
|
||||
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-1br2q5z 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>"`;
|
||||
|
||||
exports[`<ActionBar /> component when there is a button to open an issue 1`] = `"<ul class=\\"MuiList-root MuiList-padding\\"><div class=\\"MuiButtonBase-root MuiListItem-root css-1br2q5z eux6shq0 MuiListItem-gutters MuiListItem-button MuiListItem-alignItemsFlexStart\\" tabindex=\\"0\\" role=\\"button\\" aria-disabled=\\"false\\"><a href=\\"https://verdaccio.tld/bugs\\" target=\\"_blank\\"><button class=\\"MuiButtonBase-root MuiFab-root css-96oxa0 eux6shq1 MuiFab-sizeSmall\\" tabindex=\\"0\\" type=\\"button\\"><span class=\\"MuiFab-label\\"><svg class=\\"MuiSvgIcon-root\\" focusable=\\"false\\" viewBox=\\"0 0 24 24\\" aria-hidden=\\"true\\" role=\\"presentation\\"><path d=\\"M20 8h-2.81c-.45-.78-1.07-1.45-1.82-1.96L17 4.41 15.59 3l-2.17 2.17C12.96 5.06 12.49 5 12 5c-.49 0-.96.06-1.41.17L8.41 3 7 4.41l1.62 1.63C7.88 6.55 7.26 7.22 6.81 8H4v2h2.09c-.05.33-.09.66-.09 1v1H4v2h2v1c0 .34.04.67.09 1H4v2h2.81c1.04 1.79 2.97 3 5.19 3s4.15-1.21 5.19-3H20v-2h-2.09c.05-.33.09-.66.09-1v-1h2v-2h-2v-1c0-.34-.04-.67-.09-1H20V8zm-6 8h-4v-2h4v2zm0-4h-4v-2h4v2z\\"></path></svg></span><span class=\\"MuiTouchRipple-root\\"></span></button></a><span class=\\"MuiTouchRipple-root\\"></span></div></ul>"`;
|
||||
|
||||
@@ -1,15 +1,13 @@
|
||||
import styled from 'react-emotion';
|
||||
import { default as MuiFab } from '@material-ui/core/Fab';
|
||||
import ListItem from '@material-ui/core/ListItem';
|
||||
|
||||
import colors from '../../utils/styles/colors';
|
||||
import ListItem from '../../muiComponents/ListItem';
|
||||
|
||||
export const ActionListItem = styled(ListItem)({
|
||||
'&&': {
|
||||
paddingTop: 0,
|
||||
paddingLeft: 0,
|
||||
paddingRight: 0,
|
||||
},
|
||||
paddingTop: 0,
|
||||
paddingLeft: 0,
|
||||
paddingRight: 0,
|
||||
});
|
||||
|
||||
export const Fab = styled(MuiFab)({
|
||||
|
||||
@@ -1,24 +1,15 @@
|
||||
import React from 'react';
|
||||
import { mount } from 'enzyme';
|
||||
|
||||
import { DetailContext } from '../../pages/Version';
|
||||
|
||||
import Authors 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() });
|
||||
},
|
||||
}));
|
||||
const withAuthorComponent = (packageMeta: React.ContextType<typeof DetailContext>['packageMeta']): JSX.Element => (
|
||||
<DetailContext.Provider value={{ packageMeta }}>
|
||||
<Authors />
|
||||
</DetailContext.Provider>
|
||||
);
|
||||
|
||||
describe('<Author /> component', () => {
|
||||
beforeEach(() => {
|
||||
@@ -36,13 +27,12 @@ describe('<Author /> component', () => {
|
||||
url: '',
|
||||
avatar: 'https://www.gravatar.com/avatar/000000',
|
||||
},
|
||||
dist: { fileCount: 0, unpackedSize: 0 },
|
||||
},
|
||||
_uplinks: {},
|
||||
};
|
||||
|
||||
// @ts-ignore
|
||||
mockPackageMeta.mockImplementation(() => packageMeta);
|
||||
|
||||
const wrapper = mount(<Authors />);
|
||||
const wrapper = mount(withAuthorComponent(packageMeta));
|
||||
expect(wrapper.html()).toMatchSnapshot();
|
||||
});
|
||||
|
||||
@@ -51,14 +41,13 @@ describe('<Author /> component', () => {
|
||||
latest: {
|
||||
name: 'verdaccio',
|
||||
version: '4.0.0',
|
||||
dist: { fileCount: 0, unpackedSize: 0 },
|
||||
},
|
||||
_uplinks: {},
|
||||
};
|
||||
|
||||
// @ts-ignore
|
||||
mockPackageMeta.mockImplementation(() => packageMeta);
|
||||
|
||||
const wrapper = mount(<Authors />);
|
||||
expect(wrapper.html()).toEqual('');
|
||||
const wrapper = mount(withAuthorComponent(packageMeta));
|
||||
expect(wrapper.html()).toBeNull();
|
||||
});
|
||||
|
||||
test('should render the component when there is no author email', () => {
|
||||
@@ -71,13 +60,12 @@ describe('<Author /> component', () => {
|
||||
url: '',
|
||||
avatar: 'https://www.gravatar.com/avatar/000000',
|
||||
},
|
||||
dist: { fileCount: 0, unpackedSize: 0 },
|
||||
},
|
||||
_uplinks: {},
|
||||
};
|
||||
|
||||
// @ts-ignore
|
||||
mockPackageMeta.mockImplementation(() => packageMeta);
|
||||
|
||||
const wrapper = mount(<Authors />);
|
||||
const wrapper = mount(withAuthorComponent(packageMeta));
|
||||
expect(wrapper.html()).toMatchSnapshot();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,58 +1,44 @@
|
||||
import React, { Component, ReactNode, ReactElement } from 'react';
|
||||
import React, { FC, useContext } from 'react';
|
||||
|
||||
import Avatar from '@material-ui/core/Avatar';
|
||||
import List from '@material-ui/core/List';
|
||||
|
||||
import { DetailContextConsumer } from '../../pages/Version';
|
||||
import { Heading, AuthorListItem, AuthorListItemText } from './styles';
|
||||
import { DetailContext } from '../../pages/Version';
|
||||
import { isEmail } from '../../utils/url';
|
||||
import Avatar from '../../muiComponents/Avatar';
|
||||
import List from '../../muiComponents/List';
|
||||
|
||||
class Authors extends Component {
|
||||
public render(): ReactElement<HTMLElement> {
|
||||
return (
|
||||
<DetailContextConsumer>
|
||||
{context => {
|
||||
const { packageMeta } = context;
|
||||
import { StyledText, AuthorListItem, AuthorListItemText } from './styles';
|
||||
|
||||
if (!packageMeta) {
|
||||
return null;
|
||||
}
|
||||
const Author: FC = () => {
|
||||
const { packageMeta } = useContext(DetailContext);
|
||||
|
||||
return this.renderAuthor(packageMeta);
|
||||
}}
|
||||
</DetailContextConsumer>
|
||||
);
|
||||
if (!packageMeta) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public renderLinkForMail(email: string, avatarComponent: ReactNode, packageName: string, version: string): ReactElement<HTMLElement> | ReactNode {
|
||||
if (!email || isEmail(email) === false) {
|
||||
return avatarComponent;
|
||||
}
|
||||
const { author, name: packageName, version } = packageMeta.latest;
|
||||
|
||||
return (
|
||||
<a href={`mailto:${email}?subject=${packageName}@${version}`} target={'_top'}>
|
||||
{avatarComponent}
|
||||
</a>
|
||||
);
|
||||
if (!author) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public renderAuthor = ({ latest }) => {
|
||||
const { author, name: packageName, version } = latest;
|
||||
const { email, name } = author;
|
||||
|
||||
if (!author) {
|
||||
return null;
|
||||
}
|
||||
const avatarComponent = <Avatar alt={author.name} src={author.avatar} />;
|
||||
|
||||
const avatarComponent = <Avatar alt={author.name} src={author.avatar} />;
|
||||
return (
|
||||
<List subheader={<Heading variant={'subtitle1'}>{'Author'}</Heading>}>
|
||||
<AuthorListItem button={true}>
|
||||
{this.renderLinkForMail(author.email, avatarComponent, packageName, version)}
|
||||
<AuthorListItemText primary={author.name} />
|
||||
</AuthorListItem>
|
||||
</List>
|
||||
);
|
||||
};
|
||||
}
|
||||
return (
|
||||
<List subheader={<StyledText variant={'subtitle1'}>{'Author'}</StyledText>}>
|
||||
<AuthorListItem button={true}>
|
||||
{!email || !isEmail(email) ? (
|
||||
avatarComponent
|
||||
) : (
|
||||
<a href={`mailto:${email}?subject=${packageName}@${version}`} target={'_top'}>
|
||||
{avatarComponent}
|
||||
</a>
|
||||
)}
|
||||
|
||||
export default Authors;
|
||||
<AuthorListItemText primary={name} />
|
||||
</AuthorListItem>
|
||||
</List>
|
||||
);
|
||||
};
|
||||
|
||||
export default Author;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
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 in default state 1`] = `"<ul class=\\"MuiList-root MuiList-padding MuiList-subheader\\"><h6 class=\\"MuiTypography-root css-b8upko 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>"`;
|
||||
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-b8upko 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,15 +1,15 @@
|
||||
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)({
|
||||
'&&': {
|
||||
fontWeight: fontWeight.bold,
|
||||
textTransform: 'capitalize',
|
||||
},
|
||||
import { fontWeight } from '../../utils/styles/sizes';
|
||||
import ListItem from '../../muiComponents/ListItem';
|
||||
import Text from '../../muiComponents/Text';
|
||||
|
||||
export const StyledText = styled(Text)({
|
||||
fontWeight: fontWeight.bold,
|
||||
textTransform: 'capitalize',
|
||||
});
|
||||
|
||||
export const AuthorListItem = styled(ListItem)({
|
||||
'&&': {
|
||||
padding: 0,
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
import React, { KeyboardEvent } from 'react';
|
||||
import { css } from 'emotion';
|
||||
import Autosuggest from 'react-autosuggest';
|
||||
import Autosuggest, { SuggestionSelectedEventData, InputProps, ChangeEvent } from 'react-autosuggest';
|
||||
import match from 'autosuggest-highlight/match';
|
||||
import parse from 'autosuggest-highlight/parse';
|
||||
import MenuItem from '@material-ui/core/MenuItem';
|
||||
|
||||
import { fontWeight } from '../../utils/styles/sizes';
|
||||
|
||||
import { Wrapper, InputField, SuggestionContainer } from './styles';
|
||||
|
||||
interface Props {
|
||||
@@ -19,18 +20,21 @@ interface Props {
|
||||
placeholder?: string;
|
||||
startAdornment?: JSX.Element;
|
||||
disableUnderline?: boolean;
|
||||
onChange?: (event: KeyboardEvent<HTMLInputElement>, { newValue, method }: { newValue: string; method: string }) => void;
|
||||
onSuggestionsFetch?: ({ value: string }) => Promise<void>;
|
||||
onChange: (event: React.FormEvent<HTMLInputElement>, params: ChangeEvent) => void;
|
||||
onSuggestionsFetch: ({ value: string }) => Promise<void>;
|
||||
onCleanSuggestions?: () => void;
|
||||
onClick?: (event: KeyboardEvent<HTMLInputElement>, { suggestionValue, method }: { suggestionValue: string[]; method: string }) => void;
|
||||
onClick?: (event: React.FormEvent<HTMLInputElement>, data: SuggestionSelectedEventData<unknown>) => void;
|
||||
onKeyDown?: (event: KeyboardEvent<HTMLInputElement>) => void;
|
||||
onBlur?: (event: KeyboardEvent<HTMLInputElement>) => void;
|
||||
onBlur?: (event: React.FormEvent<HTMLInputElement>) => void;
|
||||
}
|
||||
|
||||
/* eslint-disable react/jsx-sort-props */
|
||||
/* eslint-disable verdaccio/jsx-spread */
|
||||
const renderInputComponent = (inputProps): JSX.Element => {
|
||||
const { ref, startAdornment, disableUnderline, onKeyDown, ...others } = inputProps;
|
||||
return (
|
||||
<InputField
|
||||
fullWidth={true}
|
||||
InputProps={{
|
||||
inputRef: node => {
|
||||
ref(node);
|
||||
@@ -39,7 +43,6 @@ const renderInputComponent = (inputProps): JSX.Element => {
|
||||
disableUnderline,
|
||||
onKeyDown,
|
||||
}}
|
||||
fullWidth={true}
|
||||
{...others}
|
||||
/>
|
||||
);
|
||||
@@ -110,10 +113,12 @@ const AutoComplete = ({
|
||||
onSuggestionsFetchRequested: onSuggestionsFetch,
|
||||
onSuggestionsClearRequested: onCleanSuggestions,
|
||||
};
|
||||
const inputProps = {
|
||||
const inputProps: InputProps<unknown> = {
|
||||
value,
|
||||
onChange,
|
||||
placeholder,
|
||||
// material-ui@4.5.1 introduce better types for TextInput, check readme
|
||||
// @ts-ignore
|
||||
startAdornment,
|
||||
disableUnderline,
|
||||
color,
|
||||
|
||||
@@ -2,7 +2,7 @@ import React from 'react';
|
||||
import styled, { css } from 'react-emotion';
|
||||
import Paper from '@material-ui/core/Paper';
|
||||
|
||||
import TextField from '../TextField';
|
||||
import TextField from '../../muiComponents/TextField';
|
||||
|
||||
export interface InputFieldProps {
|
||||
color: string;
|
||||
@@ -17,6 +17,7 @@ export const Wrapper = styled('div')({
|
||||
},
|
||||
});
|
||||
|
||||
/* eslint-disable verdaccio/jsx-spread */
|
||||
export const InputField: React.FC<InputFieldProps> = ({ color, ...others }) => (
|
||||
<TextField
|
||||
{...others}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import React, { FC } from 'react';
|
||||
|
||||
import Avatar from '@material-ui/core/Avatar';
|
||||
import Tooltip from '@material-ui/core/Tooltip';
|
||||
import { isEmail } from '../../utils/url';
|
||||
import Tooltip from '../../muiComponents/Tooltip';
|
||||
import Avatar from '../../muiComponents/Avatar';
|
||||
|
||||
export interface AvatarDeveloper {
|
||||
name: string;
|
||||
@@ -14,7 +14,7 @@ export interface AvatarDeveloper {
|
||||
|
||||
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 {
|
||||
function renderLinkForMail(email: string, avatarComponent: JSX.Element, packageName: string, version: string): JSX.Element {
|
||||
if (!email || isEmail(email) === false) {
|
||||
return avatarComponent;
|
||||
}
|
||||
|
||||
@@ -1,38 +1,27 @@
|
||||
import React from 'react';
|
||||
import { mount } from 'enzyme';
|
||||
import { mount, ReactWrapper } from 'enzyme';
|
||||
|
||||
import { copyToClipBoardUtility } from '../../utils/cli-utils';
|
||||
|
||||
import CopyToClipBoard from './CopyToClipBoard';
|
||||
import { CopyIcon } from './styles';
|
||||
|
||||
jest.mock('../../utils/cli-utils');
|
||||
|
||||
describe('<CopyToClipBoard /> component', () => {
|
||||
let wrapper;
|
||||
let wrapper: ReactWrapper;
|
||||
const copyText = 'copy text';
|
||||
|
||||
beforeEach(() => {
|
||||
wrapper = mount(<CopyToClipBoard text={'copy text'} />);
|
||||
wrapper = mount(<CopyToClipBoard text={copyText} />);
|
||||
});
|
||||
|
||||
test('render the component', () => {
|
||||
expect(wrapper.html()).toMatchSnapshot();
|
||||
});
|
||||
|
||||
test('should call the DOM APIs for copy to clipboard utility', () => {
|
||||
const event = {
|
||||
preventDefault: jest.fn(),
|
||||
};
|
||||
|
||||
// @ts-ignore: Property 'getSelection' does not exist on type 'Global'.
|
||||
global.getSelection = jest.fn(() => ({
|
||||
removeAllRanges: () => {},
|
||||
addRange: () => {},
|
||||
}));
|
||||
|
||||
// @ts-ignore: Property 'document/getSelection' does not exist on type 'Global'.
|
||||
const { document, getSelection } = global;
|
||||
|
||||
wrapper.find(CopyIcon).simulate('click', event);
|
||||
expect(event.preventDefault).toHaveBeenCalled();
|
||||
expect(document.createRange).toHaveBeenCalled();
|
||||
expect(getSelection).toHaveBeenCalled();
|
||||
expect(document.execCommand).toHaveBeenCalledWith('copy');
|
||||
test('should call the copyToClipBoardUtility for copy to clipboard utility', () => {
|
||||
wrapper.find(CopyIcon).simulate('click');
|
||||
expect(copyToClipBoardUtility).toHaveBeenCalledWith(copyText);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import Tooltip from '@material-ui/core/Tooltip';
|
||||
import FileCopy from '@material-ui/icons/FileCopy';
|
||||
import React from 'react';
|
||||
|
||||
import { copyToClipBoardUtility } from '../../utils/cli-utils';
|
||||
import { TEXT } from '../../utils/constants';
|
||||
import Tooltip from '../../muiComponents/Tooltip';
|
||||
|
||||
import { ClipBoardCopy, ClipBoardCopyText, CopyIcon } from './styles';
|
||||
|
||||
@@ -12,7 +12,7 @@ interface Props {
|
||||
children?: React.ReactNode;
|
||||
}
|
||||
|
||||
const renderText = (text, children): JSX.Element => {
|
||||
const renderText = (text: string, children: React.ReactNode): 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 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>"`;
|
||||
exports[`<CopyToClipBoard /> component render the component 1`] = `"<div class=\\"css-1mta3t8 eb8w2fo0\\"><span class=\\"css-lh0wgu 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,6 +1,7 @@
|
||||
import IconButton from '@material-ui/core/IconButton';
|
||||
import styled from 'react-emotion';
|
||||
|
||||
import IconButton from '../../muiComponents/IconButton';
|
||||
|
||||
export const ClipBoardCopy = styled('div')({
|
||||
'&&': {
|
||||
display: 'flex',
|
||||
@@ -16,6 +17,7 @@ export const ClipBoardCopyText = styled('span')({
|
||||
overflow: 'hidden',
|
||||
whiteSpace: 'nowrap',
|
||||
height: '21px',
|
||||
fontSize: '1rem',
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
92
src/components/Dependencies/Dependencies.test.tsx
Normal file
92
src/components/Dependencies/Dependencies.test.tsx
Normal file
@@ -0,0 +1,92 @@
|
||||
import React from 'react';
|
||||
import { render } from '@testing-library/react';
|
||||
import { HashRouter } from 'react-router-dom';
|
||||
|
||||
import { DetailContextProvider } from '../../pages/Version';
|
||||
|
||||
import Dependencies from './Dependencies';
|
||||
|
||||
describe('<Dependencies /> component', () => {
|
||||
test('Renders a message when there are no dependencies', () => {
|
||||
// Given
|
||||
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',
|
||||
},
|
||||
dist: { fileCount: 0, unpackedSize: 0 },
|
||||
dependencies: {},
|
||||
devDependencies: {},
|
||||
peerDependencies: {},
|
||||
},
|
||||
_uplinks: {},
|
||||
};
|
||||
|
||||
// When
|
||||
const { getByText } = render(
|
||||
<DetailContextProvider value={{ packageMeta }}>
|
||||
<Dependencies />
|
||||
</DetailContextProvider>
|
||||
);
|
||||
|
||||
// Then
|
||||
expect(getByText('verdaccio has no dependencies.')).toBeDefined();
|
||||
});
|
||||
|
||||
test('Renders a link to each dependency', () => {
|
||||
// Given
|
||||
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',
|
||||
},
|
||||
dist: { fileCount: 0, unpackedSize: 0 },
|
||||
dependencies: {
|
||||
react: '16.9.0',
|
||||
'react-dom': '16.9.0',
|
||||
},
|
||||
devDependencies: {
|
||||
'babel-core': '7.0.0-beta6',
|
||||
},
|
||||
peerDependencies: {
|
||||
'styled-components': '5.0.0',
|
||||
},
|
||||
},
|
||||
_uplinks: {},
|
||||
};
|
||||
|
||||
// When
|
||||
const { getByText } = render(
|
||||
<HashRouter>
|
||||
<DetailContextProvider value={{ packageMeta }}>
|
||||
<Dependencies />
|
||||
</DetailContextProvider>
|
||||
</HashRouter>
|
||||
);
|
||||
|
||||
// Then
|
||||
// FIXME: currently MaterialUI chips do not support the children
|
||||
// prop, therefore it is impossible to use proper links for
|
||||
// dependencies. Those are for now clickable spans
|
||||
|
||||
expect(getByText('dependencies (2)')).toBeDefined();
|
||||
expect(getByText('react@16.9.0').tagName).toBe('SPAN');
|
||||
expect(getByText('react-dom@16.9.0').tagName).toBe('SPAN');
|
||||
|
||||
expect(getByText('devDependencies (1)')).toBeDefined();
|
||||
expect(getByText('babel-core@7.0.0-beta6').tagName).toBe('SPAN');
|
||||
|
||||
expect(getByText('peerDependencies (1)')).toBeDefined();
|
||||
expect(getByText('styled-components@5.0.0').tagName).toBe('SPAN');
|
||||
});
|
||||
});
|
||||
@@ -1,119 +1,78 @@
|
||||
import React, { Component, Fragment, ReactElement } from 'react';
|
||||
import { withRouter, RouteComponentProps } from 'react-router-dom';
|
||||
import React, { useContext } from 'react';
|
||||
import { useHistory } from 'react-router-dom';
|
||||
import CardContent from '@material-ui/core/CardContent';
|
||||
|
||||
import { DetailContextConsumer, VersionPageConsumerProps } from '../../pages/Version';
|
||||
|
||||
import { CardWrap, Heading, Tags, Tag } from './styles';
|
||||
import { PackageDependencies } from '../../../types/packageMeta';
|
||||
import { DetailContext } from '../../pages/Version';
|
||||
import NoItems from '../NoItems';
|
||||
|
||||
type DepDetailProps = {
|
||||
name: string;
|
||||
version: string;
|
||||
onLoading?: () => void;
|
||||
} & RouteComponentProps;
|
||||
import { CardWrap, StyledText, Tags, Tag } from './styles';
|
||||
|
||||
interface DepDetailState {
|
||||
name: string;
|
||||
version: string;
|
||||
interface DependencyBlockProps {
|
||||
title: string;
|
||||
dependencies: PackageDependencies;
|
||||
}
|
||||
|
||||
class DepDetail extends Component<DepDetailProps, DepDetailState> {
|
||||
constructor(props: DepDetailProps) {
|
||||
super(props);
|
||||
const { name, version } = this.props;
|
||||
const DependencyBlock: React.FC<DependencyBlockProps> = ({ title, dependencies }) => {
|
||||
const { enableLoading } = useContext(DetailContext);
|
||||
const history = useHistory();
|
||||
|
||||
this.state = {
|
||||
name,
|
||||
version,
|
||||
};
|
||||
}
|
||||
const deps = Object.entries(dependencies);
|
||||
|
||||
public render(): ReactElement<HTMLElement> {
|
||||
const { name, version } = this.state;
|
||||
const tagText = `${name}@${version}`;
|
||||
return <Tag className={'dep-tag'} clickable={true} label={tagText} onClick={this.handleOnClick} />;
|
||||
}
|
||||
function handleClick(name: string): void {
|
||||
enableLoading && enableLoading();
|
||||
|
||||
private handleOnClick = () => {
|
||||
const { name } = this.state;
|
||||
const { onLoading, history } = this.props;
|
||||
|
||||
onLoading && onLoading();
|
||||
history.push(`/-/web/detail/${name}`);
|
||||
};
|
||||
}
|
||||
|
||||
return (
|
||||
<CardWrap>
|
||||
<CardContent>
|
||||
<StyledText variant="subtitle1">{`${title} (${deps.length})`}</StyledText>
|
||||
<Tags>
|
||||
{deps.map(([name, version]) => (
|
||||
// eslint-disable-next-line
|
||||
<Tag className={'dep-tag'} clickable={true} key={name} label={`${name}@${version}`} onClick={() => handleClick(name)} />
|
||||
))}
|
||||
</Tags>
|
||||
</CardContent>
|
||||
</CardWrap>
|
||||
);
|
||||
};
|
||||
|
||||
function hasKeys(object?: { [key: string]: any }): boolean {
|
||||
return !!object && Object.keys(object).length > 0;
|
||||
}
|
||||
|
||||
const WrapperDependencyDetail = withRouter(DepDetail);
|
||||
const Dependencies: React.FC<{}> = () => {
|
||||
const { packageMeta } = useContext(DetailContext);
|
||||
|
||||
class DependencyBlock extends Component<{ title: string; dependencies: [] }> {
|
||||
public render(): ReactElement<HTMLElement> {
|
||||
const { dependencies, title } = this.props;
|
||||
const deps = Object.entries(dependencies) as [];
|
||||
if (!packageMeta) {
|
||||
throw new Error('packageMeta is required at DetailContext');
|
||||
}
|
||||
|
||||
const { latest } = packageMeta;
|
||||
// FIXME: add dependencies to package meta type
|
||||
// @ts-ignore
|
||||
const { dependencies, devDependencies, peerDependencies, name } = latest;
|
||||
const dependencyMap = { dependencies, devDependencies, peerDependencies };
|
||||
const hasDependencies = hasKeys(dependencies) || hasKeys(devDependencies) || hasKeys(peerDependencies);
|
||||
|
||||
if (hasDependencies) {
|
||||
return (
|
||||
<DetailContextConsumer>
|
||||
{({ enableLoading }) => {
|
||||
return (
|
||||
<CardWrap>
|
||||
<CardContent>
|
||||
<Heading variant="subtitle1">{`${title} (${deps.length})`}</Heading>
|
||||
<Tags>{this.renderTags(deps, enableLoading)}</Tags>
|
||||
</CardContent>
|
||||
</CardWrap>
|
||||
);
|
||||
}}
|
||||
</DetailContextConsumer>
|
||||
<>
|
||||
{Object.entries(dependencyMap).map(([dependencyType, dependencies]) => {
|
||||
if (!dependencies || Object.keys(dependencies).length === 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return <DependencyBlock dependencies={dependencies} key={dependencyType} title={dependencyType} />;
|
||||
})}
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
private renderTags = (deps: [], enableLoading?: () => void) =>
|
||||
deps.map(dep => {
|
||||
const [name, version] = dep as [string, string];
|
||||
|
||||
return <WrapperDependencyDetail key={name} name={name} onLoading={enableLoading} version={version} />;
|
||||
});
|
||||
}
|
||||
|
||||
class Dependencies extends Component {
|
||||
public state = {
|
||||
tabPosition: 0,
|
||||
};
|
||||
|
||||
public render(): ReactElement<HTMLElement> {
|
||||
return (
|
||||
<DetailContextConsumer>
|
||||
{packageMeta => {
|
||||
return this.renderDependencies(packageMeta as VersionPageConsumerProps);
|
||||
}}
|
||||
</DetailContextConsumer>
|
||||
);
|
||||
}
|
||||
|
||||
private checkDependencyLength<T>(dependency: Record<string, T> = {}): boolean {
|
||||
return Object.keys(dependency).length > 0;
|
||||
}
|
||||
|
||||
private renderDependencies({ packageMeta }): ReactElement<HTMLElement> {
|
||||
const { latest } = packageMeta;
|
||||
const { dependencies, devDependencies, peerDependencies, name } = latest;
|
||||
|
||||
const dependencyMap = { dependencies, devDependencies, peerDependencies };
|
||||
|
||||
const dependencyList = Object.keys(dependencyMap).reduce((result, value, key) => {
|
||||
const selectedDepndency = dependencyMap[value];
|
||||
if (selectedDepndency && this.checkDependencyLength(selectedDepndency)) {
|
||||
// @ts-ignore
|
||||
result.push(<DependencyBlock className="dependency-block" dependencies={selectedDepndency} key={key} title={value} />);
|
||||
}
|
||||
return result;
|
||||
}, []);
|
||||
|
||||
if (dependencyList.length) {
|
||||
return <Fragment>{dependencyList}</Fragment>;
|
||||
}
|
||||
return <NoItems className="no-dependencies" text={`${name} has no dependencies.`} />;
|
||||
}
|
||||
}
|
||||
return <NoItems className="no-dependencies" text={`${name} has no dependencies.`} />;
|
||||
};
|
||||
|
||||
export default Dependencies;
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
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';
|
||||
import Text from '../../muiComponents/Text';
|
||||
import Card from '../../muiComponents/Card';
|
||||
|
||||
export const CardWrap = styled(Card)({
|
||||
'&&': {
|
||||
@@ -10,11 +11,9 @@ export const CardWrap = styled(Card)({
|
||||
},
|
||||
});
|
||||
|
||||
export const Heading = styled(Typography)({
|
||||
'&&': {
|
||||
fontWeight: fontWeight.bold,
|
||||
textTransform: 'capitalize',
|
||||
},
|
||||
export const StyledText = styled(Text)({
|
||||
fontWeight: fontWeight.bold,
|
||||
textTransform: 'capitalize',
|
||||
});
|
||||
|
||||
export const Tags = styled('div')({
|
||||
|
||||
12
src/components/DetailContainer/DetailContainer.test.tsx
Normal file
12
src/components/DetailContainer/DetailContainer.test.tsx
Normal file
@@ -0,0 +1,12 @@
|
||||
import React from 'react';
|
||||
import { render } from '@testing-library/react';
|
||||
|
||||
import DetailContainer from './DetailContainer';
|
||||
|
||||
describe('DetailContainer', () => {
|
||||
test('renders correctly', () => {
|
||||
const { container } = render(<DetailContainer />);
|
||||
expect(container.firstChild).toMatchSnapshot();
|
||||
});
|
||||
test.todo('should test click on tabs');
|
||||
});
|
||||
@@ -1,77 +1,33 @@
|
||||
import React, { Component, ReactElement, Fragment } from 'react';
|
||||
import React, { useCallback, useState, ChangeEvent, useContext } from 'react';
|
||||
import Box from '@material-ui/core/Box';
|
||||
|
||||
import { DetailContextConsumer, VersionPageConsumerProps } from '../../pages/Version';
|
||||
import Readme from '../Readme';
|
||||
import Versions from '../Versions';
|
||||
import { preventXSS } from '../../utils/sec-utils';
|
||||
import Tabs from '@material-ui/core/Tabs';
|
||||
import Tab from '@material-ui/core/Tab';
|
||||
import { Content } from './styles';
|
||||
import Dependencies from '../Dependencies';
|
||||
import UpLinks from '../UpLinks';
|
||||
import { DetailContext } from '../../pages/Version';
|
||||
|
||||
interface DetailContainerState {
|
||||
tabPosition: number;
|
||||
}
|
||||
import DetailContainerTabs from './DetailContainerTabs';
|
||||
import DetailContainerContent from './DetailContainerContent';
|
||||
import { TabPosition } from './tabs';
|
||||
|
||||
export const README_LABEL = 'Readme';
|
||||
export const DEPS_LABEL = 'Dependencies';
|
||||
export const VERSION_LABEL = 'Versions';
|
||||
export const UPLINKS_LABEL = 'Uplinks';
|
||||
const DetailContainer: React.FC = () => {
|
||||
const [tabPosition, setTabPosition] = useState(TabPosition.README);
|
||||
const detailContext = useContext(DetailContext);
|
||||
const { readMe } = detailContext;
|
||||
|
||||
class DetailContainer<P> extends Component<P, DetailContainerState> {
|
||||
public state = {
|
||||
tabPosition: 0,
|
||||
};
|
||||
const handleChangeTabPosition = useCallback(
|
||||
(event: ChangeEvent<{}>) => {
|
||||
event.preventDefault();
|
||||
const eventTarget = event.target as HTMLSpanElement;
|
||||
const chosentab = eventTarget.innerText as TabPosition;
|
||||
setTabPosition(TabPosition[chosentab]);
|
||||
},
|
||||
[setTabPosition]
|
||||
);
|
||||
|
||||
public render(): ReactElement<HTMLElement> {
|
||||
return (
|
||||
<DetailContextConsumer>
|
||||
{context => {
|
||||
return this.renderTabs(context as VersionPageConsumerProps);
|
||||
}}
|
||||
</DetailContextConsumer>
|
||||
);
|
||||
}
|
||||
|
||||
private handleChange = (event: React.ChangeEvent<{}>, tabPosition: number) => {
|
||||
event.preventDefault();
|
||||
this.setState({ tabPosition });
|
||||
};
|
||||
|
||||
private renderListTabs(tabPosition: number): React.ReactElement<HTMLElement> {
|
||||
return (
|
||||
<Tabs indicatorColor={'primary'} onChange={this.handleChange} textColor={'primary'} value={tabPosition} variant={'fullWidth'}>
|
||||
<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>
|
||||
);
|
||||
}
|
||||
|
||||
private renderTabs = ({ readMe }) => {
|
||||
const { tabPosition } = this.state;
|
||||
|
||||
return (
|
||||
<Fragment>
|
||||
<Content>
|
||||
{this.renderListTabs(tabPosition)}
|
||||
<br />
|
||||
{tabPosition === 0 && this.renderReadme(readMe)}
|
||||
{tabPosition === 1 && <Dependencies />}
|
||||
{tabPosition === 2 && <Versions />}
|
||||
{tabPosition === 3 && <UpLinks />}
|
||||
</Content>
|
||||
</Fragment>
|
||||
);
|
||||
};
|
||||
|
||||
private renderReadme = (readMe: string): ReactElement<HTMLElement> => {
|
||||
const encodedReadme = preventXSS(readMe);
|
||||
|
||||
return <Readme description={encodedReadme} />;
|
||||
};
|
||||
}
|
||||
return (
|
||||
<Box component="div" display="flex" flexDirection="column" padding={2}>
|
||||
<DetailContainerTabs onChangeTabPosition={handleChangeTabPosition} tabPosition={tabPosition} />
|
||||
<DetailContainerContent readDescription={readMe} tabPosition={tabPosition} />
|
||||
</Box>
|
||||
);
|
||||
};
|
||||
|
||||
export default DetailContainer;
|
||||
|
||||
30
src/components/DetailContainer/DetailContainerContent.tsx
Normal file
30
src/components/DetailContainer/DetailContainerContent.tsx
Normal file
@@ -0,0 +1,30 @@
|
||||
import React from 'react';
|
||||
|
||||
import Dependencies from '../Dependencies';
|
||||
import UpLinks from '../UpLinks';
|
||||
import Versions from '../Versions';
|
||||
|
||||
import DetailContainerContentReadme from './DetailContainerContentReadme';
|
||||
import { TabPosition } from './tabs';
|
||||
|
||||
interface Props {
|
||||
tabPosition: TabPosition;
|
||||
readDescription?: string;
|
||||
}
|
||||
|
||||
const DetailContainerContent: React.FC<Props> = ({ tabPosition, readDescription }) => {
|
||||
switch (tabPosition) {
|
||||
case TabPosition.README:
|
||||
return <DetailContainerContentReadme description={readDescription} />;
|
||||
case TabPosition.UPLINKS:
|
||||
return <UpLinks />;
|
||||
case TabPosition.VERSIONS:
|
||||
return <Versions />;
|
||||
case TabPosition.DEPENDENCIES:
|
||||
return <Dependencies />;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
export default DetailContainerContent;
|
||||
@@ -0,0 +1,16 @@
|
||||
import React from 'react';
|
||||
|
||||
import { preventXSS } from '../../utils/sec-utils';
|
||||
import Readme from '../Readme';
|
||||
|
||||
interface Props {
|
||||
description?: string;
|
||||
}
|
||||
|
||||
const DetailContainerContentReadme: React.FC<Props> = ({ description }) => {
|
||||
if (!description) return null;
|
||||
const encodedReadme = preventXSS(description);
|
||||
return <Readme description={encodedReadme} />;
|
||||
};
|
||||
|
||||
export default DetailContainerContentReadme;
|
||||
37
src/components/DetailContainer/DetailContainerTabs.tsx
Normal file
37
src/components/DetailContainer/DetailContainerTabs.tsx
Normal file
@@ -0,0 +1,37 @@
|
||||
import React, { ChangeEvent, useState, useEffect } from 'react';
|
||||
import { default as MuiTabs } from '@material-ui/core/Tabs';
|
||||
import Tab from '@material-ui/core/Tab';
|
||||
import styled from 'react-emotion';
|
||||
|
||||
import { TabPosition } from './tabs';
|
||||
|
||||
interface Props {
|
||||
tabPosition: TabPosition;
|
||||
onChangeTabPosition: (event: ChangeEvent<{}>) => void;
|
||||
}
|
||||
|
||||
const Tabs = styled(MuiTabs)({
|
||||
marginBottom: 16,
|
||||
});
|
||||
|
||||
const getTabIndex = (tabPosition: TabPosition): number => Object.keys(TabPosition).findIndex(position => position === String(tabPosition).toUpperCase());
|
||||
|
||||
const DetailContainerTabs: React.FC<Props> = ({ tabPosition, onChangeTabPosition }) => {
|
||||
const [tabPositionIndex, setTabPositionIndex] = useState(0);
|
||||
|
||||
useEffect(() => {
|
||||
const tabIndex = getTabIndex(tabPosition);
|
||||
setTabPositionIndex(tabIndex);
|
||||
}, [tabPosition]);
|
||||
|
||||
return (
|
||||
<Tabs indicatorColor={'primary'} onChange={onChangeTabPosition} textColor={'primary'} value={tabPositionIndex} variant={'fullWidth'}>
|
||||
<Tab data-testid={'readme-tab'} id={'readme-tab'} label={TabPosition.README} />
|
||||
<Tab data-testid={'dependencies-tab'} id={'dependencies-tab'} label={TabPosition.DEPENDENCIES} />
|
||||
<Tab data-testid={'versions-tab'} id={'versions-tab'} label={TabPosition.VERSIONS} />
|
||||
<Tab data-testid={'uplinks-tab'} id={'uplinks-tab'} label={TabPosition.UPLINKS} />
|
||||
</Tabs>
|
||||
);
|
||||
};
|
||||
|
||||
export default DetailContainerTabs;
|
||||
@@ -0,0 +1,98 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`DetailContainer renders correctly 1`] = `
|
||||
<div
|
||||
class="MuiBox-root MuiBox-root-2"
|
||||
>
|
||||
<div
|
||||
class="MuiTabs-root css-1qm1lh emotion-0"
|
||||
>
|
||||
<div
|
||||
class="MuiTabs-scroller MuiTabs-fixed"
|
||||
style="overflow: hidden;"
|
||||
>
|
||||
<div
|
||||
class="MuiTabs-flexContainer"
|
||||
role="tablist"
|
||||
>
|
||||
<button
|
||||
aria-selected="true"
|
||||
class="MuiButtonBase-root MuiTab-root MuiTab-textColorPrimary Mui-selected MuiTab-fullWidth"
|
||||
data-testid="readme-tab"
|
||||
id="readme-tab"
|
||||
role="tab"
|
||||
tabindex="0"
|
||||
type="button"
|
||||
>
|
||||
<span
|
||||
class="MuiTab-wrapper"
|
||||
>
|
||||
Readme
|
||||
</span>
|
||||
<span
|
||||
class="MuiTouchRipple-root"
|
||||
/>
|
||||
</button>
|
||||
<button
|
||||
aria-selected="false"
|
||||
class="MuiButtonBase-root MuiTab-root MuiTab-textColorPrimary MuiTab-fullWidth"
|
||||
data-testid="dependencies-tab"
|
||||
id="dependencies-tab"
|
||||
role="tab"
|
||||
tabindex="0"
|
||||
type="button"
|
||||
>
|
||||
<span
|
||||
class="MuiTab-wrapper"
|
||||
>
|
||||
Dependencies
|
||||
</span>
|
||||
<span
|
||||
class="MuiTouchRipple-root"
|
||||
/>
|
||||
</button>
|
||||
<button
|
||||
aria-selected="false"
|
||||
class="MuiButtonBase-root MuiTab-root MuiTab-textColorPrimary MuiTab-fullWidth"
|
||||
data-testid="versions-tab"
|
||||
id="versions-tab"
|
||||
role="tab"
|
||||
tabindex="0"
|
||||
type="button"
|
||||
>
|
||||
<span
|
||||
class="MuiTab-wrapper"
|
||||
>
|
||||
Versions
|
||||
</span>
|
||||
<span
|
||||
class="MuiTouchRipple-root"
|
||||
/>
|
||||
</button>
|
||||
<button
|
||||
aria-selected="false"
|
||||
class="MuiButtonBase-root MuiTab-root MuiTab-textColorPrimary MuiTab-fullWidth"
|
||||
data-testid="uplinks-tab"
|
||||
id="uplinks-tab"
|
||||
role="tab"
|
||||
tabindex="0"
|
||||
type="button"
|
||||
>
|
||||
<span
|
||||
class="MuiTab-wrapper"
|
||||
>
|
||||
Uplinks
|
||||
</span>
|
||||
<span
|
||||
class="MuiTouchRipple-root"
|
||||
/>
|
||||
</button>
|
||||
</div>
|
||||
<span
|
||||
class="PrivateTabIndicator-root-27 PrivateTabIndicator-colorPrimary-28 MuiTabs-indicator"
|
||||
style="left: 0px; width: 0px;"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
@@ -1,7 +0,0 @@
|
||||
import styled from 'react-emotion';
|
||||
|
||||
export const Content = styled('div')({
|
||||
'&&': {
|
||||
padding: '15px',
|
||||
},
|
||||
});
|
||||
6
src/components/DetailContainer/tabs.ts
Normal file
6
src/components/DetailContainer/tabs.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
export enum TabPosition {
|
||||
README = 'Readme',
|
||||
DEPENDENCIES = 'Dependencies',
|
||||
VERSIONS = 'Versions',
|
||||
UPLINKS = 'Uplinks',
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
import { ReactNode } from 'react';
|
||||
|
||||
export interface Props {
|
||||
children: ReactNode;
|
||||
open: boolean;
|
||||
onClose: () => void;
|
||||
}
|
||||
@@ -1,8 +1,5 @@
|
||||
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 Author from '../Author';
|
||||
@@ -11,29 +8,34 @@ import Dist from '../Dist/Dist';
|
||||
import Engine from '../Engines/Engines';
|
||||
import Install from '../Install';
|
||||
import Repository from '../Repository/Repository';
|
||||
|
||||
import { DetailContext } from '../../pages/Version';
|
||||
import List from '../../muiComponents/List';
|
||||
import Card from '../../muiComponents/Card';
|
||||
|
||||
import { TitleListItem, TitleListItemText } from './styles';
|
||||
import { TitleListItem, TitleListItemText, PackageDescription, PackageVersion } from './styles';
|
||||
|
||||
const renderLatestDescription = (description, version, isLatest: boolean = true) => {
|
||||
const renderLatestDescription = (description, version, isLatest: boolean = true): JSX.Element => {
|
||||
return (
|
||||
<span>
|
||||
<div>{description}</div>
|
||||
{version ? <small>{`${isLatest ? 'Latest v' : 'v'}${version}`}</small> : null}
|
||||
</span>
|
||||
<>
|
||||
<PackageDescription>{description}</PackageDescription>
|
||||
{version ? (
|
||||
<PackageVersion>
|
||||
<small>{`${isLatest ? 'Latest v' : 'v'}${version}`}</small>
|
||||
</PackageVersion>
|
||||
) : null}
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
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 renderCopyCLI = (): JSX.Element => <Install />;
|
||||
const renderMaintainers = (): JSX.Element => <Developers type="maintainers" />;
|
||||
const renderContributors = (): JSX.Element => <Developers type="contributors" />;
|
||||
const renderRepository = (): JSX.Element => <Repository />;
|
||||
const renderAuthor = (): JSX.Element => <Author />;
|
||||
const renderEngine = (): JSX.Element => <Engine />;
|
||||
const renderDist = (): JSX.Element => <Dist />;
|
||||
const renderActionBar = (): JSX.Element => <ActionBar />;
|
||||
const renderTitle = (packageName, packageVersion, packageMeta): JSX.Element => {
|
||||
const version = packageVersion ? packageVersion : packageMeta.latest.version;
|
||||
const isLatest = typeof packageVersion === 'undefined';
|
||||
|
||||
@@ -66,7 +68,7 @@ function renderSideBar(packageName, packageVersion, packageMeta): ReactElement<H
|
||||
);
|
||||
}
|
||||
|
||||
const DetailSidebar = () => {
|
||||
const DetailSidebar = (): JSX.Element => {
|
||||
const { packageName, packageMeta, packageVersion } = React.useContext(DetailContext);
|
||||
|
||||
return renderSideBar(packageName, packageVersion, packageMeta);
|
||||
|
||||
@@ -1,16 +1,12 @@
|
||||
import styled from 'react-emotion';
|
||||
import Avatar from '@material-ui/core/Avatar';
|
||||
import ListItem from '@material-ui/core/ListItem';
|
||||
import ListItemText from '@material-ui/core/ListItemText';
|
||||
|
||||
import colors from '../../utils/styles/colors';
|
||||
import ListItem from '../../muiComponents/ListItem';
|
||||
|
||||
export const TitleListItem = styled(ListItem)({
|
||||
'&&': {
|
||||
paddingLeft: 0,
|
||||
paddingRight: 0,
|
||||
paddingBottom: 0,
|
||||
},
|
||||
paddingLeft: 0,
|
||||
paddingRight: 0,
|
||||
paddingBottom: 0,
|
||||
});
|
||||
|
||||
export const TitleListItemText = styled(ListItemText)({
|
||||
@@ -21,10 +17,14 @@ export const TitleListItemText = styled(ListItemText)({
|
||||
},
|
||||
});
|
||||
|
||||
export const TitleAvatar = styled(Avatar)({
|
||||
export const PackageDescription = styled('span')({
|
||||
'&&': {
|
||||
color: colors.greySuperLight,
|
||||
backgroundColor: colors.primary,
|
||||
textTransform: 'capitalize',
|
||||
display: 'block',
|
||||
},
|
||||
});
|
||||
|
||||
export const PackageVersion = styled('span')({
|
||||
'&&': {
|
||||
display: 'block',
|
||||
},
|
||||
});
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
import React from 'react';
|
||||
import { mount } from 'enzyme';
|
||||
|
||||
import { DetailContextProvider } from '../../pages/Version';
|
||||
|
||||
import Developers, { DevelopersType } from './Developers';
|
||||
import { Fab } from './styles';
|
||||
import { DetailContextProvider } from '../../pages/Version';
|
||||
|
||||
describe('test Developers', () => {
|
||||
const packageMeta = {
|
||||
|
||||
@@ -3,7 +3,8 @@ import Add from '@material-ui/icons/Add';
|
||||
|
||||
import { DetailContext } from '../../pages/Version';
|
||||
import { AvatarTooltip } from '../AvatarTooltip';
|
||||
import { Details, Heading, Content, Fab } from './styles';
|
||||
|
||||
import { Details, StyledText, Content, Fab } from './styles';
|
||||
|
||||
export type DevelopersType = 'contributors' | 'maintainers';
|
||||
|
||||
@@ -18,22 +19,22 @@ const Developers: FC<Props> = ({ type, visibleMax }) => {
|
||||
const [visibleDevs, setVisibleDevs] = React.useState<number>(visibleMax || VISIBLE_MAX);
|
||||
const { packageMeta } = React.useContext(DetailContext);
|
||||
|
||||
const handleLoadMore = () => {
|
||||
const handleLoadMore = (): void => {
|
||||
setVisibleDevs(visibleDevs + VISIBLE_MAX);
|
||||
};
|
||||
|
||||
const renderDeveloperDetails = ({ name, avatar, email }, packageMeta) => {
|
||||
const renderDeveloperDetails = ({ name, avatar, email }, packageMeta): JSX.Element => {
|
||||
const { name: packageName, version } = packageMeta.latest;
|
||||
|
||||
return <AvatarTooltip avatar={avatar} email={email} name={name} packageName={packageName} version={version} />;
|
||||
};
|
||||
|
||||
const renderDevelopers = (developers, packageMeta) => {
|
||||
const renderDevelopers = (developers, packageMeta): JSX.Element => {
|
||||
const listVisibleDevelopers = developers.slice(0, visibleDevs);
|
||||
|
||||
return (
|
||||
<Fragment>
|
||||
<Heading variant={'subtitle1'}>{type}</Heading>
|
||||
<StyledText variant={'subtitle1'}>{type}</StyledText>
|
||||
<Content>
|
||||
{listVisibleDevelopers.map(developer => (
|
||||
<Details key={developer.email}>{renderDeveloperDetails(developer, packageMeta)}</Details>
|
||||
|
||||
@@ -4,147 +4,161 @@ exports[`test Developers should render the component for contributors with items
|
||||
<Developers
|
||||
type="contributors"
|
||||
>
|
||||
<Styled(WithStyles(ForwardRef(Typography)))
|
||||
<Styled(Component)
|
||||
variant="subtitle1"
|
||||
>
|
||||
<WithStyles(ForwardRef(Typography))
|
||||
className="css-18tsvng emotion-0"
|
||||
<ForwardRef(Text)
|
||||
className="css-48zeoi 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",
|
||||
}
|
||||
}
|
||||
<WithStyles(ForwardRef(Typography))
|
||||
className="css-48zeoi emotion-0"
|
||||
variant="subtitle1"
|
||||
>
|
||||
<h6
|
||||
className="MuiTypography-root css-18tsvng emotion-0 MuiTypography-subtitle1"
|
||||
<ForwardRef(Typography)
|
||||
className="css-48zeoi 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"
|
||||
>
|
||||
contributors
|
||||
</h6>
|
||||
</ForwardRef(Typography)>
|
||||
</WithStyles(ForwardRef(Typography))>
|
||||
</Styled(WithStyles(ForwardRef(Typography)))>
|
||||
<h6
|
||||
className="MuiTypography-root css-48zeoi emotion-0 MuiTypography-subtitle1"
|
||||
>
|
||||
contributors
|
||||
</h6>
|
||||
</ForwardRef(Typography)>
|
||||
</WithStyles(ForwardRef(Typography))>
|
||||
</ForwardRef(Text)>
|
||||
</Styled(Component)>
|
||||
<Styled(div)>
|
||||
<div
|
||||
className="css-mkcn9c emotion-5"
|
||||
className="css-mkcn9c emotion-6"
|
||||
>
|
||||
<Styled(span)
|
||||
key="dave.methvin@gmail.com"
|
||||
>
|
||||
<span
|
||||
className="css-dvxtzn emotion-3"
|
||||
className="css-dvxtzn emotion-4"
|
||||
>
|
||||
<AvatarTooltip
|
||||
email="dave.methvin@gmail.com"
|
||||
name="dmethvin"
|
||||
version="1.0.0"
|
||||
>
|
||||
<WithStyles(Tooltip)
|
||||
<ForwardRef(ToolTip)
|
||||
title="dmethvin"
|
||||
>
|
||||
<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",
|
||||
}
|
||||
}
|
||||
<WithStyles(ForwardRef(Tooltip))
|
||||
innerRef={null}
|
||||
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"
|
||||
<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"
|
||||
>
|
||||
<WithStyles(ForwardRef(Avatar))
|
||||
aria-label="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"
|
||||
>
|
||||
<ForwardRef(Avatar)
|
||||
aria-label="dmethvin"
|
||||
classes={
|
||||
Object {
|
||||
"colorDefault": "MuiAvatar-colorDefault",
|
||||
"img": "MuiAvatar-img",
|
||||
"root": "MuiAvatar-root",
|
||||
}
|
||||
}
|
||||
>
|
||||
<div
|
||||
<WithStyles(ForwardRef(Avatar))
|
||||
aria-label="dmethvin"
|
||||
className="MuiAvatar-root MuiAvatar-colorDefault"
|
||||
/>
|
||||
>
|
||||
<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))>
|
||||
</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}
|
||||
/>
|
||||
</Tooltip>
|
||||
</WithStyles(Tooltip)>
|
||||
</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))>
|
||||
</ForwardRef(ToolTip)>
|
||||
</AvatarTooltip>
|
||||
</span>
|
||||
</Styled(span)>
|
||||
@@ -152,86 +166,95 @@ exports[`test Developers should render the component for contributors with items
|
||||
key="m.goleb@gmail.com"
|
||||
>
|
||||
<span
|
||||
className="css-dvxtzn emotion-3"
|
||||
className="css-dvxtzn emotion-4"
|
||||
>
|
||||
<AvatarTooltip
|
||||
email="m.goleb@gmail.com"
|
||||
name="mgol"
|
||||
version="1.0.0"
|
||||
>
|
||||
<WithStyles(Tooltip)
|
||||
<ForwardRef(ToolTip)
|
||||
title="mgol"
|
||||
>
|
||||
<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",
|
||||
}
|
||||
}
|
||||
<WithStyles(ForwardRef(Tooltip))
|
||||
innerRef={null}
|
||||
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"
|
||||
<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"
|
||||
>
|
||||
<WithStyles(ForwardRef(Avatar))
|
||||
aria-label="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"
|
||||
>
|
||||
<ForwardRef(Avatar)
|
||||
aria-label="mgol"
|
||||
classes={
|
||||
Object {
|
||||
"colorDefault": "MuiAvatar-colorDefault",
|
||||
"img": "MuiAvatar-img",
|
||||
"root": "MuiAvatar-root",
|
||||
}
|
||||
}
|
||||
>
|
||||
<div
|
||||
<WithStyles(ForwardRef(Avatar))
|
||||
aria-label="mgol"
|
||||
className="MuiAvatar-root MuiAvatar-colorDefault"
|
||||
/>
|
||||
>
|
||||
<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))>
|
||||
</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}
|
||||
/>
|
||||
</Tooltip>
|
||||
</WithStyles(Tooltip)>
|
||||
</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))>
|
||||
</ForwardRef(ToolTip)>
|
||||
</AvatarTooltip>
|
||||
</span>
|
||||
</Styled(span)>
|
||||
@@ -244,147 +267,161 @@ exports[`test Developers should render the component for maintainers with items
|
||||
<Developers
|
||||
type="maintainers"
|
||||
>
|
||||
<Styled(WithStyles(ForwardRef(Typography)))
|
||||
<Styled(Component)
|
||||
variant="subtitle1"
|
||||
>
|
||||
<WithStyles(ForwardRef(Typography))
|
||||
className="css-18tsvng emotion-0"
|
||||
<ForwardRef(Text)
|
||||
className="css-48zeoi 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",
|
||||
}
|
||||
}
|
||||
<WithStyles(ForwardRef(Typography))
|
||||
className="css-48zeoi emotion-0"
|
||||
variant="subtitle1"
|
||||
>
|
||||
<h6
|
||||
className="MuiTypography-root css-18tsvng emotion-0 MuiTypography-subtitle1"
|
||||
<ForwardRef(Typography)
|
||||
className="css-48zeoi 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"
|
||||
>
|
||||
maintainers
|
||||
</h6>
|
||||
</ForwardRef(Typography)>
|
||||
</WithStyles(ForwardRef(Typography))>
|
||||
</Styled(WithStyles(ForwardRef(Typography)))>
|
||||
<h6
|
||||
className="MuiTypography-root css-48zeoi emotion-0 MuiTypography-subtitle1"
|
||||
>
|
||||
maintainers
|
||||
</h6>
|
||||
</ForwardRef(Typography)>
|
||||
</WithStyles(ForwardRef(Typography))>
|
||||
</ForwardRef(Text)>
|
||||
</Styled(Component)>
|
||||
<Styled(div)>
|
||||
<div
|
||||
className="css-mkcn9c emotion-5"
|
||||
className="css-mkcn9c emotion-6"
|
||||
>
|
||||
<Styled(span)
|
||||
key="dave.methvin@gmail.com"
|
||||
>
|
||||
<span
|
||||
className="css-dvxtzn emotion-3"
|
||||
className="css-dvxtzn emotion-4"
|
||||
>
|
||||
<AvatarTooltip
|
||||
email="dave.methvin@gmail.com"
|
||||
name="dmethvin"
|
||||
version="1.0.0"
|
||||
>
|
||||
<WithStyles(Tooltip)
|
||||
<ForwardRef(ToolTip)
|
||||
title="dmethvin"
|
||||
>
|
||||
<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",
|
||||
}
|
||||
}
|
||||
<WithStyles(ForwardRef(Tooltip))
|
||||
innerRef={null}
|
||||
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"
|
||||
<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"
|
||||
>
|
||||
<WithStyles(ForwardRef(Avatar))
|
||||
aria-label="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"
|
||||
>
|
||||
<ForwardRef(Avatar)
|
||||
aria-label="dmethvin"
|
||||
classes={
|
||||
Object {
|
||||
"colorDefault": "MuiAvatar-colorDefault",
|
||||
"img": "MuiAvatar-img",
|
||||
"root": "MuiAvatar-root",
|
||||
}
|
||||
}
|
||||
>
|
||||
<div
|
||||
<WithStyles(ForwardRef(Avatar))
|
||||
aria-label="dmethvin"
|
||||
className="MuiAvatar-root MuiAvatar-colorDefault"
|
||||
/>
|
||||
>
|
||||
<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))>
|
||||
</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}
|
||||
/>
|
||||
</Tooltip>
|
||||
</WithStyles(Tooltip)>
|
||||
</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))>
|
||||
</ForwardRef(ToolTip)>
|
||||
</AvatarTooltip>
|
||||
</span>
|
||||
</Styled(span)>
|
||||
@@ -392,86 +429,95 @@ exports[`test Developers should render the component for maintainers with items
|
||||
key="m.goleb@gmail.com"
|
||||
>
|
||||
<span
|
||||
className="css-dvxtzn emotion-3"
|
||||
className="css-dvxtzn emotion-4"
|
||||
>
|
||||
<AvatarTooltip
|
||||
email="m.goleb@gmail.com"
|
||||
name="mgol"
|
||||
version="1.0.0"
|
||||
>
|
||||
<WithStyles(Tooltip)
|
||||
<ForwardRef(ToolTip)
|
||||
title="mgol"
|
||||
>
|
||||
<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",
|
||||
}
|
||||
}
|
||||
<WithStyles(ForwardRef(Tooltip))
|
||||
innerRef={null}
|
||||
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"
|
||||
<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"
|
||||
>
|
||||
<WithStyles(ForwardRef(Avatar))
|
||||
aria-label="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"
|
||||
>
|
||||
<ForwardRef(Avatar)
|
||||
aria-label="mgol"
|
||||
classes={
|
||||
Object {
|
||||
"colorDefault": "MuiAvatar-colorDefault",
|
||||
"img": "MuiAvatar-img",
|
||||
"root": "MuiAvatar-root",
|
||||
}
|
||||
}
|
||||
>
|
||||
<div
|
||||
<WithStyles(ForwardRef(Avatar))
|
||||
aria-label="mgol"
|
||||
className="MuiAvatar-root MuiAvatar-colorDefault"
|
||||
/>
|
||||
>
|
||||
<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))>
|
||||
</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}
|
||||
/>
|
||||
</Tooltip>
|
||||
</WithStyles(Tooltip)>
|
||||
</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))>
|
||||
</ForwardRef(ToolTip)>
|
||||
</AvatarTooltip>
|
||||
</span>
|
||||
</Styled(span)>
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
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';
|
||||
import Text from '../../muiComponents/Text';
|
||||
|
||||
export const Details = styled('span')({
|
||||
display: 'flex',
|
||||
@@ -20,12 +20,10 @@ export const Content = styled('div')({
|
||||
},
|
||||
});
|
||||
|
||||
export const Heading = styled(Typography)({
|
||||
'&&': {
|
||||
fontWeight: fontWeight.bold,
|
||||
marginBottom: '10px',
|
||||
textTransform: 'capitalize',
|
||||
},
|
||||
export const StyledText = styled(Text)({
|
||||
fontWeight: fontWeight.bold,
|
||||
marginBottom: '10px',
|
||||
textTransform: 'capitalize',
|
||||
});
|
||||
|
||||
export const Fab = styled(MuiFab)({
|
||||
|
||||
@@ -1,30 +1,17 @@
|
||||
import React from 'react';
|
||||
import { mount } from 'enzyme';
|
||||
|
||||
import { DetailContext } from '../../pages/Version';
|
||||
|
||||
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() });
|
||||
},
|
||||
}));
|
||||
const withDistComponent = (packageMeta: React.ContextType<typeof DetailContext>['packageMeta']): JSX.Element => (
|
||||
<DetailContext.Provider value={{ packageMeta }}>
|
||||
<Dist />
|
||||
</DetailContext.Provider>
|
||||
);
|
||||
|
||||
describe('<Dist /> component', () => {
|
||||
beforeEach(() => {
|
||||
jest.resetModules();
|
||||
});
|
||||
|
||||
test('should render the component in default state', () => {
|
||||
const packageMeta = {
|
||||
latest: {
|
||||
@@ -36,12 +23,10 @@ describe('<Dist /> component', () => {
|
||||
},
|
||||
license: '',
|
||||
},
|
||||
_uplinks: {},
|
||||
};
|
||||
|
||||
// @ts-ignore
|
||||
mockPackageMeta.mockImplementation(() => packageMeta);
|
||||
|
||||
const wrapper = mount(<Dist />);
|
||||
const wrapper = mount(withDistComponent(packageMeta));
|
||||
expect(wrapper.html()).toMatchSnapshot();
|
||||
});
|
||||
|
||||
@@ -56,12 +41,10 @@ describe('<Dist /> component', () => {
|
||||
},
|
||||
license: 'MIT',
|
||||
},
|
||||
_uplinks: {},
|
||||
};
|
||||
|
||||
// @ts-ignore
|
||||
mockPackageMeta.mockImplementation(() => packageMeta);
|
||||
|
||||
const wrapper = mount(<Dist />);
|
||||
const wrapper = mount(withDistComponent(packageMeta));
|
||||
expect(wrapper.html()).toMatchSnapshot();
|
||||
});
|
||||
|
||||
@@ -79,12 +62,10 @@ describe('<Dist /> component', () => {
|
||||
url: 'https://www.opensource.org/licenses/mit-license.php',
|
||||
},
|
||||
},
|
||||
_uplinks: {},
|
||||
};
|
||||
|
||||
// @ts-ignore
|
||||
mockPackageMeta.mockImplementation(() => packageMeta);
|
||||
|
||||
const wrapper = mount(<Dist />);
|
||||
const wrapper = mount(withDistComponent(packageMeta));
|
||||
expect(wrapper.html()).toMatchSnapshot();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,56 +1,46 @@
|
||||
import React, { Component } from 'react';
|
||||
import React, { FC, useContext } from 'react';
|
||||
|
||||
import List from '@material-ui/core/List';
|
||||
|
||||
import { VersionPageConsumerProps, DetailContextConsumer } from '../../pages/Version';
|
||||
import { Heading, DistListItem, DistChips } from './styles';
|
||||
import { DetailContext } from '../../pages/Version';
|
||||
import fileSizeSI from '../../utils/file-size';
|
||||
import { PackageMetaInterface } from 'types/packageMeta';
|
||||
import { formatLicense } from '../../utils/package';
|
||||
import List from '../../muiComponents/List';
|
||||
|
||||
class Dist extends Component {
|
||||
public render(): JSX.Element {
|
||||
return (
|
||||
<DetailContextConsumer>
|
||||
{(context: Partial<VersionPageConsumerProps>) => {
|
||||
return context && context.packageMeta && this.renderDist(context.packageMeta);
|
||||
}}
|
||||
</DetailContextConsumer>
|
||||
);
|
||||
}
|
||||
import { StyledText, DistListItem, DistChips } from './styles';
|
||||
|
||||
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).map((dist, key) => {
|
||||
if (!distDict[dist]) return;
|
||||
|
||||
const value = dist === 'license' ? formatLicense(distDict[dist]) : distDict[dist];
|
||||
const label = (
|
||||
const DistChip: FC<{ name: string }> = ({ name, children }) =>
|
||||
children ? (
|
||||
<DistChips
|
||||
// lint rule conflicting with prettier
|
||||
/* eslint-disable react/jsx-wrap-multilines */
|
||||
label={
|
||||
<>
|
||||
{/* eslint-disable-next-line */}
|
||||
<b>{dist.replace('-', ' ')}</b>: {value}
|
||||
<b>{name}</b>
|
||||
{': '}
|
||||
{children}
|
||||
</>
|
||||
);
|
||||
return <DistChips key={key} label={label} />;
|
||||
});
|
||||
}
|
||||
/* eslint-enable */
|
||||
/>
|
||||
) : null;
|
||||
|
||||
return chipsList;
|
||||
const Dist: FC = () => {
|
||||
const { packageMeta } = useContext(DetailContext);
|
||||
|
||||
if (!packageMeta) {
|
||||
return null;
|
||||
}
|
||||
|
||||
private renderDist = (packageMeta: PackageMetaInterface) => {
|
||||
const { dist, license } = packageMeta && packageMeta.latest;
|
||||
const { dist, license } = packageMeta && packageMeta.latest;
|
||||
|
||||
return (
|
||||
<List subheader={<Heading variant="subtitle1">{'Latest Distribution'}</Heading>}>
|
||||
<DistListItem button={true}>{this.renderChips(dist, license)}</DistListItem>
|
||||
</List>
|
||||
);
|
||||
};
|
||||
}
|
||||
return (
|
||||
<List subheader={<StyledText variant="subtitle1">{'Latest Distribution'}</StyledText>}>
|
||||
<DistListItem button={true}>
|
||||
<DistChip name="file count">{dist.fileCount}</DistChip>
|
||||
<DistChip name="size">{dist.unpackedSize && fileSizeSI(dist.unpackedSize)}</DistChip>
|
||||
<DistChip name="license">{formatLicense(license)}</DistChip>
|
||||
</DistListItem>
|
||||
</List>
|
||||
);
|
||||
};
|
||||
|
||||
export default Dist;
|
||||
|
||||
@@ -1,7 +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 in default state 1`] = `"<ul class=\\"MuiList-root MuiList-padding MuiList-subheader\\"><h6 class=\\"MuiTypography-root css-b8upko 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 object 1`] = `"<ul class=\\"MuiList-root MuiList-padding MuiList-subheader\\"><h6 class=\\"MuiTypography-root css-b8upko 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>"`;
|
||||
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-b8upko 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>"`;
|
||||
|
||||
@@ -1,17 +1,15 @@
|
||||
import styled from 'react-emotion';
|
||||
import { default as MuiFab } from '@material-ui/core/Fab';
|
||||
import Chip from '@material-ui/core/Chip';
|
||||
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';
|
||||
import ListItem from '../../muiComponents/ListItem';
|
||||
import Text from '../../muiComponents/Text';
|
||||
|
||||
export const Heading = styled(Typography)({
|
||||
'&&': {
|
||||
fontWeight: fontWeight.bold,
|
||||
textTransform: 'capitalize',
|
||||
},
|
||||
export const StyledText = styled(Text)({
|
||||
fontWeight: fontWeight.bold,
|
||||
textTransform: 'capitalize',
|
||||
});
|
||||
|
||||
export const DistListItem = styled(ListItem)({
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
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(() => ({
|
||||
const mockPackageMeta: jest.Mock = jest.fn(() => ({
|
||||
latest: {
|
||||
homepage: 'https://verdaccio.tld',
|
||||
bugs: {
|
||||
@@ -38,7 +39,6 @@ describe('<Engines /> component', () => {
|
||||
},
|
||||
};
|
||||
|
||||
// @ts-ignore
|
||||
mockPackageMeta.mockImplementation(() => packageMeta);
|
||||
|
||||
const wrapper = mount(<Engine />);
|
||||
@@ -50,7 +50,6 @@ describe('<Engines /> component', () => {
|
||||
latest: {},
|
||||
};
|
||||
|
||||
// @ts-ignore
|
||||
mockPackageMeta.mockImplementation(() => packageMeta);
|
||||
|
||||
const wrapper = mount(<Engine />);
|
||||
@@ -64,7 +63,6 @@ describe('<Engines /> component', () => {
|
||||
},
|
||||
};
|
||||
|
||||
// @ts-ignore
|
||||
mockPackageMeta.mockImplementation(() => packageMeta);
|
||||
|
||||
const wrapper = mount(<Engine />);
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
import React, { Component, ReactElement } from 'react';
|
||||
|
||||
import Avatar from '@material-ui/core/Avatar';
|
||||
import Grid from '@material-ui/core/Grid';
|
||||
import List from '@material-ui/core/List';
|
||||
import ListItemText from '@material-ui/core/ListItemText';
|
||||
|
||||
import { VersionPageConsumerProps, DetailContextConsumer } from '../../pages/Version';
|
||||
import { Heading, EngineListItem } from './styles';
|
||||
import Avatar from '../../muiComponents/Avatar';
|
||||
import List from '../../muiComponents/List';
|
||||
import npm from '../Install/img/npm.svg';
|
||||
|
||||
import { StyledText, EngineListItem } from './styles';
|
||||
// @ts-ignore
|
||||
import node from './img/node.png';
|
||||
import npm from '../Install/img/npm.svg';
|
||||
|
||||
const ICONS = {
|
||||
'node-JS': <Avatar src={node} />,
|
||||
@@ -58,9 +58,9 @@ class Engine extends Component {
|
||||
return <Grid container={true}>{items}</Grid>;
|
||||
};
|
||||
|
||||
private renderListItems = (heading, text) => {
|
||||
private renderListItems = (heading: string, text: string) => {
|
||||
return (
|
||||
<List subheader={<Heading variant={'subtitle1'}>{text.split('-').join(' ')}</Heading>}>
|
||||
<List subheader={<StyledText variant={'subtitle1'}>{text.split('-').join(' ')}</StyledText>}>
|
||||
<EngineListItem button={true}>
|
||||
{ICONS[text]}
|
||||
<ListItemText primary={heading} />
|
||||
|
||||
@@ -1,3 +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>"`;
|
||||
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-b8upko et66bt70 MuiTypography-subtitle1\\">node JS</h6><div class=\\"MuiButtonBase-root MuiListItem-root css-131yq1t 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-b8upko et66bt70 MuiTypography-subtitle1\\">NPM version</h6><div class=\\"MuiButtonBase-root MuiListItem-root css-131yq1t 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,17 +1,14 @@
|
||||
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)({
|
||||
'&&': {
|
||||
fontWeight: fontWeight.bold,
|
||||
textTransform: 'capitalize',
|
||||
},
|
||||
import { fontWeight } from '../../utils/styles/sizes';
|
||||
import ListItem from '../../muiComponents/ListItem';
|
||||
import Text from '../../muiComponents/Text';
|
||||
|
||||
export const StyledText = styled(Text)({
|
||||
fontWeight: fontWeight.bold,
|
||||
textTransform: 'capitalize',
|
||||
});
|
||||
|
||||
export const EngineListItem = styled(ListItem)({
|
||||
'&&': {
|
||||
paddingLeft: 0,
|
||||
},
|
||||
paddingLeft: 0,
|
||||
});
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import React from 'react';
|
||||
import { mount } from 'enzyme';
|
||||
import { mount, ReactWrapper } from 'enzyme';
|
||||
|
||||
import Footer from './Footer';
|
||||
|
||||
@@ -8,12 +8,10 @@ jest.mock('../../../package.json', () => ({
|
||||
}));
|
||||
|
||||
describe('<Footer /> component', () => {
|
||||
let wrapper;
|
||||
let wrapper: ReactWrapper;
|
||||
beforeEach(() => {
|
||||
// @ts-ignore : Property 'VERDACCIO_VERSION' does not exist on type 'Window'
|
||||
window.VERDACCIO_VERSION = 'v.1.0.0';
|
||||
wrapper = mount(<Footer />);
|
||||
// @ts-ignore : Property 'VERDACCIO_VERSION' does not exist on type 'Window'
|
||||
delete window.VERDACCIO_VERSION;
|
||||
});
|
||||
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import React from 'react';
|
||||
|
||||
import { Wrapper, Left, Right, Earth, Flags, Love, Flag, Logo, Inner, ToolTip } from './styles';
|
||||
import { goToVerdaccioWebsite } from '../../utils/windows';
|
||||
|
||||
import { Wrapper, Left, Right, Earth, Flags, Love, Flag, Logo, Inner, ToolTip } from './styles';
|
||||
|
||||
const renderTooltip = (): JSX.Element => (
|
||||
<ToolTip>
|
||||
<Earth name="earth" size="md" />
|
||||
@@ -21,7 +22,6 @@ const MADEWITH_LABEL = ' Made with';
|
||||
const ON_LABEL = 'on';
|
||||
const HEARTH_EMOJI = '♥';
|
||||
|
||||
// @ts-ignore
|
||||
const renderRight = (version = window.VERDACCIO_VERSION): JSX.Element => {
|
||||
return (
|
||||
<Right>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import styled, { css } from 'react-emotion';
|
||||
|
||||
import mq from '../../utils/styles/media';
|
||||
import Icon from '../Icon/Icon';
|
||||
import colors from '../../utils/styles/colors';
|
||||
@@ -20,7 +21,6 @@ export const Inner = styled('div')`
|
||||
justify-content: flex-end;
|
||||
width: 100%;
|
||||
${() => {
|
||||
// @ts-ignore
|
||||
return mq.medium(css`
|
||||
min-width: 400px;
|
||||
max-width: 800px;
|
||||
@@ -29,7 +29,6 @@ export const Inner = styled('div')`
|
||||
`);
|
||||
}};
|
||||
${() => {
|
||||
// @ts-ignore
|
||||
return mq.large(css`
|
||||
max-width: 1240px;
|
||||
`);
|
||||
@@ -42,7 +41,6 @@ export const Left = styled('div')`
|
||||
align-items: center;
|
||||
display: none;
|
||||
${() => {
|
||||
// @ts-ignore
|
||||
return mq.medium(css`
|
||||
display: flex;
|
||||
`);
|
||||
@@ -90,7 +88,7 @@ export const Flags = styled('span')`
|
||||
border-color: ${colors.greyAthens} transparent transparent transparent;
|
||||
transform: rotate(90deg);
|
||||
}
|
||||
${ToolTip}:hover & {
|
||||
${/* sc-selector */ ToolTip}:hover & {
|
||||
visibility: visible;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,124 +1,138 @@
|
||||
import React from 'react';
|
||||
import { BrowserRouter as Router } from 'react-router-dom';
|
||||
import { shallow } from 'enzyme';
|
||||
import { render, fireEvent, waitForElementToBeRemoved, waitForElement } from '@testing-library/react';
|
||||
|
||||
import Header from './Header';
|
||||
|
||||
describe('<Header /> component with logged in state', () => {
|
||||
let wrapper;
|
||||
let routerWrapper;
|
||||
let instance;
|
||||
let props;
|
||||
const headerProps = {
|
||||
username: 'verddacio-user',
|
||||
scope: 'test scope',
|
||||
withoutSearch: true,
|
||||
handleToggleLoginModal: jest.fn(),
|
||||
handleLogout: jest.fn(),
|
||||
};
|
||||
|
||||
beforeEach(() => {
|
||||
props = {
|
||||
username: 'test user',
|
||||
handleLogout: jest.fn(),
|
||||
logo: '',
|
||||
onToggleLoginModal: jest.fn(),
|
||||
scope: 'test scope',
|
||||
withoutSearch: true,
|
||||
};
|
||||
routerWrapper = shallow(
|
||||
/* eslint-disable react/jsx-no-bind*/
|
||||
describe('<Header /> component with logged in state', () => {
|
||||
test('should load the component in logged out state', () => {
|
||||
const { container, queryByTestId, getByText } = render(
|
||||
<Router>
|
||||
<Header
|
||||
logo={props.logo}
|
||||
onLogout={props.handleLogout}
|
||||
onToggleLoginModal={props.onToggleLoginModal}
|
||||
scope={props.scope}
|
||||
username={props.username}
|
||||
withoutSearch={props.withoutSearch}
|
||||
/>
|
||||
<Header onLogout={headerProps.handleLogout} onToggleLoginModal={headerProps.handleToggleLoginModal} scope={headerProps.scope} />
|
||||
</Router>
|
||||
);
|
||||
wrapper = routerWrapper.find(Header).dive();
|
||||
instance = wrapper.instance();
|
||||
|
||||
expect(container.firstChild).toMatchSnapshot();
|
||||
expect(queryByTestId('header--menu-acountcircle')).toBeNull();
|
||||
expect(getByText('Login')).toBeTruthy();
|
||||
});
|
||||
|
||||
test('should load the component in logged in state', () => {
|
||||
const state = {
|
||||
openInfoDialog: false,
|
||||
packages: undefined,
|
||||
registryUrl: 'http://localhost',
|
||||
showMobileNavBar: false,
|
||||
};
|
||||
|
||||
expect(wrapper.state()).toEqual(state);
|
||||
expect(routerWrapper.html()).toMatchSnapshot();
|
||||
});
|
||||
|
||||
test('handleLoggedInMenu: set anchorEl to html element value in state', () => {
|
||||
// creates a sample menu
|
||||
const div = document.createElement('div');
|
||||
const text = document.createTextNode('sample menu');
|
||||
div.appendChild(text);
|
||||
|
||||
const event = {
|
||||
currentTarget: div,
|
||||
};
|
||||
|
||||
instance.handleLoggedInMenu(event);
|
||||
expect(wrapper.state('anchorEl')).toEqual(div);
|
||||
});
|
||||
});
|
||||
|
||||
describe('<Header /> component with logged out state', () => {
|
||||
let wrapper;
|
||||
let routerWrapper;
|
||||
let instance;
|
||||
let props;
|
||||
|
||||
beforeEach(() => {
|
||||
props = {
|
||||
handleLogout: jest.fn(),
|
||||
onToggleLoginModal: jest.fn(),
|
||||
scope: 'test scope',
|
||||
logo: '',
|
||||
withoutSearch: true,
|
||||
};
|
||||
routerWrapper = shallow(
|
||||
const { container, getByTestId, queryByText } = render(
|
||||
<Router>
|
||||
<Header
|
||||
logo={props.logo}
|
||||
onLogout={props.handleLogout}
|
||||
onToggleLoginModal={props.onToggleLoginModal}
|
||||
scope={props.scope}
|
||||
withoutSearch={props.withoutSearch}
|
||||
onLogout={headerProps.handleLogout}
|
||||
onToggleLoginModal={headerProps.handleToggleLoginModal}
|
||||
scope={headerProps.scope}
|
||||
username={headerProps.username}
|
||||
/>
|
||||
</Router>
|
||||
);
|
||||
wrapper = routerWrapper.find(Header).dive();
|
||||
instance = wrapper.instance();
|
||||
|
||||
expect(container.firstChild).toMatchSnapshot();
|
||||
expect(getByTestId('header--menu-acountcircle')).toBeTruthy();
|
||||
expect(queryByText('Login')).toBeNull();
|
||||
});
|
||||
|
||||
test('should load the component in logged out state', () => {
|
||||
const state = {
|
||||
openInfoDialog: false,
|
||||
packages: undefined,
|
||||
registryUrl: 'http://localhost',
|
||||
showMobileNavBar: false,
|
||||
};
|
||||
expect(wrapper.state()).toEqual(state);
|
||||
expect(routerWrapper.html()).toMatchSnapshot();
|
||||
test('should open login dialog', async () => {
|
||||
const { getByText } = render(
|
||||
<Router>
|
||||
<Header onLogout={headerProps.handleLogout} onToggleLoginModal={headerProps.handleToggleLoginModal} scope={headerProps.scope} />
|
||||
</Router>
|
||||
);
|
||||
|
||||
const loginBtn = getByText('Login');
|
||||
fireEvent.click(loginBtn);
|
||||
expect(headerProps.handleToggleLoginModal).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
test('handleLoggedInMenuClose: set anchorEl value to null in state', () => {
|
||||
instance.handleLoggedInMenuClose();
|
||||
expect(wrapper.state('anchorEl')).toBeNull();
|
||||
test('should logout the user', async () => {
|
||||
const { getByText, getByTestId } = render(
|
||||
<Router>
|
||||
<Header
|
||||
onLogout={headerProps.handleLogout}
|
||||
onToggleLoginModal={headerProps.handleToggleLoginModal}
|
||||
scope={headerProps.scope}
|
||||
username={headerProps.username}
|
||||
/>
|
||||
</Router>
|
||||
);
|
||||
|
||||
const headerMenuAccountCircle = getByTestId('header--menu-acountcircle');
|
||||
fireEvent.click(headerMenuAccountCircle);
|
||||
|
||||
// wait for button Logout's appearance and return the element
|
||||
const logoutBtn = await waitForElement(() => getByText('Logout'));
|
||||
fireEvent.click(logoutBtn);
|
||||
expect(headerProps.handleLogout).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
test('handleOpenRegistryInfoDialog: set openInfoDialog to be truthy in state', () => {
|
||||
instance.handleOpenRegistryInfoDialog();
|
||||
expect(wrapper.state('openInfoDialog')).toBeTruthy();
|
||||
test("The question icon should open a new tab of verdaccio's website - installation doc", async () => {
|
||||
const { getByTestId } = render(
|
||||
<Router>
|
||||
<Header
|
||||
onLogout={headerProps.handleLogout}
|
||||
onToggleLoginModal={headerProps.handleToggleLoginModal}
|
||||
scope={headerProps.scope}
|
||||
username={headerProps.username}
|
||||
/>
|
||||
</Router>
|
||||
);
|
||||
|
||||
const documentationBtn = getByTestId('header--tooltip-documentation');
|
||||
expect(documentationBtn.getAttribute('href')).toBe('https://verdaccio.org/docs/en/installation');
|
||||
});
|
||||
|
||||
test('handleCloseRegistryInfoDialog: set openInfoDialog to be falsy in state', () => {
|
||||
instance.handleCloseRegistryInfoDialog();
|
||||
expect(wrapper.state('openInfoDialog')).toBeFalsy();
|
||||
test('should open the registrationInfo modal when clicking on the info icon', async () => {
|
||||
const { getByTestId } = render(
|
||||
<Router>
|
||||
<Header
|
||||
onLogout={headerProps.handleLogout}
|
||||
onToggleLoginModal={headerProps.handleToggleLoginModal}
|
||||
scope={headerProps.scope}
|
||||
username={headerProps.username}
|
||||
/>
|
||||
</Router>
|
||||
);
|
||||
|
||||
const infoBtn = getByTestId('header--tooltip-info');
|
||||
fireEvent.click(infoBtn);
|
||||
|
||||
// wait for registrationInfo modal appearance and return the element
|
||||
const registrationInfoModal = await waitForElement(() => getByTestId('registryInfo--dialog'));
|
||||
expect(registrationInfoModal).toBeTruthy();
|
||||
});
|
||||
|
||||
test('handleToggleLogin: close/open popover menu', () => {
|
||||
instance.handleToggleLogin();
|
||||
expect(wrapper.state('anchorEl')).toBeNull();
|
||||
expect(props.onToggleLoginModal).toHaveBeenCalled();
|
||||
test('should close the registrationInfo modal when clicking on the button close', async () => {
|
||||
const { getByTestId, getByText, queryByTestId } = render(
|
||||
<Router>
|
||||
<Header
|
||||
onLogout={headerProps.handleLogout}
|
||||
onToggleLoginModal={headerProps.handleToggleLoginModal}
|
||||
scope={headerProps.scope}
|
||||
username={headerProps.username}
|
||||
/>
|
||||
</Router>
|
||||
);
|
||||
|
||||
const infoBtn = getByTestId('header--tooltip-info');
|
||||
fireEvent.click(infoBtn);
|
||||
|
||||
// wait for Close's button of registrationInfo modal appearance and return the element
|
||||
const closeBtn = await waitForElement(() => getByText('CLOSE'));
|
||||
fireEvent.click(closeBtn);
|
||||
|
||||
const hasRegistrationInfoModalBeenRemoved = await waitForElementToBeRemoved(() => queryByTestId('registryInfo--dialog'));
|
||||
expect(hasRegistrationInfoModalBeenRemoved).toBeTruthy();
|
||||
});
|
||||
test.todo('autocompletion should display suggestions according to the type value');
|
||||
});
|
||||
|
||||
@@ -1,26 +1,13 @@
|
||||
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';
|
||||
import MenuItem from '@material-ui/core/MenuItem';
|
||||
import Menu from '@material-ui/core/Menu';
|
||||
import Info from '@material-ui/icons/Info';
|
||||
import Help from '@material-ui/icons/Help';
|
||||
import Tooltip from '@material-ui/core/Tooltip';
|
||||
import AccountCircle from '@material-ui/icons/AccountCircle';
|
||||
import { default as IconSearch } from '@material-ui/icons/Search';
|
||||
import React, { useState } from 'react';
|
||||
|
||||
import Search from '../Search';
|
||||
import { getRegistryURL } from '../../utils/url';
|
||||
import ExternalLink from '../Link';
|
||||
import Logo from '../Logo';
|
||||
import RegistryInfoDialog from '../RegistryInfoDialog/RegistryInfoDialog';
|
||||
import Label from '../Label/Label';
|
||||
import Search from '../Search/Search';
|
||||
import RegistryInfoContent from '../RegistryInfoContent/RegistryInfoContent';
|
||||
import Button from '../../muiComponents/Button';
|
||||
|
||||
import { Greetings, NavBar, InnerNavBar, MobileNavBar, InnerMobileNavBar, LeftSide, RightSide, IconSearchButton, SearchWrapper } from './styles';
|
||||
import { NavBar, InnerNavBar, MobileNavBar, InnerMobileNavBar } from './styles';
|
||||
import HeaderLeft from './HeaderLeft';
|
||||
import HeaderRight from './HeaderRight';
|
||||
import HeaderInfoDialog from './HeaderInfoDialog';
|
||||
|
||||
interface Props {
|
||||
logo?: string;
|
||||
@@ -31,247 +18,38 @@ interface Props {
|
||||
withoutSearch?: boolean;
|
||||
}
|
||||
|
||||
interface State {
|
||||
anchorEl?: null | Element | ((element: Element) => Element);
|
||||
openInfoDialog: boolean;
|
||||
registryUrl: string;
|
||||
showMobileNavBar: boolean;
|
||||
}
|
||||
/* eslint-disable react/jsx-max-depth */
|
||||
/* eslint-disable react/jsx-no-bind*/
|
||||
const Header: React.FC<Props> = ({ logo, withoutSearch, username, onLogout, onToggleLoginModal, scope }) => {
|
||||
const [isInfoDialogOpen, setOpenInfoDialog] = useState();
|
||||
const [showMobileNavBar, setShowMobileNavBar] = useState();
|
||||
|
||||
type ToolTipType = 'search' | 'help' | 'info';
|
||||
|
||||
class Header extends Component<Props, State> {
|
||||
constructor(props: Props) {
|
||||
super(props);
|
||||
this.state = {
|
||||
openInfoDialog: false,
|
||||
registryUrl: getRegistryURL(),
|
||||
showMobileNavBar: false,
|
||||
};
|
||||
}
|
||||
|
||||
public render(): ReactElement<HTMLElement> {
|
||||
const { showMobileNavBar } = this.state;
|
||||
const { withoutSearch = false } = this.props;
|
||||
return (
|
||||
<div>
|
||||
<NavBar position="static">
|
||||
<InnerNavBar>
|
||||
{this.renderLeftSide()}
|
||||
{this.renderRightSide()}
|
||||
</InnerNavBar>
|
||||
{this.renderInfoDialog()}
|
||||
</NavBar>
|
||||
{showMobileNavBar && !withoutSearch && (
|
||||
<MobileNavBar>
|
||||
<InnerMobileNavBar>
|
||||
<Search />
|
||||
</InnerMobileNavBar>
|
||||
<Button color="inherit" onClick={this.handleDismissMNav}>
|
||||
{'Cancel'}
|
||||
</Button>
|
||||
</MobileNavBar>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* opens popover menu for logged in user.
|
||||
*/
|
||||
public handleLoggedInMenu = (event: SyntheticEvent<HTMLElement>) => {
|
||||
this.setState({
|
||||
anchorEl: event.currentTarget,
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* closes popover menu for logged in user
|
||||
*/
|
||||
public handleLoggedInMenuClose = () => {
|
||||
this.setState({
|
||||
anchorEl: null,
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* opens registry information dialog.
|
||||
*/
|
||||
public handleOpenRegistryInfoDialog = () => {
|
||||
this.setState({
|
||||
openInfoDialog: true,
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* closes registry information dialog.
|
||||
*/
|
||||
public handleCloseRegistryInfoDialog = () => {
|
||||
this.setState({
|
||||
openInfoDialog: false,
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* close/open popover menu for logged in users.
|
||||
*/
|
||||
public handleToggleLogin = () => {
|
||||
const { onToggleLoginModal } = this.props;
|
||||
this.setState(
|
||||
{
|
||||
anchorEl: null,
|
||||
},
|
||||
onToggleLoginModal
|
||||
);
|
||||
};
|
||||
|
||||
public handleToggleMNav = () => {
|
||||
const { showMobileNavBar } = this.state;
|
||||
this.setState({
|
||||
showMobileNavBar: !showMobileNavBar,
|
||||
});
|
||||
};
|
||||
|
||||
public handleDismissMNav = () => {
|
||||
this.setState({
|
||||
showMobileNavBar: false,
|
||||
});
|
||||
};
|
||||
|
||||
public renderLeftSide = () => {
|
||||
const { withoutSearch = false } = this.props;
|
||||
return (
|
||||
<LeftSide>
|
||||
<Link
|
||||
className={css`
|
||||
margin-right: 1em;
|
||||
`}
|
||||
to={'/'}>
|
||||
{this.renderLogo()}
|
||||
</Link>
|
||||
{!withoutSearch && (
|
||||
<SearchWrapper>
|
||||
return (
|
||||
<>
|
||||
<NavBar position="static">
|
||||
<InnerNavBar>
|
||||
<HeaderLeft logo={logo} />
|
||||
<HeaderRight
|
||||
onLogout={onLogout}
|
||||
onOpenRegistryInfoDialog={() => setOpenInfoDialog(true)}
|
||||
onToggleLogin={onToggleLoginModal}
|
||||
onToggleMobileNav={() => setShowMobileNavBar(!showMobileNavBar)}
|
||||
username={username}
|
||||
withoutSearch={withoutSearch}
|
||||
/>
|
||||
</InnerNavBar>
|
||||
<HeaderInfoDialog isOpen={isInfoDialogOpen} onCloseDialog={() => setOpenInfoDialog(false)} registryUrl={getRegistryURL()} scope={scope} />
|
||||
</NavBar>
|
||||
{showMobileNavBar && !withoutSearch && (
|
||||
<MobileNavBar>
|
||||
<InnerMobileNavBar>
|
||||
<Search />
|
||||
</SearchWrapper>
|
||||
)}
|
||||
</LeftSide>
|
||||
);
|
||||
};
|
||||
|
||||
public renderLogo = () => {
|
||||
const { logo } = this.props;
|
||||
|
||||
if (logo) {
|
||||
return <img alt="logo" height="40px" src={logo} />;
|
||||
} else {
|
||||
return <Logo />;
|
||||
}
|
||||
};
|
||||
|
||||
public renderToolTipIcon = (title: string, type: ToolTipType) => {
|
||||
let content;
|
||||
switch (type) {
|
||||
case 'help':
|
||||
content = (
|
||||
// @ts-ignore
|
||||
<IconButton blank={true} color={'inherit'} component={ExternalLink} to={'https://verdaccio.org/docs/en/installation'}>
|
||||
<Help />
|
||||
</IconButton>
|
||||
);
|
||||
break;
|
||||
case 'info':
|
||||
content = (
|
||||
<IconButton color="inherit" id="header--button-registryInfo" onClick={this.handleOpenRegistryInfoDialog}>
|
||||
<Info />
|
||||
</IconButton>
|
||||
);
|
||||
break;
|
||||
case 'search':
|
||||
content = (
|
||||
<IconSearchButton color="inherit" onClick={this.handleToggleMNav}>
|
||||
<IconSearch />
|
||||
</IconSearchButton>
|
||||
);
|
||||
break;
|
||||
}
|
||||
return (
|
||||
<Tooltip disableFocusListener={true} title={title}>
|
||||
{content}
|
||||
</Tooltip>
|
||||
);
|
||||
};
|
||||
|
||||
public renderRightSide = () => {
|
||||
const { username = '', withoutSearch = false } = this.props;
|
||||
return (
|
||||
<RightSide>
|
||||
{!withoutSearch && this.renderToolTipIcon('Search packages', 'search')}
|
||||
{this.renderToolTipIcon('Documentation', 'help')}
|
||||
{this.renderToolTipIcon('Registry Information', 'info')}
|
||||
{username ? (
|
||||
this.renderMenu()
|
||||
) : (
|
||||
<Button color="inherit" id="header--button-login" onClick={this.handleToggleLogin}>
|
||||
{'Login'}
|
||||
</Button>
|
||||
)}
|
||||
</RightSide>
|
||||
);
|
||||
};
|
||||
|
||||
private renderGreetings = () => {
|
||||
const { username = '' } = this.props;
|
||||
return (
|
||||
<Fragment>
|
||||
<Greetings>{'Hi,'}</Greetings>
|
||||
<Label capitalize={true} text={username} weight="bold" />
|
||||
</Fragment>
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* render popover menu
|
||||
*/
|
||||
private renderMenu = () => {
|
||||
const { onLogout } = this.props;
|
||||
const { anchorEl } = this.state;
|
||||
const open = Boolean(anchorEl);
|
||||
return (
|
||||
<>
|
||||
<IconButton color="inherit" id="header--button-account" onClick={this.handleLoggedInMenu}>
|
||||
<AccountCircle />
|
||||
</IconButton>
|
||||
<Menu
|
||||
anchorEl={anchorEl}
|
||||
anchorOrigin={{
|
||||
vertical: 'top',
|
||||
horizontal: 'right',
|
||||
}}
|
||||
id="sidebar-menu"
|
||||
onClose={this.handleLoggedInMenuClose}
|
||||
open={open}
|
||||
transformOrigin={{
|
||||
vertical: 'top',
|
||||
horizontal: 'right',
|
||||
}}>
|
||||
<MenuItem disabled={true}>{this.renderGreetings()}</MenuItem>
|
||||
<MenuItem id="header--button-logout" onClick={onLogout}>
|
||||
{'Logout'}
|
||||
</MenuItem>
|
||||
</Menu>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
private renderInfoDialog = () => {
|
||||
const { scope } = this.props;
|
||||
const { openInfoDialog, registryUrl } = this.state;
|
||||
return (
|
||||
<RegistryInfoDialog onClose={this.handleCloseRegistryInfoDialog} open={openInfoDialog}>
|
||||
<RegistryInfoContent registryUrl={registryUrl} scope={scope} />
|
||||
</RegistryInfoDialog>
|
||||
);
|
||||
};
|
||||
}
|
||||
</InnerMobileNavBar>
|
||||
<Button color="inherit">{'Cancel'}</Button>
|
||||
</MobileNavBar>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default Header;
|
||||
|
||||
18
src/components/Header/HeaderGreetings.tsx
Normal file
18
src/components/Header/HeaderGreetings.tsx
Normal file
@@ -0,0 +1,18 @@
|
||||
import React from 'react';
|
||||
|
||||
import Label from '../Label';
|
||||
|
||||
import { Greetings } from './styles';
|
||||
|
||||
interface Props {
|
||||
username: string;
|
||||
}
|
||||
|
||||
const HeaderGreetings: React.FC<Props> = ({ username }) => (
|
||||
<>
|
||||
<Greetings>{'Hi,'}</Greetings>
|
||||
<Label capitalize={true} text={username} weight="bold" />
|
||||
</>
|
||||
);
|
||||
|
||||
export default HeaderGreetings;
|
||||
19
src/components/Header/HeaderInfoDialog.tsx
Normal file
19
src/components/Header/HeaderInfoDialog.tsx
Normal file
@@ -0,0 +1,19 @@
|
||||
import React from 'react';
|
||||
|
||||
import RegistryInfoDialog from '../RegistryInfoDialog';
|
||||
import RegistryInfoContent from '../RegistryInfoContent';
|
||||
|
||||
interface Props {
|
||||
isOpen: boolean;
|
||||
onCloseDialog: () => void;
|
||||
registryUrl: string;
|
||||
scope: string;
|
||||
}
|
||||
|
||||
const HeaderInfoDialog: React.FC<Props> = ({ onCloseDialog, isOpen, registryUrl, scope }) => (
|
||||
<RegistryInfoDialog onClose={onCloseDialog} open={isOpen}>
|
||||
<RegistryInfoContent registryUrl={registryUrl} scope={scope} />
|
||||
</RegistryInfoDialog>
|
||||
);
|
||||
|
||||
export default HeaderInfoDialog;
|
||||
32
src/components/Header/HeaderLeft.tsx
Normal file
32
src/components/Header/HeaderLeft.tsx
Normal file
@@ -0,0 +1,32 @@
|
||||
import React from 'react';
|
||||
import { css } from 'emotion';
|
||||
import { Link } from 'react-router-dom';
|
||||
|
||||
import Search from '../Search/';
|
||||
|
||||
import HeaderLogo from './HeaderLogo';
|
||||
import { LeftSide, SearchWrapper } from './styles';
|
||||
|
||||
interface Props {
|
||||
withoutSearch?: boolean;
|
||||
logo?: string;
|
||||
}
|
||||
|
||||
const HeaderLeft: React.FC<Props> = ({ withoutSearch = false, logo }) => (
|
||||
<LeftSide>
|
||||
<Link
|
||||
className={css`
|
||||
margin-right: 1em;
|
||||
`}
|
||||
to={'/'}>
|
||||
<HeaderLogo logo={logo} />
|
||||
</Link>
|
||||
{!withoutSearch && (
|
||||
<SearchWrapper>
|
||||
<Search />
|
||||
</SearchWrapper>
|
||||
)}
|
||||
</LeftSide>
|
||||
);
|
||||
|
||||
export default HeaderLeft;
|
||||
17
src/components/Header/HeaderLogo.tsx
Normal file
17
src/components/Header/HeaderLogo.tsx
Normal file
@@ -0,0 +1,17 @@
|
||||
import React from 'react';
|
||||
|
||||
import Logo from '../Logo';
|
||||
|
||||
interface Props {
|
||||
logo?: string;
|
||||
}
|
||||
|
||||
const HeaderLogo: React.FC<Props> = ({ logo }) => {
|
||||
if (logo) {
|
||||
return <img alt="logo" height="40px" src={logo} />;
|
||||
}
|
||||
|
||||
return <Logo />;
|
||||
};
|
||||
|
||||
export default HeaderLogo;
|
||||
48
src/components/Header/HeaderMenu.tsx
Normal file
48
src/components/Header/HeaderMenu.tsx
Normal file
@@ -0,0 +1,48 @@
|
||||
import React, { MouseEvent } from 'react';
|
||||
import MenuItem from '@material-ui/core/MenuItem';
|
||||
import Menu from '@material-ui/core/Menu';
|
||||
import AccountCircle from '@material-ui/icons/AccountCircle';
|
||||
|
||||
import IconButton from '../../muiComponents/IconButton';
|
||||
|
||||
import HeaderGreetings from './HeaderGreetings';
|
||||
|
||||
interface Props {
|
||||
username: string;
|
||||
isMenuOpen: boolean;
|
||||
anchorEl?: Element | ((element: Element) => Element) | null | undefined;
|
||||
onLogout: () => void;
|
||||
onLoggedInMenu: (event: MouseEvent<HTMLButtonElement>) => void;
|
||||
onLoggedInMenuClose: () => void;
|
||||
}
|
||||
|
||||
/* eslint-disable react/jsx-max-depth */
|
||||
const HeaderMenu: React.FC<Props> = ({ onLogout, username, isMenuOpen = false, anchorEl, onLoggedInMenu, onLoggedInMenuClose }) => (
|
||||
<>
|
||||
<IconButton color="inherit" data-testid="header--menu-acountcircle" id="header--button-account" onClick={onLoggedInMenu}>
|
||||
<AccountCircle />
|
||||
</IconButton>
|
||||
<Menu
|
||||
anchorEl={anchorEl}
|
||||
anchorOrigin={{
|
||||
vertical: 'top',
|
||||
horizontal: 'right',
|
||||
}}
|
||||
id="header--button-account"
|
||||
onClose={onLoggedInMenuClose}
|
||||
open={isMenuOpen}
|
||||
transformOrigin={{
|
||||
vertical: 'top',
|
||||
horizontal: 'right',
|
||||
}}>
|
||||
<MenuItem disabled={true}>
|
||||
<HeaderGreetings username={username} />
|
||||
</MenuItem>
|
||||
<MenuItem id="header--button-logout" onClick={onLogout}>
|
||||
{'Logout'}
|
||||
</MenuItem>
|
||||
</Menu>
|
||||
</>
|
||||
);
|
||||
|
||||
export default HeaderMenu;
|
||||
71
src/components/Header/HeaderRight.tsx
Normal file
71
src/components/Header/HeaderRight.tsx
Normal file
@@ -0,0 +1,71 @@
|
||||
import React, { useState, useEffect, MouseEvent } from 'react';
|
||||
|
||||
import Button from '../../muiComponents/Button';
|
||||
|
||||
import { RightSide } from './styles';
|
||||
import HeaderToolTip from './HeaderToolTip';
|
||||
import HeaderMenu from './HeaderMenu';
|
||||
|
||||
interface Props {
|
||||
withoutSearch?: boolean;
|
||||
username?: string;
|
||||
onToggleLogin: () => void;
|
||||
onOpenRegistryInfoDialog: () => void;
|
||||
onToggleMobileNav: () => void;
|
||||
onLogout: () => void;
|
||||
}
|
||||
|
||||
const HeaderRight: React.FC<Props> = ({ withoutSearch = false, username, onToggleLogin, onLogout, onToggleMobileNav, onOpenRegistryInfoDialog }) => {
|
||||
const [anchorEl, setAnchorEl] = useState();
|
||||
const [isMenuOpen, setIsMenuOpen] = useState();
|
||||
|
||||
useEffect(() => {
|
||||
setIsMenuOpen(Boolean(anchorEl));
|
||||
}, [anchorEl]);
|
||||
|
||||
/**
|
||||
* opens popover menu for logged in user.
|
||||
*/
|
||||
const handleLoggedInMenu = (event: MouseEvent<HTMLButtonElement>) => {
|
||||
setAnchorEl(event.currentTarget);
|
||||
};
|
||||
|
||||
/**
|
||||
* closes popover menu for logged in user
|
||||
*/
|
||||
const handleLoggedInMenuClose = () => {
|
||||
setAnchorEl(null);
|
||||
};
|
||||
|
||||
/**
|
||||
* close/open popover menu for logged in users.
|
||||
*/
|
||||
const handleToggleLogin = () => {
|
||||
setAnchorEl(null);
|
||||
onToggleLogin();
|
||||
};
|
||||
|
||||
return (
|
||||
<RightSide>
|
||||
{!withoutSearch && <HeaderToolTip onClick={onToggleMobileNav} title={'Search packages'} tooltipIconType={'search'} />}
|
||||
<HeaderToolTip title={'Documentation'} tooltipIconType={'help'} />
|
||||
<HeaderToolTip onClick={onOpenRegistryInfoDialog} title={'Registry Information'} tooltipIconType={'info'} />
|
||||
{username ? (
|
||||
<HeaderMenu
|
||||
anchorEl={anchorEl}
|
||||
isMenuOpen={isMenuOpen}
|
||||
onLoggedInMenu={handleLoggedInMenu}
|
||||
onLoggedInMenuClose={handleLoggedInMenuClose}
|
||||
onLogout={onLogout}
|
||||
username={username}
|
||||
/>
|
||||
) : (
|
||||
<Button color="inherit" data-testid="header--button-login" onClick={handleToggleLogin}>
|
||||
{'Login'}
|
||||
</Button>
|
||||
)}
|
||||
</RightSide>
|
||||
);
|
||||
};
|
||||
|
||||
export default HeaderRight;
|
||||
19
src/components/Header/HeaderToolTip.tsx
Normal file
19
src/components/Header/HeaderToolTip.tsx
Normal file
@@ -0,0 +1,19 @@
|
||||
import React from 'react';
|
||||
|
||||
import Tooltip from '../../muiComponents/Tooltip';
|
||||
|
||||
import HeaderToolTipIcon, { TooltipIconType } from './HeaderToolTipIcon';
|
||||
|
||||
interface Props {
|
||||
title: string;
|
||||
tooltipIconType: TooltipIconType;
|
||||
onClick?: () => void;
|
||||
}
|
||||
|
||||
const HeaderToolTip: React.FC<Props> = ({ tooltipIconType, title, onClick }) => (
|
||||
<Tooltip disableFocusListener={true} title={title}>
|
||||
<HeaderToolTipIcon onClick={onClick} tooltipIconType={tooltipIconType} />
|
||||
</Tooltip>
|
||||
);
|
||||
|
||||
export default HeaderToolTip;
|
||||
44
src/components/Header/HeaderToolTipIcon.tsx
Normal file
44
src/components/Header/HeaderToolTipIcon.tsx
Normal file
@@ -0,0 +1,44 @@
|
||||
import React from 'react';
|
||||
import Info from '@material-ui/icons/Info';
|
||||
import Help from '@material-ui/icons/Help';
|
||||
import Search from '@material-ui/icons/Search';
|
||||
|
||||
import IconButton from '../../muiComponents/IconButton';
|
||||
|
||||
import { IconSearchButton, StyledExternalLink } from './styles';
|
||||
|
||||
export type TooltipIconType = 'search' | 'help' | 'info';
|
||||
|
||||
interface Props {
|
||||
tooltipIconType: TooltipIconType;
|
||||
onClick?: () => void;
|
||||
}
|
||||
|
||||
const HeaderToolTipIcon: React.FC<Props> = ({ tooltipIconType, onClick }) => {
|
||||
switch (tooltipIconType) {
|
||||
case 'help':
|
||||
return (
|
||||
<StyledExternalLink blank={true} data-testid={'header--tooltip-documentation'} to={'https://verdaccio.org/docs/en/installation'}>
|
||||
<IconButton color={'inherit'}>
|
||||
<Help />
|
||||
</IconButton>
|
||||
</StyledExternalLink>
|
||||
);
|
||||
case 'info':
|
||||
return (
|
||||
<IconButton color="inherit" data-testid={'header--tooltip-info'} id="header--button-registryInfo" onClick={onClick}>
|
||||
<Info />
|
||||
</IconButton>
|
||||
);
|
||||
case 'search':
|
||||
return (
|
||||
<IconSearchButton color="inherit" onClick={onClick}>
|
||||
<Search />
|
||||
</IconSearchButton>
|
||||
);
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
export default HeaderToolTipIcon;
|
||||
@@ -1,5 +1,366 @@
|
||||
// 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 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 in state should load the component in logged in state 1`] = `
|
||||
<header
|
||||
class="MuiPaper-root MuiPaper-elevation4 MuiAppBar-root MuiAppBar-positionStatic css-rfunvc emotion-9 MuiAppBar-colorPrimary"
|
||||
>
|
||||
<div
|
||||
class="MuiToolbar-root MuiToolbar-regular css-1pwdmmq emotion-8 MuiToolbar-gutters"
|
||||
>
|
||||
<div
|
||||
class="MuiToolbar-root MuiToolbar-regular css-1vacr9s emotion-4 MuiToolbar-gutters"
|
||||
>
|
||||
<a
|
||||
class="css-1dk30lc"
|
||||
href="/"
|
||||
>
|
||||
<div
|
||||
class="css-1sifsqk emotion-0"
|
||||
/>
|
||||
</a>
|
||||
<div
|
||||
class="css-13zpdre emotion-3"
|
||||
>
|
||||
<div
|
||||
class="css-1crzyyo emotion-2"
|
||||
>
|
||||
<div
|
||||
aria-expanded="false"
|
||||
aria-haspopup="listbox"
|
||||
aria-owns="react-autowhatever-1"
|
||||
class="react-autosuggest__container"
|
||||
role="combobox"
|
||||
>
|
||||
<div
|
||||
aria-autocomplete="list"
|
||||
aria-controls="react-autowhatever-1"
|
||||
class="MuiFormControl-root MuiTextField-root react-autosuggest__input MuiFormControl-fullWidth"
|
||||
>
|
||||
<div
|
||||
class="MuiInputBase-root MuiInput-root css-n9ojyg MuiInput-underline MuiInputBase-fullWidth MuiInput-fullWidth MuiInputBase-formControl MuiInput-formControl MuiInputBase-adornedStart"
|
||||
>
|
||||
<div
|
||||
class="MuiInputAdornment-root css-16qv2i2 MuiInputAdornment-positionStart"
|
||||
>
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
class="MuiSvgIcon-root"
|
||||
focusable="false"
|
||||
role="presentation"
|
||||
viewBox="0 0 24 24"
|
||||
>
|
||||
<path
|
||||
d="M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"
|
||||
/>
|
||||
</svg>
|
||||
</div>
|
||||
<input
|
||||
aria-invalid="false"
|
||||
autocomplete="off"
|
||||
class="MuiInputBase-input MuiInput-input css-hodoyq MuiInputBase-inputAdornedStart"
|
||||
placeholder="Search Packages"
|
||||
type="text"
|
||||
value=""
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="MuiPaper-root MuiPaper-elevation1 react-autosuggest__suggestions-container css-cfo6a emotion-1"
|
||||
id="react-autowhatever-1"
|
||||
role="listbox"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="MuiToolbar-root MuiToolbar-regular css-m61s5i emotion-7 MuiToolbar-gutters"
|
||||
>
|
||||
<button
|
||||
class="MuiButtonBase-root MuiIconButton-root css-1y1xi9f emotion-5 MuiIconButton-colorInherit"
|
||||
tabindex="0"
|
||||
type="button"
|
||||
>
|
||||
<span
|
||||
class="MuiIconButton-label"
|
||||
>
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
class="MuiSvgIcon-root"
|
||||
focusable="false"
|
||||
role="presentation"
|
||||
viewBox="0 0 24 24"
|
||||
>
|
||||
<path
|
||||
d="M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"
|
||||
/>
|
||||
</svg>
|
||||
</span>
|
||||
<span
|
||||
class="MuiTouchRipple-root"
|
||||
/>
|
||||
</button>
|
||||
<a
|
||||
class="css-1aacqdd emotion-6"
|
||||
data-testid="header--tooltip-documentation"
|
||||
href="https://verdaccio.org/docs/en/installation"
|
||||
target="_blank"
|
||||
>
|
||||
<button
|
||||
class="MuiButtonBase-root MuiIconButton-root MuiIconButton-colorInherit"
|
||||
tabindex="0"
|
||||
type="button"
|
||||
>
|
||||
<span
|
||||
class="MuiIconButton-label"
|
||||
>
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
class="MuiSvgIcon-root"
|
||||
focusable="false"
|
||||
role="presentation"
|
||||
viewBox="0 0 24 24"
|
||||
>
|
||||
<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"
|
||||
/>
|
||||
</svg>
|
||||
</span>
|
||||
<span
|
||||
class="MuiTouchRipple-root"
|
||||
/>
|
||||
</button>
|
||||
</a>
|
||||
<button
|
||||
class="MuiButtonBase-root MuiIconButton-root MuiIconButton-colorInherit"
|
||||
data-testid="header--tooltip-info"
|
||||
id="header--button-registryInfo"
|
||||
tabindex="0"
|
||||
type="button"
|
||||
>
|
||||
<span
|
||||
class="MuiIconButton-label"
|
||||
>
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
class="MuiSvgIcon-root"
|
||||
focusable="false"
|
||||
role="presentation"
|
||||
viewBox="0 0 24 24"
|
||||
>
|
||||
<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"
|
||||
/>
|
||||
</svg>
|
||||
</span>
|
||||
<span
|
||||
class="MuiTouchRipple-root"
|
||||
/>
|
||||
</button>
|
||||
<button
|
||||
class="MuiButtonBase-root MuiIconButton-root MuiIconButton-colorInherit"
|
||||
data-testid="header--menu-acountcircle"
|
||||
id="header--button-account"
|
||||
tabindex="0"
|
||||
type="button"
|
||||
>
|
||||
<span
|
||||
class="MuiIconButton-label"
|
||||
>
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
class="MuiSvgIcon-root"
|
||||
focusable="false"
|
||||
role="presentation"
|
||||
viewBox="0 0 24 24"
|
||||
>
|
||||
<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"
|
||||
/>
|
||||
</svg>
|
||||
</span>
|
||||
<span
|
||||
class="MuiTouchRipple-root"
|
||||
/>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
`;
|
||||
|
||||
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>"`;
|
||||
exports[`<Header /> component with logged in state should load the component in logged out state 1`] = `
|
||||
<header
|
||||
class="MuiPaper-root MuiPaper-elevation4 MuiAppBar-root MuiAppBar-positionStatic css-rfunvc emotion-9 MuiAppBar-colorPrimary"
|
||||
>
|
||||
<div
|
||||
class="MuiToolbar-root MuiToolbar-regular css-1pwdmmq emotion-8 MuiToolbar-gutters"
|
||||
>
|
||||
<div
|
||||
class="MuiToolbar-root MuiToolbar-regular css-1vacr9s emotion-4 MuiToolbar-gutters"
|
||||
>
|
||||
<a
|
||||
class="css-1dk30lc"
|
||||
href="/"
|
||||
>
|
||||
<div
|
||||
class="css-1sifsqk emotion-0"
|
||||
/>
|
||||
</a>
|
||||
<div
|
||||
class="css-13zpdre emotion-3"
|
||||
>
|
||||
<div
|
||||
class="css-1crzyyo emotion-2"
|
||||
>
|
||||
<div
|
||||
aria-expanded="false"
|
||||
aria-haspopup="listbox"
|
||||
aria-owns="react-autowhatever-1"
|
||||
class="react-autosuggest__container"
|
||||
role="combobox"
|
||||
>
|
||||
<div
|
||||
aria-autocomplete="list"
|
||||
aria-controls="react-autowhatever-1"
|
||||
class="MuiFormControl-root MuiTextField-root react-autosuggest__input MuiFormControl-fullWidth"
|
||||
>
|
||||
<div
|
||||
class="MuiInputBase-root MuiInput-root css-n9ojyg MuiInput-underline MuiInputBase-fullWidth MuiInput-fullWidth MuiInputBase-formControl MuiInput-formControl MuiInputBase-adornedStart"
|
||||
>
|
||||
<div
|
||||
class="MuiInputAdornment-root css-16qv2i2 MuiInputAdornment-positionStart"
|
||||
>
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
class="MuiSvgIcon-root"
|
||||
focusable="false"
|
||||
role="presentation"
|
||||
viewBox="0 0 24 24"
|
||||
>
|
||||
<path
|
||||
d="M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"
|
||||
/>
|
||||
</svg>
|
||||
</div>
|
||||
<input
|
||||
aria-invalid="false"
|
||||
autocomplete="off"
|
||||
class="MuiInputBase-input MuiInput-input css-hodoyq MuiInputBase-inputAdornedStart"
|
||||
placeholder="Search Packages"
|
||||
type="text"
|
||||
value=""
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="MuiPaper-root MuiPaper-elevation1 react-autosuggest__suggestions-container css-cfo6a emotion-1"
|
||||
id="react-autowhatever-1"
|
||||
role="listbox"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="MuiToolbar-root MuiToolbar-regular css-m61s5i emotion-7 MuiToolbar-gutters"
|
||||
>
|
||||
<button
|
||||
class="MuiButtonBase-root MuiIconButton-root css-1y1xi9f emotion-5 MuiIconButton-colorInherit"
|
||||
tabindex="0"
|
||||
type="button"
|
||||
>
|
||||
<span
|
||||
class="MuiIconButton-label"
|
||||
>
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
class="MuiSvgIcon-root"
|
||||
focusable="false"
|
||||
role="presentation"
|
||||
viewBox="0 0 24 24"
|
||||
>
|
||||
<path
|
||||
d="M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"
|
||||
/>
|
||||
</svg>
|
||||
</span>
|
||||
<span
|
||||
class="MuiTouchRipple-root"
|
||||
/>
|
||||
</button>
|
||||
<a
|
||||
class="css-1aacqdd emotion-6"
|
||||
data-testid="header--tooltip-documentation"
|
||||
href="https://verdaccio.org/docs/en/installation"
|
||||
target="_blank"
|
||||
>
|
||||
<button
|
||||
class="MuiButtonBase-root MuiIconButton-root MuiIconButton-colorInherit"
|
||||
tabindex="0"
|
||||
type="button"
|
||||
>
|
||||
<span
|
||||
class="MuiIconButton-label"
|
||||
>
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
class="MuiSvgIcon-root"
|
||||
focusable="false"
|
||||
role="presentation"
|
||||
viewBox="0 0 24 24"
|
||||
>
|
||||
<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"
|
||||
/>
|
||||
</svg>
|
||||
</span>
|
||||
<span
|
||||
class="MuiTouchRipple-root"
|
||||
/>
|
||||
</button>
|
||||
</a>
|
||||
<button
|
||||
class="MuiButtonBase-root MuiIconButton-root MuiIconButton-colorInherit"
|
||||
data-testid="header--tooltip-info"
|
||||
id="header--button-registryInfo"
|
||||
tabindex="0"
|
||||
type="button"
|
||||
>
|
||||
<span
|
||||
class="MuiIconButton-label"
|
||||
>
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
class="MuiSvgIcon-root"
|
||||
focusable="false"
|
||||
role="presentation"
|
||||
viewBox="0 0 24 24"
|
||||
>
|
||||
<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"
|
||||
/>
|
||||
</svg>
|
||||
</span>
|
||||
<span
|
||||
class="MuiTouchRipple-root"
|
||||
/>
|
||||
</button>
|
||||
<button
|
||||
class="MuiButtonBase-root MuiButton-root MuiButton-text MuiButton-colorInherit"
|
||||
data-testid="header--button-login"
|
||||
tabindex="0"
|
||||
type="button"
|
||||
>
|
||||
<span
|
||||
class="MuiButton-label"
|
||||
>
|
||||
Login
|
||||
</span>
|
||||
<span
|
||||
class="MuiTouchRipple-root"
|
||||
/>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
`;
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import styled, { css } from 'react-emotion';
|
||||
import AppBar from '@material-ui/core/AppBar';
|
||||
import Toolbar from '@material-ui/core/Toolbar';
|
||||
import IconButton from '@material-ui/core/IconButton';
|
||||
|
||||
import colors from '../../utils/styles/colors';
|
||||
import mq from '../../utils/styles/media';
|
||||
import IconButton from '../../muiComponents/IconButton';
|
||||
import ExternalLink from '../Link';
|
||||
|
||||
export const InnerNavBar = styled(Toolbar)({
|
||||
'&&': {
|
||||
@@ -74,9 +75,8 @@ export const NavBar = styled(AppBar)`
|
||||
min-height: 60px;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
${() => {
|
||||
// @ts-ignore
|
||||
return mq.medium(css`
|
||||
${() =>
|
||||
mq.medium(css`
|
||||
${SearchWrapper} {
|
||||
display: flex;
|
||||
}
|
||||
@@ -86,25 +86,26 @@ export const NavBar = styled(AppBar)`
|
||||
${MobileNavBar} {
|
||||
display: none;
|
||||
}
|
||||
`);
|
||||
}};
|
||||
${() => {
|
||||
// @ts-ignore
|
||||
return mq.large(css`
|
||||
`)};
|
||||
${() =>
|
||||
mq.large(css`
|
||||
${InnerNavBar} {
|
||||
padding: 0 20px;
|
||||
}
|
||||
`);
|
||||
}};
|
||||
${() => {
|
||||
// @ts-ignore
|
||||
return mq.xlarge(css`
|
||||
`)};
|
||||
${() =>
|
||||
mq.xlarge(css`
|
||||
${InnerNavBar} {
|
||||
max-width: 1240px;
|
||||
width: 100%;
|
||||
margin: 0 auto;
|
||||
}
|
||||
`);
|
||||
}};
|
||||
`)};
|
||||
}
|
||||
`;
|
||||
|
||||
export const StyledExternalLink = styled(ExternalLink)({
|
||||
'&&': {
|
||||
color: 'white',
|
||||
},
|
||||
});
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import React from 'react';
|
||||
import { mount } from 'enzyme';
|
||||
|
||||
import Help from './Help';
|
||||
|
||||
describe('<Help /> component', () => {
|
||||
|
||||
@@ -1,18 +1,19 @@
|
||||
import Button from '@material-ui/core/Button';
|
||||
import CardActions from '@material-ui/core/CardActions';
|
||||
import CardContent from '@material-ui/core/CardContent';
|
||||
import Typography from '@material-ui/core/Typography';
|
||||
import React, { Fragment } from 'react';
|
||||
|
||||
import { getRegistryURL } from '../../utils/url';
|
||||
import CopyToClipBoard from '../CopyToClipBoard';
|
||||
import Button from '../../muiComponents/Button';
|
||||
import { default as Typography } from '../../muiComponents/Heading';
|
||||
import Text from '../../muiComponents/Text';
|
||||
|
||||
import { CardStyled as Card, HelpTitle } from './styles';
|
||||
|
||||
function renderHeadingClipboardSegments(title: string, text: string): React.ReactNode {
|
||||
return (
|
||||
<Fragment>
|
||||
<Typography variant={'body1'}>{title}</Typography>
|
||||
<Text variant={'body1'}>{title}</Text>
|
||||
<CopyToClipBoard text={text} />
|
||||
</Fragment>
|
||||
);
|
||||
@@ -32,10 +33,10 @@ const Help: React.FC = () => {
|
||||
</HelpTitle>
|
||||
{renderHeadingClipboardSegments('1. Login', `npm adduser --registry ${registryUrl}`)}
|
||||
{renderHeadingClipboardSegments('2. Publish', `npm publish --registry ${registryUrl}`)}
|
||||
<Typography variant="body2">{'3. Refresh this page.'}</Typography>
|
||||
<Text variant="body2">{'3. Refresh this page.'}</Text>
|
||||
</CardContent>
|
||||
<CardActions>
|
||||
<Button color="primary" href="https://verdaccio.org/docs/en/installation" size="small" target="_blank">
|
||||
<Button color="primary" href="https://verdaccio.org/docs/en/installation" size="small">
|
||||
{'Learn More'}
|
||||
</Button>
|
||||
</CardActions>
|
||||
|
||||
@@ -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 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>"`;
|
||||
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><h6 class=\\"MuiTypography-root css-zg2fwz e1wgaou61 MuiTypography-h6 MuiTypography-colorTextSecondary MuiTypography-gutterBottom\\">To publish your first package just:</h6><p class=\\"MuiTypography-root MuiTypography-body1\\">1. Login</p><div class=\\"css-1mta3t8 eb8w2fo0\\"><span class=\\"css-lh0wgu 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-lh0wgu 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-textSizeSmall MuiButton-sizeSmall\\" tabindex=\\"0\\" aria-disabled=\\"false\\" href=\\"https://verdaccio.org/docs/en/installation\\"><span class=\\"MuiButton-label\\">Learn More</span><span class=\\"MuiTouchRipple-root\\"></span></a></div></div>"`;
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import Card from '@material-ui/core/Card';
|
||||
import Typography from '@material-ui/core/Typography';
|
||||
import styled from 'react-emotion';
|
||||
|
||||
import { default as Typography } from '../../muiComponents/Heading';
|
||||
import Card from '../../muiComponents/Card';
|
||||
|
||||
export const CardStyled = styled(Card)({
|
||||
'&&': {
|
||||
width: '600px',
|
||||
|
||||
@@ -3,7 +3,6 @@ import capitalize from 'lodash/capitalize';
|
||||
import { Breakpoint } from '@material-ui/core/styles/createBreakpoints';
|
||||
|
||||
import { Svg, Img, ImgWrapper } from './styles';
|
||||
|
||||
import brazil from './img/brazil.svg';
|
||||
import china from './img/china.svg';
|
||||
import india from './img/india.svg';
|
||||
@@ -65,14 +64,12 @@ export interface Props {
|
||||
}
|
||||
|
||||
const Icon: React.FC<Props> = ({ className, name, size = 'sm', img = false, pointer = false, ...props }) => {
|
||||
// @ts-ignore
|
||||
const title = capitalize(name);
|
||||
const title = capitalize(name.toString());
|
||||
return img ? (
|
||||
<ImgWrapper className={className} name={name} pointer={pointer} size={size} title={title} {...props}>
|
||||
<Img alt={title} src={Icons[name]} />
|
||||
</ImgWrapper>
|
||||
) : (
|
||||
// @ts-ignore
|
||||
<Svg className={className} pointer={pointer} size={size} {...props}>
|
||||
<title>{title}</title>
|
||||
<use xlinkHref={`${Icons[name]}#${name}`} />
|
||||
|
||||
@@ -1,11 +1,54 @@
|
||||
import React from 'react';
|
||||
import { mount } from 'enzyme';
|
||||
import { render } from '@testing-library/react';
|
||||
|
||||
import { DetailContext, DetailContextProps } from '../../pages/Version';
|
||||
|
||||
import data from './__partials__/data.json';
|
||||
import Install from './Install';
|
||||
|
||||
describe('<Install /> component', () => {
|
||||
test('should render the component in default state', () => {
|
||||
const wrapper = mount(<Install />);
|
||||
expect(wrapper.html()).toMatchSnapshot();
|
||||
const detailContextValue: Partial<DetailContextProps> = {
|
||||
packageName: 'foo',
|
||||
packageMeta: data,
|
||||
};
|
||||
|
||||
const ComponentToBeRendered: React.FC = () => (
|
||||
<DetailContext.Provider value={detailContextValue}>
|
||||
<Install />
|
||||
</DetailContext.Provider>
|
||||
);
|
||||
|
||||
/* eslint-disable react/jsx-no-bind*/
|
||||
describe('<Install />', () => {
|
||||
test('renders correctly', () => {
|
||||
const { container } = render(<ComponentToBeRendered />);
|
||||
expect(container.firstChild).toMatchSnapshot();
|
||||
});
|
||||
|
||||
test('should have 3 children', () => {
|
||||
const { getByTestId } = render(<ComponentToBeRendered />);
|
||||
const installListItems = getByTestId('installList');
|
||||
// installitems + subHeader = 4
|
||||
expect(installListItems.children.length).toBe(4);
|
||||
});
|
||||
|
||||
test('should have the element NPM', () => {
|
||||
const { getByTestId, queryByText } = render(<ComponentToBeRendered />);
|
||||
expect(getByTestId('installListItem-npm')).toBeTruthy();
|
||||
expect(queryByText(`npm install ${detailContextValue.packageName}`)).toBeTruthy();
|
||||
expect(queryByText('Install using npm')).toBeTruthy();
|
||||
});
|
||||
|
||||
test('should have the element YARN', () => {
|
||||
const { getByTestId, queryByText } = render(<ComponentToBeRendered />);
|
||||
expect(getByTestId('installListItem-yarn')).toBeTruthy();
|
||||
expect(queryByText(`yarn add ${detailContextValue.packageName}`)).toBeTruthy();
|
||||
expect(queryByText('Install using yarn')).toBeTruthy();
|
||||
});
|
||||
|
||||
test('should have the element PNPM', () => {
|
||||
const { getByTestId, queryByText } = render(<ComponentToBeRendered />);
|
||||
expect(getByTestId('installListItem-pnpm')).toBeTruthy();
|
||||
expect(queryByText(`pnpm install ${detailContextValue.packageName}`)).toBeTruthy();
|
||||
expect(queryByText('Install using pnpm')).toBeTruthy();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,54 +1,34 @@
|
||||
import List from '@material-ui/core/List';
|
||||
import React, { Component } from 'react';
|
||||
import React, { useContext } from 'react';
|
||||
import styled from 'react-emotion';
|
||||
|
||||
import { DetailContextConsumer, VersionPageConsumerProps } from '../../pages/Version';
|
||||
import { DetailContext } from '../../pages/Version';
|
||||
import { fontWeight } from '../../utils/styles/sizes';
|
||||
import Text from '../../muiComponents/Text';
|
||||
import List from '../../muiComponents/List';
|
||||
|
||||
import CopyToClipBoard from '../CopyToClipBoard';
|
||||
import InstallListItem, { DependencyManager } from './InstallListItem';
|
||||
|
||||
// logos of package managers
|
||||
import npm from './img/npm.svg';
|
||||
import pnpm from './img/pnpm.svg';
|
||||
import yarn from './img/yarn.svg';
|
||||
const StyledText = styled(Text)({
|
||||
fontWeight: fontWeight.bold,
|
||||
textTransform: 'capitalize',
|
||||
});
|
||||
|
||||
import { Heading, InstallItem, PackageMangerAvatar, InstallListItemText } from './styles';
|
||||
const Install: React.FC = () => {
|
||||
const detailContext = useContext(DetailContext);
|
||||
|
||||
class Install extends Component {
|
||||
public render(): JSX.Element {
|
||||
return (
|
||||
<DetailContextConsumer>
|
||||
{(context: Partial<VersionPageConsumerProps>) => {
|
||||
return context && context.packageName && this.renderCopyCLI(context);
|
||||
}}
|
||||
</DetailContextConsumer>
|
||||
);
|
||||
const { packageMeta, packageName } = detailContext;
|
||||
|
||||
if (!packageMeta || !packageName) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public renderCopyCLI = ({ packageName = '' }: Partial<VersionPageConsumerProps>) => {
|
||||
return (
|
||||
<>
|
||||
<List subheader={<Heading variant={'subtitle1'}>{'Installation'}</Heading>}>{this.renderListItems(packageName)}</List>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
public renderListItems = (packageName: string) => {
|
||||
return (
|
||||
<>
|
||||
<InstallItem button={true}>
|
||||
<PackageMangerAvatar alt={'npm logo'} src={npm} />
|
||||
<InstallListItemText primary={<CopyToClipBoard text={`npm install ${packageName}`} />} secondary={'Install using NPM'} />
|
||||
</InstallItem>
|
||||
<InstallItem button={true}>
|
||||
<PackageMangerAvatar alt={'yarn logo'} src={yarn} />
|
||||
<InstallListItemText primary={<CopyToClipBoard text={`yarn add ${packageName}`} />} secondary={'Install using Yarn'} />
|
||||
</InstallItem>
|
||||
<InstallItem button={true}>
|
||||
<PackageMangerAvatar alt={'pnpm logo'} src={pnpm} />
|
||||
<InstallListItemText primary={<CopyToClipBoard text={`pnpm install ${packageName}`} />} secondary={'Install using PNPM'} />
|
||||
</InstallItem>
|
||||
</>
|
||||
);
|
||||
};
|
||||
}
|
||||
return (
|
||||
<List data-testid={'installList'} subheader={<StyledText variant={'subtitle1'}>{'Installation'}</StyledText>}>
|
||||
<InstallListItem dependencyManager={DependencyManager.NPM} packageName={packageName} />
|
||||
<InstallListItem dependencyManager={DependencyManager.YARN} packageName={packageName} />
|
||||
<InstallListItem dependencyManager={DependencyManager.PNPM} packageName={packageName} />
|
||||
</List>
|
||||
);
|
||||
};
|
||||
|
||||
export default Install;
|
||||
|
||||
70
src/components/Install/InstallListItem.tsx
Normal file
70
src/components/Install/InstallListItem.tsx
Normal file
@@ -0,0 +1,70 @@
|
||||
import React from 'react';
|
||||
import styled from 'react-emotion';
|
||||
import ListItemText from '@material-ui/core/ListItemText';
|
||||
|
||||
import CopyToClipBoard from '../CopyToClipBoard';
|
||||
import Avatar from '../../muiComponents/Avatar';
|
||||
import ListItem from '../../muiComponents/ListItem';
|
||||
|
||||
// logos of package managers
|
||||
import npmLogo from './img/npm.svg';
|
||||
import pnpmLogo from './img/pnpm.svg';
|
||||
import yarnLogo from './img/yarn.svg';
|
||||
|
||||
const InstallItem = styled(ListItem)({
|
||||
padding: 0,
|
||||
':hover': {
|
||||
backgroundColor: 'transparent',
|
||||
},
|
||||
});
|
||||
|
||||
const InstallListItemText = styled(ListItemText)({
|
||||
padding: '0 10px',
|
||||
margin: 0,
|
||||
});
|
||||
|
||||
const PackageMangerAvatar = styled(Avatar)({
|
||||
borderRadius: '0px',
|
||||
padding: '0',
|
||||
});
|
||||
|
||||
export enum DependencyManager {
|
||||
NPM = 'npm',
|
||||
YARN = 'yarn',
|
||||
PNPM = 'pnpm',
|
||||
}
|
||||
|
||||
interface Interface {
|
||||
packageName: string;
|
||||
dependencyManager: DependencyManager;
|
||||
}
|
||||
|
||||
const InstallListItem: React.FC<Interface> = ({ packageName, dependencyManager }) => {
|
||||
switch (dependencyManager) {
|
||||
case DependencyManager.NPM:
|
||||
return (
|
||||
<InstallItem button={true} data-testid={'installListItem-npm'}>
|
||||
<PackageMangerAvatar alt="npm" src={npmLogo} />
|
||||
<InstallListItemText primary={<CopyToClipBoard text={`npm install ${packageName}`} />} secondary={'Install using npm'} />
|
||||
</InstallItem>
|
||||
);
|
||||
case DependencyManager.YARN:
|
||||
return (
|
||||
<InstallItem button={true} data-testid={'installListItem-yarn'}>
|
||||
<PackageMangerAvatar alt="yarn" src={yarnLogo} />
|
||||
<InstallListItemText primary={<CopyToClipBoard text={`yarn add ${packageName}`} />} secondary={'Install using yarn'} />
|
||||
</InstallItem>
|
||||
);
|
||||
case DependencyManager.PNPM:
|
||||
return (
|
||||
<InstallItem button={true} data-testid={'installListItem-pnpm'}>
|
||||
<PackageMangerAvatar alt={'pnpm'} src={pnpmLogo} />
|
||||
<InstallListItemText primary={<CopyToClipBoard text={`pnpm install ${packageName}`} />} secondary={'Install using pnpm'} />
|
||||
</InstallItem>
|
||||
);
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
export default InstallListItem;
|
||||
6406
src/components/Install/__partials__/data.json
Normal file
6406
src/components/Install/__partials__/data.json
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1,3 +1,215 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`<Install /> component should render the component in default state 1`] = `null`;
|
||||
exports[`<Install /> renders correctly 1`] = `
|
||||
<ul
|
||||
class="MuiList-root MuiList-padding MuiList-subheader"
|
||||
data-testid="installList"
|
||||
>
|
||||
<h6
|
||||
class="MuiTypography-root css-b8upko emotion-0 MuiTypography-subtitle1"
|
||||
>
|
||||
Installation
|
||||
</h6>
|
||||
<div
|
||||
aria-disabled="false"
|
||||
class="MuiButtonBase-root MuiListItem-root css-zw46c6 emotion-6 MuiListItem-gutters MuiListItem-button"
|
||||
data-testid="installListItem-npm"
|
||||
role="button"
|
||||
tabindex="0"
|
||||
>
|
||||
<div
|
||||
class="MuiAvatar-root css-19top7x emotion-1"
|
||||
>
|
||||
<img
|
||||
alt="npm"
|
||||
class="MuiAvatar-img"
|
||||
src="[object Object]"
|
||||
/>
|
||||
</div>
|
||||
<div
|
||||
class="MuiListItemText-root css-fipixf emotion-5 MuiListItemText-multiline"
|
||||
>
|
||||
<span
|
||||
class="MuiTypography-root MuiListItemText-primary MuiTypography-body1"
|
||||
>
|
||||
<div
|
||||
class="css-1mta3t8 emotion-4"
|
||||
>
|
||||
<span
|
||||
class="css-lh0wgu emotion-2"
|
||||
>
|
||||
npm install foo
|
||||
</span>
|
||||
<button
|
||||
class="MuiButtonBase-root MuiIconButton-root css-0 emotion-3"
|
||||
tabindex="0"
|
||||
title="Copy to Clipboard"
|
||||
type="button"
|
||||
>
|
||||
<span
|
||||
class="MuiIconButton-label"
|
||||
>
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
class="MuiSvgIcon-root"
|
||||
focusable="false"
|
||||
role="presentation"
|
||||
viewBox="0 0 24 24"
|
||||
>
|
||||
<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"
|
||||
/>
|
||||
</svg>
|
||||
</span>
|
||||
<span
|
||||
class="MuiTouchRipple-root"
|
||||
/>
|
||||
</button>
|
||||
</div>
|
||||
</span>
|
||||
<p
|
||||
class="MuiTypography-root MuiListItemText-secondary MuiTypography-body2 MuiTypography-colorTextSecondary"
|
||||
>
|
||||
Install using npm
|
||||
</p>
|
||||
</div>
|
||||
<span
|
||||
class="MuiTouchRipple-root"
|
||||
/>
|
||||
</div>
|
||||
<div
|
||||
aria-disabled="false"
|
||||
class="MuiButtonBase-root MuiListItem-root css-zw46c6 emotion-6 MuiListItem-gutters MuiListItem-button"
|
||||
data-testid="installListItem-yarn"
|
||||
role="button"
|
||||
tabindex="0"
|
||||
>
|
||||
<div
|
||||
class="MuiAvatar-root css-19top7x emotion-1"
|
||||
>
|
||||
<img
|
||||
alt="yarn"
|
||||
class="MuiAvatar-img"
|
||||
src="[object Object]"
|
||||
/>
|
||||
</div>
|
||||
<div
|
||||
class="MuiListItemText-root css-fipixf emotion-5 MuiListItemText-multiline"
|
||||
>
|
||||
<span
|
||||
class="MuiTypography-root MuiListItemText-primary MuiTypography-body1"
|
||||
>
|
||||
<div
|
||||
class="css-1mta3t8 emotion-4"
|
||||
>
|
||||
<span
|
||||
class="css-lh0wgu emotion-2"
|
||||
>
|
||||
yarn add foo
|
||||
</span>
|
||||
<button
|
||||
class="MuiButtonBase-root MuiIconButton-root css-0 emotion-3"
|
||||
tabindex="0"
|
||||
title="Copy to Clipboard"
|
||||
type="button"
|
||||
>
|
||||
<span
|
||||
class="MuiIconButton-label"
|
||||
>
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
class="MuiSvgIcon-root"
|
||||
focusable="false"
|
||||
role="presentation"
|
||||
viewBox="0 0 24 24"
|
||||
>
|
||||
<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"
|
||||
/>
|
||||
</svg>
|
||||
</span>
|
||||
<span
|
||||
class="MuiTouchRipple-root"
|
||||
/>
|
||||
</button>
|
||||
</div>
|
||||
</span>
|
||||
<p
|
||||
class="MuiTypography-root MuiListItemText-secondary MuiTypography-body2 MuiTypography-colorTextSecondary"
|
||||
>
|
||||
Install using yarn
|
||||
</p>
|
||||
</div>
|
||||
<span
|
||||
class="MuiTouchRipple-root"
|
||||
/>
|
||||
</div>
|
||||
<div
|
||||
aria-disabled="false"
|
||||
class="MuiButtonBase-root MuiListItem-root css-zw46c6 emotion-6 MuiListItem-gutters MuiListItem-button"
|
||||
data-testid="installListItem-pnpm"
|
||||
role="button"
|
||||
tabindex="0"
|
||||
>
|
||||
<div
|
||||
class="MuiAvatar-root css-19top7x emotion-1"
|
||||
>
|
||||
<img
|
||||
alt="pnpm"
|
||||
class="MuiAvatar-img"
|
||||
src="[object Object]"
|
||||
/>
|
||||
</div>
|
||||
<div
|
||||
class="MuiListItemText-root css-fipixf emotion-5 MuiListItemText-multiline"
|
||||
>
|
||||
<span
|
||||
class="MuiTypography-root MuiListItemText-primary MuiTypography-body1"
|
||||
>
|
||||
<div
|
||||
class="css-1mta3t8 emotion-4"
|
||||
>
|
||||
<span
|
||||
class="css-lh0wgu emotion-2"
|
||||
>
|
||||
pnpm install foo
|
||||
</span>
|
||||
<button
|
||||
class="MuiButtonBase-root MuiIconButton-root css-0 emotion-3"
|
||||
tabindex="0"
|
||||
title="Copy to Clipboard"
|
||||
type="button"
|
||||
>
|
||||
<span
|
||||
class="MuiIconButton-label"
|
||||
>
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
class="MuiSvgIcon-root"
|
||||
focusable="false"
|
||||
role="presentation"
|
||||
viewBox="0 0 24 24"
|
||||
>
|
||||
<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"
|
||||
/>
|
||||
</svg>
|
||||
</span>
|
||||
<span
|
||||
class="MuiTouchRipple-root"
|
||||
/>
|
||||
</button>
|
||||
</div>
|
||||
</span>
|
||||
<p
|
||||
class="MuiTypography-root MuiListItemText-secondary MuiTypography-body2 MuiTypography-colorTextSecondary"
|
||||
>
|
||||
Install using pnpm
|
||||
</p>
|
||||
</div>
|
||||
<span
|
||||
class="MuiTouchRipple-root"
|
||||
/>
|
||||
</div>
|
||||
</ul>
|
||||
`;
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
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)({
|
||||
'&&': {
|
||||
fontWeight: fontWeight.bold,
|
||||
textTransform: 'capitalize',
|
||||
},
|
||||
});
|
||||
|
||||
export const InstallItem = styled(ListItem)({
|
||||
'&&': {
|
||||
padding: 0,
|
||||
},
|
||||
'&&:hover': {
|
||||
backgroundColor: 'transparent',
|
||||
},
|
||||
});
|
||||
|
||||
export const InstallListItemText = styled(ListItemText)({
|
||||
'&&': {
|
||||
padding: '0 10px',
|
||||
margin: 0,
|
||||
},
|
||||
});
|
||||
|
||||
export const PackageMangerAvatar = styled(Avatar)({
|
||||
'&&': {
|
||||
borderRadius: '0px',
|
||||
padding: '0',
|
||||
},
|
||||
});
|
||||
@@ -1,5 +1,6 @@
|
||||
import React from 'react';
|
||||
import styled from 'react-emotion';
|
||||
|
||||
import { fontWeight } from '../../utils/styles/sizes';
|
||||
|
||||
interface Props {
|
||||
@@ -9,18 +10,20 @@ interface Props {
|
||||
modifiers?: null | undefined;
|
||||
}
|
||||
|
||||
interface WrapperProps {
|
||||
capitalize: boolean;
|
||||
weight: string;
|
||||
modifiers?: null;
|
||||
}
|
||||
|
||||
const Wrapper = styled('div')`
|
||||
font-weight: ${({ weight }) => {
|
||||
// @ts-ignore
|
||||
return fontWeight[weight];
|
||||
}};
|
||||
text-transform: ${({ capitalize }) => (capitalize ? 'capitalize' : 'none')};
|
||||
${({ modifiers }: Props) => modifiers && modifiers};
|
||||
font-weight: ${({ weight }: WrapperProps) => fontWeight[weight]};
|
||||
text-transform: ${({ capitalize }: WrapperProps) => (capitalize ? 'capitalize' : 'none')};
|
||||
${({ modifiers }: WrapperProps) => modifiers};
|
||||
`;
|
||||
|
||||
const Label: React.FC<Props> = ({ text = '', capitalize = false, weight = 'regular', ...props }) => {
|
||||
return (
|
||||
// @ts-ignore
|
||||
<Wrapper capitalize={capitalize} weight={weight} {...props}>
|
||||
{text}
|
||||
</Wrapper>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import styled, { css } from 'react-emotion';
|
||||
|
||||
import colors from '../../utils/styles/colors';
|
||||
|
||||
export const Content = styled('div')({
|
||||
@@ -11,15 +12,18 @@ export const Content = styled('div')({
|
||||
},
|
||||
});
|
||||
|
||||
interface ContainerProps {
|
||||
isLoading: boolean;
|
||||
}
|
||||
|
||||
export const Container = styled('div')`
|
||||
&& {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
min-height: 100vh;
|
||||
overflow: hidden;
|
||||
${props =>
|
||||
// @ts-ignore
|
||||
props.isLoading &&
|
||||
${({ isLoading }: ContainerProps) =>
|
||||
isLoading &&
|
||||
css`
|
||||
${Content} {
|
||||
background-color: #f5f6f8;
|
||||
|
||||
@@ -1,9 +1,4 @@
|
||||
import React, { Component } from 'react';
|
||||
import Button from '@material-ui/core/Button';
|
||||
import DialogTitle from '@material-ui/core/DialogTitle';
|
||||
import Dialog from '@material-ui/core/Dialog';
|
||||
import DialogActions from '@material-ui/core/DialogActions';
|
||||
import DialogContent from '@material-ui/core/DialogContent';
|
||||
import SnackbarContent from '@material-ui/core/SnackbarContent';
|
||||
import ErrorIcon from '@material-ui/icons/Error';
|
||||
import InputLabel from '@material-ui/core/InputLabel';
|
||||
@@ -12,6 +7,12 @@ import FormControl from '@material-ui/core/FormControl';
|
||||
import FormHelperText from '@material-ui/core/FormHelperText';
|
||||
import { css } from 'emotion';
|
||||
|
||||
import Button from '../../muiComponents/Button';
|
||||
import Dialog from '../../muiComponents/Dialog';
|
||||
import DialogTitle from '../../muiComponents/DialogTitle';
|
||||
import DialogContent from '../../muiComponents/DialogContent';
|
||||
import DialogActions from '../../muiComponents/DialogActions';
|
||||
|
||||
import * as classes from './styles';
|
||||
|
||||
interface FormFields {
|
||||
@@ -150,7 +151,7 @@ export default class LoginModal extends Component<Partial<LoginModalProps>, Logi
|
||||
});
|
||||
};
|
||||
|
||||
public renderErrorMessage(title, description): JSX.Element {
|
||||
public renderErrorMessage(title: string, description: string): JSX.Element {
|
||||
return (
|
||||
<span>
|
||||
<div>
|
||||
@@ -161,7 +162,7 @@ export default class LoginModal extends Component<Partial<LoginModalProps>, Logi
|
||||
);
|
||||
}
|
||||
|
||||
public renderMessage(title, description): JSX.Element {
|
||||
public renderMessage(title: string, description: string): JSX.Element {
|
||||
return (
|
||||
<div className={classes.loginErrorMsg} id={'client-snackbar'}>
|
||||
<ErrorIcon className={classes.loginIcon} />
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
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 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=\\"none presentation\\" 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 MuiButton-colorInherit Mui-disabled 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=\\"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>"`;
|
||||
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=\\"none presentation\\" 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 MuiButton-colorInherit Mui-disabled 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,4 +1,5 @@
|
||||
import { css } from 'emotion';
|
||||
|
||||
import colors from '../../utils/styles/colors';
|
||||
|
||||
export const loginDialog = css({
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import React from 'react';
|
||||
|
||||
import styled from 'react-emotion';
|
||||
|
||||
import logo from './img/logo.svg';
|
||||
|
||||
export enum Size {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import React from 'react';
|
||||
import Typography from '@material-ui/core/Typography';
|
||||
|
||||
import Text from '../../muiComponents/Text';
|
||||
|
||||
interface Props {
|
||||
text: string;
|
||||
@@ -7,9 +8,9 @@ interface Props {
|
||||
}
|
||||
|
||||
const NoItems: React.FC<Props> = ({ className, text }) => (
|
||||
<Typography className={className} gutterBottom={true} variant="subtitle1">
|
||||
<Text className={className} gutterBottom={true} variant="subtitle1">
|
||||
{text}
|
||||
</Typography>
|
||||
</Text>
|
||||
);
|
||||
|
||||
export default NoItems;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import React from 'react';
|
||||
import { shallow, mount } from 'enzyme';
|
||||
|
||||
import NoItems from './NoItems';
|
||||
|
||||
console.error = jest.fn();
|
||||
|
||||
@@ -1,53 +1,47 @@
|
||||
import ListItem from '@material-ui/core/ListItem';
|
||||
import Box from '@material-ui/core/Box';
|
||||
import Typography from '@material-ui/core/Typography';
|
||||
import withWidth, { isWidthUp } from '@material-ui/core/withWidth';
|
||||
import styled from 'react-emotion';
|
||||
import React, { useCallback } from 'react';
|
||||
import { RouteComponentProps, withRouter } from 'react-router-dom';
|
||||
import { useHistory } from 'react-router-dom';
|
||||
|
||||
import Button from '../../muiComponents/Button';
|
||||
import colors from '../../utils/styles/colors';
|
||||
import { spacings } from '../../utils/styles/spacings';
|
||||
|
||||
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 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 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 GO_TO_HOME_PAGE = 'Go to the home page';
|
||||
|
||||
export type NotFoundProps = RouteComponentProps & { width: Breakpoint; history };
|
||||
const EmptyPackage = styled('img')({
|
||||
width: '150px',
|
||||
margin: '0 auto',
|
||||
});
|
||||
|
||||
const HOME_LABEL = 'Home';
|
||||
const StyledHeading = styled(Typography)({
|
||||
color: colors.primary,
|
||||
marginBottom: spacings.sm,
|
||||
});
|
||||
|
||||
const renderSubTitle = (): JSX.Element => (
|
||||
<Typography variant="subtitle1">
|
||||
<div>{LABEL_NOT_FOUND}</div>
|
||||
<div>{LABEL_FOOTER_NOT_FOUND}</div>
|
||||
</Typography>
|
||||
);
|
||||
const NotFound: React.FC = () => {
|
||||
const history = useHistory();
|
||||
|
||||
const NotFound: React.FC<NotFoundProps> = ({ history, width }) => {
|
||||
const handleGomHome = useCallback(() => {
|
||||
const handleGoHome = useCallback(() => {
|
||||
history.push('/');
|
||||
}, [history]);
|
||||
|
||||
const renderList = (): JSX.Element => (
|
||||
<List>
|
||||
<ListItem button={true} divider={true} onClick={handleGomHome}>
|
||||
{HOME_LABEL}
|
||||
</ListItem>
|
||||
</List>
|
||||
);
|
||||
|
||||
return (
|
||||
<Wrapper data-testid="404">
|
||||
<Inner>
|
||||
<EmptyPackage alt="404 - Page not found" src={PackageImg} />
|
||||
<Heading className="not-found-text" variant={isWidthUp('sm', width) ? 'h2' : 'h4'}>
|
||||
{NOT_FOUND_TEXT}
|
||||
</Heading>
|
||||
{renderSubTitle()}
|
||||
<Card>{renderList()}</Card>
|
||||
</Inner>
|
||||
</Wrapper>
|
||||
<Box alignItems="center" data-testid="404" display="flex" flexDirection="column" flexGrow={1} justifyContent="center" p={2}>
|
||||
<EmptyPackage alt="404 - Page not found" src={PackageImg} />
|
||||
<StyledHeading className="not-found-text" variant="h4">
|
||||
{NOT_FOUND_TEXT}
|
||||
</StyledHeading>
|
||||
<Button onClick={handleGoHome} variant="contained">
|
||||
{GO_TO_HOME_PAGE}
|
||||
</Button>
|
||||
</Box>
|
||||
);
|
||||
};
|
||||
|
||||
export default withRouter(withWidth()(NotFound));
|
||||
export default NotFound;
|
||||
|
||||
@@ -1,17 +1,29 @@
|
||||
import React from 'react';
|
||||
import { BrowserRouter as Router } from 'react-router-dom';
|
||||
import { shallow } from 'enzyme';
|
||||
import NotFound from './NotFound';
|
||||
import { render, fireEvent } from '@testing-library/react';
|
||||
|
||||
console.error = jest.fn();
|
||||
import NotFound, { GO_TO_HOME_PAGE } from './NotFound';
|
||||
|
||||
describe('<NotFound /> component', () => {
|
||||
test('should load the component in default state', () => {
|
||||
const routerWrapper = shallow(
|
||||
const { container } = render(
|
||||
<Router>
|
||||
<NotFound />
|
||||
</Router>
|
||||
);
|
||||
expect(routerWrapper.find(NotFound)).toMatchSnapshot();
|
||||
expect(container.firstChild).toMatchSnapshot();
|
||||
});
|
||||
test('go to Home Page button click', () => {
|
||||
const spy = jest.spyOn(React, 'useCallback');
|
||||
const { getByText } = render(
|
||||
<Router>
|
||||
<NotFound />
|
||||
</Router>
|
||||
);
|
||||
|
||||
const node = getByText(GO_TO_HOME_PAGE);
|
||||
fireEvent.click(node);
|
||||
|
||||
expect(spy).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user