1
0
mirror of https://github.com/SomboChea/ui synced 2026-01-13 06:35:44 +07:00

Compare commits

...

227 Commits

Author SHA1 Message Date
Juan Picado @jotadeveloper
2a2784ba39 chore(release): 0.3.4 2019-10-26 18:20:11 +02:00
Juan Picado @jotadeveloper
6d553ea607 chore(#225): Update stack (#225) 2019-10-26 17:17:38 +02:00
Juan Picado @jotadeveloper
95f173d29a chore(#223): update stack dev 2019-10-26 14:00:06 +02:00
Ayush Sharma
531295a6d0 refactor: adds missing test spec for button click in not found (#222)
* refactor: adds missing test spec for button click in not found

* refactor: improves test description
2019-10-26 13:13:47 +02:00
Priscila Oliveira
a38b93e127 refactor(162): introduced forwardRefDivider (#218) 2019-10-26 12:19:14 +02:00
Ayush Sharma
52ed8ad67b refactor: adds download tarball spec to action bar (#220)
* refactor: adds download tarball spec to action bar

* refactor: fixes typo
2019-10-26 12:02:03 +02:00
Alfonso Austin
ae0222cf65 fix: PackageList component is converted to functional (#219) #116 2019-10-26 11:36:16 +02:00
Priscila Oliveira
2bc49f3ab7 fix(162): added forwardRef Card (#216) 2019-10-26 08:44:25 +02:00
Ayush Sharma
ade548a7da fix: adds no uplink spec (#213) 2019-10-25 20:21:48 +02:00
Ayush Sharma
6dfcd70025 refactor: adds test for registry info component (#214) 2019-10-25 10:45:42 +02:00
Anix
4498aad4bf fix(installlistitem): changed the wrong icon (#211) 2019-10-24 23:51:27 +02:00
Thomas Klein
5d6ad3d783 fix: api typings (#210) 2019-10-22 22:31:39 +02:00
Priscila Oliveira
5c06ace14a fix: routes - Replaced class by func. comp (#159)
* refactor: updated routes

* fix: fixed conflicts issues

* fix: rollback port
2019-10-19 10:49:04 +02:00
Priscila Oliveira
8c66dbc4d7 chore(#203): updated typescript to version 3.7 - beta 2019-10-18 12:36:17 +02:00
hugoazevedosoares
302f4dbd89 chore(#206): remove snapshot test and added more relevant tests 2019-10-18 10:26:08 +02:00
hugoazevedosoares
ff791a35f7 chore(#207): added more descriptive tests 2019-10-17 11:52:11 +02:00
Priscila Oliveira
f5c77ff43c fix: version Page - Replaces class by func. (#171)
* refactor: updated version page

* refactor: rollback context

* fix: added version provider
2019-10-17 07:36:41 +02:00
Juan Picado @jotadeveloper
d69fc1b260 Update README.md 2019-10-16 18:54:49 +02:00
Brian Pedersen
16b12ddc76 refactor(#204): copyToClipBoard.test, moved test of utility to it's own test 2019-10-16 10:00:05 +02:00
Juan Picado @jotadeveloper
dd532955de chore: add more info about commits 2019-10-16 07:49:21 +02:00
Juan Picado @jotadeveloper
0d581718ab chore(release): 0.3.3 2019-10-16 07:45:59 +02:00
Juan Picado @jotadeveloper
7de6983d1e chore: add some extra notes to readme 2019-10-16 07:44:26 +02:00
Sergio Hg
48c03fe472 fix(deps): remove types from dependencies (#201) 2019-10-15 20:34:45 +02:00
Thomas Klein
1abc15603e refactor: Added typings for getRecentReleases (#190) 2019-10-15 12:08:16 +02:00
Andrew Smith
6f87be68be fix: changes font size for items of the register-info component (#196)
* fix: changes font size for items of the register-info component

This changes the font size for items of the register-info component to 1rem
Fixes #193.

* chore: added missing snapshots for previous commit
2019-10-15 07:37:39 +02:00
Thomas Klein
cfb29ce325 fix: added typings for react-autosuggest (#200) 2019-10-15 07:36:35 +02:00
Daniel Ruf
245247cbed ci: use node-version (#197) 2019-10-13 18:21:43 +02:00
Thomas Klein
e0e7c07bce fix: better type inference for MediaQuery (#180) 2019-10-13 10:49:55 +02:00
Juan Picado @jotadeveloper
d1b3e6e3b5 build: e2e integration with puppeteer (#192)
* build: add e2e testing scripts

* build: add e2e testing scripts

* chore: fix script

* chore: fix script

* chore: ignore e2e normal test

* chore: fix node_latest_browser

* chore: move lint to prepare

* chore: fix lint

* chore: add local theme

* fix: e2e tests
2019-10-13 10:27:01 +02:00
Priscila Oliveira
0c4fb7da13 fix: introduced forwardRef (#181) 2019-10-12 22:26:56 +02:00
Priscila Oliveira
a8deeb9b9d fix: typography Component - Introduced ForwardRef (#179)
* refactor: introduced forwardref

* refacttor: updated ref's

* fix: fixed func's name

* fix: fixed snapshots

* fix: updated snap
2019-10-12 21:41:42 +02:00
Priscila Oliveira
82d7107de7 fix: listItem Component - Introduced ForwardRef (#183)
* refactor: introduced forwardRef

* fix: fixed button prop listItem

* chore: rollback package upgrade

* fix: fixed snap
2019-10-12 21:11:23 +02:00
Thomas Klein
d2c1130efd fix: removed tsignore for AppContext (#188) 2019-10-12 19:59:47 +02:00
Priscila Oliveira
fdbdb6303b feat: new not found component (#170)
* refactor: updated not found component

* chore: removed react-router

* refactored: applied feedbacks

* fix: removed doc folder

* refactor: rollback yarn.lock
2019-10-12 13:23:14 +02:00
Juan Picado @jotadeveloper
7529c02e58 chore: add codecov setup (#186)
* chore: add codecov setup

* chore: add dump functions

* chore: update codecov

* chore: update codecov

* chore: update codecov

* chore: update codecov

* chore: update codecov

* chore: update codecov

* chore: update codecov

* chore: update codecov

* chore: update codecov
2019-10-12 12:05:07 +02:00
Priscila Oliveira
8b86ded434 fix: introduced SvgIcon (#184) 2019-10-12 11:42:29 +02:00
Thomas Klein
3b4d823845 build: added typings for hot reload (#187) 2019-10-12 11:41:54 +02:00
Priscila Oliveira
7548c89401 fix: introduced forwardRef (#185) 2019-10-12 09:55:37 +02:00
Priscila Oliveira
af8ed8b3e3 fix: introduced ForwardRef (#177)
* refactor: introduced forwardref - circular progress

* refactor: replaced HTMLElementTagNameMap with HTMLElementDiv

* fix: fixed func name
2019-10-12 09:54:52 +02:00
Priscila Oliveira
d0d4139dd3 fix: fixed import (#176) 2019-10-12 09:26:53 +02:00
Priscila Oliveira
3888736e45 fix: fixed imports & func's name (#182) 2019-10-12 08:45:39 +02:00
Thomas Klein
752e2b963d fix: dist-tags attribute #175 (#178) 2019-10-12 00:06:18 +02:00
Antoine Chalifour
99621b6baf Refactor: Dependencies - Replaced class with func. comp (#169) 2019-10-11 15:02:53 +02:00
Thomas Klein
e0642a9d0d fix: improved typing (#174) 2019-10-10 22:20:05 +02:00
Thomas Klein
68b7171de4 chore: readded null check (#173) 2019-10-10 20:52:59 +02:00
Priscila Oliveira
d1ce82854a fix: Header Component - Replaced class by func. comp (#142)
* refactor: replaced class by func.comp

* refactor: replacing jest test by react-testing-library

* refactor: added test todos

* feat: added more unit tests

* fix: fixed tooltip import

* fix: fixed test

* fix: fixed typo

* fix: fixed imports
2019-10-08 07:47:11 +02:00
Priscila Oliveira
ae73772a37 feat(eslint-config): add order rule in import
* refactor: added eslint-plugin-import

* refactor: disable some rules for muiComponents

* fix: fixed import
2019-10-07 22:19:18 +02:00
Antoine Chalifour
950f6defca refactor: migrate Uplinks to function component (#165) 2019-10-07 14:13:05 +02:00
Juan Picado @jotadeveloper
0ca89dcbe7 Merge pull request #153 from antoinechalifour/fix-ts-ignore
Fix a few ts-ignore
2019-10-07 07:52:47 +02:00
antoinechalifour
f4da5e692d fix(Developers): remove compilation warnings 2019-10-06 18:32:51 +02:00
antoinechalifour
6f52838531 fix: media query ts ignore 2019-10-06 18:32:51 +02:00
antoinechalifour
a8eb1f36fc fix(api): remove unnecessary ts ignore 2019-10-06 18:32:51 +02:00
antoinechalifour
1fb0bf96d1 fix(Footer): remove unnecessary ts ignore 2019-10-06 18:32:51 +02:00
antoinechalifour
f6eb74736a fix(App): ts ignore 2019-10-06 18:32:51 +02:00
Antoine Chalifour
35d691c1e0 fix: fix DependencyBlock props interface 2019-10-06 18:32:51 +02:00
Antoine Chalifour
b35baa069f fix: add new window property to interface definition 2019-10-06 18:32:51 +02:00
Antoine Chalifour
7a8b158188 fix: remove unnecessary ts ignore 2019-10-06 18:32:51 +02:00
Antoine Chalifour
852f6eeb22 fix: improve jest mock typings 2019-10-06 18:32:51 +02:00
Antoine Chalifour
b1804d7644 fix: remove ts ignore from some components 2019-10-06 18:31:30 +02:00
Antoine Chalifour
32f4389b73 fix: remove unnecessary ts ignore 2019-10-06 18:31:30 +02:00
Antoine Chalifour
3166673875 fix: spinner typings 2019-10-06 18:31:30 +02:00
Priscila Oliveira
626bcce5cb fix: introduced forwardRef (#163) 2019-10-06 18:30:05 +02:00
Priscila Oliveira
909a8d9fb8 fix: introduced forwardRef (#164) 2019-10-06 17:17:36 +02:00
Priscila Oliveira
9eb698f7e1 fix: install Component - Replaced class by func. comp (#152)
* refactor: convert class to func comp

* fix: fixed wrong maintainer type

* refactor: created a partials folder

* fix: fixed test
2019-10-06 16:55:49 +02:00
Andrew Hughson
43a9628ec4 fix: incorrect Tooltip import in avatar component (#160) 2019-10-06 16:01:58 +02:00
Andrew Hughson
d2f1f1c06a refactor: convert Author component to hooks (#150) 2019-10-06 15:44:48 +02:00
Antoine Chalifour
a365ec548a feat: use React.lazy for loading components (#158) 2019-10-05 20:13:36 +02:00
Andrew Hughson
f1f8f8ae3f fix: convert Dist component to hooks (#156) 2019-10-05 10:33:31 +02:00
Antoine Chalifour
583ddd555a fix: some warnings in console (#155)
* fix: remove react emotion selector warning

* fix: validate DOM nesting
2019-10-04 23:19:50 +02:00
Juan Picado @jotadeveloper
7bd9eb7a07 fix: lock file was corrupted 2019-10-04 19:12:00 +02:00
Thomas Klein
61a400fbd8 chore: added typings (#157) 2019-10-04 14:56:20 +02:00
Priscila Oliveira
f84fd79c5b fix: detailContainer Component - Replaced class by func. comp (#130)
* refactor: coverted class comp. into func.comp

* refactor: added forward ref comp.

* fix: fixed external link color

* fix: fixed typo

* refactor: applied feedbacks
2019-10-03 18:17:04 +02:00
Juan Picado @jotadeveloper
28c982a7da chore: trigger ci on pr 2019-10-03 14:19:13 +02:00
Suman Bhattarai
f8e3013b59 fix: tarball download not working on Firefox and Edge (#144)
* fix tarball download not working on firefox and edge

* update lastModified to be a date number
2019-10-03 12:47:30 +02:00
Priscila Oliveira
1d705da38c feat: version Component - Replaced classes by func. comp (#129)
* refactor: replaced classes by func comp

* fix: fixed space margin

* refactor: changed display logic

* fix: fixed types

* fix: fixed Version test

* fix: fixed version style
2019-10-03 10:27:08 +02:00
Jesús Márquez
1a74c08b5d chore: update react version to 16.10.0 (#149) 2019-10-03 09:11:52 +02:00
Thomas Klein
f8a1f2cbb8 feat: upgraded typescript to 3.6.3 (#145) 2019-10-02 22:32:31 +02:00
Gagan Deep
74576bda12 fix: linter error fixed (#143) 2019-10-02 21:52:27 +02:00
Daniel Ruf
cf050f234d docs: remove contributing link (#146) 2019-10-02 17:01:20 +02:00
Antoine Chalifour
e14729006a fix: warning about modules with names differing in casing (#148) 2019-10-02 16:46:29 +02:00
Juan Picado @jotadeveloper
584f4c141e chore(release): 0.3.2 2019-09-30 20:28:36 +02:00
Juan Picado @jotadeveloper
91d818c478 fix: sidebar view on small screens (#136) 2019-09-30 20:28:02 +02:00
Sergio Hg
ae6e479f16 Merge pull request #139 from verdaccio/security-deps
chore(deps): bump detect-secrets for enhanced dev workflow
2019-09-29 23:46:38 +02:00
Juan Picado @jotadeveloper
18ef27eac6 Merge branch 'master' into security-deps 2019-09-29 20:21:43 +02:00
Juan Picado @jotadeveloper
eabc0b9f5b chore: add detect-secrets deps 2019-09-29 20:20:10 +02:00
Juan Picado @jotadeveloper
3779caa4e3 chore(release): 0.3.1 2019-09-29 20:03:29 +02:00
Juan Picado @jotadeveloper
543877a077 chore: add detect-secrets deps 2019-09-29 18:33:04 +02:00
Juan Picado @jotadeveloper
7e6702c34b chore: update dependencies (#138)
* chore: update dependencies

dependencies maintenance

* chore: restore date-fns@1.30.1
2019-09-29 18:26:04 +02:00
Filip Messa
2e50981514 fix(ui): fix the hover effect on the packageItem's author area (#137) 2019-09-29 16:44:10 +02:00
Daniel Ruf
f61913c2d3 fix: correctly load font files - closes #128 (#134)
* fix: correctly load font files - closes #128

* Resolve issue with the moduleNameWrapper in Jest
2019-09-29 16:36:38 +02:00
Priscila Oliveira
ffc97c373c chore: pumped mui version (#131)
* chore: updated mui libs

* fix: updated snap
2019-09-28 00:31:01 +02:00
Sergio Hg
3a889b67ee Merge pull request #127 from verdaccio/refactor-ci
chore: refactor ci
2019-09-11 22:55:04 +02:00
Sergio Herrera Guzmán
de0f91a6d2 test: skip non-deterministic test 2019-09-11 22:47:45 +02:00
Sergio Herrera Guzmán
195a79a809 ci: drop Node 8 support 2019-09-11 22:35:29 +02:00
Sergio Herrera Guzmán
0a7428edab chore: fix Prettier and Stylelint glob expansion for Windows 2019-09-11 15:53:57 +02:00
Sergio Herrera Guzmán
9ad506d569 test: fix one failing snapshot 2019-09-11 15:53:07 +02:00
Sergio Herrera Guzmán
3b52a17623 chore: update lockfile 2019-09-11 15:53:07 +02:00
Sergio Herrera Guzmán
3309e449d1 ci(circleci): improve workflow and add linting 2019-09-11 15:53:07 +02:00
Sergio Herrera Guzmán
7853ec2acb ci(github): remove workflow before deprecation and improve current 2019-09-11 15:53:07 +02:00
Juan Picado @jotadeveloper
2890e5a27e chore(release): 0.3.0 2019-09-01 13:16:44 +02:00
Juan Picado @jotadeveloper
1904179af3 feat: add browser features to browse by version (#125)
* feat: add browser features to browse by version

* chore: verify whether version exist

* chore: add link on versions

* chore: udpate imports

* chore: use mui links

* test: add unit test

* chore: Add todo list

* chore: remove imports
2019-09-01 04:09:23 -07:00
Juan Picado @jotadeveloper
bbec54d602 chore(release): 0.2.4 2019-08-31 11:08:06 +02:00
Juan Picado @jotadeveloper
67d7188cf5 feat: update material-ui@4.x (#123)
* chore: update material-ui@4.x

* test: update test for ActionBar and TestField

* chore: add types

* chore: update types

* test: update test for Author

* chore: fixed bunch of unit test

* chore: remove unused import

* chore: remove comments

* chore: replace shallow my mount

* chore: update git hooks

* chore: fix styles

* chore: update dependencies

* chore: remove types material-ui
2019-08-31 02:02:46 -07:00
Juan Picado @jotadeveloper
376b84f8c9 chore(release): 0.2.3 2019-08-25 17:55:59 +02:00
Juan Picado @jotadeveloper
5a9bd6001a fix: remove ToReplaceByVerdaccio #108 (#122)
* fix: remove ToReplaceByVerdaccio #108

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

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

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

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

* refactor: migrate version page to hooks

* refactor: Version page better imports

* fix: #100 render not found on click item

* test: add test for version page

* chore: update mocks

* test: add scenario for not found package

* chore: fix wrong mock path

* chore: update mock

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

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

Signed-off-by: dependabot[bot] <support@github.com>
2019-07-10 22:51:21 +00:00
Ayush Sharma
157addfd00 Merge branch '4.x-master' into 4.x-adds-unit-tests-for-repository-component 2019-07-10 22:13:41 +02:00
Juan Picado @jotadeveloper
c6c164de50 chore(release): 0.2.1 2019-07-10 14:18:10 +02:00
Juan Picado @jotadeveloper
640e8ca5ee Merge pull request #94 from verdaccio/89-fix-incorrect-logos-style
fix: incorrect logos styles
2019-07-10 14:15:04 +02:00
Sergio Herrera Guzmán
0d00ab4490 refactor: use an enum with Logo size 2019-07-10 11:25:12 +02:00
Juan Picado @jotadeveloper
e9b881b979 Merge remote-tracking branch 'origin/4.x-master' into 89-fix-incorrect-logos-style
# Conflicts:
#	src/components/Login/__snapshots__/Login.test.tsx.snap
2019-07-10 07:57:53 +02:00
Juan Picado @jotadeveloper
6ab3aa2885 Merge branch '4.x-master' into 4.x-adds-unit-tests-for-repository-component 2019-07-10 07:30:39 +02:00
Juan Picado @jotadeveloper
50664dc008 Merge pull request #85 from griffithtp/refactor/78_replace-node-sass-with-emotion
refactor: 78 replace node sass with emotion
2019-07-10 00:14:01 +02:00
Ayush Sharma
9e0c9db78c chore: adds unit tests for <Repository /> component 2019-07-09 23:48:46 +02:00
Griffithtp
3ab3506958 build: testing circle-ci with empty commit 2019-07-09 22:14:34 +01:00
Griffithtp
78b4c3fac1 fix: remove token from AppState 2019-07-09 21:00:59 +01:00
Sergio Herrera Guzmán
fdad635072 fix: incorrect logos styles
- Remove unnecessary quotes in Emotion css templated string
- Revert md prop removed in #47 (with the size set before that)
2019-07-09 18:46:01 +02:00
Juan Picado @jotadeveloper
6a421ab22d Merge branch '4.x-master' into refactor/78_replace-node-sass-with-emotion 2019-07-09 13:52:25 +02:00
Thomas Klein
6afc2c0e54 build: updated typescript to 3.5.2 (#91) 2019-07-09 10:48:00 +02:00
Juan Picado @jotadeveloper
542038e03f Merge branch '4.x-master' into refactor/78_replace-node-sass-with-emotion 2019-07-09 00:12:06 +02:00
Ayush Sharma
c667bea33b test: adds unit tests for <Engines /> component (#92) 2019-07-09 00:10:56 +02:00
Juan Picado @jotadeveloper
bb4d36840f Merge branch '4.x-master' into refactor/78_replace-node-sass-with-emotion 2019-07-08 09:28:32 +02:00
Griffithtp
60b71611ca fix: container breakpoint 2019-07-08 08:06:52 +01:00
Juan Picado @jotadeveloper
39867938b6 chore: fix small eslint error 2019-07-08 08:36:10 +02:00
Juan Picado @jotadeveloper
30568bfe13 Merge branch '4.x-master' into refactor/78_replace-node-sass-with-emotion 2019-07-07 20:49:19 +02:00
Ayush Sharma
f6e62d95bb chore: adds tests for action bar component (#88) 2019-07-07 19:30:01 +02:00
Griffithtp
c57f9dde35 fix: add missing global font-family 2019-07-07 13:33:16 +01:00
Griffithtp
0e14146c77 refactor: remove node-sass packages 2019-07-07 13:27:58 +01:00
Griffithtp
b6717497aa refactor: remove scss files 2019-07-07 13:27:57 +01:00
Griffithtp
99e1bb3ea3 refactor: update global styles using emotion 2019-07-07 13:27:56 +01:00
Griffithtp
a49780f5f0 refactor: remove scss from PackageList component 2019-07-07 13:27:55 +01:00
Griffithtp
0c4ebbffa8 refactor: remove sass from Login component 2019-07-07 13:27:53 +01:00
Juan Picado @jotadeveloper
b6b0ecdb1e Merge pull request #86 from griffithtp/fix/83_support-deprecated-license-object-properties
fix: 83 support deprecated license object properties
2019-07-07 13:07:22 +02:00
Griffithtp
13c7aa6d03 refactor: formatLicense to return undefined instead of null 2019-07-07 11:17:22 +01:00
Griffithtp
cf1f47e86c chore: add unit test for <Dist/> component 2019-07-06 17:43:00 +01:00
Griffithtp
b2e420dbd9 fix: support deprecated license object properties 2019-07-06 10:50:09 +01:00
Juan Picado @jotadeveloper
283464fd13 Merge pull request #82 from verdaccio/4.x-adds-unit-test-for-author-component
chore: adds unit test for <Author/> component
2019-07-03 22:47:27 +02:00
Juan Picado @jotadeveloper
7c254471a6 Merge branch '4.x-master' into 4.x-adds-unit-test-for-author-component 2019-07-03 22:41:44 +02:00
Juan Picado @jotadeveloper
8e3e619eea Merge pull request #80 from griffithtp/refactor/typescript-warning-jsx-no-style
Refactor/typescript warning jsx no style
2019-07-03 19:08:30 +02:00
Ayush Sharma
531e7579a4 chore: adds unit test for <Author/> component 2019-07-02 21:37:36 +02:00
Griffithtp
e7d145f547 fix: update snapshot for verdaccio/jsx-no-style 2019-06-30 23:31:08 +01:00
Griffithtp
210bcf3ff5 fix: logo component styled 2019-06-30 23:31:06 +01:00
Griffithtp
55b1402456 fix: verdaccio/jsx-no-style 2019-06-30 23:31:05 +01:00
Juan Picado @jotadeveloper
4746f4070c Merge pull request #79 from griffithtp/refactor/typescript-warning-withRoute
fix: @typescript-eslint/no-explicit-any
2019-06-30 22:18:23 +02:00
Griffithtp
ec8ed1214b fix: @typescript-eslint/no-explicit-any 2019-06-29 09:03:41 +01:00
Juan Picado @jotadeveloper
a0f0c80e2e Merge pull request #77 from griffithtp/refactor/74_linting-warnings
refactor: 74 linting warnings
2019-06-27 08:56:53 +02:00
Griffithtp
d1ed3e705f fix: remove undefined error 2019-06-27 07:54:36 +01:00
Griffithtp
b683b68a2c fix: @typescript-eslint/no-explicit-any for file-size.ts 2019-06-26 00:41:21 +01:00
Griffithtp
6eec4f45d9 fix: @typescript-eslint/no-explicit-any 2019-06-26 00:10:15 +01:00
Griffithtp
7cab3f289e fix: updated type to fix unit test 2019-06-25 23:29:53 +01:00
Griffithtp
2f28ade710 fix: @typescript-eslint/no-explicit-any 2019-06-25 00:44:12 +01:00
Griffithtp
31c11f2b5b fix: @typescript-eslint/explicit-function-return-type 2019-06-24 23:08:57 +01:00
Griffithtp
55f50e9f4d fix: @typescript-eslint/explicit-member-accessibility 2019-06-24 22:05:13 +01:00
Griffithtp
e33570b3f0 fix: typescript warnings - prefer-rest-params 2019-06-24 22:04:24 +01:00
Griffithtp
91e603ef21 fix: type lint for login 2019-06-24 21:44:14 +01:00
Griffithtp
116055c5d1 fix: remove any types and added additional component state interfaces 2019-06-24 21:42:59 +01:00
Griffith Tchen Pan
3c54b116c9 fix: added packageMeta type 2019-06-24 21:42:34 +01:00
Juan Picado @jotadeveloper
df4e45cd6c Merge branch '4.x-master' into test/bdd-acceptance-testing-setup 2019-05-08 22:07:24 +02:00
Juan Picado @jotadeveloper
df58d463e8 Merge branch '4.x-master' into test/bdd-acceptance-testing-setup 2019-05-04 12:15:18 +02:00
Juan Picado @jotadeveloper
313fb33480 Merge branch '4.x-master' into test/bdd-acceptance-testing-setup 2019-05-03 08:05:06 +02:00
Daniel Ruf
d468ca7c5f test: BDD / acceptance tests
Implement acceptance testing using codeceptjs and puppeteer.
2019-05-02 11:15:33 +02:00
282 changed files with 86059 additions and 8253 deletions

View File

@@ -1,5 +1,3 @@
{ {
"presets": [ "presets": [["@verdaccio"]]
["@verdaccio", { "typescript": true }]
]
} }

View File

@@ -1,31 +1,28 @@
version: 2 version: 2
aliases: aliases:
- &repo_path
~/ui-theme
- &defaults - &defaults
working_directory: ~/ui-theme working_directory: *repo_path
- &node11_executor - &node_latest_browser
docker: docker:
- image: circleci/node:11.10.1 - image: circleci/node:latest-browsers
- &node8_executor - &node_latest_executor
docker: docker:
- image: circleci/node:8 - image: circleci/node:latest
- &node10_executor - &node_lts_executor
docker: docker:
- image: circleci/node:10 - image: circleci/node:lts
- &default_executor - &default_executor
<<: *node10_executor <<: *node_latest_executor
- &repo_key
repo-{{ .Branch }}-{{ .Revision }}
- &coverage_key
coverage-{{ .Branch }}-{{ .Revision }}
- &base_config_key
base-config-{{ .Branch }}-{{ .Revision }}
- &yarn_cache_key - &yarn_cache_key
yarn-sha-{{ checksum "yarn.lock" }} yarn-sha-{{ checksum "yarn.lock" }}
- &coverage_key
coverage-{{ .Branch }}-{{ .Revision }}
- &restore_repo - &restore_repo
restore_cache: attach_workspace:
keys: at: *repo_path
- *repo_key
- &ignore_non_dev_branches - &ignore_non_dev_branches
filters: filters:
tags: tags:
@@ -36,7 +33,7 @@ aliases:
- &execute_on_release - &execute_on_release
filters: filters:
tags: tags:
only: /(v)?[0-9]+(\.[0-9]+)*/ only: /v?[0-9]+(\.[0-9]+)*([-+\.][a-zA-Z0-9]+)*/
branches: branches:
ignore: ignore:
- /.*/ - /.*/
@@ -48,34 +45,28 @@ jobs:
steps: steps:
- *restore_repo - *restore_repo
- checkout - 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: - restore_cache:
key: *yarn_cache_key key: *yarn_cache_key
- run: - run:
name: Install Js dependencies name: Install dependencies
command: yarn install --no-progress --registry https://registry.verdaccio.org --no-lockfile command: yarn install --frozen-lockfile
- run:
name: Lint code
command: yarn lint
- run: - run:
name: Build project name: Build project
command: yarn run build command: yarn build
- save_cache: - save_cache:
key: *yarn_cache_key key: *yarn_cache_key
paths: paths:
- ~/.yarn - ~/.yarn
- ~/.cache/yarn - ~/.cache/yarn
- node_modules - node_modules
- save_cache: - persist_to_workspace:
key: *repo_key root: *repo_path
paths: paths:
- ~/ui-theme - ./*
test_bundlesize: test_bundlesize:
<<: *defaults <<: *defaults
<<: *default_executor <<: *default_executor
@@ -85,37 +76,37 @@ jobs:
name: Test BundleSize name: Test BundleSize
command: yarn test:size command: yarn test:size
test_node11: test_node_latest:
<<: *defaults <<: *defaults
<<: *node11_executor <<: *node_latest_executor
steps: steps:
- *restore_repo - *restore_repo
- run: - run:
name: Test with Node 11 name: Test with Node (Latest)
command: yarn test 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: - save_cache:
key: *coverage_key key: *coverage_key
paths: paths:
- coverage - 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: coverage:
<<: *defaults <<: *defaults
<<: *default_executor <<: *default_executor
@@ -140,8 +131,9 @@ jobs:
<<: *default_executor <<: *default_executor
steps: steps:
- *restore_repo - *restore_repo
- restore_cache: - run:
key: *base_config_key name: 'Setup publish credentials'
command: echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc
- run: - run:
name: Publish name: Publish
command: yarn publish command: yarn publish
@@ -152,29 +144,31 @@ workflows:
jobs: jobs:
- prepare: - prepare:
<<: *ignore_non_dev_branches <<: *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: - test_bundlesize:
requires: requires:
- test_node11 - prepare
- test_node8 <<: *ignore_non_dev_branches
- test_node10 - 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 <<: *ignore_non_dev_branches
- coverage: - coverage:
requires: requires:
- test_bundlesize - test_node_latest
<<: *ignore_non_dev_branches <<: *ignore_non_dev_branches
- publish_package: - publish_package:
requires: requires:
- test_bundlesize
- test_node_latest
- test_node_lts
- test_e2e
- coverage - coverage
<<: *execute_on_release <<: *execute_on_release

View File

@@ -3,6 +3,7 @@ coverage/
static/ static/
.github/ .github/
.circleci/ .circleci/
build
*.md *.md
*.lock *.lock
*.yaml *.yaml
@@ -10,3 +11,4 @@ Dockerfile
*.html *.html
*.scss *.scss
*.png *.png
doc

View File

@@ -5,26 +5,32 @@
"plugin:jest/recommended", "plugin:jest/recommended",
"plugin:prettier/recommended", "plugin:prettier/recommended",
"plugin:verdaccio/recommended", "plugin:verdaccio/recommended",
"plugin:jsx-a11y/recommended" "plugin:jsx-a11y/recommended",
"plugin:import/typescript"
], ],
"plugins": [ "plugins": [
"react", "react",
"jest", "jest",
"prettier", "prettier",
"verdaccio", "verdaccio",
"jsx-a11y" "jsx-a11y",
"codeceptjs",
"react-hooks",
"import"
], ],
"settings": { "settings": {
"react": { "react": {
"version": "detect" "version": "detect"
} }
}, },
"parser": "@typescript-eslint/parser",
"parserOptions": { "parserOptions": {
"ecmaFeatures": { "ecmaFeatures": {
"jsx": true "jsx": true
} }
}, },
"rules": { "rules": {
"import/order": ["error", {"newlines-between": "always"}],
"babel/no-invalid-this": 0, "babel/no-invalid-this": 0,
"no-invalid-this": 0, "no-invalid-this": 0,
"no-console": ["error", { "allow": ["warn", "error"] }], "no-console": ["error", { "allow": ["warn", "error"] }],
@@ -106,6 +112,8 @@
2, 2,
"always" "always"
], ],
"react-hooks/rules-of-hooks": "error",
"react-hooks/exhaustive-deps": "warn",
"verdaccio/jsx-no-style": ["warn"], "verdaccio/jsx-no-style": ["warn"],
"verdaccio/jsx-spread": ["warn"], "verdaccio/jsx-spread": ["warn"],
"jest/expect-expect": 0, "jest/expect-expect": 0,
@@ -119,6 +127,7 @@
}, },
"env": { "env": {
"browser": true, "browser": true,
"jest/globals": true "jest/globals": true,
"codeceptjs/codeceptjs": true,
} }
} }

67
.github/main.workflow vendored
View File

@@ -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
View 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

2
.gitignore vendored
View File

@@ -2,6 +2,8 @@ npm-debug.log
verdaccio-*.tgz verdaccio-*.tgz
.DS_Store .DS_Store
build/ build/
doc
### ###
node_modules node_modules
package-lock.json package-lock.json

1
.nvmrc Normal file
View File

@@ -0,0 +1 @@
stable

View File

@@ -1,4 +1,5 @@
{ {
"endOfLine": "auto",
"useTabs": false, "useTabs": false,
"printWidth": 160, "printWidth": 160,
"tabWidth": 2, "tabWidth": 2,

40
.secrets-baseline Normal file
View 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"
}

View File

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

View File

@@ -5,5 +5,6 @@
"javascriptreact", "javascriptreact",
"typescript", "typescript",
"typescriptreact" "typescriptreact"
] ],
"typescript.tsdk": "node_modules/typescript/lib"
} }

View File

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

View File

@@ -1,7 +1,155 @@
# Change Log # Changelog
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. 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)
### Features
* add browser features to browse by version ([#125](https://github.com/verdaccio/ui/issues/125)) ([1904179](https://github.com/verdaccio/ui/commit/1904179))
### [0.2.4](https://github.com/verdaccio/ui/compare/v0.2.3...v0.2.4) (2019-08-31)
### Features
* update material-ui@4.x ([#123](https://github.com/verdaccio/ui/issues/123)) ([67d7188](https://github.com/verdaccio/ui/commit/67d7188))
### [0.2.3](https://github.com/verdaccio/ui/compare/v0.2.2...v0.2.3) (2019-08-25)
### Bug Fixes
* missing headers on search endpoint with token ([#121](https://github.com/verdaccio/ui/issues/121)) ([ac58730](https://github.com/verdaccio/ui/commit/ac58730))
* refactoring version page / fix issue not found page [#100](https://github.com/verdaccio/ui/issues/100) ([#117](https://github.com/verdaccio/ui/issues/117)) ([97e8448](https://github.com/verdaccio/ui/commit/97e8448))
* remove ToReplaceByVerdaccio [#108](https://github.com/verdaccio/ui/issues/108) ([#122](https://github.com/verdaccio/ui/issues/122)) ([5a9bd60](https://github.com/verdaccio/ui/commit/5a9bd60))
* **api:** correctly handle responses with missing content-type header ([2049022](https://github.com/verdaccio/ui/commit/2049022))
<a name="0.2.2"></a>
## [0.2.2](https://github.com/verdaccio/ui/compare/v0.2.1...v0.2.2) (2019-07-29)
### Bug Fixes
* css repetition is not closed in Logo component ([ec243b1](https://github.com/verdaccio/ui/commit/ec243b1))
* localhost domain download tarball button ([cca2c3c](https://github.com/verdaccio/ui/commit/cca2c3c))
* proxy webpack setting ([5c484bb](https://github.com/verdaccio/ui/commit/5c484bb))
* token were not being send it ([fd74c52](https://github.com/verdaccio/ui/commit/fd74c52))
<a name="0.2.1"></a>
## [0.2.1](https://github.com/verdaccio/ui/compare/v0.2.0...v0.2.1) (2019-07-10)
### Bug Fixes
* [@typescript-eslint](https://github.com/typescript-eslint)/explicit-function-return-type ([31c11f2](https://github.com/verdaccio/ui/commit/31c11f2))
* [@typescript-eslint](https://github.com/typescript-eslint)/explicit-member-accessibility ([55f50e9](https://github.com/verdaccio/ui/commit/55f50e9))
* [@typescript-eslint](https://github.com/typescript-eslint)/no-explicit-any ([2f28ade](https://github.com/verdaccio/ui/commit/2f28ade))
* [@typescript-eslint](https://github.com/typescript-eslint)/no-explicit-any ([6eec4f4](https://github.com/verdaccio/ui/commit/6eec4f4))
* [@typescript-eslint](https://github.com/typescript-eslint)/no-explicit-any ([ec8ed12](https://github.com/verdaccio/ui/commit/ec8ed12))
* [@typescript-eslint](https://github.com/typescript-eslint)/no-explicit-any for file-size.ts ([b683b68](https://github.com/verdaccio/ui/commit/b683b68))
* add missing global font-family ([c57f9dd](https://github.com/verdaccio/ui/commit/c57f9dd))
* added packageMeta type ([3c54b11](https://github.com/verdaccio/ui/commit/3c54b11))
* container breakpoint ([60b7161](https://github.com/verdaccio/ui/commit/60b7161))
* incorrect logos styles ([fdad635](https://github.com/verdaccio/ui/commit/fdad635)), closes [#47](https://github.com/verdaccio/ui/issues/47)
* logo component styled ([210bcf3](https://github.com/verdaccio/ui/commit/210bcf3))
* remove any types and added additional component state interfaces ([116055c](https://github.com/verdaccio/ui/commit/116055c))
* remove token from AppState ([78b4c3f](https://github.com/verdaccio/ui/commit/78b4c3f))
* remove undefined error ([d1ed3e7](https://github.com/verdaccio/ui/commit/d1ed3e7))
* support deprecated license object properties ([b2e420d](https://github.com/verdaccio/ui/commit/b2e420d))
* type lint for login ([91e603e](https://github.com/verdaccio/ui/commit/91e603e))
* typescript warnings - prefer-rest-params ([e33570b](https://github.com/verdaccio/ui/commit/e33570b))
* update snapshot for verdaccio/jsx-no-style ([e7d145f](https://github.com/verdaccio/ui/commit/e7d145f))
* updated type to fix unit test ([7cab3f2](https://github.com/verdaccio/ui/commit/7cab3f2))
* verdaccio/jsx-no-style ([55b1402](https://github.com/verdaccio/ui/commit/55b1402))
<a name="0.2.0"></a> <a name="0.2.0"></a>
# [0.2.0](https://github.com/verdaccio/ui/compare/v0.1.11...v0.2.0) (2019-06-20) # [0.2.0](https://github.com/verdaccio/ui/compare/v0.1.11...v0.2.0) (2019-06-20)

View File

@@ -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 For development run the following command, it will execute `webpack` and `verdaccio` to
``` ```bash
yarn dev yarn dev
``` ```
The configuration file is located on `tools/_config.yaml`. The configuration file is located on `tools/_config.yaml`.
Run linting tooling and test to check your code is clean before commit. 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 yarn lint && yarn test
``` ```
#### Commits
Remember we follow the [the Conventional Commits specification](https://www.conventionalcommits.org/en/v1.0.0-beta.4/). 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. 🤓 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 ## Open Collective Sponsors
@@ -65,7 +83,7 @@ Thank you to all our backers! 🙏 [[Become a backer](https://opencollective.com
## Contributors ## Contributors
This project exists thanks to all the people who contribute. [[Contribute](CONTRIBUTING.md)]. This project exists thanks to all the people who contribute.
[![contrubitors](https://opencollective.com/verdaccio/contributors.svg?width=890&button=true)](../../graphs/contributors) [![contrubitors](https://opencollective.com/verdaccio/contributors.svg?width=890&button=true)](../../graphs/contributors)

21
codecept.conf.js Normal file
View File

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

29
codecov.yml Normal file
View 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

View File

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

View File

@@ -3,6 +3,7 @@ const { defaults } = require('jest-config');
module.exports = { module.exports = {
name: 'verdaccio-ui-jest', name: 'verdaccio-ui-jest',
verbose: true, verbose: true,
automock: false,
collectCoverage: true, collectCoverage: true,
testEnvironment: 'jest-environment-jsdom-global', testEnvironment: 'jest-environment-jsdom-global',
moduleFileExtensions: [...defaults.moduleFileExtensions, 'ts', 'tsx'], moduleFileExtensions: [...defaults.moduleFileExtensions, 'ts', 'tsx'],
@@ -10,7 +11,15 @@ module.exports = {
rootDir: '..', rootDir: '..',
setupFiles: ['<rootDir>/jest/setup.ts'], setupFiles: ['<rootDir>/jest/setup.ts'],
transformIgnorePatterns: ['<rootDir>/node_modules/(?!react-syntax-highlighter)'], 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'], snapshotSerializers: ['enzyme-to-json/serializer', 'jest-emotion'],
moduleNameMapper: { moduleNameMapper: {
'\\.(s?css)$': '<rootDir>/node_modules/identity-obj-proxy', '\\.(s?css)$': '<rootDir>/node_modules/identity-obj-proxy',

View File

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

View File

@@ -39,8 +39,8 @@ const register = (url, method = 'get', options = {}) => {
* Bind API methods * Bind API methods
*/ */
class API { class API {
request() { public request(...rest) {
return register.call(null, ...arguments); return register.call(null, ...rest);
} }
} }

View File

@@ -15,6 +15,11 @@ export function generateTokenWithTimeRange(limit = 0) {
export function generateTokenWithExpirationAsString() { export function generateTokenWithExpirationAsString() {
const payload = { username: 'verdaccio', exp: 'I am not a number' }; 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`; return `xxxxxx.${Base64.encode(payload)}.xxxxxx`;
} }

View File

@@ -2,6 +2,6 @@
* Mock response for logo api * Mock response for logo api
* @returns {promise} * @returns {promise}
*/ */
export default function() { export default function<T>(): Promise<T> {
return Promise.resolve('http://localhost/-/static/logo.png'); return Promise.resolve('http://localhost/-/static/logo.png');
} }

View File

@@ -1,106 +1,125 @@
{ {
"name": "@verdaccio/ui-theme", "name": "@verdaccio/ui-theme",
"version": "0.2.0", "version": "0.3.4",
"description": "Verdaccio User Interface", "description": "Verdaccio User Interface",
"author": { "author": {
"name": "Verdaccio Core Team" "name": "Verdaccio Core Team",
"email": "verdaccio.npm@gmail.com"
}, },
"repository": { "repository": {
"type": "git", "type": "git",
"url": "git://github.com/verdaccio/ui" "url": "git://github.com/verdaccio/ui"
}, },
"homepage": "https://verdaccio.org",
"main": "index.js", "main": "index.js",
"devDependencies": { "devDependencies": {
"@commitlint/cli": "8.0.0", "@commitlint/cli": "8.2.0",
"@commitlint/config-conventional": "8.0.0", "@commitlint/config-conventional": "8.2.0",
"@material-ui/core": "3.9.3", "@material-ui/core": "4.5.1",
"@material-ui/icons": "3.0.2", "@material-ui/icons": "4.5.1",
"@octokit/rest": "16.23.2", "@octokit/rest": "16.34.0",
"@types/enzyme": "3.9.3", "@testing-library/react": "9.3.0",
"@types/lodash": "4.14.134", "@types/autosuggest-highlight": "3.1.0",
"@types/material-ui": "0.21.6", "@types/enzyme": "3.10.3",
"@types/node": "12.0.8", "@types/jest": "24.0.20",
"@types/react": "16.8.16", "@types/js-base64": "2.3.1",
"@types/react-dom": "16.8.4", "@types/lodash": "4.14.144",
"@types/react-router-dom": "4.3.2", "@types/node": "12.11.7",
"@verdaccio/babel-preset": "0.2.1", "@types/react": "16.9.11",
"@verdaccio/eslint-config": "0.0.1", "@types/react-autosuggest": "9.3.13",
"@verdaccio/types": "6.1.0", "@types/react-dom": "16.9.3",
"@types/react-router-dom": "5.1.0",
"@types/request": "2.48.3",
"@types/validator": "10.11.3",
"@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.1.0",
"autosuggest-highlight": "3.1.1", "autosuggest-highlight": "3.1.1",
"babel-loader": "8.0.6", "babel-loader": "8.0.6",
"bundlesize": "0.17.2", "bundlesize": "0.18.0",
"codecov": "3.5.0", "codeceptjs": "2.3.5",
"concurrently": "4.1.0", "codecov": "3.6.1",
"cross-env": "5.2.0", "concurrently": "5.0.0",
"css-loader": "0.28.10", "cross-env": "6.0.3",
"css-loader": "3.2.0",
"date-fns": "1.30.1", "date-fns": "1.30.1",
"detect-secrets": "1.0.4",
"emotion": "9.2.12", "emotion": "9.2.12",
"enzyme": "3.10.0", "enzyme": "3.10.0",
"enzyme-adapter-react-16": "1.14.0", "enzyme-adapter-react-16": "1.15.1",
"enzyme-to-json": "3.3.5", "enzyme-to-json": "3.4.3",
"eslint": "5.16.0", "eslint": "6.5.1",
"eslint-plugin-jsx-a11y": "6.2.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-prettier": "3.1.0",
"eslint-plugin-react": "7.13.0", "eslint-plugin-react": "7.14.3",
"eslint-plugin-verdaccio": "0.0.5", "eslint-plugin-react-hooks": "2.0.1",
"file-loader": "2.0.0", "eslint-plugin-verdaccio": "2.0.0",
"file-loader": "4.2.0",
"friendly-errors-webpack-plugin": "1.7.0", "friendly-errors-webpack-plugin": "1.7.0",
"get-stdin": "6.0.0", "get-stdin": "7.0.0",
"github-markdown-css": "2.10.0", "github-markdown-css": "3.0.1",
"html-webpack-plugin": "3.2.0", "html-webpack-plugin": "3.2.0",
"husky": "2.4.1", "husky": "3.0.9",
"identity-obj-proxy": "3.0.0", "identity-obj-proxy": "3.0.0",
"in-publish": "2.0.0", "in-publish": "2.0.0",
"jest": "24.8.0", "jest": "24.9.0",
"jest-emotion": "10.0.11", "jest-emotion": "10.0.17",
"jest-environment-jsdom": "24.8.0", "jest-environment-jsdom": "24.9.0",
"jest-environment-jsdom-global": "1.2.0", "jest-environment-jsdom-global": "1.2.0",
"jest-environment-node": "24.8.0", "jest-environment-node": "24.9.0",
"jest-fetch-mock": "2.1.2",
"js-base64": "2.5.1",
"js-yaml": "3.13.1", "js-yaml": "3.13.1",
"lint-staged": "8.2.1",
"localstorage-memory": "1.0.3", "localstorage-memory": "1.0.3",
"mini-css-extract-plugin": "0.7.0", "lockfile-lint": "2.1.6",
"node-mocks-http": "1.7.3", "lodash": "^4.17.15",
"node-sass": "4.12.0", "mini-css-extract-plugin": "0.8.0",
"node-mocks-http": "1.8.0",
"normalize.css": "8.0.1", "normalize.css": "8.0.1",
"optimize-css-assets-webpack-plugin": "5.0.1", "optimize-css-assets-webpack-plugin": "5.0.3",
"ora": "3.4.0", "ora": "4.0.2",
"prettier": "1.18.2", "prettier": "1.18.2",
"prop-types": "15.7.2", "prop-types": "15.7.2",
"puppeteer": "1.17.0", "puppeteer": "1.8.0",
"react": "16.8.3", "react": "16.11.0",
"react-autosuggest": "9.4.2", "react-autosuggest": "9.4.3",
"react-dom": "16.8.3", "react-dom": "16.11.0",
"react-emotion": "9.2.12", "react-emotion": "9.2.12",
"react-hot-loader": "4.7.1", "react-hot-loader": "4.12.15",
"react-router": "4.3.1", "react-router-dom": "5.1.2",
"react-router-dom": "4.3.1", "request": "2.88.0",
"resolve-url-loader": "3.0.1", "resolve-url-loader": "3.1.0",
"rimraf": "2.6.3", "rimraf": "3.0.0",
"sass-loader": "7.1.0",
"source-map-loader": "0.2.4", "source-map-loader": "0.2.4",
"standard-version": "4.4.0", "standard-version": "7.0.0",
"style-loader": "0.23.1", "style-loader": "1.0.0",
"stylelint": "10.1.0", "stylelint": "11.1.1",
"stylelint-config-recommended": "2.2.0", "stylelint-config-recommended": "3.0.0",
"stylelint-config-recommended-scss": "3.3.0",
"stylelint-config-styled-components": "0.1.1", "stylelint-config-styled-components": "0.1.1",
"stylelint-processor-styled-components": "1.8.0", "stylelint-processor-styled-components": "1.8.0",
"stylelint-scss": "3.8.0", "stylelint-webpack-plugin": "1.0.3",
"stylelint-webpack-plugin": "0.10.5",
"supertest": "4.0.2", "supertest": "4.0.2",
"typeface-roboto": "0.0.54", "typeface-roboto": "0.0.75",
"typescript": "3.4.5", "typescript": "3.7.1-rc",
"url-loader": "1.1.2", "uglifyjs-webpack-plugin": "2.2.0",
"validator": "10.11.0", "url-loader": "2.2.0",
"verdaccio": "4.0.3", "validator": "11.1.0",
"verdaccio-auth-memory": "0.0.4", "verdaccio": "4.3.4",
"verdaccio-memory": "2.0.0", "verdaccio-auth-memory": "8.2.0",
"webpack": "4.20.2", "verdaccio-memory": "8.2.0",
"webpack-bundle-analyzer": "3.3.2", "wait-on": "3.3.0",
"webpack-bundle-size-analyzer": "3.0.0", "webpack": "4.41.2",
"webpack-cli": "3.2.3", "webpack-bundle-analyzer": "3.6.0",
"webpack-dev-server": "3.2.1", "webpack-bundle-size-analyzer": "3.1.0",
"webpack-merge": "4.2.1", "webpack-cli": "3.3.9",
"webpack-dev-server": "3.9.0",
"webpack-merge": "4.2.2",
"whatwg-fetch": "3.0.0", "whatwg-fetch": "3.0.0",
"xss": "1.0.6" "xss": "1.0.6"
}, },
@@ -136,14 +155,20 @@
} }
], ],
"scripts": { "scripts": {
"type-check": "tsc --noEmit", "type-check": "tsc --noEmit --pretty",
"type-check:watch": "npm run type-check -- --watch", "type-check:watch": "npm run type-check -- --watch",
"release": "standard-version -a -s", "type-check-strict:watch": "tsc --project ./tsconfig.strict.json --noEmit --pretty --watch",
"test": "cross-env NODE_ENV=test BABEL_ENV=test TZ=UTC jest --config ./jest/jest.config.js --maxWorkers 2", "release": "standard-version -a",
"test:clean": "npx jest --clearCache",
"test:acceptance": "codeceptjs run --steps",
"test:acceptance:server": "concurrently --kill-others \"npm run verdaccio:server\" \"npm run test:acceptance\"",
"test: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", "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: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", "coverage:publish": "codecov",
"pre:webpack": "rimraf static/*", "pre:webpack": "rimraf static/*",
"prepublish": "in-publish && npm run build || not-in-publish", "prepublish": "in-publish && npm run build || not-in-publish",
@@ -160,9 +185,26 @@
}, },
"husky": { "husky": {
"hooks": { "hooks": {
"pre-commit": "commitlint -e $GIT_PARAMS" "pre-commit": "lint-staged",
"commit-msg": "commitlint -e $GIT_PARAMS"
} }
}, },
"lint-staged": {
"relative": true,
"linters": {
"*.{js,tsx,ts}": [
"eslint .",
"prettier --write"
],
"*": [
"detect-secrets-launcher --baseline .secrets-baseline",
"git add"
]
},
"ignore": [
"*.json"
]
},
"license": "MIT", "license": "MIT",
"commitlint": { "commitlint": {
"extends": [ "extends": [

View File

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

Binary file not shown.

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@@ -1,26 +1,28 @@
import React from 'react'; import React from 'react';
import { mount } from 'enzyme'; import { mount, ReactWrapper } from 'enzyme';
import storage from '../utils/storage';
import App from './App';
import storage from '../utils/storage';
import { generateTokenWithTimeRange } from '../../jest/unit/components/__mocks__/token'; import { generateTokenWithTimeRange } from '../../jest/unit/components/__mocks__/token';
import App from './App';
import { AppProps } from './AppContext';
jest.mock('../utils/storage', () => { jest.mock('../utils/storage', () => {
class LocalStorageMock { class LocalStorageMock {
store: object; private store: Record<string, string>;
public constructor() { public constructor() {
this.store = {}; this.store = {};
} }
public clear(): void { public clear(): void {
this.store = {}; this.store = {};
} }
public getItem(key): unknown { public getItem(key: string): unknown {
return this.store[key] || null; return this.store[key] || null;
} }
public setItem(key, value): void { public setItem(key: string, value: string): void {
this.store[key] = value.toString(); this.store[key] = value.toString();
} }
public removeItem(key): void { public removeItem(key: string): void {
delete this.store[key]; delete this.store[key];
} }
} }
@@ -32,7 +34,7 @@ jest.mock('../utils/api', () => ({
})); }));
describe('App', () => { describe('App', () => {
let wrapper; let wrapper: ReactWrapper<{}, AppProps, App>;
beforeEach(() => { beforeEach(() => {
wrapper = mount(<App />); wrapper = mount(<App />);
@@ -43,7 +45,7 @@ describe('App', () => {
expect(wrapper.state().showLoginModal).toBeFalsy(); expect(wrapper.state().showLoginModal).toBeFalsy();
handleToggleLoginModal(); handleToggleLoginModal();
expect(wrapper.state('showLoginModal')).toBeTruthy(); expect(wrapper.state('showLoginModal')).toBeTruthy();
expect(wrapper.state('error')).toEqual({}); expect(wrapper.state('error')).toEqual(undefined);
}); });
test('isUserAlreadyLoggedIn: token already available in storage', async () => { test('isUserAlreadyLoggedIn: token already available in storage', async () => {
@@ -71,7 +73,6 @@ describe('App', () => {
await handleDoLogin('sam', '1234'); await handleDoLogin('sam', '1234');
const result = { const result = {
username: 'sam', username: 'sam',
token: 'TEST_TOKEN',
}; };
expect(wrapper.state('isUserLoggedIn')).toBeTruthy(); expect(wrapper.state('isUserLoggedIn')).toBeTruthy();
expect(wrapper.state('showLoginModal')).toBeFalsy(); expect(wrapper.state('showLoginModal')).toBeFalsy();

View File

@@ -1,32 +1,26 @@
import React, { Component, ReactElement } from 'react'; import React, { Component, ReactElement } from 'react';
import isNil from 'lodash/isNil'; import isNil from 'lodash/isNil';
import 'normalize.css';
import 'typeface-roboto/index.css';
import storage from '../utils/storage'; import storage from '../utils/storage';
import { makeLogin, isTokenExpire } from '../utils/login'; import { makeLogin, isTokenExpire } from '../utils/login';
import Loading from '../components/Loading'; import Loading from '../components/Loading';
import LoginModal from '../components/Login'; import LoginModal from '../components/Login';
import Header from '../components/Header'; import Header from '../components/Header';
import { Container, Content } from '../components/Layout'; import { Container, Content } from '../components/Layout';
import RouterApp from '../router';
import API from '../utils/api'; import API from '../utils/api';
import '../styles/typeface-roboto.scss'; import '../utils/styles/global';
import '../styles/main.scss';
import 'normalize.css';
import Footer from '../components/Footer'; import Footer from '../components/Footer';
export const AppContext = React.createContext<null>(null); import AppRoute from './AppRoute';
export const AppContextProvider = AppContext.Provider; import { AppProps, AppContextProvider } from './AppContext';
export const AppContextConsumer = AppContext.Consumer;
export default class App extends Component<any, any> { export default class App extends Component<{}, AppProps> {
public state = { public state: AppProps = {
error: {},
// @ts-ignore
logoUrl: window.VERDACCIO_LOGO, logoUrl: window.VERDACCIO_LOGO,
user: {}, user: {},
// @ts-ignore scope: window.VERDACCIO_SCOPE || '',
scope: window.VERDACCIO_SCOPE ? `${window.VERDACCIO_SCOPE}:` : '',
showLoginModal: false, showLoginModal: false,
isUserLoggedIn: false, isUserLoggedIn: false,
packages: [], packages: [],
@@ -39,7 +33,7 @@ export default class App extends Component<any, any> {
} }
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
public componentDidUpdate(_, prevState): void { public componentDidUpdate(_: AppProps, prevState: AppProps): void {
const { isUserLoggedIn } = this.state; const { isUserLoggedIn } = this.state;
if (prevState.isUserLoggedIn !== isUserLoggedIn) { if (prevState.isUserLoggedIn !== isUserLoggedIn) {
this.loadOnHandler(); this.loadOnHandler();
@@ -49,18 +43,11 @@ export default class App extends Component<any, any> {
public render(): React.ReactElement<HTMLDivElement> { public render(): React.ReactElement<HTMLDivElement> {
const { isLoading, isUserLoggedIn, packages, logoUrl, user, scope } = this.state; const { isLoading, isUserLoggedIn, packages, logoUrl, user, scope } = this.state;
const context: any = { isUserLoggedIn, packages, logoUrl, user, scope }; const context = { isUserLoggedIn, packages, logoUrl, user, scope };
return ( return (
// @ts-ignore
<Container isLoading={isLoading}> <Container isLoading={isLoading}>
{isLoading ? ( {isLoading ? <Loading /> : <AppContextProvider value={context}>{this.renderContent()}</AppContextProvider>}
<Loading />
) : (
<>
<AppContextProvider value={context}>{this.renderContent()}</AppContextProvider>
</>
)}
{this.renderLoginModal()} {this.renderLoginModal()}
</Container> </Container>
); );
@@ -69,12 +56,12 @@ export default class App extends Component<any, any> {
public isUserAlreadyLoggedIn = () => { public isUserAlreadyLoggedIn = () => {
// checks for token validity // checks for token validity
const token = storage.getItem('token'); const token = storage.getItem('token');
const username = storage.getItem('username'); const username: string = storage.getItem('username') as string;
if (isTokenExpire(token) || isNil(username)) { if (isTokenExpire(token) || isNil(username)) {
this.handleLogout(); this.handleLogout();
} else { } else {
this.setState({ this.setState({
user: { username, token }, user: { username },
isUserLoggedIn: true, isUserLoggedIn: true,
}); });
} }
@@ -82,11 +69,10 @@ export default class App extends Component<any, any> {
public loadOnHandler = async () => { public loadOnHandler = async () => {
try { try {
// @ts-ignore const packages = await API.request<any[]>('packages', 'GET');
this.req = await API.request('packages', 'GET'); // @ts-ignore: FIX THIS TYPE: Type 'any[]' is not assignable to type '[]'
this.setState({ this.setState({
// @ts-ignore packages,
packages: this.req,
isLoading: false, isLoading: false,
}); });
} catch (error) { } catch (error) {
@@ -99,7 +85,7 @@ export default class App extends Component<any, any> {
} }
}; };
public setLoading = isLoading => public setLoading = (isLoading: boolean) =>
this.setState({ this.setState({
isLoading, isLoading,
}); });
@@ -110,9 +96,7 @@ export default class App extends Component<any, any> {
*/ */
public handleToggleLoginModal = () => { public handleToggleLoginModal = () => {
this.setState(prevState => ({ this.setState(prevState => ({
// @ts-ignore
showLoginModal: !prevState.showLoginModal, showLoginModal: !prevState.showLoginModal,
error: {},
})); }));
}; };
@@ -120,14 +104,13 @@ export default class App extends Component<any, any> {
* handles login * handles login
* Required by: <Header /> * Required by: <Header />
*/ */
public handleDoLogin = async (usernameValue, passwordValue) => { public handleDoLogin = async (usernameValue: string, passwordValue: string) => {
// @ts-ignore
const { username, token, error } = await makeLogin(usernameValue, passwordValue); const { username, token, error } = await makeLogin(usernameValue, passwordValue);
if (username && token) { if (username && token) {
storage.setItem('username', username); storage.setItem('username', username);
storage.setItem('token', token); storage.setItem('token', token);
this.setLoggedUser(username, token); this.setLoggedUser(username);
} }
if (error) { if (error) {
@@ -138,11 +121,10 @@ export default class App extends Component<any, any> {
} }
}; };
public setLoggedUser = (username, token) => { public setLoggedUser = (username: string) => {
this.setState({ this.setState({
user: { user: {
username, username,
token,
}, },
isUserLoggedIn: true, // close login modal after successful login isUserLoggedIn: true, // close login modal after successful login
showLoginModal: false, // set isUserLoggedIn to true showLoginModal: false, // set isUserLoggedIn to true
@@ -171,9 +153,7 @@ export default class App extends Component<any, any> {
return ( return (
<> <>
<Content> <Content>
<RouterApp onLogout={this.handleLogout} onToggleLoginModal={this.handleToggleLoginModal}> <AppRoute>{this.renderHeader()}</AppRoute>
{this.renderHeader()}
</RouterApp>
</Content> </Content>
<Footer /> <Footer />
</> </>
@@ -183,7 +163,6 @@ export default class App extends Component<any, any> {
public renderHeader = (): ReactElement<HTMLElement> => { public renderHeader = (): ReactElement<HTMLElement> => {
const { const {
logoUrl, logoUrl,
// @ts-ignore
user: { username }, user: { username },
scope, scope,
} = this.state; } = this.state;

20
src/App/AppContext.tsx Normal file
View 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;

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

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

68
src/App/AppRoute.tsx Normal file
View 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;

View File

@@ -1,16 +0,0 @@
@import './styles/variables';
.alertError {
background-color: $red !important;
min-width: inherit !important;
}
.alertErrorMsg {
display: flex;
align-items: center;
}
.alertIcon {
opacity: 0.9;
margin-right: 8px;
}

18
src/App/styles.ts Normal file
View File

@@ -0,0 +1,18 @@
import { css } from 'emotion';
import colors from '../utils/styles/colors';
export const alertError = css({
backgroundColor: `${colors.red} !important`,
minWidth: 'inherit !important',
});
export const alertErrorMsg = css({
display: 'flex',
alignItems: 'center',
});
export const alertIcon = css({
opacity: 0.9,
marginRight: '8px',
});

View File

@@ -0,0 +1,89 @@
import React from 'react';
import { mount } from 'enzyme';
import api from '../../utils/api';
import { ActionBar } from './ActionBar';
const mockPackageMeta: jest.Mock = jest.fn(() => ({
latest: {
homepage: 'https://verdaccio.tld',
bugs: {
url: 'https://verdaccio.tld/bugs',
},
dist: {
tarball: 'https://verdaccio.tld/download',
},
},
}));
jest.mock('../../pages/Version', () => ({
DetailContextConsumer: component => {
return component.children({ packageMeta: mockPackageMeta() });
},
}));
describe('<ActionBar /> component', () => {
beforeEach(() => {
jest.resetModules();
jest.resetAllMocks();
});
test('should render the component in default state', () => {
const wrapper = mount(<ActionBar />);
expect(wrapper.html()).toMatchSnapshot();
});
test('when there is no action bar data', () => {
mockPackageMeta.mockImplementation(() => ({
latest: {},
}));
const wrapper = mount(<ActionBar />);
// FIXME: this only renders the DetailContextConsumer, thus
// the wrapper will be always empty
expect(wrapper.html()).toEqual('');
});
test('when there is 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', () => {
mockPackageMeta.mockImplementation(() => ({
latest: {
dist: {
tarball: 'http://localhost:8080/bootstrap/-/bootstrap-4.3.1.tgz',
},
},
}));
const wrapper = mount(<ActionBar />);
expect(wrapper.html()).toMatchSnapshot();
const button = wrapper.find('button');
expect(button).toHaveLength(1);
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);
});
});

View File

@@ -1,14 +1,32 @@
import React, { Component, ReactElement } from 'react'; import React, { Component, ReactElement } from 'react';
import BugReportIcon from '@material-ui/icons/BugReport'; import BugReportIcon from '@material-ui/icons/BugReport';
import DownloadIcon from '@material-ui/icons/CloudDownload'; import DownloadIcon from '@material-ui/icons/CloudDownload';
import HomeIcon from '@material-ui/icons/Home'; import HomeIcon from '@material-ui/icons/Home';
import List from '@material-ui/core/List';
import Tooltip from '@material-ui/core/Tooltip';
import { DetailContextConsumer, VersionPageConsumerProps } from '../../pages/version/Version'; import { DetailContextConsumer, VersionPageConsumerProps } from '../../pages/Version';
import { 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'; import { Fab, ActionListItem } from './styles';
import { isURL } from '../../utils/url';
export interface Action {
icon: string;
title: string;
handler?: Function;
}
export async function downloadHandler(link: string): Promise<void> {
const fileStream: Blob = await api.request(link, 'GET', {
headers: {
['accept']: 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3',
},
credentials: 'include',
});
const fileName = extractFileName(link);
downloadFile(fileStream, fileName);
}
const ACTIONS = { const ACTIONS = {
homepage: { homepage: {
@@ -22,21 +40,28 @@ const ACTIONS = {
tarball: { tarball: {
icon: <DownloadIcon />, icon: <DownloadIcon />,
title: 'Download tarball', title: 'Download tarball',
handler: downloadHandler,
}, },
}; };
class ActionBar extends Component<any, any> { class ActionBar extends Component {
public render(): ReactElement<HTMLElement> { public render(): ReactElement<HTMLElement> {
return ( return (
<DetailContextConsumer> <DetailContextConsumer>
{context => { {context => {
const { packageMeta } = context;
if (!packageMeta) {
return null;
}
return this.renderActionBar(context as VersionPageConsumerProps); return this.renderActionBar(context as VersionPageConsumerProps);
}} }}
</DetailContextConsumer> </DetailContextConsumer>
); );
} }
private renderIconsWithLink(link: string, component: any): ReactElement<HTMLElement> { private renderIconsWithLink(link: string, component: JSX.Element): ReactElement<HTMLElement> {
return ( return (
<a href={link} target={'_blank'}> <a href={link} target={'_blank'}>
{component} {component}
@@ -44,40 +69,64 @@ class ActionBar extends Component<any, any> {
); );
} }
private renderActionBarListItems = packageMeta => { private renderActionBar = ({ packageMeta }) => {
// @ts-ignore const { latest } = packageMeta;
const { latest: { bugs: { url: issue } = {}, homepage, dist: { tarball } = {} } = {} } = packageMeta;
if (!latest) {
return null;
}
const { homepage, bugs, dist } = latest;
const actionsMap = { const actionsMap = {
homepage, homepage,
issue, issue: bugs ? bugs.url : null,
tarball, tarball: dist ? dist.tarball : null,
}; };
const renderList = Object.keys(actionsMap).reduce((component, value, key) => { const renderList = Object.keys(actionsMap).reduce((component: React.ReactElement[], value, key) => {
const link = actionsMap[value]; const link = actionsMap[value];
if (link && isURL(link)) { if (link && isURL(link)) {
const fab = <Fab size={'small'}>{ACTIONS[value]['icon']}</Fab>; const actionItem: Action = ACTIONS[value];
component.push( if (actionItem.handler) {
// @ts-ignore const fab = (
<Tooltip key={key} title={ACTIONS[value]['title']}> <Tooltip key={key} title={actionItem['title']}>
<>{this.renderIconsWithLink(link, fab)}</> <Fab
</Tooltip> /* eslint-disable react/jsx-no-bind */
); onClick={() => {
/* eslint-disable @typescript-eslint/no-non-null-assertion */
actionItem.handler!(link);
}}
size={'small'}>
{actionItem['icon']}
</Fab>
</Tooltip>
);
component.push(fab);
} else {
const fab = <Fab size={'small'}>{actionItem['icon']}</Fab>;
component.push(
<Tooltip key={key} title={actionItem['title']}>
<>{this.renderIconsWithLink(link, fab)}</>
</Tooltip>
);
}
} }
return component; return component;
}, []); }, []);
return ( if (renderList.length > 0) {
<> return (
<ActionListItem alignItems={'flex-start'}>{renderList}</ActionListItem> <List>
</> <ActionListItem alignItems={'flex-start'} button={true}>
); {renderList}
}; </ActionListItem>
</List>
);
}
private renderActionBar = ({ packageMeta = {} }) => { return null;
return <List>{this.renderActionBarListItems(packageMeta)}</List>;
}; };
} }
export default ActionBar; export { ActionBar };

View File

@@ -0,0 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`<ActionBar /> component should render the component in default state 1`] = `""`;
exports[`<ActionBar /> component when there is a button to download a tarball 1`] = `"<ul class=\\"MuiList-root MuiList-padding\\"><div class=\\"MuiButtonBase-root MuiListItem-root css-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>"`;

View File

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

View File

@@ -1,11 +1,71 @@
import React from 'react'; import React from 'react';
import { shallow } from 'enzyme'; import { mount } from 'enzyme';
import Author from './Author'; import { DetailContext } from '../../pages/Version';
import Authors from './Author';
const withAuthorComponent = (packageMeta: React.ContextType<typeof DetailContext>['packageMeta']): JSX.Element => (
<DetailContext.Provider value={{ packageMeta }}>
<Authors />
</DetailContext.Provider>
);
describe('<Author /> component', () => { describe('<Author /> component', () => {
beforeEach(() => {
jest.resetAllMocks();
});
test('should render the component in default state', () => { test('should render the component in default state', () => {
const wrapper = shallow(<Author />); const packageMeta = {
latest: {
name: 'verdaccio',
version: '4.0.0',
author: {
name: 'verdaccio user',
email: 'verdaccio.user@verdaccio.org',
url: '',
avatar: 'https://www.gravatar.com/avatar/000000',
},
dist: { fileCount: 0, unpackedSize: 0 },
},
_uplinks: {},
};
const wrapper = mount(withAuthorComponent(packageMeta));
expect(wrapper.html()).toMatchSnapshot();
});
test('should render the component when there is no author information available', () => {
const packageMeta = {
latest: {
name: 'verdaccio',
version: '4.0.0',
dist: { fileCount: 0, unpackedSize: 0 },
},
_uplinks: {},
};
const wrapper = mount(withAuthorComponent(packageMeta));
expect(wrapper.html()).toBeNull();
});
test('should render the component when there is no author email', () => {
const packageMeta = {
latest: {
name: 'verdaccio',
version: '4.0.0',
author: {
name: 'verdaccio user',
url: '',
avatar: 'https://www.gravatar.com/avatar/000000',
},
dist: { fileCount: 0, unpackedSize: 0 },
},
_uplinks: {},
};
const wrapper = mount(withAuthorComponent(packageMeta));
expect(wrapper.html()).toMatchSnapshot(); expect(wrapper.html()).toMatchSnapshot();
}); });
}); });

View File

@@ -1,53 +1,44 @@
import React, { Component, ReactNode } from 'react'; import React, { FC, useContext } from 'react';
import Avatar from '@material-ui/core/Avatar'; import { DetailContext } from '../../pages/Version';
import List from '@material-ui/core/List';
import ListItemText from '@material-ui/core/ListItemText';
import { DetailContextConsumer } from '../../pages/version/Version';
import { Heading, AuthorListItem } from './styles';
import { isEmail } from '../../utils/url'; import { isEmail } from '../../utils/url';
import Avatar from '../../muiComponents/Avatar';
import List from '../../muiComponents/List';
class Authors extends Component<any, any> { import { StyledText, AuthorListItem, AuthorListItemText } from './styles';
render() {
return ( const Author: FC = () => {
<DetailContextConsumer> const { packageMeta } = useContext(DetailContext);
{(context: any) => {
return context && context.packageMeta && this.renderAuthor(context.packageMeta); if (!packageMeta) {
}} return null;
</DetailContextConsumer>
);
} }
renderLinkForMail(email: string, avatarComponent: ReactNode, packageName: string, version: string) { const { author, name: packageName, version } = packageMeta.latest;
if (!email || isEmail(email) === false) {
return avatarComponent;
}
return ( if (!author) {
<a href={`mailto:${email}?subject=${packageName}@${version}`} target={'_top'}> return null;
{avatarComponent}
</a>
);
} }
renderAuthor = packageMeta => { const { email, name } = author;
const { author, name: packageName, version } = packageMeta.latest;
if (!author) { const avatarComponent = <Avatar alt={author.name} src={author.avatar} />;
return null;
}
const avatarComponent = <Avatar alt={author.name} src={author.avatar} />; return (
return ( <List subheader={<StyledText variant={'subtitle1'}>{'Author'}</StyledText>}>
<List subheader={<Heading variant={'subheading'}>{'Author'}</Heading>}> <AuthorListItem button={true}>
<AuthorListItem> {!email || !isEmail(email) ? (
{this.renderLinkForMail(author.email, avatarComponent, packageName, version)} avatarComponent
<ListItemText primary={author.name} /> ) : (
</AuthorListItem> <a href={`mailto:${email}?subject=${packageName}@${version}`} target={'_top'}>
</List> {avatarComponent}
); </a>
}; )}
}
export default Authors; <AuthorListItemText primary={name} />
</AuthorListItem>
</List>
);
};
export default Author;

View File

@@ -1,3 +1,5 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`<Author /> component should render the component in default state 1`] = `""`; exports[`<Author /> component should render the component in default state 1`] = `"<ul class=\\"MuiList-root MuiList-padding MuiList-subheader\\"><h6 class=\\"MuiTypography-root css-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-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>"`;

View File

@@ -1,16 +1,27 @@
import styled from 'react-emotion'; import styled from 'react-emotion';
import ListItem from '@material-ui/core/ListItem'; import ListItemText from '@material-ui/core/ListItemText';
import Typography from '@material-ui/core/Typography';
export const Heading = styled(Typography)` import { fontWeight } from '../../utils/styles/sizes';
&& { import ListItem from '../../muiComponents/ListItem';
font-weight: 700; import Text from '../../muiComponents/Text';
text-transform: capitalize;
} export const StyledText = styled(Text)({
`; fontWeight: fontWeight.bold,
export const AuthorListItem = styled(ListItem)` textTransform: 'capitalize',
&& { });
padding-left: 0;
padding-right: 0; export const AuthorListItem = styled(ListItem)({
} '&&': {
`; padding: 0,
},
'&&:hover': {
backgroundColor: 'transparent',
},
});
export const AuthorListItemText = styled(ListItemText)({
'&&': {
padding: '0 10px',
margin: 0,
},
});

View File

@@ -1,14 +1,16 @@
import React, { KeyboardEvent } from 'react'; import React, { KeyboardEvent } from 'react';
import Autosuggest from 'react-autosuggest'; import { css } from 'emotion';
import Autosuggest, { SuggestionSelectedEventData, InputProps, ChangeEvent } from 'react-autosuggest';
import match from 'autosuggest-highlight/match'; import match from 'autosuggest-highlight/match';
import parse from 'autosuggest-highlight/parse'; import parse from 'autosuggest-highlight/parse';
import MenuItem from '@material-ui/core/MenuItem'; import MenuItem from '@material-ui/core/MenuItem';
import { fontWeight } from '../../utils/styles/sizes'; import { fontWeight } from '../../utils/styles/sizes';
import { Wrapper, InputField, SuggestionContainer } from './styles'; import { Wrapper, InputField, SuggestionContainer } from './styles';
export interface Props { interface Props {
suggestions: any[]; suggestions: unknown[];
suggestionsLoading?: boolean; suggestionsLoading?: boolean;
suggestionsLoaded?: boolean; suggestionsLoaded?: boolean;
suggestionsError?: boolean; suggestionsError?: boolean;
@@ -16,20 +18,23 @@ export interface Props {
color?: string; color?: string;
value?: string; value?: string;
placeholder?: string; placeholder?: string;
startAdornment?: any; startAdornment?: JSX.Element;
disableUnderline?: boolean; disableUnderline?: boolean;
onChange?: (event: KeyboardEvent<HTMLInputElement>, { newValue, method }: { newValue: string; method: string }) => void; onChange: (event: React.FormEvent<HTMLInputElement>, params: ChangeEvent) => void;
onSuggestionsFetch?: ({ value: string }) => Promise<void>; onSuggestionsFetch: ({ value: string }) => Promise<void>;
onCleanSuggestions?: () => void; onCleanSuggestions?: () => void;
onClick?: (event: KeyboardEvent<HTMLInputElement>, { suggestionValue, method }: { suggestionValue: any[]; method: string }) => void; onClick?: (event: React.FormEvent<HTMLInputElement>, data: SuggestionSelectedEventData<unknown>) => void;
onKeyDown?: (event: KeyboardEvent<HTMLInputElement>) => void; onKeyDown?: (event: KeyboardEvent<HTMLInputElement>) => void;
onBlur?: (event: KeyboardEvent<HTMLInputElement>) => void; onBlur?: (event: React.FormEvent<HTMLInputElement>) => void;
} }
const renderInputComponent = inputProps => { /* eslint-disable react/jsx-sort-props */
/* eslint-disable verdaccio/jsx-spread */
const renderInputComponent = (inputProps): JSX.Element => {
const { ref, startAdornment, disableUnderline, onKeyDown, ...others } = inputProps; const { ref, startAdornment, disableUnderline, onKeyDown, ...others } = inputProps;
return ( return (
<InputField <InputField
fullWidth={true}
InputProps={{ InputProps={{
inputRef: node => { inputRef: node => {
ref(node); ref(node);
@@ -38,7 +43,6 @@ const renderInputComponent = inputProps => {
disableUnderline, disableUnderline,
onKeyDown, onKeyDown,
}} }}
fullWidth={true}
{...others} {...others}
/> />
); );
@@ -46,19 +50,21 @@ const renderInputComponent = inputProps => {
const getSuggestionValue = (suggestion): string => suggestion.name; const getSuggestionValue = (suggestion): string => suggestion.name;
const renderSuggestion = (suggestion, { query, isHighlighted }) => { const renderSuggestion = (suggestion, { query, isHighlighted }): JSX.Element => {
const matches = match(suggestion.name, query); const matches = match(suggestion.name, query);
const parts = parse(suggestion.name, matches); const parts = parse(suggestion.name, matches);
return ( return (
<MenuItem component="div" selected={isHighlighted}> <MenuItem component="div" selected={isHighlighted}>
<div> <div>
{parts.map((part, index) => { {parts.map((part, index) => {
return part.highlight ? ( const fw = part.highlight ? fontWeight.semiBold : fontWeight.light;
<a href={suggestion.link} key={String(index)} style={{ fontWeight: fontWeight.semiBold }}> return (
{part.text} <a
</a> className={css`
) : ( font-weight: ${fw};
<a href={suggestion.link} key={String(index)} style={{ fontWeight: fontWeight.light }}> `}
href={suggestion.link}
key={String(index)}>
{part.text} {part.text}
</a> </a>
); );
@@ -68,7 +74,7 @@ const renderSuggestion = (suggestion, { query, isHighlighted }) => {
); );
}; };
const renderMessage = message => { const renderMessage = (message): JSX.Element => {
return ( return (
<MenuItem component="div" selected={false}> <MenuItem component="div" selected={false}>
<div>{message}</div> <div>{message}</div>
@@ -98,7 +104,7 @@ const AutoComplete = ({
suggestionsLoading = false, suggestionsLoading = false,
suggestionsLoaded = false, suggestionsLoaded = false,
suggestionsError = false, suggestionsError = false,
}: Props) => { }: Props): JSX.Element => {
const autosuggestProps = { const autosuggestProps = {
renderInputComponent, renderInputComponent,
suggestions, suggestions,
@@ -107,10 +113,12 @@ const AutoComplete = ({
onSuggestionsFetchRequested: onSuggestionsFetch, onSuggestionsFetchRequested: onSuggestionsFetch,
onSuggestionsClearRequested: onCleanSuggestions, onSuggestionsClearRequested: onCleanSuggestions,
}; };
const inputProps = { const inputProps: InputProps<unknown> = {
value, value,
onChange, onChange,
placeholder, placeholder,
// material-ui@4.5.1 introduce better types for TextInput, check readme
// @ts-ignore
startAdornment, startAdornment,
disableUnderline, disableUnderline,
color, color,
@@ -119,7 +127,7 @@ const AutoComplete = ({
}; };
// this format avoid arrow function eslint rule // this format avoid arrow function eslint rule
function renderSuggestionsContainer({ containerProps, children, query }) { function renderSuggestionsContainer({ containerProps, children, query }): JSX.Element {
return ( return (
<SuggestionContainer {...containerProps} square={true}> <SuggestionContainer {...containerProps} square={true}>
{suggestionsLoaded && children === null && query && renderMessage(SUGGESTIONS_RESPONSE.NO_RESULT)} {suggestionsLoaded && children === null && query && renderMessage(SUGGESTIONS_RESPONSE.NO_RESULT)}

View File

@@ -2,21 +2,22 @@ import React from 'react';
import styled, { css } from 'react-emotion'; import styled, { css } from 'react-emotion';
import Paper from '@material-ui/core/Paper'; import Paper from '@material-ui/core/Paper';
import TextField from '../TextField'; import TextField from '../../muiComponents/TextField';
export interface InputFieldProps { export interface InputFieldProps {
color: string; color: string;
} }
export const Wrapper = styled('div')` export const Wrapper = styled('div')({
&& { '&&': {
width: 100%; width: '100%',
height: 32px; height: '32px',
position: relative; position: 'relative',
z-index: 1; zIndex: 1,
} },
`; });
/* eslint-disable verdaccio/jsx-spread */
export const InputField: React.FC<InputFieldProps> = ({ color, ...others }) => ( export const InputField: React.FC<InputFieldProps> = ({ color, ...others }) => (
<TextField <TextField
{...others} {...others}
@@ -51,9 +52,9 @@ export const InputField: React.FC<InputFieldProps> = ({ color, ...others }) => (
/> />
); );
export const SuggestionContainer = styled(Paper)` export const SuggestionContainer = styled(Paper)({
&& { '&&': {
max-height: 500px; maxHeight: '500px',
overflow-y: auto; overflowY: 'auto',
} },
`; });

View File

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

View File

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

View File

@@ -1,38 +1,27 @@
import React from 'react'; import React from 'react';
import { shallow } from 'enzyme'; import { mount, ReactWrapper } from 'enzyme';
import { copyToClipBoardUtility } from '../../utils/cli-utils';
import CopyToClipBoard from './CopyToClipBoard'; import CopyToClipBoard from './CopyToClipBoard';
import { CopyIcon } from './styles'; import { CopyIcon } from './styles';
jest.mock('../../utils/cli-utils');
describe('<CopyToClipBoard /> component', () => { describe('<CopyToClipBoard /> component', () => {
let wrapper; let wrapper: ReactWrapper;
const copyText = 'copy text';
beforeEach(() => { beforeEach(() => {
wrapper = shallow(<CopyToClipBoard text={'copy text'} />); wrapper = mount(<CopyToClipBoard text={copyText} />);
}); });
test('render the component', () => { test('render the component', () => {
expect(wrapper.html()).toMatchSnapshot(); expect(wrapper.html()).toMatchSnapshot();
}); });
test('should call the DOM APIs for copy to clipboard utility', () => { test('should call the copyToClipBoardUtility for copy to clipboard utility', () => {
const event = { wrapper.find(CopyIcon).simulate('click');
preventDefault: jest.fn(), expect(copyToClipBoardUtility).toHaveBeenCalledWith(copyText);
};
// @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');
}); });
}); });

View File

@@ -1,9 +1,9 @@
import Tooltip from '@material-ui/core/Tooltip';
import FileCopy from '@material-ui/icons/FileCopy'; import FileCopy from '@material-ui/icons/FileCopy';
import React from 'react'; import React from 'react';
import { copyToClipBoardUtility } from '../../utils/cli-utils'; import { copyToClipBoardUtility } from '../../utils/cli-utils';
import { TEXT } from '../../utils/constants'; import { TEXT } from '../../utils/constants';
import Tooltip from '../../muiComponents/Tooltip';
import { ClipBoardCopy, ClipBoardCopyText, CopyIcon } from './styles'; import { ClipBoardCopy, ClipBoardCopyText, CopyIcon } from './styles';
@@ -12,7 +12,7 @@ interface Props {
children?: React.ReactNode; children?: React.ReactNode;
} }
const renderText: React.FC<any> = (text: string, children: React.ReactNode): React.ReactElement<HTMLElement> => { const renderText = (text: string, children: React.ReactNode): JSX.Element => {
if (children) { if (children) {
return <ClipBoardCopyText>{children}</ClipBoardCopyText>; return <ClipBoardCopyText>{children}</ClipBoardCopyText>;
} }

View File

@@ -1,3 +1,3 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`<CopyToClipBoard /> component render the component 1`] = `"<div class=\\"css-1mta3t8 eb8w2fo0\\"><span class=\\"css-1m8aenu eb8w2fo1\\">copy text</span><button class=\\"MuiButtonBase-root-15 MuiIconButton-root-9 css-56v3u0 eb8w2fo2\\" tabindex=\\"0\\" type=\\"button\\" title=\\"Copy to Clipboard\\"><span class=\\"MuiIconButton-label-14\\"><svg class=\\"MuiSvgIcon-root-18\\" focusable=\\"false\\" viewBox=\\"0 0 24 24\\" aria-hidden=\\"true\\" role=\\"presentation\\"><path fill=\\"none\\" d=\\"M0 0h24v24H0z\\"></path><path d=\\"M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm-1 4l6 6v10c0 1.1-.9 2-2 2H7.99C6.89 23 6 22.1 6 21l.01-14c0-1.1.89-2 1.99-2h7zm-1 7h5.5L14 6.5V12z\\"></path></svg></span></button></div>"`; exports[`<CopyToClipBoard /> component render the component 1`] = `"<div class=\\"css-1mta3t8 eb8w2fo0\\"><span class=\\"css-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>"`;

View File

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

View 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');
});
});

View File

@@ -1,108 +1,78 @@
import React, { Component, Fragment, ReactElement } from 'react'; import React, { useContext } from 'react';
import { withRouter } from 'react-router-dom'; import { useHistory } from 'react-router-dom';
import CardContent from '@material-ui/core/CardContent'; import CardContent from '@material-ui/core/CardContent';
import { DetailContextConsumer, VersionPageConsumerProps } from '../../pages/version/Version'; import { PackageDependencies } from '../../../types/packageMeta';
import { DetailContext } from '../../pages/Version';
import { CardWrap, Heading, Tags, Tag } from './styles';
import NoItems from '../NoItems'; import NoItems from '../NoItems';
class DepDetail extends Component<any, any> { import { CardWrap, StyledText, Tags, Tag } from './styles';
constructor(props: any) {
super(props);
const { name, version } = this.props;
this.state = { interface DependencyBlockProps {
name, title: string;
version, dependencies: PackageDependencies;
}; }
}
public render(): ReactElement<HTMLElement> { const DependencyBlock: React.FC<DependencyBlockProps> = ({ title, dependencies }) => {
const { name, version } = this.state; const { enableLoading } = useContext(DetailContext);
const tagText = `${name}@${version}`; const history = useHistory();
return <Tag className={'dep-tag'} clickable={true} component={'div'} label={tagText} onClick={this.handleOnClick} />;
}
private handleOnClick = () => { const deps = Object.entries(dependencies);
const { name } = this.state;
const { onLoading, history } = this.props; function handleClick(name: string): void {
enableLoading && enableLoading();
onLoading();
history.push(`/-/web/detail/${name}`); 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<any, any> { if (!packageMeta) {
public render(): ReactElement<HTMLElement> { throw new Error('packageMeta is required at DetailContext');
const { dependencies, title } = this.props; }
const deps = Object.entries(dependencies);
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 ( return (
<DetailContextConsumer> <>
{({ enableLoading }: any) => { {Object.entries(dependencyMap).map(([dependencyType, dependencies]) => {
return ( if (!dependencies || Object.keys(dependencies).length === 0) {
<CardWrap> return null;
<CardContent> }
<Heading variant="subheading">{`${title} (${deps.length})`}</Heading>
<Tags>{this.renderTags(deps, enableLoading)}</Tags> return <DependencyBlock dependencies={dependencies} key={dependencyType} title={dependencyType} />;
</CardContent> })}
</CardWrap> </>
);
}}
</DetailContextConsumer>
); );
} }
private renderTags = (deps: any, enableLoading: any) => return <NoItems className="no-dependencies" text={`${name} has no dependencies.`} />;
deps.map(dep => { };
const [name, version] = dep;
return <WrapperDependencyDetail key={name} name={name} onLoading={enableLoading} version={version} />;
});
}
class Dependencies extends Component<any, any> {
public state = {
tabPosition: 0,
};
public render(): ReactElement<HTMLElement> {
return (
<DetailContextConsumer>
{packageMeta => {
return this.renderDependencies(packageMeta as VersionPageConsumerProps);
}}
</DetailContextConsumer>
);
}
private checkDependencyLength(dependency: Record<string, any> = {}): 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.`} />;
}
}
export default Dependencies; export default Dependencies;

View File

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

View 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');
});

View File

@@ -1,72 +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/Version'; import { DetailContext } 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';
interface DetailContainerState { import DetailContainerTabs from './DetailContainerTabs';
tabPosition: number; import DetailContainerContent from './DetailContainerContent';
} import { TabPosition } from './tabs';
class DetailContainer extends Component<any, DetailContainerState> { const DetailContainer: React.FC = () => {
public state = { const [tabPosition, setTabPosition] = useState(TabPosition.README);
tabPosition: 0, const detailContext = useContext(DetailContext);
}; const { readMe } = detailContext;
public render(): ReactElement<HTMLElement> { const handleChangeTabPosition = useCallback(
return ( (event: ChangeEvent<{}>) => {
<DetailContextConsumer> event.preventDefault();
{context => { const eventTarget = event.target as HTMLSpanElement;
return this.renderTabs(context as VersionPageConsumerProps); const chosentab = eventTarget.innerText as TabPosition;
}} setTabPosition(TabPosition[chosentab]);
</DetailContextConsumer> },
); [setTabPosition]
} );
private handleChange = (event: any, tabPosition: number) => { return (
event.preventDefault(); <Box component="div" display="flex" flexDirection="column" padding={2}>
this.setState({ tabPosition }); <DetailContainerTabs onChangeTabPosition={handleChangeTabPosition} tabPosition={tabPosition} />
}; <DetailContainerContent readDescription={readMe} tabPosition={tabPosition} />
</Box>
private renderListTabs(tabPosition: number): React.ReactElement<HTMLElement> { );
return ( };
<Tabs indicatorColor={'primary'} onChange={this.handleChange} textColor={'primary'} value={tabPosition} variant={'fullWidth'}>
<Tab id={'readme-tab'} label={'Readme'} />
<Tab id={'dependencies-tab'} label={'Dependencies'} />
<Tab id={'versions-tab'} label={'Versions'} />
<Tab id={'uplinks-tab'} label={'Uplinks'} />
</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} />;
};
}
export default DetailContainer; export default DetailContainer;

View 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;

View File

@@ -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;

View 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;

View File

@@ -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>
`;

View File

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

View File

@@ -0,0 +1,6 @@
export enum TabPosition {
README = 'Readme',
DEPENDENCIES = 'Dependencies',
VERSIONS = 'Versions',
UPLINKS = 'Uplinks',
}

View File

@@ -1,7 +0,0 @@
import { ReactNode } from 'react';
export interface Props {
children: ReactNode;
open: boolean;
onClose: () => void;
}

View File

@@ -1,87 +1,77 @@
import React, { Component, ReactElement } from 'react'; import React, { ReactElement } from 'react';
import Card from '@material-ui/core/Card';
import CardContent from '@material-ui/core/CardContent'; import CardContent from '@material-ui/core/CardContent';
import List from '@material-ui/core/List';
import ActionBar from '../ActionBar/ActionBar'; import { ActionBar } from '../ActionBar/ActionBar';
import Author from '../Author'; import Author from '../Author';
import Developers from '../Developers'; import Developers from '../Developers';
import Dist from '../Dist/Dist'; import Dist from '../Dist/Dist';
import Engine from '../Engines/Engines'; import Engine from '../Engines/Engines';
import Install from '../Install'; import Install from '../Install';
import Repository from '../Repository/Repository'; import Repository from '../Repository/Repository';
import { DetailContext } from '../../pages/Version';
import List from '../../muiComponents/List';
import Card from '../../muiComponents/Card';
import { DetailContextConsumer, VersionPageConsumerProps } from '../../pages/version/Version'; import { TitleListItem, TitleListItemText, PackageDescription, PackageVersion } from './styles';
import { TitleListItem, TitleListItemText } from './styles'; const renderLatestDescription = (description, version, isLatest: boolean = true): JSX.Element => {
return (
<>
<PackageDescription>{description}</PackageDescription>
{version ? (
<PackageVersion>
<small>{`${isLatest ? 'Latest v' : 'v'}${version}`}</small>
</PackageVersion>
) : null}
</>
);
};
class DetailSidebar extends Component { const renderCopyCLI = (): JSX.Element => <Install />;
public render(): ReactElement<HTMLElement> { const renderMaintainers = (): JSX.Element => <Developers type="maintainers" />;
return <DetailContextConsumer>{context => this.renderSideBar(context as VersionPageConsumerProps)}</DetailContextConsumer>; 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';
private renderSideBar = ({ packageName, packageMeta }): ReactElement<HTMLElement> => { return (
return ( <List className="detail-info">
<div className={'sidebar-info'}> <TitleListItem alignItems="flex-start" button={true}>
<Card> <TitleListItemText primary={<b>{packageName}</b>} secondary={renderLatestDescription(packageMeta.latest.description, version, isLatest)} />
<CardContent> </TitleListItem>
{this.renderTitle(packageName, packageMeta)} </List>
{this.renderActionBar()} );
{this.renderCopyCLI()} };
{this.renderRepository()}
{this.renderEngine()}
{this.renderDist()}
{this.renderAuthor()}
{this.renderMaintainers()}
{this.renderContributors()}
</CardContent>
</Card>
</div>
);
};
private renderTitle = (packageName, packageMeta) => { function renderSideBar(packageName, packageVersion, packageMeta): ReactElement<HTMLElement> {
return ( return (
<List className="detail-info"> <div className={'sidebar-info'}>
<TitleListItem alignItems="flex-start"> <Card>
<TitleListItemText primary={<b>{packageName}</b>} secondary={packageMeta.latest.description} /> <CardContent>
</TitleListItem> {renderTitle(packageName, packageVersion, packageMeta)}
</List> {renderActionBar()}
); {renderCopyCLI()}
}; {renderRepository()}
{renderEngine()}
private renderCopyCLI = () => { {renderDist()}
return <Install />; {renderAuthor()}
}; {renderMaintainers()}
{renderContributors()}
private renderMaintainers = () => { </CardContent>
return <Developers type="maintainers" />; </Card>
}; </div>
);
private renderContributors = () => {
return <Developers type="contributors" />;
};
private renderRepository = () => {
return <Repository />;
};
private renderAuthor = () => {
return <Author />;
};
private renderEngine = () => {
return <Engine />;
};
private renderDist = () => {
return <Dist />;
};
private renderActionBar = () => {
return <ActionBar />;
};
} }
const DetailSidebar = (): JSX.Element => {
const { packageName, packageMeta, packageVersion } = React.useContext(DetailContext);
return renderSideBar(packageName, packageVersion, packageMeta);
};
export default DetailSidebar; export default DetailSidebar;

View File

@@ -1,30 +1,30 @@
import styled from 'react-emotion'; 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 ListItemText from '@material-ui/core/ListItemText';
import colors from '../../utils/styles/colors'; import ListItem from '../../muiComponents/ListItem';
export const TitleListItem = styled(ListItem)` export const TitleListItem = styled(ListItem)({
&& { paddingLeft: 0,
padding-left: 0; paddingRight: 0,
padding-right: 0; paddingBottom: 0,
padding-bottom: 0; });
}
`;
export const TitleListItemText = styled(ListItemText)` export const TitleListItemText = styled(ListItemText)({
&& { '&&': {
padding-left: 0; paddingLeft: 0,
padding-right: 0; paddingRight: 0,
padding-top: 8px; paddingTop: '8px',
} },
`; });
export const TitleAvatar = styled(Avatar)` export const PackageDescription = styled('span')({
&& { '&&': {
color: ${colors.greySuperLight}; display: 'block',
background-color: ${colors.primary}; },
text-transform: capitalize; });
}
`; export const PackageVersion = styled('span')({
'&&': {
display: 'block',
},
});

View File

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

View File

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

View File

@@ -0,0 +1,533 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`test Developers should render the component for contributors with items 1`] = `
<Developers
type="contributors"
>
<Styled(Component)
variant="subtitle1"
>
<ForwardRef(Text)
className="css-48zeoi emotion-0"
variant="subtitle1"
>
<WithStyles(ForwardRef(Typography))
className="css-48zeoi emotion-0"
variant="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"
>
<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-6"
>
<Styled(span)
key="dave.methvin@gmail.com"
>
<span
className="css-dvxtzn emotion-4"
>
<AvatarTooltip
email="dave.methvin@gmail.com"
name="dmethvin"
version="1.0.0"
>
<ForwardRef(ToolTip)
title="dmethvin"
>
<WithStyles(ForwardRef(Tooltip))
innerRef={null}
title="dmethvin"
>
<ForwardRef(Tooltip)
classes={
Object {
"popper": "MuiTooltip-popper",
"popperInteractive": "MuiTooltip-popperInteractive",
"tooltip": "MuiTooltip-tooltip",
"tooltipPlacementBottom": "MuiTooltip-tooltipPlacementBottom",
"tooltipPlacementLeft": "MuiTooltip-tooltipPlacementLeft",
"tooltipPlacementRight": "MuiTooltip-tooltipPlacementRight",
"tooltipPlacementTop": "MuiTooltip-tooltipPlacementTop",
"touch": "MuiTooltip-touch",
}
}
title="dmethvin"
>
<a
aria-describedby={null}
className=""
href="mailto:dave.methvin@gmail.com?subject=undefined@1.0.0"
onBlur={[Function]}
onFocus={[Function]}
onMouseLeave={[Function]}
onMouseOver={[Function]}
onTouchEnd={[Function]}
onTouchStart={[Function]}
target="_top"
title="dmethvin"
>
<ForwardRef(Avatar)
aria-label="dmethvin"
>
<WithStyles(ForwardRef(Avatar))
aria-label="dmethvin"
>
<ForwardRef(Avatar)
aria-label="dmethvin"
classes={
Object {
"colorDefault": "MuiAvatar-colorDefault",
"img": "MuiAvatar-img",
"root": "MuiAvatar-root",
}
}
>
<div
aria-label="dmethvin"
className="MuiAvatar-root MuiAvatar-colorDefault"
/>
</ForwardRef(Avatar)>
</WithStyles(ForwardRef(Avatar))>
</ForwardRef(Avatar)>
</a>
<ForwardRef(Popper)
anchorEl={
<a
class=""
href="mailto:dave.methvin@gmail.com?subject=undefined@1.0.0"
target="_top"
title="dmethvin"
>
<div
aria-label="dmethvin"
class="MuiAvatar-root MuiAvatar-colorDefault"
/>
</a>
}
className="MuiTooltip-popper"
id={null}
open={false}
placement="bottom"
transition={true}
/>
</ForwardRef(Tooltip)>
</WithStyles(ForwardRef(Tooltip))>
</ForwardRef(ToolTip)>
</AvatarTooltip>
</span>
</Styled(span)>
<Styled(span)
key="m.goleb@gmail.com"
>
<span
className="css-dvxtzn emotion-4"
>
<AvatarTooltip
email="m.goleb@gmail.com"
name="mgol"
version="1.0.0"
>
<ForwardRef(ToolTip)
title="mgol"
>
<WithStyles(ForwardRef(Tooltip))
innerRef={null}
title="mgol"
>
<ForwardRef(Tooltip)
classes={
Object {
"popper": "MuiTooltip-popper",
"popperInteractive": "MuiTooltip-popperInteractive",
"tooltip": "MuiTooltip-tooltip",
"tooltipPlacementBottom": "MuiTooltip-tooltipPlacementBottom",
"tooltipPlacementLeft": "MuiTooltip-tooltipPlacementLeft",
"tooltipPlacementRight": "MuiTooltip-tooltipPlacementRight",
"tooltipPlacementTop": "MuiTooltip-tooltipPlacementTop",
"touch": "MuiTooltip-touch",
}
}
title="mgol"
>
<a
aria-describedby={null}
className=""
href="mailto:m.goleb@gmail.com?subject=undefined@1.0.0"
onBlur={[Function]}
onFocus={[Function]}
onMouseLeave={[Function]}
onMouseOver={[Function]}
onTouchEnd={[Function]}
onTouchStart={[Function]}
target="_top"
title="mgol"
>
<ForwardRef(Avatar)
aria-label="mgol"
>
<WithStyles(ForwardRef(Avatar))
aria-label="mgol"
>
<ForwardRef(Avatar)
aria-label="mgol"
classes={
Object {
"colorDefault": "MuiAvatar-colorDefault",
"img": "MuiAvatar-img",
"root": "MuiAvatar-root",
}
}
>
<div
aria-label="mgol"
className="MuiAvatar-root MuiAvatar-colorDefault"
/>
</ForwardRef(Avatar)>
</WithStyles(ForwardRef(Avatar))>
</ForwardRef(Avatar)>
</a>
<ForwardRef(Popper)
anchorEl={
<a
class=""
href="mailto:m.goleb@gmail.com?subject=undefined@1.0.0"
target="_top"
title="mgol"
>
<div
aria-label="mgol"
class="MuiAvatar-root MuiAvatar-colorDefault"
/>
</a>
}
className="MuiTooltip-popper"
id={null}
open={false}
placement="bottom"
transition={true}
/>
</ForwardRef(Tooltip)>
</WithStyles(ForwardRef(Tooltip))>
</ForwardRef(ToolTip)>
</AvatarTooltip>
</span>
</Styled(span)>
</div>
</Styled(div)>
</Developers>
`;
exports[`test Developers should render the component for maintainers with items 1`] = `
<Developers
type="maintainers"
>
<Styled(Component)
variant="subtitle1"
>
<ForwardRef(Text)
className="css-48zeoi emotion-0"
variant="subtitle1"
>
<WithStyles(ForwardRef(Typography))
className="css-48zeoi emotion-0"
variant="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"
>
<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-6"
>
<Styled(span)
key="dave.methvin@gmail.com"
>
<span
className="css-dvxtzn emotion-4"
>
<AvatarTooltip
email="dave.methvin@gmail.com"
name="dmethvin"
version="1.0.0"
>
<ForwardRef(ToolTip)
title="dmethvin"
>
<WithStyles(ForwardRef(Tooltip))
innerRef={null}
title="dmethvin"
>
<ForwardRef(Tooltip)
classes={
Object {
"popper": "MuiTooltip-popper",
"popperInteractive": "MuiTooltip-popperInteractive",
"tooltip": "MuiTooltip-tooltip",
"tooltipPlacementBottom": "MuiTooltip-tooltipPlacementBottom",
"tooltipPlacementLeft": "MuiTooltip-tooltipPlacementLeft",
"tooltipPlacementRight": "MuiTooltip-tooltipPlacementRight",
"tooltipPlacementTop": "MuiTooltip-tooltipPlacementTop",
"touch": "MuiTooltip-touch",
}
}
title="dmethvin"
>
<a
aria-describedby={null}
className=""
href="mailto:dave.methvin@gmail.com?subject=undefined@1.0.0"
onBlur={[Function]}
onFocus={[Function]}
onMouseLeave={[Function]}
onMouseOver={[Function]}
onTouchEnd={[Function]}
onTouchStart={[Function]}
target="_top"
title="dmethvin"
>
<ForwardRef(Avatar)
aria-label="dmethvin"
>
<WithStyles(ForwardRef(Avatar))
aria-label="dmethvin"
>
<ForwardRef(Avatar)
aria-label="dmethvin"
classes={
Object {
"colorDefault": "MuiAvatar-colorDefault",
"img": "MuiAvatar-img",
"root": "MuiAvatar-root",
}
}
>
<div
aria-label="dmethvin"
className="MuiAvatar-root MuiAvatar-colorDefault"
/>
</ForwardRef(Avatar)>
</WithStyles(ForwardRef(Avatar))>
</ForwardRef(Avatar)>
</a>
<ForwardRef(Popper)
anchorEl={
<a
class=""
href="mailto:dave.methvin@gmail.com?subject=undefined@1.0.0"
target="_top"
title="dmethvin"
>
<div
aria-label="dmethvin"
class="MuiAvatar-root MuiAvatar-colorDefault"
/>
</a>
}
className="MuiTooltip-popper"
id={null}
open={false}
placement="bottom"
transition={true}
/>
</ForwardRef(Tooltip)>
</WithStyles(ForwardRef(Tooltip))>
</ForwardRef(ToolTip)>
</AvatarTooltip>
</span>
</Styled(span)>
<Styled(span)
key="m.goleb@gmail.com"
>
<span
className="css-dvxtzn emotion-4"
>
<AvatarTooltip
email="m.goleb@gmail.com"
name="mgol"
version="1.0.0"
>
<ForwardRef(ToolTip)
title="mgol"
>
<WithStyles(ForwardRef(Tooltip))
innerRef={null}
title="mgol"
>
<ForwardRef(Tooltip)
classes={
Object {
"popper": "MuiTooltip-popper",
"popperInteractive": "MuiTooltip-popperInteractive",
"tooltip": "MuiTooltip-tooltip",
"tooltipPlacementBottom": "MuiTooltip-tooltipPlacementBottom",
"tooltipPlacementLeft": "MuiTooltip-tooltipPlacementLeft",
"tooltipPlacementRight": "MuiTooltip-tooltipPlacementRight",
"tooltipPlacementTop": "MuiTooltip-tooltipPlacementTop",
"touch": "MuiTooltip-touch",
}
}
title="mgol"
>
<a
aria-describedby={null}
className=""
href="mailto:m.goleb@gmail.com?subject=undefined@1.0.0"
onBlur={[Function]}
onFocus={[Function]}
onMouseLeave={[Function]}
onMouseOver={[Function]}
onTouchEnd={[Function]}
onTouchStart={[Function]}
target="_top"
title="mgol"
>
<ForwardRef(Avatar)
aria-label="mgol"
>
<WithStyles(ForwardRef(Avatar))
aria-label="mgol"
>
<ForwardRef(Avatar)
aria-label="mgol"
classes={
Object {
"colorDefault": "MuiAvatar-colorDefault",
"img": "MuiAvatar-img",
"root": "MuiAvatar-root",
}
}
>
<div
aria-label="mgol"
className="MuiAvatar-root MuiAvatar-colorDefault"
/>
</ForwardRef(Avatar)>
</WithStyles(ForwardRef(Avatar))>
</ForwardRef(Avatar)>
</a>
<ForwardRef(Popper)
anchorEl={
<a
class=""
href="mailto:m.goleb@gmail.com?subject=undefined@1.0.0"
target="_top"
title="mgol"
>
<div
aria-label="mgol"
class="MuiAvatar-root MuiAvatar-colorDefault"
/>
</a>
}
className="MuiTooltip-popper"
id={null}
open={false}
placement="bottom"
transition={true}
/>
</ForwardRef(Tooltip)>
</WithStyles(ForwardRef(Tooltip))>
</ForwardRef(ToolTip)>
</AvatarTooltip>
</span>
</Styled(span)>
</div>
</Styled(div)>
</Developers>
`;
exports[`test Developers should render the component with no items 1`] = `
<Developers
type="maintainers"
/>
`;

View File

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

View File

@@ -0,0 +1,71 @@
import React from 'react';
import { mount } from 'enzyme';
import { DetailContext } from '../../pages/Version';
import Dist from './Dist';
const withDistComponent = (packageMeta: React.ContextType<typeof DetailContext>['packageMeta']): JSX.Element => (
<DetailContext.Provider value={{ packageMeta }}>
<Dist />
</DetailContext.Provider>
);
describe('<Dist /> component', () => {
test('should render the component in default state', () => {
const packageMeta = {
latest: {
name: 'verdaccio',
version: '4.0.0',
dist: {
fileCount: 7,
unpackedSize: 10,
},
license: '',
},
_uplinks: {},
};
const wrapper = mount(withDistComponent(packageMeta));
expect(wrapper.html()).toMatchSnapshot();
});
test('should render the component with license as string', () => {
const packageMeta = {
latest: {
name: 'verdaccio',
version: '4.0.0',
dist: {
fileCount: 7,
unpackedSize: 10,
},
license: 'MIT',
},
_uplinks: {},
};
const wrapper = mount(withDistComponent(packageMeta));
expect(wrapper.html()).toMatchSnapshot();
});
test('should render the component with license as object', () => {
const packageMeta = {
latest: {
name: 'verdaccio',
version: '4.0.0',
dist: {
fileCount: 7,
unpackedSize: 10,
},
license: {
type: 'MIT',
url: 'https://www.opensource.org/licenses/mit-license.php',
},
},
_uplinks: {},
};
const wrapper = mount(withDistComponent(packageMeta));
expect(wrapper.html()).toMatchSnapshot();
});
});

View File

@@ -1,57 +1,46 @@
import React, { Component } from 'react'; import React, { FC, useContext } from 'react';
import List from '@material-ui/core/List'; import { DetailContext } from '../../pages/Version';
import { DetailContextConsumer } from '../../pages/version/Version';
import { Heading, DistListItem, DistChips } from './styles';
import fileSizeSI from '../../utils/file-size'; import fileSizeSI from '../../utils/file-size';
import { formatLicense } from '../../utils/package';
import List from '../../muiComponents/List';
class Dist extends Component<any, any> { import { StyledText, DistListItem, DistChips } from './styles';
render() {
return (
<DetailContextConsumer>
{(context: any) => {
return this.renderDist(context);
}}
</DetailContextConsumer>
);
}
renderChips(dist: any, license: string) { const DistChip: FC<{ name: string }> = ({ name, children }) =>
const distDict = { children ? (
'file-count': dist.fileCount, <DistChips
size: dist.unpackedSize && fileSizeSI(dist.unpackedSize), // lint rule conflicting with prettier
license, /* eslint-disable react/jsx-wrap-multilines */
}; label={
<>
const chipsList = Object.keys(distDict).reduce((componentList, title, key) => { <b>{name}</b>
// @ts-ignore {': '}
const value = distDict[title]; {children}
if (value) { </>
const label = (
<span>
{/* eslint-disable-next-line */}
<b>{title.split('-').join(' ')}</b>:{value}
</span>
);
// @ts-ignore is not assignable to parameter of type 'never'
componentList.push(<DistChips key={key} label={label} />);
} }
return componentList; /* eslint-enable */
}, []); />
) : null;
return chipsList; const Dist: FC = () => {
const { packageMeta } = useContext(DetailContext);
if (!packageMeta) {
return null;
} }
renderDist = ({ packageMeta }: any) => { const { dist, license } = packageMeta && packageMeta.latest;
const { dist = {}, license } = packageMeta.latest;
return ( return (
<List subheader={<Heading variant="subheading">{'Latest Distribution'}</Heading>}> <List subheader={<StyledText variant="subtitle1">{'Latest Distribution'}</StyledText>}>
<DistListItem>{this.renderChips(dist, license)}</DistListItem> <DistListItem button={true}>
</List> <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; export default Dist;

View File

@@ -0,0 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`<Dist /> component should render the component in default state 1`] = `"<ul class=\\"MuiList-root MuiList-padding MuiList-subheader\\"><h6 class=\\"MuiTypography-root css-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-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-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>"`;

View File

@@ -1,35 +1,34 @@
import styled from 'react-emotion'; import styled from 'react-emotion';
import { default as MuiFab } from '@material-ui/core/Fab'; import { default as MuiFab } from '@material-ui/core/Fab';
import Chip from '@material-ui/core/Chip'; 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 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)` export const StyledText = styled(Text)({
&& { fontWeight: fontWeight.bold,
font-weight: 700; textTransform: 'capitalize',
text-transform: capitalize; });
}
`;
export const DistListItem = styled(ListItem)` export const DistListItem = styled(ListItem)({
&& { '&&': {
padding-left: 0; paddingLeft: 0,
padding-right: 0; paddingRight: 0,
} },
`; });
export const DistChips = styled(Chip)` export const DistChips = styled(Chip)({
&& { '&&': {
margin-right: 5px; marginRight: '5px',
text-transform: capitalize; textTransform: 'capitalize',
} },
`; });
export const DownloadButton = styled(MuiFab)` export const DownloadButton = styled(MuiFab)({
&& { '&&': {
background-color: ${colors.primary}; backgroundColor: colors.primary,
color: ${colors.white}; color: colors.white,
} },
`; });

View File

@@ -0,0 +1,71 @@
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.Mock = jest.fn(() => ({
latest: {
homepage: 'https://verdaccio.tld',
bugs: {
url: 'https://verdaccio.tld/bugs',
},
dist: {
tarball: 'https://verdaccio.tld/download',
},
},
}));
jest.mock('../../pages/Version', () => ({
DetailContextConsumer: component => {
return component.children({ packageMeta: mockPackageMeta() });
},
}));
describe('<Engines /> component', () => {
beforeEach(() => {
jest.resetAllMocks();
});
test('should render the component in default state', () => {
const packageMeta = {
latest: {
engines: {
node: '>= 0.1.98',
npm: '>3',
},
},
};
mockPackageMeta.mockImplementation(() => packageMeta);
const wrapper = mount(<Engine />);
expect(wrapper.html()).toMatchSnapshot();
});
test('should render the component when there is no engine key in package meta', () => {
const packageMeta = {
latest: {},
};
mockPackageMeta.mockImplementation(() => packageMeta);
const wrapper = mount(<Engine />);
expect(wrapper.html()).toEqual('');
});
test('should render the component when there is no keys in engine in package meta', () => {
const packageMeta = {
latest: {
engines: {},
},
};
mockPackageMeta.mockImplementation(() => packageMeta);
const wrapper = mount(<Engine />);
expect(wrapper.html()).toEqual('');
});
});

View File

@@ -1,15 +1,15 @@
import React, { Component, ReactElement } from 'react'; import React, { Component, ReactElement } from 'react';
import Avatar from '@material-ui/core/Avatar';
import Grid from '@material-ui/core/Grid'; import Grid from '@material-ui/core/Grid';
import List from '@material-ui/core/List';
import ListItemText from '@material-ui/core/ListItemText'; import ListItemText from '@material-ui/core/ListItemText';
import { DetailContextConsumer, VersionPageConsumerProps } from '../../pages/version/Version'; import { VersionPageConsumerProps, DetailContextConsumer } from '../../pages/Version';
import { Heading, EngineListItem } from './styles'; import Avatar from '../../muiComponents/Avatar';
import List from '../../muiComponents/List';
import npm from '../Install/img/npm.svg';
import { StyledText, EngineListItem } from './styles';
// @ts-ignore // @ts-ignore
import node from './img/node.png'; import node from './img/node.png';
import npm from '../Install/img/npm.svg';
const ICONS = { const ICONS = {
'node-JS': <Avatar src={node} />, 'node-JS': <Avatar src={node} />,
@@ -58,10 +58,10 @@ class Engine extends Component {
return <Grid container={true}>{items}</Grid>; return <Grid container={true}>{items}</Grid>;
}; };
private renderListItems = (heading, text) => { private renderListItems = (heading: string, text: string) => {
return ( return (
<List subheader={<Heading variant={'subheading'}>{text.split('-').join(' ')}</Heading>}> <List subheader={<StyledText variant={'subtitle1'}>{text.split('-').join(' ')}</StyledText>}>
<EngineListItem> <EngineListItem button={true}>
{ICONS[text]} {ICONS[text]}
<ListItemText primary={heading} /> <ListItemText primary={heading} />
</EngineListItem> </EngineListItem>

View File

@@ -0,0 +1,3 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`<Engines /> component should render the component in default state 1`] = `"<div class=\\"MuiGrid-root MuiGrid-container\\"><div class=\\"MuiGrid-root MuiGrid-item MuiGrid-grid-xs-6\\"><ul class=\\"MuiList-root MuiList-padding MuiList-subheader\\"><h6 class=\\"MuiTypography-root css-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\\">&gt;= 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\\">&gt;3</span></div><span class=\\"MuiTouchRipple-root\\"></span></div></ul></div></div>"`;

View File

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

View File

@@ -1,5 +1,5 @@
import React from 'react'; import React from 'react';
import { mount } from 'enzyme'; import { mount, ReactWrapper } from 'enzyme';
import Footer from './Footer'; import Footer from './Footer';
@@ -8,12 +8,10 @@ jest.mock('../../../package.json', () => ({
})); }));
describe('<Footer /> component', () => { describe('<Footer /> component', () => {
let wrapper; let wrapper: ReactWrapper;
beforeEach(() => { beforeEach(() => {
// @ts-ignore : Property 'VERDACCIO_VERSION' does not exist on type 'Window'
window.VERDACCIO_VERSION = 'v.1.0.0'; window.VERDACCIO_VERSION = 'v.1.0.0';
wrapper = mount(<Footer />); wrapper = mount(<Footer />);
// @ts-ignore : Property 'VERDACCIO_VERSION' does not exist on type 'Window'
delete window.VERDACCIO_VERSION; delete window.VERDACCIO_VERSION;
}); });

View File

@@ -1,9 +1,10 @@
import React from 'react'; import React from 'react';
import { Wrapper, Left, Right, Earth, Flags, Love, Flag, Logo, Inner, ToolTip } from './styles';
import { goToVerdaccioWebsite } from '../../utils/windows'; import { goToVerdaccioWebsite } from '../../utils/windows';
const renderTooltip = () => ( import { Wrapper, Left, Right, Earth, Flags, Love, Flag, Logo, Inner, ToolTip } from './styles';
const renderTooltip = (): JSX.Element => (
<ToolTip> <ToolTip>
<Earth name="earth" size="md" /> <Earth name="earth" size="md" />
<Flags> <Flags>
@@ -21,8 +22,7 @@ const MADEWITH_LABEL = ' Made with';
const ON_LABEL = 'on'; const ON_LABEL = 'on';
const HEARTH_EMOJI = '♥'; const HEARTH_EMOJI = '♥';
// @ts-ignore const renderRight = (version = window.VERDACCIO_VERSION): JSX.Element => {
const renderRight = (version = window.VERDACCIO_VERSION) => {
return ( return (
<Right> <Right>
{POWERED_LABEL} {POWERED_LABEL}
@@ -32,7 +32,7 @@ const renderRight = (version = window.VERDACCIO_VERSION) => {
); );
}; };
const renderLeft = () => ( const renderLeft = (): JSX.Element => (
<Left> <Left>
{MADEWITH_LABEL} {MADEWITH_LABEL}
<Love>{HEARTH_EMOJI}</Love> <Love>{HEARTH_EMOJI}</Love>

View File

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

View File

@@ -1,17 +1,18 @@
import styled, { css } from 'react-emotion'; import styled, { css } from 'react-emotion';
import mq from '../../utils/styles/media'; import mq from '../../utils/styles/media';
import Icon from '../Icon/Icon'; import Icon from '../Icon/Icon';
import colors from '../../utils/styles/colors'; import colors from '../../utils/styles/colors';
export const Wrapper = styled('div')` export const Wrapper = styled('div')({
&& { '&&': {
background: ${colors.snow}; background: colors.snow,
border-top: 1px solid ${colors.greyGainsboro}; borderTop: `1px solid ${colors.greyGainsboro}`,
color: ${colors.nobel01}; color: colors.nobel01,
font-size: 14px; fontSize: '14px',
padding: 20px; padding: '20px',
} },
`; });
export const Inner = styled('div')` export const Inner = styled('div')`
&& { && {
@@ -20,7 +21,6 @@ export const Inner = styled('div')`
justify-content: flex-end; justify-content: flex-end;
width: 100%; width: 100%;
${() => { ${() => {
// @ts-ignore
return mq.medium(css` return mq.medium(css`
min-width: 400px; min-width: 400px;
max-width: 800px; max-width: 800px;
@@ -29,7 +29,6 @@ export const Inner = styled('div')`
`); `);
}}; }};
${() => { ${() => {
// @ts-ignore
return mq.large(css` return mq.large(css`
max-width: 1240px; max-width: 1240px;
`); `);
@@ -42,7 +41,6 @@ export const Left = styled('div')`
align-items: center; align-items: center;
display: none; display: none;
${() => { ${() => {
// @ts-ignore
return mq.medium(css` return mq.medium(css`
display: flex; display: flex;
`); `);
@@ -50,24 +48,24 @@ export const Left = styled('div')`
} }
`; `;
export const Right = styled(Left)` export const Right = styled(Left)({
&& { '&&': {
display: flex; display: 'flex',
} },
`; });
export const ToolTip = styled('span')` export const ToolTip = styled('span')({
&& { '&&': {
position: relative; position: 'relative',
height: 18px; height: '18px',
} },
`; });
export const Earth = styled(Icon)` export const Earth = styled(Icon)({
&& { '&&': {
padding: 0 10px; padding: '0 10px',
} },
`; });
export const Flags = styled('span')` export const Flags = styled('span')`
&& { && {
@@ -90,23 +88,23 @@ export const Flags = styled('span')`
border-color: ${colors.greyAthens} transparent transparent transparent; border-color: ${colors.greyAthens} transparent transparent transparent;
transform: rotate(90deg); transform: rotate(90deg);
} }
${ToolTip}:hover & { ${/* sc-selector */ ToolTip}:hover & {
visibility: visible; visibility: visible;
} }
} }
`; `;
export const Love = styled('span')` export const Love = styled('span')({
&& { '&&': {
color: ${colors.love}; color: colors.love,
padding: 0 5px; padding: '0 5px',
} },
`; });
export const Flag = styled(Icon)` export const Flag = styled(Icon)({
&& { '&&': {
padding: 0 5px; padding: '0 5px',
} },
`; });
export const Logo = Flag; export const Logo = Flag;

View File

@@ -1,124 +1,138 @@
import React from 'react'; import React from 'react';
import { BrowserRouter as Router } from 'react-router-dom'; 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'; import Header from './Header';
describe('<Header /> component with logged in state', () => { const headerProps = {
let wrapper; username: 'verddacio-user',
let routerWrapper; scope: 'test scope',
let instance; withoutSearch: true,
let props; handleToggleLoginModal: jest.fn(),
handleLogout: jest.fn(),
};
beforeEach(() => { /* eslint-disable react/jsx-no-bind*/
props = { describe('<Header /> component with logged in state', () => {
username: 'test user', test('should load the component in logged out state', () => {
handleLogout: jest.fn(), const { container, queryByTestId, getByText } = render(
logo: '',
onToggleLoginModal: jest.fn(),
scope: 'test scope',
withoutSearch: true,
};
routerWrapper = shallow(
<Router> <Router>
<Header <Header onLogout={headerProps.handleLogout} onToggleLoginModal={headerProps.handleToggleLoginModal} scope={headerProps.scope} />
logo={props.logo}
onLogout={props.handleLogout}
onToggleLoginModal={props.onToggleLoginModal}
scope={props.scope}
username={props.username}
withoutSearch={props.withoutSearch}
/>
</Router> </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', () => { test('should load the component in logged in state', () => {
const state = { const { container, getByTestId, queryByText } = render(
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(
<Router> <Router>
<Header <Header
logo={props.logo} onLogout={headerProps.handleLogout}
onLogout={props.handleLogout} onToggleLoginModal={headerProps.handleToggleLoginModal}
onToggleLoginModal={props.onToggleLoginModal} scope={headerProps.scope}
scope={props.scope} username={headerProps.username}
withoutSearch={props.withoutSearch}
/> />
</Router> </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', () => { test('should open login dialog', async () => {
const state = { const { getByText } = render(
openInfoDialog: false, <Router>
packages: undefined, <Header onLogout={headerProps.handleLogout} onToggleLoginModal={headerProps.handleToggleLoginModal} scope={headerProps.scope} />
registryUrl: 'http://localhost', </Router>
showMobileNavBar: false, );
};
expect(wrapper.state()).toEqual(state); const loginBtn = getByText('Login');
expect(routerWrapper.html()).toMatchSnapshot(); fireEvent.click(loginBtn);
expect(headerProps.handleToggleLoginModal).toHaveBeenCalled();
}); });
test('handleLoggedInMenuClose: set anchorEl value to null in state', () => { test('should logout the user', async () => {
instance.handleLoggedInMenuClose(); const { getByText, getByTestId } = render(
expect(wrapper.state('anchorEl')).toBeNull(); <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', () => { test("The question icon should open a new tab of verdaccio's website - installation doc", async () => {
instance.handleOpenRegistryInfoDialog(); const { getByTestId } = render(
expect(wrapper.state('openInfoDialog')).toBeTruthy(); <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', () => { test('should open the registrationInfo modal when clicking on the info icon', async () => {
instance.handleCloseRegistryInfoDialog(); const { getByTestId } = render(
expect(wrapper.state('openInfoDialog')).toBeFalsy(); <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', () => { test('should close the registrationInfo modal when clicking on the button close', async () => {
instance.handleToggleLogin(); const { getByTestId, getByText, queryByTestId } = render(
expect(wrapper.state('anchorEl')).toBeNull(); <Router>
expect(props.onToggleLoginModal).toHaveBeenCalled(); <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');
}); });

View File

@@ -1,28 +1,16 @@
import React, { SyntheticEvent, Component, Fragment, ReactElement } from 'react'; import React, { useState } from 'react';
import { Link } from 'react-router-dom';
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 Search from '../Search';
import { getRegistryURL } from '../../utils/url'; import { getRegistryURL } from '../../utils/url';
import ExternalLink from '../Link'; import Button from '../../muiComponents/Button';
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 { 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 { interface Props {
logo: string; logo?: string;
username?: string; username?: string;
onLogout: () => void; onLogout: () => void;
onToggleLoginModal: () => void; onToggleLoginModal: () => void;
@@ -30,243 +18,38 @@ interface Props {
withoutSearch?: boolean; withoutSearch?: boolean;
} }
interface State { /* eslint-disable react/jsx-max-depth */
anchorEl?: any; /* eslint-disable react/jsx-no-bind*/
openInfoDialog: boolean; const Header: React.FC<Props> = ({ logo, withoutSearch, username, onLogout, onToggleLoginModal, scope }) => {
registryUrl: string; const [isInfoDialogOpen, setOpenInfoDialog] = useState();
showMobileNavBar: boolean; const [showMobileNavBar, setShowMobileNavBar] = useState();
}
type ToolTipType = 'search' | 'help' | 'info'; return (
<>
class Header extends Component<Props, State> { <NavBar position="static">
constructor(props: Props) { <InnerNavBar>
super(props); <HeaderLeft logo={logo} />
this.state = { <HeaderRight
openInfoDialog: false, onLogout={onLogout}
registryUrl: getRegistryURL(), onOpenRegistryInfoDialog={() => setOpenInfoDialog(true)}
showMobileNavBar: false, onToggleLogin={onToggleLoginModal}
}; onToggleMobileNav={() => setShowMobileNavBar(!showMobileNavBar)}
} username={username}
withoutSearch={withoutSearch}
public render(): ReactElement<HTMLElement> { />
const { showMobileNavBar } = this.state; </InnerNavBar>
const { withoutSearch = false } = this.props; <HeaderInfoDialog isOpen={isInfoDialogOpen} onCloseDialog={() => setOpenInfoDialog(false)} registryUrl={getRegistryURL()} scope={scope} />
return ( </NavBar>
<div> {showMobileNavBar && !withoutSearch && (
<NavBar position="static"> <MobileNavBar>
<InnerNavBar> <InnerMobileNavBar>
{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 style={{ marginRight: '1em' }} to={'/'}>
{this.renderLogo()}
</Link>
{!withoutSearch && (
<SearchWrapper>
<Search /> <Search />
</SearchWrapper> </InnerMobileNavBar>
)} <Button color="inherit">{'Cancel'}</Button>
</LeftSide> </MobileNavBar>
); )}
}; </>
);
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>
);
};
}
export default Header; export default Header;

View 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;

View 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;

View 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;

View 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;

View 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;

View 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;

View 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;

View 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;

View File

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

View File

@@ -1,72 +1,73 @@
import styled, { css } from 'react-emotion'; import styled, { css } from 'react-emotion';
import AppBar from '@material-ui/core/AppBar'; import AppBar from '@material-ui/core/AppBar';
import Toolbar from '@material-ui/core/Toolbar'; import Toolbar from '@material-ui/core/Toolbar';
import IconButton from '@material-ui/core/IconButton';
import colors from '../../utils/styles/colors'; import colors from '../../utils/styles/colors';
import mq from '../../utils/styles/media'; import mq from '../../utils/styles/media';
import IconButton from '../../muiComponents/IconButton';
import ExternalLink from '../Link';
export const InnerNavBar = styled(Toolbar)` export const InnerNavBar = styled(Toolbar)({
&& { '&&': {
justify-content: space-between; justifyContent: 'space-between',
align-items: center; alignItems: 'center',
padding: 0 15px; padding: '0 15px',
} },
`; });
export const Greetings = styled('span')` export const Greetings = styled('span')({
&& { '&&': {
margin: 0 5px 0 0; margin: '0 5px 0 0',
} },
`; });
export const RightSide = styled(Toolbar)` export const RightSide = styled(Toolbar)({
&& { '&&': {
display: flex; display: 'flex',
padding: 0; padding: 0,
} },
`; });
export const LeftSide = styled(RightSide)` export const LeftSide = styled(RightSide)({
&& { '&&': {
flex: 1; flex: 1,
} },
`; });
export const MobileNavBar = styled('div')` export const MobileNavBar = styled('div')({
&& { '&&': {
align-items: center; alignItems: 'center',
display: flex; display: 'flex',
border-bottom: 1px solid ${colors.greyLight}; borderBottom: `1px solid ${colors.greyLight}`,
padding: 8px; padding: '8px',
position: relative; position: 'relative',
} },
`; });
export const InnerMobileNavBar = styled('div')` export const InnerMobileNavBar = styled('div')({
&& { '&&': {
border-radius: 4px; borderRadius: '4px',
background-color: ${colors.greyLight}; backgroundColor: colors.greyLight,
color: ${colors.white}; color: colors.white,
width: 100%; width: '100%',
padding: 0px 5px; padding: '0 5px',
margin: 0 10px 0 0; margin: '0 10px 0 0',
} },
`; });
export const IconSearchButton = styled(IconButton)` export const IconSearchButton = styled(IconButton)({
&& { '&&': {
display: block; display: 'block',
} },
`; });
export const SearchWrapper = styled('div')` export const SearchWrapper = styled('div')({
&& { '&&': {
display: none; display: 'none',
max-width: 393px; maxWidth: '393px',
width: 100%; width: '100%',
} },
`; });
export const NavBar = styled(AppBar)` export const NavBar = styled(AppBar)`
&& { && {
@@ -74,9 +75,8 @@ export const NavBar = styled(AppBar)`
min-height: 60px; min-height: 60px;
display: flex; display: flex;
justify-content: center; justify-content: center;
${() => { ${() =>
// @ts-ignore mq.medium(css`
return mq.medium(css`
${SearchWrapper} { ${SearchWrapper} {
display: flex; display: flex;
} }
@@ -86,25 +86,26 @@ export const NavBar = styled(AppBar)`
${MobileNavBar} { ${MobileNavBar} {
display: none; display: none;
} }
`); `)};
}}; ${() =>
${() => { mq.large(css`
// @ts-ignore
return mq.large(css`
${InnerNavBar} { ${InnerNavBar} {
padding: 0 20px; padding: 0 20px;
} }
`); `)};
}}; ${() =>
${() => { mq.xlarge(css`
// @ts-ignore
return mq.xlarge(css`
${InnerNavBar} { ${InnerNavBar} {
max-width: 1240px; max-width: 1240px;
width: 100%; width: 100%;
margin: 0 auto; margin: 0 auto;
} }
`); `)};
}};
} }
`; `;
export const StyledExternalLink = styled(ExternalLink)({
'&&': {
color: 'white',
},
});

View File

@@ -1,10 +1,11 @@
import React from 'react'; import React from 'react';
import { shallow } from 'enzyme'; import { mount } from 'enzyme';
import Help from './Help'; import Help from './Help';
describe('<Help /> component', () => { describe('<Help /> component', () => {
test('should render the component in default state', () => { test('should render the component in default state', () => {
const wrapper = shallow(<Help />); const wrapper = mount(<Help />);
expect(wrapper.html()).toMatchSnapshot(); expect(wrapper.html()).toMatchSnapshot();
}); });
}); });

View File

@@ -1,18 +1,19 @@
import Button from '@material-ui/core/Button';
import CardActions from '@material-ui/core/CardActions'; import CardActions from '@material-ui/core/CardActions';
import CardContent from '@material-ui/core/CardContent'; import CardContent from '@material-ui/core/CardContent';
import Typography from '@material-ui/core/Typography';
import React, { Fragment } from 'react'; import React, { Fragment } from 'react';
import { getRegistryURL } from '../../utils/url'; import { getRegistryURL } from '../../utils/url';
import CopyToClipBoard from '../CopyToClipBoard'; 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'; import { CardStyled as Card, HelpTitle } from './styles';
function renderHeadingClipboardSegments(title: string, text: string): React.ReactNode { function renderHeadingClipboardSegments(title: string, text: string): React.ReactNode {
return ( return (
<Fragment> <Fragment>
<Typography variant={'body2'}>{title}</Typography> <Text variant={'body1'}>{title}</Text>
<CopyToClipBoard text={text} /> <CopyToClipBoard text={text} />
</Fragment> </Fragment>
); );
@@ -24,7 +25,7 @@ const Help: React.FC = () => {
return ( return (
<Card id="help-card"> <Card id="help-card">
<CardContent> <CardContent>
<Typography component="h2" gutterBottom={true} id="help-card__title" variant="headline"> <Typography component="h2" gutterBottom={true} id="help-card__title" variant="h5">
{'No Package Published Yet.'} {'No Package Published Yet.'}
</Typography> </Typography>
<HelpTitle color="textSecondary" gutterBottom={true}> <HelpTitle color="textSecondary" gutterBottom={true}>
@@ -32,10 +33,10 @@ const Help: React.FC = () => {
</HelpTitle> </HelpTitle>
{renderHeadingClipboardSegments('1. Login', `npm adduser --registry ${registryUrl}`)} {renderHeadingClipboardSegments('1. Login', `npm adduser --registry ${registryUrl}`)}
{renderHeadingClipboardSegments('2. Publish', `npm publish --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> </CardContent>
<CardActions> <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'} {'Learn More'}
</Button> </Button>
</CardActions> </CardActions>

View File

@@ -1,3 +1,3 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`<Help /> component should render the component in default state 1`] = `"<div class=\\"MuiPaper-root-2 MuiPaper-elevation1-5 MuiPaper-rounded-3 MuiCard-root-1 css-ryznli e1wgaou60\\" id=\\"help-card\\"><div class=\\"MuiCardContent-root-29\\"><h2 class=\\"MuiTypography-root-30 MuiTypography-headline-35 MuiTypography-gutterBottom-57\\" id=\\"help-card__title\\">No Package Published Yet.</h2><p class=\\"MuiTypography-root-30 MuiTypography-body1-39 MuiTypography-colorTextSecondary-63 MuiTypography-gutterBottom-57 css-zg2fwz e1wgaou61\\">To publish your first package just:</p><p class=\\"MuiTypography-root-30 MuiTypography-body2-38\\">1. Login</p><div class=\\"css-1mta3t8 eb8w2fo0\\"><span class=\\"css-1m8aenu eb8w2fo1\\">npm adduser --registry http://localhost</span><button class=\\"MuiButtonBase-root-80 MuiIconButton-root-74 css-56v3u0 eb8w2fo2\\" tabindex=\\"0\\" type=\\"button\\" title=\\"Copy to Clipboard\\"><span class=\\"MuiIconButton-label-79\\"><svg class=\\"MuiSvgIcon-root-83\\" focusable=\\"false\\" viewBox=\\"0 0 24 24\\" aria-hidden=\\"true\\" role=\\"presentation\\"><path fill=\\"none\\" d=\\"M0 0h24v24H0z\\"></path><path d=\\"M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm-1 4l6 6v10c0 1.1-.9 2-2 2H7.99C6.89 23 6 22.1 6 21l.01-14c0-1.1.89-2 1.99-2h7zm-1 7h5.5L14 6.5V12z\\"></path></svg></span></button></div><p class=\\"MuiTypography-root-30 MuiTypography-body2-38\\">2. Publish</p><div class=\\"css-1mta3t8 eb8w2fo0\\"><span class=\\"css-1m8aenu eb8w2fo1\\">npm publish --registry http://localhost</span><button class=\\"MuiButtonBase-root-80 MuiIconButton-root-74 css-56v3u0 eb8w2fo2\\" tabindex=\\"0\\" type=\\"button\\" title=\\"Copy to Clipboard\\"><span class=\\"MuiIconButton-label-79\\"><svg class=\\"MuiSvgIcon-root-83\\" focusable=\\"false\\" viewBox=\\"0 0 24 24\\" aria-hidden=\\"true\\" role=\\"presentation\\"><path fill=\\"none\\" d=\\"M0 0h24v24H0z\\"></path><path d=\\"M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm-1 4l6 6v10c0 1.1-.9 2-2 2H7.99C6.89 23 6 22.1 6 21l.01-14c0-1.1.89-2 1.99-2h7zm-1 7h5.5L14 6.5V12z\\"></path></svg></span></button></div><p class=\\"MuiTypography-root-30 MuiTypography-body2-38\\">3. Refresh this page.</p></div><div class=\\"MuiCardActions-root-92\\"><a class=\\"MuiButtonBase-root-80 MuiButton-root-95 MuiButton-text-97 MuiButton-textPrimary-98 MuiButton-flat-100 MuiButton-flatPrimary-101 MuiButton-sizeSmall-118 MuiCardActions-action-94\\" tabindex=\\"0\\" role=\\"button\\" href=\\"https://verdaccio.org/docs/en/installation\\" target=\\"_blank\\"><span class=\\"MuiButton-label-96\\">Learn More</span></a></div></div>"`; exports[`<Help /> component should render the component in default state 1`] = `"<div class=\\"MuiPaper-root MuiPaper-elevation1 MuiCard-root css-ryznli e1wgaou60 MuiPaper-rounded\\" id=\\"help-card\\"><div class=\\"MuiCardContent-root\\"><h2 class=\\"MuiTypography-root MuiTypography-h5 MuiTypography-gutterBottom\\" id=\\"help-card__title\\">No Package Published Yet.</h2><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>"`;

View File

@@ -1,16 +1,17 @@
import Card from '@material-ui/core/Card';
import Typography from '@material-ui/core/Typography';
import styled from 'react-emotion'; import styled from 'react-emotion';
export const CardStyled = styled(Card)` import { default as Typography } from '../../muiComponents/Heading';
&& { import Card from '../../muiComponents/Card';
width: 600px;
margin: auto;
}
`;
export const HelpTitle = styled(Typography)` export const CardStyled = styled(Card)({
&& { '&&': {
margin-bottom: 20px; width: '600px',
} margin: 'auto',
`; },
});
export const HelpTitle = styled(Typography)({
'&&': {
marginBottom: '20px',
},
});

View File

@@ -1,8 +1,8 @@
import React, { MouseEvent } from 'react'; import React, { MouseEvent } from 'react';
import capitalize from 'lodash/capitalize'; import capitalize from 'lodash/capitalize';
import { Breakpoint } from '@material-ui/core/styles/createBreakpoints';
import { Svg, Img, ImgWrapper } from './styles'; import { Svg, Img, ImgWrapper } from './styles';
import brazil from './img/brazil.svg'; import brazil from './img/brazil.svg';
import china from './img/china.svg'; import china from './img/china.svg';
import india from './img/india.svg'; import india from './img/india.svg';
@@ -57,21 +57,19 @@ export interface Props {
name: keyof IconsMap; name: keyof IconsMap;
className?: string; className?: string;
onClick?: (event: MouseEvent<SVGElement | HTMLSpanElement>) => void; onClick?: (event: MouseEvent<SVGElement | HTMLSpanElement>) => void;
size?: 'sm' | 'md'; size?: Breakpoint;
pointer?: boolean; pointer?: boolean;
img?: boolean; img?: boolean;
modifiers?: any; modifiers?: null | undefined;
} }
const Icon: React.FC<Props> = ({ className, name, size = 'sm', img = false, pointer = false, ...props }) => { const Icon: React.FC<Props> = ({ className, name, size = 'sm', img = false, pointer = false, ...props }) => {
// @ts-ignore const title = capitalize(name.toString());
const title = capitalize(name);
return img ? ( return img ? (
<ImgWrapper className={className} name={name} pointer={pointer} size={size} title={title} {...props}> <ImgWrapper className={className} name={name} pointer={pointer} size={size} title={title} {...props}>
<Img alt={title} src={Icons[name]} /> <Img alt={title} src={Icons[name]} />
</ImgWrapper> </ImgWrapper>
) : ( ) : (
// @ts-ignore
<Svg className={className} pointer={pointer} size={size} {...props}> <Svg className={className} pointer={pointer} size={size} {...props}>
<title>{title}</title> <title>{title}</title>
<use xlinkHref={`${Icons[name]}#${name}`} /> <use xlinkHref={`${Icons[name]}#${name}`} />

View File

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

View File

@@ -1,6 +1,9 @@
import styled, { css } from 'react-emotion'; import styled, { css } from 'react-emotion';
import { Breakpoint } from '@material-ui/core/styles/createBreakpoints';
import { StyledOtherComponent } from 'create-emotion-styled';
import { DetailedHTMLProps, HTMLAttributes } from 'react';
const getSize = (size?: 'md' | 'sm') => { const getSize = (size: Breakpoint): string => {
switch (size) { switch (size) {
case 'md': case 'md':
return ` return `
@@ -15,10 +18,10 @@ const getSize = (size?: 'md' | 'sm') => {
} }
}; };
const commonStyle = ({ size = 'sm', pointer, modifiers }: any) => css` const commonStyle = ({ size = 'sm' as Breakpoint, pointer, modifiers = null }): string => css`
&& { && {
display: inline-block; display: inline-block;
cursor: ${pointer ? 'pointer' : 'default'}; cursor: ${pointer ? 'pointer' : 'Developers'};
${getSize(size)}; ${getSize(size)};
${modifiers && modifiers}; ${modifiers && modifiers};
} }
@@ -30,15 +33,24 @@ export const Svg = styled('svg')`
} }
`; `;
export const ImgWrapper = styled('span')` export const ImgWrapper: StyledOtherComponent<
{
size?: Breakpoint;
pointer: boolean;
modifiers?: null | undefined;
name?: string | unknown;
},
DetailedHTMLProps<HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>,
{}
> = styled('span')`
&& { && {
${commonStyle}; ${commonStyle};
} }
`; `;
export const Img = styled('img')` export const Img = styled('img')({
&& { '&&': {
width: 100%; width: '100%',
height: auto; height: 'auto',
} },
`; });

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