mirror of
https://github.com/SomboChea/ui
synced 2026-01-12 22:25:52 +07:00
Compare commits
4 Commits
feat-dark-
...
refactor/m
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8c9076d0a2 | ||
|
|
ea19a2bb47 | ||
|
|
d9f463688d | ||
|
|
571d9c3fa7 |
7
.babelrc
7
.babelrc
@@ -1,8 +1,3 @@
|
||||
{
|
||||
"presets": [["@verdaccio"]],
|
||||
"plugins": [
|
||||
"emotion",
|
||||
"@babel/plugin-proposal-optional-chaining",
|
||||
"@babel/plugin-proposal-nullish-coalescing-operator"
|
||||
]
|
||||
"presets": [["@verdaccio"]]
|
||||
}
|
||||
|
||||
@@ -136,7 +136,7 @@ jobs:
|
||||
command: echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc
|
||||
- run:
|
||||
name: Publish
|
||||
command: npm publish
|
||||
command: yarn publish
|
||||
|
||||
workflows:
|
||||
version: 2
|
||||
|
||||
11
.eslintrc
11
.eslintrc
@@ -45,8 +45,11 @@
|
||||
}
|
||||
}
|
||||
],
|
||||
"@typescript-eslint/explicit-function-return-type": 0,
|
||||
"react/display-name": 0,
|
||||
"@typescript-eslint/explicit-function-return-type": ["warn",
|
||||
{
|
||||
"allowExpressions": true,
|
||||
"allowTypedFunctionExpressions": true
|
||||
}],
|
||||
"react/no-deprecated": 1,
|
||||
"react/jsx-no-target-blank": 1,
|
||||
"react/destructuring-assignment": ["error", "always"],
|
||||
@@ -72,7 +75,7 @@
|
||||
"arrow": "parens",
|
||||
"condition": "parens",
|
||||
"logical": "parens",
|
||||
"prop": "ignore"
|
||||
"prop": "parens"
|
||||
}],
|
||||
"react/jsx-boolean-value": ["error", "always"],
|
||||
"react/jsx-closing-tag-location": ["error"],
|
||||
@@ -83,7 +86,7 @@
|
||||
"react/jsx-indent": ["error", 2],
|
||||
"react/jsx-indent-props": ["error", 2],
|
||||
"react/jsx-key": ["error"],
|
||||
"react/jsx-max-depth":["error", { "max": 5}],
|
||||
"react/jsx-max-depth": ["error", { "max": 2}],
|
||||
"react/jsx-max-props-per-line": ["error", {"maximum": 3, "when": "multiline" }],
|
||||
"react/jsx-no-bind": ["error"],
|
||||
"react/jsx-no-comment-textnodes": ["error"],
|
||||
|
||||
11
.github/workflows/security.yml
vendored
11
.github/workflows/security.yml
vendored
@@ -1,11 +0,0 @@
|
||||
name: Security Flow
|
||||
on: push
|
||||
jobs:
|
||||
security:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@master
|
||||
- name: Run Snyk to check for vulnerabilities
|
||||
uses: snyk/actions/node@0.1.0
|
||||
env:
|
||||
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
|
||||
2
.vscode/settings.json
vendored
2
.vscode/settings.json
vendored
@@ -7,4 +7,4 @@
|
||||
"typescriptreact"
|
||||
],
|
||||
"typescript.tsdk": "node_modules/typescript/lib"
|
||||
}
|
||||
}
|
||||
72
CHANGELOG.md
72
CHANGELOG.md
@@ -2,78 +2,6 @@
|
||||
|
||||
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.13](https://github.com/verdaccio/ui/compare/v0.3.12...v0.3.13) (2020-02-02)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* do not capitalize heading - closes [#428](https://github.com/verdaccio/ui/issues/428) ([#431](https://github.com/verdaccio/ui/issues/431)) ([d481f54](https://github.com/verdaccio/ui/commit/d481f549484361c1d1bc011e0858e8f99b8a2528))
|
||||
* package list refresh based on logged-in user ([#415](https://github.com/verdaccio/ui/issues/415)) ([222ffed](https://github.com/verdaccio/ui/commit/222ffed0226f5aaa62f2d5b91bb08717b2aa24ef)), closes [#414](https://github.com/verdaccio/ui/issues/414) [#414](https://github.com/verdaccio/ui/issues/414)
|
||||
* reload packages on log in ([#421](https://github.com/verdaccio/ui/issues/421)) ([1eca1f4](https://github.com/verdaccio/ui/commit/1eca1f40797790e87d9592204ca061527d09c4ae))
|
||||
* typo ([#423](https://github.com/verdaccio/ui/issues/423)) ([164cea6](https://github.com/verdaccio/ui/commit/164cea6c10804c1d2097c2a582eb3e1e51814d4a))
|
||||
* update dependencies ([#420](https://github.com/verdaccio/ui/issues/420)) ([ee1c3f0](https://github.com/verdaccio/ui/commit/ee1c3f08eb16da2313d8841cfab18358d7f4ea10))
|
||||
|
||||
### [0.3.12](https://github.com/verdaccio/ui/compare/v0.3.11...v0.3.12) (2020-01-09)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* generate correct registry URL ([#413](https://github.com/verdaccio/ui/issues/413)) ([6b322ad](https://github.com/verdaccio/ui/commit/6b322ad553e9fb3ee65b2968dcfe856ba42a0bfb)), closes [#300](https://github.com/verdaccio/ui/issues/300) [#311](https://github.com/verdaccio/ui/issues/311)
|
||||
|
||||
### [0.3.11](https://github.com/verdaccio/ui/compare/v0.3.10...v0.3.11) (2020-01-08)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* remove prevent default and use react context ([#411](https://github.com/verdaccio/ui/issues/411)) ([6bd38b8](https://github.com/verdaccio/ui/commit/6bd38b812032857bb19af8978d48f6f8969af6cf))
|
||||
* removed unused style file ([#406](https://github.com/verdaccio/ui/issues/406)) ([6eeae63](https://github.com/verdaccio/ui/commit/6eeae630ef441a871d06b888b6a21178e36e0db7))
|
||||
|
||||
### [0.3.10](https://github.com/verdaccio/ui/compare/v0.3.9...v0.3.10) (2019-12-30)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* added "Fund this package" button ([#375](https://github.com/verdaccio/ui/issues/375)) ([bf093cc](https://github.com/verdaccio/ui/commit/bf093cc27b8625cdc50dbfc9b8dd7e37f4e24da9))
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* add missing trailing slash to publicPath - closes [#395](https://github.com/verdaccio/ui/issues/395) ([#396](https://github.com/verdaccio/ui/issues/396)) ([bae9638](https://github.com/verdaccio/ui/commit/bae9638b23b70eff78b78b8ca52ff40162333354))
|
||||
* engine warning on console for ui ([#403](https://github.com/verdaccio/ui/issues/403)) ([d554049](https://github.com/verdaccio/ui/commit/d554049699494e946f4caf345177839b4f0cba8b))
|
||||
* remove background from styled Avatar components - closes [#371](https://github.com/verdaccio/ui/issues/371) ([#398](https://github.com/verdaccio/ui/issues/398)) ([787dda4](https://github.com/verdaccio/ui/commit/787dda4a016a1fcd1142bd4b705e2c71e232d13e))
|
||||
* remove double padding and add missing background color - closes [#373](https://github.com/verdaccio/ui/issues/373) ([#399](https://github.com/verdaccio/ui/issues/399)) ([797c238](https://github.com/verdaccio/ui/commit/797c2381e453d4f40e1703402f192eb7675d6fbe))
|
||||
* remove whitespace from logo image - closes [#374](https://github.com/verdaccio/ui/issues/374) ([#400](https://github.com/verdaccio/ui/issues/400)) ([544b999](https://github.com/verdaccio/ui/commit/544b999f81e39557e0fc002d21b24c512cfebc54))
|
||||
|
||||
### [0.3.9](https://github.com/verdaccio/ui/compare/v0.3.8...v0.3.9) (2019-12-14)
|
||||
|
||||
### [0.3.8](https://github.com/verdaccio/ui/compare/v0.3.7...v0.3.8) (2019-12-14)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* login Dialog Component - Replaced class by func. comp + added react-hook-form ([#341](https://github.com/verdaccio/ui/issues/341)) ([42d3bb8](https://github.com/verdaccio/ui/commit/42d3bb8508c666c28250432ada734d58ccb0eca8))
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* formatDate ([#308](https://github.com/verdaccio/ui/issues/308)) ([33f873a](https://github.com/verdaccio/ui/commit/33f873a8c78e419a36e3a29f7ea216714172b174))
|
||||
* removed deade import ([#346](https://github.com/verdaccio/ui/issues/346)) ([ae617a5](https://github.com/verdaccio/ui/commit/ae617a5c04ad1b82309d36d3bdcf6b6b6fd925d0))
|
||||
* updated actionbar snap ([#340](https://github.com/verdaccio/ui/issues/340)) ([09b831a](https://github.com/verdaccio/ui/commit/09b831a40d4e82a122f8fae3e45bdd161a3281bb))
|
||||
|
||||
### [0.3.7](https://github.com/verdaccio/ui/compare/v0.3.6...v0.3.7) (2019-11-24)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* Added Theme and migrate to emotion@10.x 🚀 ([#286](https://github.com/verdaccio/ui/issues/286)) ([111f0c5](https://github.com/verdaccio/ui/commit/111f0c50e5053202ca55fe4f3f28dd30e4932240))
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **#300:** correctly reference registry url from options ([ee74474](https://github.com/verdaccio/ui/commit/ee74474811eb609072e1678bcb90db33756dcf38)), closes [#300](https://github.com/verdaccio/ui/issues/300)
|
||||
* restore lint-staged@8.2.1 ([dbaa0c4](https://github.com/verdaccio/ui/commit/dbaa0c43b8104b350e4907387f89d4e9e719741f))
|
||||
* update snapshots ([fd306de](https://github.com/verdaccio/ui/commit/fd306def9535d9168dc79ab020ec288a4d5df1a8))
|
||||
|
||||
### [0.3.6](https://github.com/verdaccio/ui/compare/v0.3.5...v0.3.6) (2019-11-08)
|
||||
|
||||
### [0.3.5](https://github.com/verdaccio/ui/compare/v0.3.4...v0.3.5) (2019-11-07)
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
[](https://stackshare.io/verdaccio)
|
||||
[](http://chat.verdaccio.org/)
|
||||
[](https://www.npmjs.com/package/@verdaccio/ui-theme)
|
||||
[](./LICENSE)
|
||||

|
||||
[](https://crowdin.com/project/verdaccio)
|
||||
[](https://codecov.io/gh/verdaccio/ui)
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
|
||||
## Contributing
|
||||
|
||||
We use `>=yarn@1.13.0`, keep in mind that we use lockfiles and use at least Node `v10.13.0` to be able to build the project.
|
||||
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
|
||||
|
||||
|
||||
@@ -1 +1 @@
|
||||
jest.requireActual('babel/polyfill');
|
||||
require.requireActual('babel/polyfill');
|
||||
|
||||
@@ -6,15 +6,15 @@ import 'raf/polyfill';
|
||||
import { configure } from 'enzyme';
|
||||
import Adapter from 'enzyme-adapter-react-16';
|
||||
import { GlobalWithFetchMock } from 'jest-fetch-mock';
|
||||
import 'mutationobserver-shim';
|
||||
|
||||
// @ts-ignore : Only a void function can be called with the 'new' keyword
|
||||
configure({ adapter: new Adapter() });
|
||||
|
||||
// @ts-ignore : Property '__APP_VERSION__' does not exist on type 'Global'.
|
||||
global.__APP_VERSION__ = '1.0.0';
|
||||
// @ts-ignore : Property '__VERDACCIO_BASENAME_UI_OPTIONS' does not exist on type 'Global'.
|
||||
global.__VERDACCIO_BASENAME_UI_OPTIONS = { base: 'http://localhost' };
|
||||
// @ts-ignore : Property 'VERDACCIO_API_URL' does not exist on type 'Global'.
|
||||
global.__VERDACCIO_BASENAME_UI_OPTIONS = {};
|
||||
|
||||
global.VERDACCIO_API_URL = 'https://verdaccio.tld';
|
||||
|
||||
const customGlobal: GlobalWithFetchMock = global as GlobalWithFetchMock;
|
||||
|
||||
5
jest/unit/components/__mocks__/.eslintrc
Normal file
5
jest/unit/components/__mocks__/.eslintrc
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"rules": {
|
||||
"@typescript-eslint/explicit-function-return-type": 0
|
||||
}
|
||||
}
|
||||
@@ -3,19 +3,12 @@
|
||||
*/
|
||||
|
||||
import { Base64 } from 'js-base64';
|
||||
import dayjs from 'dayjs';
|
||||
import addHours from 'date-fns/addHours';
|
||||
|
||||
export function generateTokenWithTimeRange(amount = 0) {
|
||||
export function generateTokenWithTimeRange(limit = 0) {
|
||||
const payload = {
|
||||
username: 'verdaccio',
|
||||
exp: Number.parseInt(
|
||||
String(
|
||||
dayjs(new Date())
|
||||
.add(amount, 'hour')
|
||||
.valueOf() / 1000
|
||||
),
|
||||
10
|
||||
),
|
||||
exp: Number.parseInt(String(addHours(new Date(), limit).getTime() / 1000), 10),
|
||||
};
|
||||
return `xxxxxx.${Base64.encode(JSON.stringify(payload))}.xxxxxx`;
|
||||
}
|
||||
|
||||
@@ -192,7 +192,7 @@ export const packageMeta = {
|
||||
jest: { snapshotSerializers: ['jest-serializer-enzyme'] },
|
||||
engines: { node: '>=4.6.1', npm: '>=2.15.9' },
|
||||
preferGlobal: true,
|
||||
publishConfig: { registry: 'https://registry.verdaccio.org' },
|
||||
publishConfig: { registry: 'http://localhost:4873/' },
|
||||
license: 'WTFPL',
|
||||
contributors: [
|
||||
{
|
||||
@@ -578,7 +578,7 @@ export const packageMeta = {
|
||||
_npmUser: {},
|
||||
dist: {
|
||||
shasum: '958c919180e7f2ed6775f48d4ec64bd8de2a14df',
|
||||
tarball: 'https://registry.verdaccio.org/verdaccio/-/verdaccio-2.7.1.tgz',
|
||||
tarball: 'http://localhost:4873/verdaccio/-/verdaccio-2.7.1.tgz',
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
154
package.json
154
package.json
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@verdaccio/ui-theme",
|
||||
"version": "0.3.13",
|
||||
"version": "0.3.6",
|
||||
"description": "Verdaccio User Interface",
|
||||
"author": {
|
||||
"name": "Verdaccio Core Team",
|
||||
@@ -13,81 +13,74 @@
|
||||
"homepage": "https://verdaccio.org",
|
||||
"main": "index.js",
|
||||
"devDependencies": {
|
||||
"@babel/plugin-proposal-nullish-coalescing-operator": "7.8.0",
|
||||
"@babel/plugin-proposal-optional-chaining": "7.8.0",
|
||||
"@commitlint/cli": "8.3.4",
|
||||
"@commitlint/config-conventional": "8.3.4",
|
||||
"@emotion/core": "10.0.22",
|
||||
"@emotion/styled": "10.0.23",
|
||||
"@material-ui/core": "4.8.0",
|
||||
"@commitlint/cli": "8.2.0",
|
||||
"@commitlint/config-conventional": "8.2.0",
|
||||
"@material-ui/core": "4.6.1",
|
||||
"@material-ui/icons": "4.5.1",
|
||||
"@octokit/rest": "16.35.2",
|
||||
"@testing-library/jest-dom": "4.2.4",
|
||||
"@testing-library/react": "9.4.0",
|
||||
"@octokit/rest": "16.35.0",
|
||||
"@testing-library/react": "9.3.2",
|
||||
"@types/autosuggest-highlight": "3.1.0",
|
||||
"@types/enzyme": "3.10.4",
|
||||
"@types/jest": "24.0.24",
|
||||
"@types/enzyme": "3.10.3",
|
||||
"@types/jest": "24.0.23",
|
||||
"@types/js-base64": "2.3.1",
|
||||
"@types/lodash": "4.14.149",
|
||||
"@types/node": "13.1.6",
|
||||
"@types/react": "16.9.17",
|
||||
"@types/lodash": "4.14.147",
|
||||
"@types/node": "12.12.7",
|
||||
"@types/react": "16.9.11",
|
||||
"@types/react-autosuggest": "9.3.13",
|
||||
"@types/react-dom": "16.9.4",
|
||||
"@types/react-router-dom": "5.1.3",
|
||||
"@types/request": "2.48.4",
|
||||
"@types/validator": "12.0.1",
|
||||
"@types/webpack-env": "1.15.0",
|
||||
"@typescript-eslint/parser": "2.18.0",
|
||||
"@verdaccio/babel-preset": "9.0.0",
|
||||
"@verdaccio/commons-api": "9.0.0",
|
||||
"@verdaccio/eslint-config": "8.4.2",
|
||||
"@verdaccio/types": "9.0.0",
|
||||
"@types/react-router-dom": "5.1.2",
|
||||
"@types/request": "2.48.3",
|
||||
"@types/validator": "10.11.3",
|
||||
"@types/webpack-env": "1.14.1",
|
||||
"@typescript-eslint/parser": "2.7.0",
|
||||
"@verdaccio/babel-preset": "8.2.0",
|
||||
"@verdaccio/commons-api": "8.3.0",
|
||||
"@verdaccio/eslint-config": "8.2.0",
|
||||
"@verdaccio/types": "8.3.0",
|
||||
"autosuggest-highlight": "3.1.1",
|
||||
"babel-loader": "8.0.6",
|
||||
"bundlesize": "0.18.0",
|
||||
"codeceptjs": "2.4.0",
|
||||
"codecov": "3.6.5",
|
||||
"concurrently": "5.0.2",
|
||||
"codeceptjs": "2.3.5",
|
||||
"codecov": "3.6.1",
|
||||
"concurrently": "5.0.0",
|
||||
"cross-env": "6.0.3",
|
||||
"css-loader": "3.4.2",
|
||||
"dayjs": "1.8.19",
|
||||
"css-loader": "3.2.0",
|
||||
"date-fns": "2.7.0",
|
||||
"detect-secrets": "1.0.5",
|
||||
"emotion": "10.0.27",
|
||||
"emotion-theming": "10.0.27",
|
||||
"enzyme": "3.11.0",
|
||||
"enzyme-adapter-react-16": "1.15.2",
|
||||
"emotion": "10.0.23",
|
||||
"enzyme": "3.10.0",
|
||||
"enzyme-adapter-react-16": "1.15.1",
|
||||
"enzyme-to-json": "3.4.3",
|
||||
"eslint": "6.7.2",
|
||||
"eslint-plugin-codeceptjs": "1.2.0",
|
||||
"eslint-plugin-import": "2.19.1",
|
||||
"eslint": "6.6.0",
|
||||
"eslint-plugin-codeceptjs": "1.1.0",
|
||||
"eslint-plugin-import": "2.18.2",
|
||||
"eslint-plugin-jsx-a11y": "6.2.3",
|
||||
"eslint-plugin-prettier": "3.1.2",
|
||||
"eslint-plugin-react": "7.17.0",
|
||||
"eslint-plugin-prettier": "3.1.1",
|
||||
"eslint-plugin-react": "7.16.0",
|
||||
"eslint-plugin-react-hooks": "2.3.0",
|
||||
"eslint-plugin-verdaccio": "8.4.2",
|
||||
"file-loader": "5.0.2",
|
||||
"eslint-plugin-verdaccio": "8.2.0",
|
||||
"file-loader": "4.2.0",
|
||||
"friendly-errors-webpack-plugin": "1.7.0",
|
||||
"get-stdin": "7.0.0",
|
||||
"github-markdown-css": "3.0.1",
|
||||
"html-webpack-plugin": "3.2.0",
|
||||
"husky": "3.1.0",
|
||||
"husky": "3.0.9",
|
||||
"identity-obj-proxy": "3.0.0",
|
||||
"in-publish": "2.0.0",
|
||||
"jest": "24.9.0",
|
||||
"jest-emotion": "10.0.27",
|
||||
"jest-emotion": "10.0.17",
|
||||
"jest-environment-jsdom": "24.9.0",
|
||||
"jest-environment-jsdom-global": "1.2.0",
|
||||
"jest-environment-node": "25.1.0",
|
||||
"jest-fetch-mock": "3.0.1",
|
||||
"jest-environment-node": "24.9.0",
|
||||
"jest-fetch-mock": "2.1.2",
|
||||
"js-base64": "2.5.1",
|
||||
"js-yaml": "3.13.1",
|
||||
"lint-staged": "9.5.0",
|
||||
"lint-staged": "9.4.3",
|
||||
"localstorage-memory": "1.0.3",
|
||||
"lockfile-lint": "3.0.5",
|
||||
"lockfile-lint": "2.2.0",
|
||||
"lodash": "^4.17.15",
|
||||
"mini-css-extract-plugin": "0.9.0",
|
||||
"mutationobserver-shim": "0.3.3",
|
||||
"node-mocks-http": "1.8.1",
|
||||
"mini-css-extract-plugin": "0.8.0",
|
||||
"node-mocks-http": "1.8.0",
|
||||
"normalize.css": "8.0.1",
|
||||
"optimize-css-assets-webpack-plugin": "5.0.3",
|
||||
"ora": "4.0.3",
|
||||
@@ -97,35 +90,34 @@
|
||||
"react": "16.12.0",
|
||||
"react-autosuggest": "9.4.3",
|
||||
"react-dom": "16.12.0",
|
||||
"react-hook-form": "3.29.4",
|
||||
"react-hot-loader": "4.12.18",
|
||||
"react-hot-loader": "4.12.17",
|
||||
"react-router-dom": "5.1.2",
|
||||
"request": "2.88.0",
|
||||
"resolve-url-loader": "3.1.1",
|
||||
"rimraf": "3.0.0",
|
||||
"source-map-loader": "0.2.4",
|
||||
"standard-version": "7.0.1",
|
||||
"style-loader": "1.1.2",
|
||||
"stylelint": "12.0.0",
|
||||
"standard-version": "7.0.0",
|
||||
"style-loader": "1.0.0",
|
||||
"stylelint": "11.1.1",
|
||||
"stylelint-config-recommended": "3.0.0",
|
||||
"stylelint-config-styled-components": "0.1.1",
|
||||
"stylelint-processor-styled-components": "1.9.0",
|
||||
"stylelint-webpack-plugin": "1.1.2",
|
||||
"stylelint-processor-styled-components": "1.8.0",
|
||||
"stylelint-webpack-plugin": "1.0.4",
|
||||
"supertest": "4.0.2",
|
||||
"typeface-roboto": "0.0.75",
|
||||
"typescript": "3.7.4",
|
||||
"typescript": "3.7.2",
|
||||
"uglifyjs-webpack-plugin": "2.2.0",
|
||||
"url-loader": "3.0.0",
|
||||
"validator": "12.1.0",
|
||||
"verdaccio": "4.4.2",
|
||||
"verdaccio-auth-memory": "9.0.0",
|
||||
"verdaccio-memory": "9.0.0",
|
||||
"url-loader": "2.2.0",
|
||||
"validator": "12.0.0",
|
||||
"verdaccio": "4.3.4",
|
||||
"verdaccio-auth-memory": "8.3.0",
|
||||
"verdaccio-memory": "8.3.0",
|
||||
"wait-on": "3.3.0",
|
||||
"webpack": "4.41.5",
|
||||
"webpack": "4.41.2",
|
||||
"webpack-bundle-analyzer": "3.6.0",
|
||||
"webpack-bundle-size-analyzer": "3.1.0",
|
||||
"webpack-cli": "3.3.10",
|
||||
"webpack-dev-server": "3.10.1",
|
||||
"webpack-dev-server": "3.9.0",
|
||||
"webpack-merge": "4.2.2",
|
||||
"whatwg-fetch": "3.0.0",
|
||||
"xss": "1.0.6"
|
||||
@@ -138,7 +130,7 @@
|
||||
"bundlesize": [
|
||||
{
|
||||
"path": "./static/vendors.*.js",
|
||||
"maxSize": "185 kB"
|
||||
"maxSize": "180 kB"
|
||||
},
|
||||
{
|
||||
"path": "./static/main.*.js",
|
||||
@@ -171,7 +163,6 @@
|
||||
"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:update-snapshot": "npm run test -- -u",
|
||||
"test:size": "bundlesize",
|
||||
"lint": "npm run lint:js && npm run lint:css && npm run lint:lockfile",
|
||||
"lint:js": "npm run type-check && eslint . --ext .js,.ts,.tsx",
|
||||
@@ -187,23 +178,29 @@
|
||||
"dev": "concurrently --kill-others \"npm run dev:web\" \"npm run verdaccio:server\""
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 8",
|
||||
"node": ">=8",
|
||||
"npm": ">=5"
|
||||
},
|
||||
"husky": {
|
||||
"hooks": {
|
||||
"pre-commit": "lint-staged --relative",
|
||||
"pre-commit": "lint-staged",
|
||||
"commit-msg": "commitlint -e $GIT_PARAMS"
|
||||
}
|
||||
},
|
||||
"lint-staged": {
|
||||
"*.{js,tsx,ts}": [
|
||||
"eslint . --ext .js,.ts,.tsx",
|
||||
"prettier --write"
|
||||
],
|
||||
"*": [
|
||||
"detect-secrets-launcher --baseline .secrets-baseline",
|
||||
"git add"
|
||||
"relative": true,
|
||||
"linters": {
|
||||
"*.{js,tsx,ts}": [
|
||||
"eslint . --ext .js,.ts,.tsx",
|
||||
"prettier --write"
|
||||
],
|
||||
"*": [
|
||||
"detect-secrets-launcher --baseline .secrets-baseline",
|
||||
"git add"
|
||||
]
|
||||
},
|
||||
"ignore": [
|
||||
"*.json"
|
||||
]
|
||||
},
|
||||
"license": "MIT",
|
||||
@@ -216,5 +213,10 @@
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/verdaccio",
|
||||
"logo": "https://opencollective.com/verdaccio/logo.txt"
|
||||
},
|
||||
"dependencies": {
|
||||
"@emotion/core": "10.0.22",
|
||||
"@emotion/styled": "10.0.23",
|
||||
"@material-ui/lab": "4.0.0-alpha.31"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import React from 'react';
|
||||
import { mount, ReactWrapper } from 'enzyme';
|
||||
|
||||
import { render, waitForElement, fireEvent } from '../utils/test-react-testing-library';
|
||||
import storage from '../utils/storage';
|
||||
// eslint-disable-next-line jest/no-mocks-import
|
||||
import { generateTokenWithTimeRange } from '../../jest/unit/components/__mocks__/token';
|
||||
|
||||
import App from './App';
|
||||
import { AppProps } from './AppContext';
|
||||
|
||||
jest.mock('../utils/storage', () => {
|
||||
class LocalStorageMock {
|
||||
@@ -30,75 +30,66 @@ jest.mock('../utils/storage', () => {
|
||||
});
|
||||
|
||||
jest.mock('../utils/api', () => ({
|
||||
// eslint-disable-next-line jest/no-mocks-import
|
||||
request: require('../../jest/unit/components/__mocks__/api').default.request,
|
||||
}));
|
||||
|
||||
/* eslint-disable react/jsx-no-bind*/
|
||||
describe('<App />', () => {
|
||||
test('should display the Loading component at the beginning ', () => {
|
||||
const { container, queryByTestId } = render(<App />);
|
||||
describe('App', () => {
|
||||
let wrapper: ReactWrapper<{}, AppProps, App>;
|
||||
|
||||
expect(container.firstChild).toMatchSnapshot();
|
||||
expect(queryByTestId('loading')).toBeTruthy();
|
||||
beforeEach(() => {
|
||||
wrapper = mount(<App />);
|
||||
});
|
||||
|
||||
test('should display the Header component ', async () => {
|
||||
const { container, queryByTestId } = render(<App />);
|
||||
|
||||
expect(container.firstChild).toMatchSnapshot();
|
||||
expect(queryByTestId('loading')).toBeTruthy();
|
||||
|
||||
// wait for the Header component appearance and return the element
|
||||
const headerElement = await waitForElement(() => queryByTestId('header'));
|
||||
expect(headerElement).toBeTruthy();
|
||||
});
|
||||
|
||||
test('handleLogout - logouts the user and clear localstorage', async () => {
|
||||
storage.setItem('username', 'verdaccio');
|
||||
storage.setItem('token', generateTokenWithTimeRange(24));
|
||||
|
||||
const { queryByTestId } = render(<App />);
|
||||
|
||||
// wait for the Account's circle element component appearance and return the element
|
||||
const accountCircleElement = await waitForElement(() => queryByTestId('header--menu-accountcircle'));
|
||||
expect(accountCircleElement).toBeTruthy();
|
||||
|
||||
if (accountCircleElement) {
|
||||
fireEvent.click(accountCircleElement);
|
||||
|
||||
// wait for the Button's logout element component appearance and return the element
|
||||
const buttonLogoutElement = await waitForElement(() => queryByTestId('header--button-logout'));
|
||||
expect(buttonLogoutElement).toBeTruthy();
|
||||
|
||||
if (buttonLogoutElement) {
|
||||
fireEvent.click(buttonLogoutElement);
|
||||
|
||||
expect(queryByTestId('greetings-label')).toBeFalsy();
|
||||
}
|
||||
}
|
||||
test('toggleLoginModal: should toggle the value in state', () => {
|
||||
const { handleToggleLoginModal } = wrapper.instance();
|
||||
expect(wrapper.state().showLoginModal).toBeFalsy();
|
||||
handleToggleLoginModal();
|
||||
expect(wrapper.state('showLoginModal')).toBeTruthy();
|
||||
expect(wrapper.state('error')).toEqual(undefined);
|
||||
});
|
||||
|
||||
test('isUserAlreadyLoggedIn: token already available in storage', async () => {
|
||||
storage.setItem('username', 'verdaccio');
|
||||
storage.setItem('token', generateTokenWithTimeRange(24));
|
||||
const { isUserAlreadyLoggedIn } = wrapper.instance();
|
||||
|
||||
const { queryByTestId, queryAllByText } = render(<App />);
|
||||
isUserAlreadyLoggedIn();
|
||||
|
||||
// wait for the Account's circle element component appearance and return the element
|
||||
const accountCircleElement = await waitForElement(() => queryByTestId('header--menu-accountcircle'));
|
||||
expect(accountCircleElement).toBeTruthy();
|
||||
expect(wrapper.state('user').username).toEqual('verdaccio');
|
||||
});
|
||||
|
||||
if (accountCircleElement) {
|
||||
fireEvent.click(accountCircleElement);
|
||||
test('handleLogout - logouts the user and clear localstorage', async () => {
|
||||
const { handleLogout } = wrapper.instance();
|
||||
storage.setItem('username', 'verdaccio');
|
||||
storage.setItem('token', 'xxxx.TOKEN.xxxx');
|
||||
|
||||
// wait for the Greeting's label element component appearance and return the element
|
||||
const greetingsLabelElement = await waitForElement(() => queryByTestId('greetings-label'));
|
||||
expect(greetingsLabelElement).toBeTruthy();
|
||||
await handleLogout();
|
||||
expect(wrapper.state('user')).toEqual({});
|
||||
expect(wrapper.state('isUserLoggedIn')).toBeFalsy();
|
||||
});
|
||||
|
||||
if (greetingsLabelElement) {
|
||||
expect(queryAllByText('verdaccio')).toBeTruthy();
|
||||
}
|
||||
}
|
||||
test('handleDoLogin - login the user successfully', async () => {
|
||||
const { handleDoLogin } = wrapper.instance();
|
||||
await handleDoLogin('sam', '1234');
|
||||
const result = {
|
||||
username: 'sam',
|
||||
};
|
||||
expect(wrapper.state('isUserLoggedIn')).toBeTruthy();
|
||||
expect(wrapper.state('showLoginModal')).toBeFalsy();
|
||||
expect(storage.getItem('username')).toEqual('sam');
|
||||
expect(storage.getItem('token')).toEqual('TEST_TOKEN');
|
||||
expect(wrapper.state('user')).toEqual(result);
|
||||
});
|
||||
|
||||
test('handleDoLogin - authentication failure', async () => {
|
||||
const { handleDoLogin } = wrapper.instance();
|
||||
await handleDoLogin('sam', '12345');
|
||||
const result = {
|
||||
description: 'bad username/password, access denied',
|
||||
title: 'Unable to login',
|
||||
type: 'error',
|
||||
};
|
||||
expect(wrapper.state('user')).toEqual({});
|
||||
expect(wrapper.state('error')).toEqual(result);
|
||||
});
|
||||
});
|
||||
|
||||
235
src/App/App.tsx
235
src/App/App.tsx
@@ -1,83 +1,188 @@
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import styled from '@emotion/styled';
|
||||
import React, { Component, ReactElement } from 'react';
|
||||
import isNil from 'lodash/isNil';
|
||||
import { Router } from 'react-router-dom';
|
||||
|
||||
import storage from '../utils/storage';
|
||||
import { isTokenExpire } from '../utils/login';
|
||||
import { makeLogin, isTokenExpire } from '../utils/login';
|
||||
import Loading from '../components/Loading';
|
||||
import LoginModal from '../components/Login';
|
||||
import Header from '../components/Header';
|
||||
import { Container, Content } from '../components/Layout';
|
||||
import API from '../utils/api';
|
||||
import Footer from '../components/Footer';
|
||||
import Box from '../muiComponents/Box';
|
||||
import StyleBaseline from '../design-tokens/StyleBaseline';
|
||||
import { Theme } from '../design-tokens/theme';
|
||||
|
||||
import AppContextProvider from './AppContextProvider';
|
||||
import AppRoute, { history } from './AppRoute';
|
||||
import AppRoute from './AppRoute';
|
||||
import { AppProps, AppContextProvider } from './AppContext';
|
||||
|
||||
const StyledBox = styled(Box)<{ theme?: Theme }>(({ theme }) => ({
|
||||
backgroundColor: theme && theme.palette.backgroundBody,
|
||||
}));
|
||||
|
||||
const StyledBoxContent = styled(Box)<{ theme?: Theme }>(({ theme }) => ({
|
||||
[`@media screen and (min-width: ${theme && theme.breakPoints.container}px)`]: {
|
||||
maxWidth: theme && theme.breakPoints.container,
|
||||
width: '100%',
|
||||
marginLeft: 'auto',
|
||||
marginRight: 'auto',
|
||||
},
|
||||
}));
|
||||
|
||||
/* eslint-disable react/jsx-no-bind */
|
||||
/* eslint-disable react-hooks/exhaustive-deps */
|
||||
const App: React.FC = () => {
|
||||
const [user, setUser] = useState();
|
||||
|
||||
/**
|
||||
* Logout user
|
||||
* Required by: <Header />
|
||||
*/
|
||||
const logout = () => {
|
||||
storage.removeItem('username');
|
||||
storage.removeItem('token');
|
||||
setUser(undefined);
|
||||
export default class App extends Component<{}, AppProps> {
|
||||
public state: AppProps = {
|
||||
logoUrl: window.VERDACCIO_LOGO,
|
||||
user: {},
|
||||
scope: window.VERDACCIO_SCOPE || '',
|
||||
showLoginModal: false,
|
||||
isUserLoggedIn: false,
|
||||
packages: [],
|
||||
isLoading: true,
|
||||
};
|
||||
|
||||
const checkUserAlreadyLoggedIn = () => {
|
||||
public componentDidMount(): void {
|
||||
this.isUserAlreadyLoggedIn();
|
||||
this.loadOnHandler();
|
||||
}
|
||||
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
public componentDidUpdate(_: AppProps, prevState: AppProps): void {
|
||||
const { isUserLoggedIn } = this.state;
|
||||
if (prevState.isUserLoggedIn !== isUserLoggedIn) {
|
||||
this.loadOnHandler();
|
||||
}
|
||||
}
|
||||
|
||||
public render(): React.ReactElement<HTMLDivElement> {
|
||||
const { isLoading, isUserLoggedIn, packages, logoUrl, user, scope } = this.state;
|
||||
|
||||
const context = { isUserLoggedIn, packages, logoUrl, user, scope };
|
||||
|
||||
return (
|
||||
<>
|
||||
<StyleBaseline />
|
||||
<Container isLoading={isLoading}>
|
||||
{isLoading ? <Loading /> : <AppContextProvider value={context}>{this.renderContent()}</AppContextProvider>}
|
||||
{this.renderLoginModal()}
|
||||
</Container>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
public isUserAlreadyLoggedIn = () => {
|
||||
// checks for token validity
|
||||
const token = storage.getItem('token');
|
||||
const username = storage.getItem('username');
|
||||
|
||||
const username: string = storage.getItem('username') as string;
|
||||
if (isTokenExpire(token) || isNil(username)) {
|
||||
logout();
|
||||
return;
|
||||
this.handleLogout();
|
||||
} else {
|
||||
this.setState({
|
||||
user: { username },
|
||||
isUserLoggedIn: true,
|
||||
});
|
||||
}
|
||||
|
||||
setUser({ username });
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
checkUserAlreadyLoggedIn();
|
||||
}, []);
|
||||
public loadOnHandler = async () => {
|
||||
try {
|
||||
const packages = await API.request<any[]>('packages', 'GET');
|
||||
// @ts-ignore: FIX THIS TYPE: Type 'any[]' is not assignable to type '[]'
|
||||
this.setState({
|
||||
packages,
|
||||
isLoading: false,
|
||||
});
|
||||
} catch (error) {
|
||||
// FIXME: add dialog
|
||||
console.error({
|
||||
title: 'Warning',
|
||||
message: `Unable to load package list: ${error.message}`,
|
||||
});
|
||||
this.setLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<StyleBaseline />
|
||||
<StyledBox display="flex" flexDirection="column" height="100%">
|
||||
<>
|
||||
<Router history={history}>
|
||||
<AppContextProvider user={user}>
|
||||
<Header />
|
||||
<StyledBoxContent flexGrow={1}>
|
||||
{/* eslint-disable-next-line react/jsx-max-depth */}
|
||||
<AppRoute />
|
||||
</StyledBoxContent>
|
||||
</AppContextProvider>
|
||||
</Router>
|
||||
<Footer />
|
||||
</>
|
||||
</StyledBox>
|
||||
</>
|
||||
);
|
||||
};
|
||||
public setLoading = (isLoading: boolean) =>
|
||||
this.setState({
|
||||
isLoading,
|
||||
});
|
||||
|
||||
export default App;
|
||||
/**
|
||||
* Toggles the login modal
|
||||
* Required by: <LoginModal /> <Header />
|
||||
*/
|
||||
public handleToggleLoginModal = () => {
|
||||
this.setState(prevState => ({
|
||||
showLoginModal: !prevState.showLoginModal,
|
||||
}));
|
||||
};
|
||||
|
||||
/**
|
||||
* handles login
|
||||
* Required by: <Header />
|
||||
*/
|
||||
public handleDoLogin = async (usernameValue: string, passwordValue: string) => {
|
||||
const { username, token, error } = await makeLogin(usernameValue, passwordValue);
|
||||
|
||||
if (username && token) {
|
||||
storage.setItem('username', username);
|
||||
storage.setItem('token', token);
|
||||
this.setLoggedUser(username);
|
||||
}
|
||||
|
||||
if (error) {
|
||||
this.setState({
|
||||
user: {},
|
||||
error,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
public setLoggedUser = (username: string) => {
|
||||
this.setState({
|
||||
user: {
|
||||
username,
|
||||
},
|
||||
isUserLoggedIn: true, // close login modal after successful login
|
||||
showLoginModal: false, // set isUserLoggedIn to true
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Logouts user
|
||||
* Required by: <Header />
|
||||
*/
|
||||
public handleLogout = () => {
|
||||
storage.removeItem('username');
|
||||
storage.removeItem('token');
|
||||
this.setState({
|
||||
user: {},
|
||||
isUserLoggedIn: false,
|
||||
});
|
||||
};
|
||||
|
||||
public renderLoginModal = (): ReactElement<HTMLElement> => {
|
||||
const { error, showLoginModal } = this.state;
|
||||
return (
|
||||
<LoginModal
|
||||
error={error}
|
||||
onCancel={this.handleToggleLoginModal}
|
||||
onSubmit={this.handleDoLogin}
|
||||
visibility={showLoginModal}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
public renderContent = (): ReactElement<HTMLElement> => {
|
||||
return (
|
||||
<>
|
||||
<Content>
|
||||
<AppRoute>{this.renderHeader()}</AppRoute>
|
||||
</Content>
|
||||
<Footer />
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
public renderHeader = (): ReactElement<HTMLElement> => {
|
||||
const {
|
||||
logoUrl,
|
||||
user: { username },
|
||||
scope,
|
||||
} = this.state;
|
||||
|
||||
return (
|
||||
<Header
|
||||
logo={logoUrl}
|
||||
onLogout={this.handleLogout}
|
||||
onToggleLoginModal={this.handleToggleLoginModal}
|
||||
scope={scope}
|
||||
username={username}
|
||||
/>
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
import { createContext } from 'react';
|
||||
|
||||
export interface AppProps {
|
||||
user?: User;
|
||||
scope: string;
|
||||
}
|
||||
|
||||
export interface User {
|
||||
username: string;
|
||||
}
|
||||
|
||||
export interface AppContextProps extends AppProps {
|
||||
setUser: (user?: User) => void;
|
||||
}
|
||||
|
||||
const AppContext = createContext<undefined | AppContextProps>(undefined);
|
||||
|
||||
export default AppContext;
|
||||
20
src/App/AppContext.tsx
Normal file
20
src/App/AppContext.tsx
Normal file
@@ -0,0 +1,20 @@
|
||||
import { createContext } from 'react';
|
||||
|
||||
import { FormError } from '../components/Login/Login';
|
||||
|
||||
export interface AppProps {
|
||||
error?: FormError;
|
||||
logoUrl: string;
|
||||
user: {
|
||||
username?: string;
|
||||
};
|
||||
scope: string;
|
||||
showLoginModal: boolean;
|
||||
isUserLoggedIn: boolean;
|
||||
packages: [];
|
||||
isLoading: boolean;
|
||||
}
|
||||
|
||||
export const AppContext = createContext<Partial<AppProps>>({});
|
||||
export const AppContextProvider = AppContext.Provider;
|
||||
export const AppContextConsumer = AppContext.Consumer;
|
||||
@@ -1,41 +0,0 @@
|
||||
import React, { useState, useEffect } from 'react';
|
||||
|
||||
import AppContext, { AppProps, User } from './AppContext';
|
||||
|
||||
interface Props {
|
||||
user?: User;
|
||||
}
|
||||
|
||||
/* eslint-disable react-hooks/exhaustive-deps */
|
||||
const AppContextProvider: React.FC<Props> = ({ children, user }) => {
|
||||
const [state, setState] = useState<AppProps>({
|
||||
scope: window.VERDACCIO_SCOPE || '',
|
||||
user,
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
setState({
|
||||
...state,
|
||||
user,
|
||||
});
|
||||
}, [user]);
|
||||
|
||||
const setUser = (user?: User) => {
|
||||
setState({
|
||||
...state,
|
||||
user,
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<AppContext.Provider
|
||||
value={{
|
||||
...state,
|
||||
setUser,
|
||||
}}>
|
||||
{children}
|
||||
</AppContext.Provider>
|
||||
);
|
||||
};
|
||||
|
||||
export default AppContextProvider;
|
||||
@@ -4,7 +4,7 @@ import { createBrowserHistory } from 'history';
|
||||
|
||||
import Loading from '../components/Loading';
|
||||
|
||||
import AppContext from './AppContext';
|
||||
import { AppContext } from './AppContext';
|
||||
|
||||
const NotFound = lazy(() => import('../components/NotFound'));
|
||||
const VersionContextProvider = lazy(() => import('../pages/Version/VersionContextProvider'));
|
||||
@@ -19,27 +19,22 @@ enum Route {
|
||||
PACKAGE_VERSION = '/-/web/detail/:package/v/:version',
|
||||
}
|
||||
|
||||
export const history = createBrowserHistory({
|
||||
const history = createBrowserHistory({
|
||||
basename: window.__VERDACCIO_BASENAME_UI_OPTIONS && window.__VERDACCIO_BASENAME_UI_OPTIONS.url_prefix,
|
||||
});
|
||||
|
||||
const AppRoute: React.FC = () => {
|
||||
/* eslint react/jsx-max-depth: 0 */
|
||||
const AppRoute: React.FC = ({ children }) => {
|
||||
const appContext = useContext(AppContext);
|
||||
|
||||
if (!appContext) {
|
||||
throw Error('The app Context was not correct used');
|
||||
}
|
||||
|
||||
const { user } = appContext;
|
||||
|
||||
const isUserLoggedIn = user && user.username;
|
||||
const { isUserLoggedIn, packages } = appContext;
|
||||
|
||||
return (
|
||||
<Router history={history}>
|
||||
<Suspense fallback={<Loading />}>
|
||||
{children}
|
||||
<Switch>
|
||||
<ReactRouterDomRoute exact={true} path={Route.ROOT}>
|
||||
<HomePage isUserLoggedIn={!!isUserLoggedIn} />
|
||||
<HomePage isUserLoggedIn={!!isUserLoggedIn} packages={packages || []} />
|
||||
</ReactRouterDomRoute>
|
||||
<ReactRouterDomRoute exact={true} path={Route.PACKAGE}>
|
||||
<VersionContextProvider>
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,2 +1 @@
|
||||
export { default } from './App';
|
||||
export { default as AppContextProvider } from './AppContextProvider';
|
||||
|
||||
18
src/App/styles.ts
Normal file
18
src/App/styles.ts
Normal 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',
|
||||
});
|
||||
@@ -1,71 +1,89 @@
|
||||
import React from 'react';
|
||||
import { mount } from 'enzyme';
|
||||
|
||||
import { render, cleanup } from '../../utils/test-react-testing-library';
|
||||
import { DetailContext, DetailContextProps } from '../../pages/Version';
|
||||
import api from '../../utils/api';
|
||||
|
||||
import ActionBar from './ActionBar';
|
||||
import { ActionBar } from './ActionBar';
|
||||
|
||||
const detailContextValue: DetailContextProps = {
|
||||
packageName: 'foo',
|
||||
readMe: 'test',
|
||||
enableLoading: () => {},
|
||||
isLoading: false,
|
||||
hasNotBeenFound: false,
|
||||
packageMeta: {
|
||||
_uplinks: {},
|
||||
latest: {
|
||||
name: '@verdaccio/local-storage',
|
||||
version: '8.0.1-next.1',
|
||||
dist: { fileCount: 0, unpackedSize: 0, tarball: 'http://localhost:8080/bootstrap/-/bootstrap-4.3.1.tgz' },
|
||||
homepage: 'https://verdaccio.org',
|
||||
bugs: {
|
||||
url: 'https://github.com/verdaccio/monorepo/issues',
|
||||
},
|
||||
const mockPackageMeta: jest.Mock = jest.fn(() => ({
|
||||
latest: {
|
||||
homepage: 'https://verdaccio.tld',
|
||||
bugs: {
|
||||
url: 'https://verdaccio.tld/bugs',
|
||||
},
|
||||
dist: {
|
||||
tarball: 'https://verdaccio.tld/download',
|
||||
},
|
||||
},
|
||||
};
|
||||
}));
|
||||
|
||||
const ComponentToBeRendered: React.FC<{ contextValue: DetailContextProps }> = ({ contextValue }) => (
|
||||
<DetailContext.Provider value={contextValue}>
|
||||
<ActionBar />
|
||||
</DetailContext.Provider>
|
||||
);
|
||||
jest.mock('../../pages/Version', () => ({
|
||||
DetailContextConsumer: component => {
|
||||
return component.children({ packageMeta: mockPackageMeta() });
|
||||
},
|
||||
}));
|
||||
|
||||
describe('<ActionBar /> component', () => {
|
||||
afterEach(() => {
|
||||
cleanup();
|
||||
beforeEach(() => {
|
||||
jest.resetModules();
|
||||
jest.resetAllMocks();
|
||||
});
|
||||
|
||||
test('should render the component in default state', () => {
|
||||
const { container } = render(<ComponentToBeRendered contextValue={detailContextValue} />);
|
||||
expect(container.firstChild).toMatchSnapshot();
|
||||
const wrapper = mount(<ActionBar />);
|
||||
expect(wrapper.html()).toMatchSnapshot();
|
||||
});
|
||||
|
||||
test('when there is no action bar data', () => {
|
||||
const packageMeta = {
|
||||
...detailContextValue.packageMeta,
|
||||
latest: {
|
||||
...detailContextValue.packageMeta.latest,
|
||||
homepage: undefined,
|
||||
bugs: undefined,
|
||||
dist: {
|
||||
...detailContextValue.packageMeta.latest.dist,
|
||||
tarball: undefined,
|
||||
},
|
||||
},
|
||||
};
|
||||
mockPackageMeta.mockImplementation(() => ({
|
||||
latest: {},
|
||||
}));
|
||||
|
||||
const { container } = render(<ComponentToBeRendered contextValue={{ ...detailContextValue, packageMeta }} />);
|
||||
expect(container.firstChild).toMatchSnapshot();
|
||||
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', () => {
|
||||
const { getByTitle } = render(<ComponentToBeRendered contextValue={{ ...detailContextValue }} />);
|
||||
expect(getByTitle('Download tarball')).toBeTruthy();
|
||||
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', () => {
|
||||
const { getByTitle } = render(<ComponentToBeRendered contextValue={{ ...detailContextValue }} />);
|
||||
expect(getByTitle('Open an issue')).toBeTruthy();
|
||||
mockPackageMeta.mockImplementation(() => ({
|
||||
latest: {
|
||||
bugs: {
|
||||
url: 'https://verdaccio.tld/bugs',
|
||||
},
|
||||
},
|
||||
}));
|
||||
|
||||
const wrapper = mount(<ActionBar />);
|
||||
expect(wrapper.html()).toMatchSnapshot();
|
||||
|
||||
const button = wrapper.find('button');
|
||||
expect(button).toHaveLength(1);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,44 +1,133 @@
|
||||
import React from 'react';
|
||||
import React, { Component, ReactElement } from 'react';
|
||||
import BugReportIcon from '@material-ui/icons/BugReport';
|
||||
import DownloadIcon from '@material-ui/icons/CloudDownload';
|
||||
import HomeIcon from '@material-ui/icons/Home';
|
||||
|
||||
import { DetailContext } from '../../pages/Version';
|
||||
import { isURL } from '../../utils/url';
|
||||
import Box from '../../muiComponents/Box';
|
||||
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 ActionBarAction, { ActionBarActionProps } from './ActionBarAction';
|
||||
import { Fab, ActionListItem } from './styles';
|
||||
|
||||
/* eslint-disable verdaccio/jsx-spread */
|
||||
const ActionBar: React.FC = () => {
|
||||
const detailContext = React.useContext(DetailContext);
|
||||
export interface Action {
|
||||
icon: string;
|
||||
title: string;
|
||||
handler?: Function;
|
||||
}
|
||||
|
||||
const { packageMeta } = detailContext;
|
||||
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);
|
||||
}
|
||||
|
||||
if (!packageMeta?.latest) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const { homepage, bugs, dist } = packageMeta.latest;
|
||||
|
||||
const actions: Array<ActionBarActionProps> = [];
|
||||
|
||||
if (homepage && isURL(homepage)) {
|
||||
actions.push({ type: 'VISIT_HOMEPAGE', link: homepage });
|
||||
}
|
||||
|
||||
if (bugs?.url && isURL(bugs.url)) {
|
||||
actions.push({ type: 'OPEN_AN_ISSUE', link: bugs.url });
|
||||
}
|
||||
|
||||
if (dist?.tarball && isURL(dist.tarball)) {
|
||||
actions.push({ type: 'DOWNLOAD_TARBALL', link: dist.tarball });
|
||||
}
|
||||
|
||||
return (
|
||||
<Box alignItems="center" display="flex" marginBottom="8px">
|
||||
{actions.map(action => (
|
||||
<ActionBarAction key={action.link} {...action} />
|
||||
))}
|
||||
</Box>
|
||||
);
|
||||
const ACTIONS = {
|
||||
homepage: {
|
||||
icon: <HomeIcon />,
|
||||
title: 'Visit homepage',
|
||||
},
|
||||
issue: {
|
||||
icon: <BugReportIcon />,
|
||||
title: 'Open an issue',
|
||||
},
|
||||
tarball: {
|
||||
icon: <DownloadIcon />,
|
||||
title: 'Download tarball',
|
||||
handler: downloadHandler,
|
||||
},
|
||||
};
|
||||
|
||||
export default ActionBar;
|
||||
class ActionBar extends Component {
|
||||
public render(): ReactElement<HTMLElement> {
|
||||
return (
|
||||
<DetailContextConsumer>
|
||||
{context => {
|
||||
const { packageMeta } = context;
|
||||
|
||||
if (!packageMeta) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return this.renderActionBar(context as VersionPageConsumerProps);
|
||||
}}
|
||||
</DetailContextConsumer>
|
||||
);
|
||||
}
|
||||
|
||||
private renderIconsWithLink(link: string, component: JSX.Element): ReactElement<HTMLElement> {
|
||||
return (
|
||||
<a href={link} target={'_blank'}>
|
||||
{component}
|
||||
</a>
|
||||
);
|
||||
}
|
||||
|
||||
private renderActionBar = ({ packageMeta }) => {
|
||||
const { latest } = packageMeta;
|
||||
|
||||
if (!latest) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const { homepage, bugs, dist } = latest;
|
||||
|
||||
const actionsMap = {
|
||||
homepage,
|
||||
issue: bugs ? bugs.url : null,
|
||||
tarball: dist ? dist.tarball : null,
|
||||
};
|
||||
|
||||
const renderList = Object.keys(actionsMap).reduce((component: React.ReactElement[], value, key) => {
|
||||
const link = actionsMap[value];
|
||||
if (link && isURL(link)) {
|
||||
const actionItem: Action = ACTIONS[value];
|
||||
if (actionItem.handler) {
|
||||
const fab = (
|
||||
<Tooltip key={key} title={actionItem['title']}>
|
||||
<Fab
|
||||
/* eslint-disable react/jsx-no-bind */
|
||||
onClick={() => {
|
||||
/* eslint-disable @typescript-eslint/no-non-null-assertion */
|
||||
actionItem.handler!(link);
|
||||
}}
|
||||
size={'small'}>
|
||||
{actionItem['icon']}
|
||||
</Fab>
|
||||
</Tooltip>
|
||||
);
|
||||
component.push(fab);
|
||||
} else {
|
||||
const fab = <Fab size={'small'}>{actionItem['icon']}</Fab>;
|
||||
component.push(
|
||||
<Tooltip key={key} title={actionItem['title']}>
|
||||
<>{this.renderIconsWithLink(link, fab)}</>
|
||||
</Tooltip>
|
||||
);
|
||||
}
|
||||
}
|
||||
return component;
|
||||
}, []);
|
||||
|
||||
if (renderList.length > 0) {
|
||||
return (
|
||||
<List>
|
||||
<ActionListItem alignItems={'flex-start'} button={true}>
|
||||
{renderList}
|
||||
</ActionListItem>
|
||||
</List>
|
||||
);
|
||||
}
|
||||
|
||||
return null;
|
||||
};
|
||||
}
|
||||
|
||||
export { ActionBar };
|
||||
|
||||
@@ -1,61 +0,0 @@
|
||||
import React from 'react';
|
||||
import styled from '@emotion/styled';
|
||||
import BugReportIcon from '@material-ui/icons/BugReport';
|
||||
import DownloadIcon from '@material-ui/icons/CloudDownload';
|
||||
import HomeIcon from '@material-ui/icons/Home';
|
||||
|
||||
import Tooltip from '../../muiComponents/Tooltip';
|
||||
import Link from '../Link';
|
||||
import FloatingActionButton from '../../muiComponents/FloatingActionButton';
|
||||
import { Theme } from '../../design-tokens/theme';
|
||||
|
||||
import downloadTarball from './download-tarball';
|
||||
|
||||
export const Fab = styled(FloatingActionButton)<{ theme?: Theme }>(props => ({
|
||||
backgroundColor: props.theme && props.theme.palette.primary.main,
|
||||
color: props.theme && props.theme.palette.white,
|
||||
marginRight: 10,
|
||||
}));
|
||||
|
||||
type ActionType = 'VISIT_HOMEPAGE' | 'OPEN_AN_ISSUE' | 'DOWNLOAD_TARBALL';
|
||||
|
||||
export interface ActionBarActionProps {
|
||||
type: ActionType;
|
||||
link: string;
|
||||
}
|
||||
|
||||
/* eslint-disable react/jsx-no-bind */
|
||||
const ActionBarAction: React.FC<ActionBarActionProps> = ({ type, link }) => {
|
||||
switch (type) {
|
||||
case 'VISIT_HOMEPAGE':
|
||||
return (
|
||||
<Tooltip title="Visit homepage">
|
||||
<Link external={true} to={link}>
|
||||
<Fab size="small">
|
||||
<HomeIcon />
|
||||
</Fab>
|
||||
</Link>
|
||||
</Tooltip>
|
||||
);
|
||||
case 'OPEN_AN_ISSUE':
|
||||
return (
|
||||
<Tooltip title="Open an issue">
|
||||
<Link external={true} to={link}>
|
||||
<Fab size="small">
|
||||
<BugReportIcon />
|
||||
</Fab>
|
||||
</Link>
|
||||
</Tooltip>
|
||||
);
|
||||
case 'DOWNLOAD_TARBALL':
|
||||
return (
|
||||
<Tooltip title="Download tarball">
|
||||
<Fab data-testid="download-tarball-btn" onClick={downloadTarball(link)} size="small">
|
||||
<DownloadIcon />
|
||||
</Fab>
|
||||
</Tooltip>
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
export default ActionBarAction;
|
||||
@@ -1,118 +1,7 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`<ActionBar /> component should render the component in default state 1`] = `
|
||||
.emotion-0 {
|
||||
background-color: #4b5e40;
|
||||
color: #fff;
|
||||
margin-right: 10px;
|
||||
}
|
||||
exports[`<ActionBar /> component should render the component in default state 1`] = `""`;
|
||||
|
||||
<div
|
||||
class="MuiBox-root MuiBox-root-2"
|
||||
>
|
||||
<a
|
||||
class=""
|
||||
href="https://verdaccio.org"
|
||||
rel="noopener noreferrer"
|
||||
target="_blank"
|
||||
title="Visit homepage"
|
||||
>
|
||||
<h6
|
||||
class="MuiTypography-root MuiTypography-subtitle1"
|
||||
>
|
||||
<button
|
||||
class="MuiButtonBase-root MuiFab-root emotion-0 emotion-1 MuiFab-sizeSmall"
|
||||
tabindex="0"
|
||||
type="button"
|
||||
>
|
||||
<span
|
||||
class="MuiFab-label"
|
||||
>
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
class="MuiSvgIcon-root"
|
||||
focusable="false"
|
||||
role="presentation"
|
||||
viewBox="0 0 24 24"
|
||||
>
|
||||
<path
|
||||
d="M10 20v-6h4v6h5v-8h3L12 3 2 12h3v8z"
|
||||
/>
|
||||
</svg>
|
||||
</span>
|
||||
<span
|
||||
class="MuiTouchRipple-root"
|
||||
/>
|
||||
</button>
|
||||
</h6>
|
||||
</a>
|
||||
<a
|
||||
class=""
|
||||
href="https://github.com/verdaccio/monorepo/issues"
|
||||
rel="noopener noreferrer"
|
||||
target="_blank"
|
||||
title="Open an issue"
|
||||
>
|
||||
<h6
|
||||
class="MuiTypography-root MuiTypography-subtitle1"
|
||||
>
|
||||
<button
|
||||
class="MuiButtonBase-root MuiFab-root emotion-0 emotion-1 MuiFab-sizeSmall"
|
||||
tabindex="0"
|
||||
type="button"
|
||||
>
|
||||
<span
|
||||
class="MuiFab-label"
|
||||
>
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
class="MuiSvgIcon-root"
|
||||
focusable="false"
|
||||
role="presentation"
|
||||
viewBox="0 0 24 24"
|
||||
>
|
||||
<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"
|
||||
/>
|
||||
</svg>
|
||||
</span>
|
||||
<span
|
||||
class="MuiTouchRipple-root"
|
||||
/>
|
||||
</button>
|
||||
</h6>
|
||||
</a>
|
||||
<button
|
||||
class="MuiButtonBase-root MuiFab-root emotion-0 emotion-1 MuiFab-sizeSmall"
|
||||
data-testid="download-tarball-btn"
|
||||
tabindex="0"
|
||||
title="Download tarball"
|
||||
type="button"
|
||||
>
|
||||
<span
|
||||
class="MuiFab-label"
|
||||
>
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
class="MuiSvgIcon-root"
|
||||
focusable="false"
|
||||
role="presentation"
|
||||
viewBox="0 0 24 24"
|
||||
>
|
||||
<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"
|
||||
/>
|
||||
</svg>
|
||||
</span>
|
||||
<span
|
||||
class="MuiTouchRipple-root"
|
||||
/>
|
||||
</button>
|
||||
</div>
|
||||
`;
|
||||
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-z6z5me 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 no action bar data 1`] = `
|
||||
<div
|
||||
class="MuiBox-root MuiBox-root-77"
|
||||
/>
|
||||
`;
|
||||
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-z6z5me eux6shq1 MuiFab-sizeSmall\\" tabindex=\\"0\\" type=\\"button\\"><span class=\\"MuiFab-label\\"><svg class=\\"MuiSvgIcon-root\\" focusable=\\"false\\" viewBox=\\"0 0 24 24\\" aria-hidden=\\"true\\" role=\\"presentation\\"><path d=\\"M20 8h-2.81c-.45-.78-1.07-1.45-1.82-1.96L17 4.41 15.59 3l-2.17 2.17C12.96 5.06 12.49 5 12 5c-.49 0-.96.06-1.41.17L8.41 3 7 4.41l1.62 1.63C7.88 6.55 7.26 7.22 6.81 8H4v2h2.09c-.05.33-.09.66-.09 1v1H4v2h2v1c0 .34.04.67.09 1H4v2h2.81c1.04 1.79 2.97 3 5.19 3s4.15-1.21 5.19-3H20v-2h-2.09c.05-.33.09-.66.09-1v-1h2v-2h-2v-1c0-.34-.04-.67-.09-1H20V8zm-6 8h-4v-2h4v2zm0-4h-4v-2h4v2z\\"></path></svg></span><span class=\\"MuiTouchRipple-root\\"></span></button></a><span class=\\"MuiTouchRipple-root\\"></span></div></ul>"`;
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
import api from '../../utils/api';
|
||||
import { extractFileName, downloadFile } from '../../utils/url';
|
||||
|
||||
function downloadTarball(link: string) {
|
||||
return async function downloadHandler(): 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);
|
||||
};
|
||||
}
|
||||
|
||||
export default downloadTarball;
|
||||
@@ -1,2 +1 @@
|
||||
export { default } from './ActionBar';
|
||||
export { default as downloadTarball } from './download-tarball';
|
||||
|
||||
17
src/components/ActionBar/styles.ts
Normal file
17
src/components/ActionBar/styles.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import styled from '@emotion/styled';
|
||||
|
||||
import colors from '../../utils/styles/colors';
|
||||
import ListItem from '../../muiComponents/ListItem';
|
||||
import FloatingActionButton from '../../muiComponents/FloatingActionButton';
|
||||
|
||||
export const ActionListItem = styled(ListItem)({
|
||||
paddingTop: 0,
|
||||
paddingLeft: 0,
|
||||
paddingRight: 0,
|
||||
});
|
||||
|
||||
export const Fab = styled(FloatingActionButton)({
|
||||
backgroundColor: colors.primary,
|
||||
color: colors.white,
|
||||
marginRight: '10px',
|
||||
});
|
||||
@@ -1,6 +1,6 @@
|
||||
import React from 'react';
|
||||
import { mount } from 'enzyme';
|
||||
|
||||
import { mount } from '../../utils/test-enzyme';
|
||||
import { DetailContext } from '../../pages/Version';
|
||||
|
||||
import Authors from './Author';
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`<Author /> component should render the component in default state 1`] = `"<ul class=\\"MuiList-root MuiList-padding MuiList-subheader\\"><h6 class=\\"MuiTypography-root css-1na337r-StyledText e1xuehjw0 MuiTypography-subtitle1\\">Author</h6><div class=\\"MuiButtonBase-root MuiListItem-root css-1k45khb-AuthorListItem 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 MuiAvatar-circle\\"><img alt=\\"verdaccio user\\" src=\\"https://www.gravatar.com/avatar/000000\\" class=\\"MuiAvatar-img\\"></div></a><div class=\\"MuiListItemText-root css-1cnlq5d-AuthorListItemText e1xuehjw2\\"><span class=\\"MuiTypography-root MuiListItemText-primary MuiTypography-body1\\">verdaccio user</span></div><span class=\\"MuiTouchRipple-root\\"></span></div></ul>"`;
|
||||
exports[`<Author /> component should render the component in default state 1`] = `"<ul class=\\"MuiList-root MuiList-padding MuiList-subheader\\"><h6 class=\\"MuiTypography-root css-b8upko e1xuehjw0 MuiTypography-subtitle1\\">Author</h6><div class=\\"MuiButtonBase-root MuiListItem-root css-zw46c6 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 MuiAvatar-circle\\"><img alt=\\"verdaccio user\\" src=\\"https://www.gravatar.com/avatar/000000\\" class=\\"MuiAvatar-img\\"></div></a><div class=\\"MuiListItemText-root css-fipixf 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-1na337r-StyledText e1xuehjw0 MuiTypography-subtitle1\\">Author</h6><div class=\\"MuiButtonBase-root MuiListItem-root css-1k45khb-AuthorListItem e1xuehjw1 MuiListItem-gutters MuiListItem-button\\" tabindex=\\"0\\" role=\\"button\\" aria-disabled=\\"false\\"><div class=\\"MuiAvatar-root MuiAvatar-circle\\"><img alt=\\"verdaccio user\\" src=\\"https://www.gravatar.com/avatar/000000\\" class=\\"MuiAvatar-img\\"></div><div class=\\"MuiListItemText-root css-1cnlq5d-AuthorListItemText 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-zw46c6 e1xuehjw1 MuiListItem-gutters MuiListItem-button\\" tabindex=\\"0\\" role=\\"button\\" aria-disabled=\\"false\\"><div class=\\"MuiAvatar-root MuiAvatar-circle\\"><img alt=\\"verdaccio user\\" src=\\"https://www.gravatar.com/avatar/000000\\" class=\\"MuiAvatar-img\\"></div><div class=\\"MuiListItemText-root css-fipixf e1xuehjw2\\"><span class=\\"MuiTypography-root MuiListItemText-primary MuiTypography-body1\\">verdaccio user</span></div><span class=\\"MuiTouchRipple-root\\"></span></div></ul>"`;
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
import styled from '@emotion/styled';
|
||||
|
||||
import { fontWeight } from '../../utils/styles/sizes';
|
||||
import ListItem from '../../muiComponents/ListItem';
|
||||
import Text from '../../muiComponents/Text';
|
||||
import ListItemText from '../../muiComponents/ListItemText';
|
||||
import { Theme } from '../../design-tokens/theme';
|
||||
|
||||
export const StyledText = styled(Text)<{ theme?: Theme }>(props => ({
|
||||
fontWeight: props.theme && props.theme.fontWeight.bold,
|
||||
export const StyledText = styled(Text)({
|
||||
fontWeight: fontWeight.bold,
|
||||
textTransform: 'capitalize',
|
||||
}));
|
||||
});
|
||||
|
||||
export const AuthorListItem = styled(ListItem)({
|
||||
padding: 0,
|
||||
|
||||
@@ -1,28 +1,20 @@
|
||||
import React, { KeyboardEvent, memo } from 'react';
|
||||
import styled from '@emotion/styled';
|
||||
import React, { KeyboardEvent } from 'react';
|
||||
import Autosuggest, { SuggestionSelectedEventData, InputProps, ChangeEvent } from 'react-autosuggest';
|
||||
import match from 'autosuggest-highlight/match';
|
||||
import parse from 'autosuggest-highlight/parse';
|
||||
|
||||
import { fontWeight } from '../../utils/styles/sizes';
|
||||
import MenuItem from '../../muiComponents/MenuItem';
|
||||
import { Theme } from '../../design-tokens/theme';
|
||||
|
||||
import { Wrapper, InputField, SuggestionContainer } from './styles';
|
||||
|
||||
const StyledAnchor = styled('a')<{ highlight: boolean; theme?: Theme }>(props => ({
|
||||
fontWeight: props.theme && props.highlight ? props.theme.fontWeight.semiBold : props.theme.fontWeight.light,
|
||||
}));
|
||||
|
||||
const StyledMenuItem = styled(MenuItem)({
|
||||
cursor: 'pointer',
|
||||
});
|
||||
|
||||
interface Props {
|
||||
suggestions: unknown[];
|
||||
suggestionsLoading?: boolean;
|
||||
suggestionsLoaded?: boolean;
|
||||
suggestionsError?: boolean;
|
||||
apiLoading?: boolean;
|
||||
color?: string;
|
||||
value?: string;
|
||||
placeholder?: string;
|
||||
startAdornment?: JSX.Element;
|
||||
@@ -61,17 +53,23 @@ const renderSuggestion = (suggestion, { query, isHighlighted }): JSX.Element =>
|
||||
const matches = match(suggestion.name, query);
|
||||
const parts = parse(suggestion.name, matches);
|
||||
return (
|
||||
<StyledMenuItem component="div" selected={isHighlighted}>
|
||||
<MenuItem component="div" selected={isHighlighted}>
|
||||
<div>
|
||||
{parts.map((part, index) => {
|
||||
const fw = part.highlight ? fontWeight.semiBold : fontWeight.light;
|
||||
return (
|
||||
<StyledAnchor highlight={part.highlight} key={String(index)}>
|
||||
<a
|
||||
className={css`
|
||||
font-weight: ${fw};
|
||||
`}
|
||||
href={suggestion.link}
|
||||
key={String(index)}>
|
||||
{part.text}
|
||||
</StyledAnchor>
|
||||
</a>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</StyledMenuItem>
|
||||
</MenuItem>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -89,66 +87,61 @@ const SUGGESTIONS_RESPONSE = {
|
||||
NO_RESULT: 'No results found.',
|
||||
};
|
||||
|
||||
const AutoComplete = memo(
|
||||
({
|
||||
const AutoComplete = ({
|
||||
suggestions,
|
||||
startAdornment,
|
||||
onChange,
|
||||
onSuggestionsFetch,
|
||||
onCleanSuggestions,
|
||||
value = '',
|
||||
placeholder = '',
|
||||
disableUnderline = false,
|
||||
color,
|
||||
onClick,
|
||||
onKeyDown,
|
||||
onBlur,
|
||||
suggestionsLoading = false,
|
||||
suggestionsLoaded = false,
|
||||
suggestionsError = false,
|
||||
}: Props): JSX.Element => {
|
||||
const autosuggestProps = {
|
||||
renderInputComponent,
|
||||
suggestions,
|
||||
startAdornment,
|
||||
getSuggestionValue,
|
||||
renderSuggestion,
|
||||
onSuggestionsFetchRequested: onSuggestionsFetch,
|
||||
onSuggestionsClearRequested: onCleanSuggestions,
|
||||
};
|
||||
const inputProps: InputProps<unknown> = {
|
||||
value,
|
||||
onChange,
|
||||
onSuggestionsFetch,
|
||||
onCleanSuggestions,
|
||||
value = '',
|
||||
placeholder = '',
|
||||
disableUnderline = false,
|
||||
onClick,
|
||||
placeholder,
|
||||
// material-ui@4.5.1 introduce better types for TextInput, check readme
|
||||
// @ts-ignore
|
||||
startAdornment,
|
||||
disableUnderline,
|
||||
color,
|
||||
onKeyDown,
|
||||
onBlur,
|
||||
suggestionsLoading = false,
|
||||
suggestionsLoaded = false,
|
||||
suggestionsError = false,
|
||||
}: Props) => {
|
||||
const autosuggestProps = {
|
||||
renderInputComponent,
|
||||
suggestions,
|
||||
getSuggestionValue,
|
||||
renderSuggestion,
|
||||
onSuggestionsFetchRequested: onSuggestionsFetch,
|
||||
onSuggestionsClearRequested: onCleanSuggestions,
|
||||
};
|
||||
const inputProps: InputProps<unknown> = {
|
||||
value,
|
||||
onChange,
|
||||
placeholder,
|
||||
// material-ui@4.5.1 introduce better types for TextInput, check readme
|
||||
// @ts-ignore
|
||||
startAdornment,
|
||||
disableUnderline,
|
||||
onKeyDown,
|
||||
onBlur,
|
||||
};
|
||||
|
||||
// this format avoid arrow function eslint rule
|
||||
function renderSuggestionsContainer({ containerProps, children, query }): JSX.Element {
|
||||
return (
|
||||
<SuggestionContainer {...containerProps} square={true}>
|
||||
{suggestionsLoaded && children === null && query && renderMessage(SUGGESTIONS_RESPONSE.NO_RESULT)}
|
||||
{suggestionsLoading && query && renderMessage(SUGGESTIONS_RESPONSE.LOADING)}
|
||||
{suggestionsError && renderMessage(SUGGESTIONS_RESPONSE.FAILURE)}
|
||||
{children}
|
||||
</SuggestionContainer>
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
// this format avoid arrow function eslint rule
|
||||
function renderSuggestionsContainer({ containerProps, children, query }): JSX.Element {
|
||||
return (
|
||||
<Wrapper>
|
||||
<Autosuggest
|
||||
{...autosuggestProps}
|
||||
inputProps={inputProps}
|
||||
onSuggestionSelected={onClick}
|
||||
renderSuggestionsContainer={renderSuggestionsContainer}
|
||||
/>
|
||||
</Wrapper>
|
||||
<SuggestionContainer {...containerProps} square={true}>
|
||||
{suggestionsLoaded && children === null && query && renderMessage(SUGGESTIONS_RESPONSE.NO_RESULT)}
|
||||
{suggestionsLoading && query && renderMessage(SUGGESTIONS_RESPONSE.LOADING)}
|
||||
{suggestionsError && renderMessage(SUGGESTIONS_RESPONSE.FAILURE)}
|
||||
{children}
|
||||
</SuggestionContainer>
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
return (
|
||||
<Wrapper>
|
||||
<Autosuggest {...autosuggestProps} inputProps={inputProps} onSuggestionSelected={onClick} renderSuggestionsContainer={renderSuggestionsContainer} />
|
||||
</Wrapper>
|
||||
);
|
||||
};
|
||||
|
||||
export default AutoComplete;
|
||||
|
||||
@@ -1,44 +1,61 @@
|
||||
import React from 'react';
|
||||
import styled from '@emotion/styled';
|
||||
import { css } from '@emotion/core';
|
||||
|
||||
import TextField from '../../muiComponents/TextField';
|
||||
import Paper from '../../muiComponents/Paper';
|
||||
import { Theme } from '../../design-tokens/theme';
|
||||
|
||||
export interface InputFieldProps {
|
||||
color: string;
|
||||
}
|
||||
|
||||
export const Wrapper = styled('div')({
|
||||
width: '100%',
|
||||
height: '32px',
|
||||
position: 'relative',
|
||||
zIndex: 1,
|
||||
'&&': {
|
||||
width: '100%',
|
||||
height: '32px',
|
||||
position: 'relative',
|
||||
zIndex: 1,
|
||||
},
|
||||
});
|
||||
|
||||
export const StyledTextField = styled(TextField)<{ theme?: Theme }>(props => ({
|
||||
'& .MuiInputBase-root': {
|
||||
':before': {
|
||||
content: "''",
|
||||
border: 'none',
|
||||
},
|
||||
':after': {
|
||||
borderColor: props.theme && props.theme.palette.white,
|
||||
},
|
||||
':hover:before': {
|
||||
content: 'none',
|
||||
},
|
||||
},
|
||||
'& .MuiInputBase-input': {
|
||||
color: props.theme && props.theme.palette.white,
|
||||
},
|
||||
}));
|
||||
|
||||
/* eslint-disable verdaccio/jsx-spread */
|
||||
// @ts-ignore types of color are incompatible
|
||||
export const InputField: React.FC<InputFieldProps> = ({ ...others }) => <StyledTextField {...others} />;
|
||||
export const InputField: React.FC<InputFieldProps> = ({ color, ...others }) => (
|
||||
<TextField
|
||||
{...others}
|
||||
classes={{
|
||||
// @ts-ignore
|
||||
input: css`
|
||||
&& {
|
||||
${color &&
|
||||
css`
|
||||
color: ${color};
|
||||
`};
|
||||
}
|
||||
`,
|
||||
root: css`
|
||||
&& {
|
||||
&:before {
|
||||
content: '';
|
||||
border: none;
|
||||
}
|
||||
&:after {
|
||||
${color &&
|
||||
css`
|
||||
border-color: ${color};
|
||||
`};
|
||||
}
|
||||
&:hover:before {
|
||||
content: none;
|
||||
}
|
||||
}
|
||||
`,
|
||||
}}
|
||||
/>
|
||||
);
|
||||
|
||||
export const SuggestionContainer = styled(Paper)({
|
||||
maxHeight: '500px',
|
||||
overflowY: 'auto',
|
||||
'&&': {
|
||||
maxHeight: '500px',
|
||||
overflowY: 'auto',
|
||||
},
|
||||
});
|
||||
|
||||
37
src/components/AvatarTooltip/AvatarTooltip.tsx
Normal file
37
src/components/AvatarTooltip/AvatarTooltip.tsx
Normal file
@@ -0,0 +1,37 @@
|
||||
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 };
|
||||
4
src/components/AvatarTooltip/index.ts
Normal file
4
src/components/AvatarTooltip/index.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
import { AvatarTooltip } from './AvatarTooltip';
|
||||
|
||||
export { AvatarTooltip };
|
||||
export default AvatarTooltip;
|
||||
@@ -1,8 +1,7 @@
|
||||
import React from 'react';
|
||||
import { ReactWrapper } from 'enzyme';
|
||||
import { mount, ReactWrapper } from 'enzyme';
|
||||
|
||||
import { copyToClipBoardUtility } from '../../utils/cli-utils';
|
||||
import { mount } from '../../utils/test-enzyme';
|
||||
|
||||
import CopyToClipBoard from './CopyToClipBoard';
|
||||
import { CopyIcon } from './styles';
|
||||
@@ -17,7 +16,7 @@ describe('<CopyToClipBoard /> component', () => {
|
||||
wrapper = mount(<CopyToClipBoard text={copyText} />);
|
||||
});
|
||||
|
||||
test('should load the component in default state', () => {
|
||||
test('render the component', () => {
|
||||
expect(wrapper.html()).toMatchSnapshot();
|
||||
});
|
||||
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`<CopyToClipBoard /> component should load the component in default state 1`] = `"<div class=\\"css-1in239f-ClipBoardCopy eb8w2fo0\\"><span class=\\"css-7gar9h-ClipBoardCopyText eb8w2fo1\\">copy text</span><button class=\\"MuiButtonBase-root MuiIconButton-root css-1fs86cq-CopyIcon eb8w2fo2\\" tabindex=\\"0\\" type=\\"button\\" title=\\"Copy to Clipboard\\"><span class=\\"MuiIconButton-label\\"><svg class=\\"MuiSvgIcon-root\\" focusable=\\"false\\" viewBox=\\"0 0 24 24\\" aria-hidden=\\"true\\" role=\\"presentation\\"><path d=\\"M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm-1 4l6 6v10c0 1.1-.9 2-2 2H7.99C6.89 23 6 22.1 6 21l.01-14c0-1.1.89-2 1.99-2h7zm-1 7h5.5L14 6.5V12z\\"></path></svg></span><span class=\\"MuiTouchRipple-root\\"></span></button></div>"`;
|
||||
exports[`<CopyToClipBoard /> component render the component 1`] = `"<div class=\\"css-1mta3t8 eb8w2fo0\\"><span class=\\"css-lh0wgu eb8w2fo1\\">copy text</span><button class=\\"MuiButtonBase-root MuiIconButton-root css-0 eb8w2fo2\\" tabindex=\\"0\\" type=\\"button\\" title=\\"Copy to Clipboard\\"><span class=\\"MuiIconButton-label\\"><svg class=\\"MuiSvgIcon-root\\" focusable=\\"false\\" viewBox=\\"0 0 24 24\\" aria-hidden=\\"true\\" role=\\"presentation\\"><path d=\\"M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm-1 4l6 6v10c0 1.1-.9 2-2 2H7.99C6.89 23 6 22.1 6 21l.01-14c0-1.1.89-2 1.99-2h7zm-1 7h5.5L14 6.5V12z\\"></path></svg></span><span class=\\"MuiTouchRipple-root\\"></span></button></div>"`;
|
||||
|
||||
@@ -3,18 +3,22 @@ import styled from '@emotion/styled';
|
||||
import IconButton from '../../muiComponents/IconButton';
|
||||
|
||||
export const ClipBoardCopy = styled('div')({
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
justifyContent: 'space-between',
|
||||
'&&': {
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
justifyContent: 'space-between',
|
||||
},
|
||||
});
|
||||
|
||||
export const ClipBoardCopyText = styled('span')({
|
||||
display: 'inline-block',
|
||||
textOverflow: 'ellipsis',
|
||||
overflow: 'hidden',
|
||||
whiteSpace: 'nowrap',
|
||||
height: '21px',
|
||||
fontSize: '1rem',
|
||||
'&&': {
|
||||
display: 'inline-block',
|
||||
textOverflow: 'ellipsis',
|
||||
overflow: 'hidden',
|
||||
whiteSpace: 'nowrap',
|
||||
height: '21px',
|
||||
fontSize: '1rem',
|
||||
},
|
||||
});
|
||||
|
||||
export const CopyIcon = styled(IconButton)({});
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import React from 'react';
|
||||
import { render } from '@testing-library/react';
|
||||
import { HashRouter } from 'react-router-dom';
|
||||
|
||||
import { DetailContextProvider } from '../../pages/Version';
|
||||
import { render } from '../../utils/test-react-testing-library';
|
||||
|
||||
import Dependencies from './Dependencies';
|
||||
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
import styled from '@emotion/styled';
|
||||
|
||||
import { fontWeight } from '../../utils/styles/sizes';
|
||||
import Text from '../../muiComponents/Text';
|
||||
import Card from '../../muiComponents/Card';
|
||||
import Chip from '../../muiComponents/Chip';
|
||||
import { Theme } from '../../design-tokens/theme';
|
||||
|
||||
export const CardWrap = styled(Card)({
|
||||
margin: '0 0 16px',
|
||||
});
|
||||
|
||||
export const StyledText = styled(Text)<{ theme?: Theme }>(props => ({
|
||||
fontWeight: props.theme && props.theme.fontWeight.bold,
|
||||
export const StyledText = styled(Text)({
|
||||
fontWeight: fontWeight.bold,
|
||||
textTransform: 'capitalize',
|
||||
}));
|
||||
});
|
||||
|
||||
export const Tags = styled('div')({
|
||||
display: 'flex',
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import React from 'react';
|
||||
|
||||
import { render } from '../../utils/test-react-testing-library';
|
||||
import { render } from '@testing-library/react';
|
||||
|
||||
import DetailContainer from './DetailContainer';
|
||||
|
||||
|
||||
@@ -6,7 +6,6 @@ import Box from '../../muiComponents/Box';
|
||||
import DetailContainerTabs from './DetailContainerTabs';
|
||||
import DetailContainerContent from './DetailContainerContent';
|
||||
import { TabPosition } from './tabs';
|
||||
import { DetailTheme } from './styles';
|
||||
|
||||
const DetailContainer: React.FC = () => {
|
||||
const [tabPosition, setTabPosition] = useState(TabPosition.README);
|
||||
@@ -24,12 +23,10 @@ const DetailContainer: React.FC = () => {
|
||||
);
|
||||
|
||||
return (
|
||||
<Box component="div" display="flex" flexDirection="column">
|
||||
<DetailContainerTabs onChangeTabPosition={handleChangeTabPosition} tabPosition={tabPosition} />
|
||||
<DetailTheme>
|
||||
<DetailContainerContent readDescription={readMe} tabPosition={tabPosition} />
|
||||
</DetailTheme>
|
||||
</Box>
|
||||
<Box component="div" display="flex" flexDirection="column" padding={2}>
|
||||
<DetailContainerTabs onChangeTabPosition={handleChangeTabPosition} tabPosition={tabPosition} />
|
||||
<DetailContainerContent readDescription={readMe} tabPosition={tabPosition} />
|
||||
</Box>
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
@@ -2,18 +2,15 @@ import React from 'react';
|
||||
|
||||
import { preventXSS } from '../../utils/sec-utils';
|
||||
import Readme from '../Readme';
|
||||
import { ReadmeSpacing } from './styles';
|
||||
|
||||
interface Props {
|
||||
description?: string;
|
||||
}
|
||||
|
||||
const DetailContainerContentReadme: React.FC<Props> = ({ description }) => {
|
||||
if (!description) {
|
||||
return null;
|
||||
}
|
||||
if (!description) return null;
|
||||
const encodedReadme = preventXSS(description);
|
||||
return <ReadmeSpacing><Readme description={encodedReadme} /></ReadmeSpacing>;
|
||||
return <Readme description={encodedReadme} />;
|
||||
};
|
||||
|
||||
export default DetailContainerContentReadme;
|
||||
|
||||
@@ -28,9 +28,9 @@ const DetailContainerTabs: React.FC<Props> = ({ tabPosition, onChangeTabPosition
|
||||
|
||||
return (
|
||||
<Tabs
|
||||
indicatorColor={'secondary'}
|
||||
indicatorColor={'primary'}
|
||||
onChange={onChangeTabPosition}
|
||||
textColor={'secondary'}
|
||||
textColor={'primary'}
|
||||
value={tabPositionIndex}
|
||||
variant={'fullWidth'}>
|
||||
<Tab data-testid={'readme-tab'} id={'readme-tab'} label={TabPosition.README} />
|
||||
|
||||
@@ -1,15 +1,11 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`DetailContainer renders correctly 1`] = `
|
||||
.emotion-0 {
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
<div
|
||||
class="MuiBox-root MuiBox-root-2"
|
||||
>
|
||||
<div
|
||||
class="MuiTabs-root emotion-0 emotion-1"
|
||||
class="MuiTabs-root css-1qm1lh emotion-0"
|
||||
>
|
||||
<div
|
||||
class="MuiTabs-scroller MuiTabs-fixed"
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
import styled from '@emotion/styled';
|
||||
|
||||
import { Theme } from '../../design-tokens/theme';
|
||||
|
||||
export const DetailTheme = styled('div')<{ theme?: Theme }>(props => ({
|
||||
backgroundColor: props?.theme?.palette.readmeBackgroundColor,
|
||||
}));
|
||||
|
||||
export const ReadmeSpacing = styled('div')<{ theme?: Theme }>(props => ({
|
||||
padding: '20px',
|
||||
}));
|
||||
@@ -1,52 +1,80 @@
|
||||
import React, { useContext } from 'react';
|
||||
import styled from '@emotion/styled';
|
||||
import React, { ReactElement } from 'react';
|
||||
|
||||
import { DetailContext } from '../../pages/Version';
|
||||
import Paper from '../../muiComponents/Paper';
|
||||
import ActionBar from '../ActionBar';
|
||||
import Repository from '../Repository';
|
||||
import Engines from '../Engines';
|
||||
import Dist from '../Dist';
|
||||
import Install from '../Install';
|
||||
import { ActionBar } from '../ActionBar/ActionBar';
|
||||
import Author from '../Author';
|
||||
import Developers, { DeveloperType } from '../Developers';
|
||||
import { Theme } from '../../design-tokens/theme';
|
||||
import Developers from '../Developers';
|
||||
import Dist from '../Dist/Dist';
|
||||
import Engine from '../Engines/Engines';
|
||||
import Install from '../Install';
|
||||
import Repository from '../Repository/Repository';
|
||||
import { DetailContext } from '../../pages/Version';
|
||||
import List from '../../muiComponents/List';
|
||||
import Card from '../../muiComponents/Card';
|
||||
import CardContent from '../../muiComponents/CardContent';
|
||||
|
||||
import DetailSidebarTitle from './DetailSidebarTitle';
|
||||
import DetailSidebarFundButton from './DetailSidebarFundButton';
|
||||
|
||||
const StyledPaper = styled(Paper)<{ theme?: Theme }>(({ theme }) => ({
|
||||
padding: theme.spacing(3, 2),
|
||||
}));
|
||||
|
||||
const DetailSidebar: React.FC = () => {
|
||||
const detailContext = useContext(DetailContext);
|
||||
|
||||
const { packageMeta, packageName, packageVersion } = detailContext;
|
||||
|
||||
if (!packageMeta || !packageName) {
|
||||
return null;
|
||||
}
|
||||
import { TitleListItem, TitleListItemText, PackageDescription, PackageVersion } from './styles';
|
||||
|
||||
const renderLatestDescription = (description, version, isLatest = true): JSX.Element => {
|
||||
return (
|
||||
<StyledPaper className={'sidebar-info'}>
|
||||
<DetailSidebarTitle
|
||||
description={packageMeta.latest?.description}
|
||||
isLatest={typeof packageVersion === 'undefined'}
|
||||
packageName={packageName}
|
||||
version={packageVersion || packageMeta.latest.version}
|
||||
/>
|
||||
<ActionBar />
|
||||
<Install />
|
||||
<DetailSidebarFundButton />
|
||||
<Repository />
|
||||
<Engines />
|
||||
<Dist />
|
||||
<Author />
|
||||
<Developers type={DeveloperType.MAINTAINERS} />
|
||||
<Developers type={DeveloperType.CONTRIBUTORS} />
|
||||
</StyledPaper>
|
||||
<>
|
||||
<PackageDescription>{description}</PackageDescription>
|
||||
{version ? (
|
||||
<PackageVersion>
|
||||
<small>{`${isLatest ? 'Latest v' : 'v'}${version}`}</small>
|
||||
</PackageVersion>
|
||||
) : null}
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
const renderCopyCLI = (): JSX.Element => <Install />;
|
||||
const renderMaintainers = (): JSX.Element => <Developers type="maintainers" />;
|
||||
const renderContributors = (): JSX.Element => <Developers type="contributors" />;
|
||||
const renderRepository = (): JSX.Element => <Repository />;
|
||||
const renderAuthor = (): JSX.Element => <Author />;
|
||||
const renderEngine = (): JSX.Element => <Engine />;
|
||||
const renderDist = (): JSX.Element => <Dist />;
|
||||
const renderActionBar = (): JSX.Element => <ActionBar />;
|
||||
const renderTitle = (packageName, packageVersion, packageMeta): JSX.Element => {
|
||||
const version = packageVersion ? packageVersion : packageMeta.latest.version;
|
||||
const isLatest = typeof packageVersion === 'undefined';
|
||||
|
||||
return (
|
||||
<List className="detail-info">
|
||||
<TitleListItem alignItems="flex-start" button={true}>
|
||||
<TitleListItemText
|
||||
primary={<b>{packageName}</b>}
|
||||
secondary={renderLatestDescription(packageMeta.latest.description, version, isLatest)}
|
||||
/>
|
||||
</TitleListItem>
|
||||
</List>
|
||||
);
|
||||
};
|
||||
|
||||
function renderSideBar(packageName, packageVersion, packageMeta): ReactElement<HTMLElement> {
|
||||
return (
|
||||
<div className={'sidebar-info'}>
|
||||
<Card>
|
||||
<CardContent>
|
||||
{renderTitle(packageName, packageVersion, packageMeta)}
|
||||
{renderActionBar()}
|
||||
{renderCopyCLI()}
|
||||
{renderRepository()}
|
||||
{renderEngine()}
|
||||
{renderDist()}
|
||||
{renderAuthor()}
|
||||
{renderMaintainers()}
|
||||
{renderContributors()}
|
||||
</CardContent>
|
||||
</Card>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
const DetailSidebar = (): JSX.Element => {
|
||||
const { packageName, packageMeta, packageVersion } = React.useContext(DetailContext);
|
||||
|
||||
return renderSideBar(packageName, packageVersion, packageMeta);
|
||||
};
|
||||
|
||||
export default DetailSidebar;
|
||||
|
||||
@@ -1,103 +0,0 @@
|
||||
import React from 'react';
|
||||
import _ from 'lodash';
|
||||
|
||||
import { render } from '../../utils/test-react-testing-library';
|
||||
import { DetailContext, DetailContextProps } from '../../pages/Version';
|
||||
|
||||
import DetailSidebarFundButton from './DetailSidebarFundButton';
|
||||
|
||||
const ComponentToBeRendered: React.FC<{ contextValue: DetailContextProps }> = ({ contextValue }) => (
|
||||
<DetailContext.Provider value={contextValue}>
|
||||
<DetailSidebarFundButton />
|
||||
</DetailContext.Provider>
|
||||
);
|
||||
|
||||
const detailContextValue: DetailContextProps = {
|
||||
packageName: 'foo',
|
||||
readMe: 'test',
|
||||
enableLoading: () => {},
|
||||
isLoading: false,
|
||||
hasNotBeenFound: false,
|
||||
packageMeta: {
|
||||
_uplinks: {},
|
||||
latest: {
|
||||
name: '@verdaccio/local-storage',
|
||||
version: '8.0.1-next.1',
|
||||
dist: { fileCount: 0, unpackedSize: 0, tarball: 'http://localhost:8080/bootstrap/-/bootstrap-4.3.1.tgz' },
|
||||
homepage: 'https://verdaccio.org',
|
||||
bugs: {
|
||||
url: 'https://github.com/verdaccio/monorepo/issues',
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
describe('test DetailSidebarFundButton', () => {
|
||||
test('should not display the button if fund is missing', () => {
|
||||
const wrapper = render(<ComponentToBeRendered contextValue={detailContextValue} />);
|
||||
|
||||
expect(wrapper.queryByText('Fund')).toBeNull();
|
||||
});
|
||||
|
||||
test('should not display the button if url is missing', () => {
|
||||
const value = _.merge(detailContextValue, {
|
||||
packageMeta: {
|
||||
latest: {
|
||||
funding: {},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const wrapper = render(<ComponentToBeRendered contextValue={value} />);
|
||||
|
||||
expect(wrapper.queryByText('Fund')).toBeNull();
|
||||
});
|
||||
|
||||
test('should not display the button if url is not a string', () => {
|
||||
const value = _.merge(detailContextValue, {
|
||||
packageMeta: {
|
||||
latest: {
|
||||
funding: {
|
||||
url: null,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const wrapper = render(<ComponentToBeRendered contextValue={value} />);
|
||||
|
||||
expect(wrapper.queryByText('Fund')).toBeNull();
|
||||
});
|
||||
|
||||
test('should not display the button if url is not an url', () => {
|
||||
const value = _.merge(detailContextValue, {
|
||||
packageMeta: {
|
||||
latest: {
|
||||
funding: {
|
||||
url: 'somethign different as url',
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const wrapper = render(<ComponentToBeRendered contextValue={value} />);
|
||||
|
||||
expect(wrapper.queryByText('Fund')).toBeNull();
|
||||
});
|
||||
|
||||
test('should display the button if url is a valid url', () => {
|
||||
const value = _.merge(detailContextValue, {
|
||||
packageMeta: {
|
||||
latest: {
|
||||
funding: {
|
||||
url: 'https://opencollective.com/verdaccio',
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const wrapper = render(<ComponentToBeRendered contextValue={value} />);
|
||||
|
||||
expect(wrapper.getByText('Fund')).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@@ -1,48 +0,0 @@
|
||||
import React, { useContext } from 'react';
|
||||
import styled from '@emotion/styled';
|
||||
import Favorite from '@material-ui/icons/Favorite';
|
||||
|
||||
import Button from '../../muiComponents/Button';
|
||||
import Link from '../Link';
|
||||
import { isURL } from '../../utils/url';
|
||||
import { Theme } from '../../design-tokens/theme';
|
||||
import { DetailContext } from '../../pages/Version';
|
||||
|
||||
const StyledLink = styled(Link)<{ theme?: Theme }>(({ theme }) => ({
|
||||
marginTop: theme && theme.spacing(1),
|
||||
marginBottom: theme && theme.spacing(1),
|
||||
textDecoration: 'none',
|
||||
display: 'block',
|
||||
}));
|
||||
|
||||
const StyledFavoriteIcon = styled(Favorite)<{ theme?: Theme }>(({ theme }) => ({
|
||||
color: theme && theme.palette.orange,
|
||||
}));
|
||||
|
||||
const StyledFundStrong = styled('strong')({
|
||||
marginRight: 3,
|
||||
});
|
||||
|
||||
/* eslint-disable react/jsx-no-bind */
|
||||
const DetailSidebarFundButton: React.FC = () => {
|
||||
const detailContext = useContext(DetailContext);
|
||||
|
||||
const { packageMeta } = detailContext;
|
||||
|
||||
const fundingUrl = packageMeta?.latest?.funding?.url as string;
|
||||
|
||||
if (!isURL(fundingUrl)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<StyledLink external={true} to={fundingUrl}>
|
||||
<Button color="primary" fullWidth={true} startIcon={<StyledFavoriteIcon />} variant="outlined">
|
||||
<StyledFundStrong>{'Fund'}</StyledFundStrong>
|
||||
{'this package'}
|
||||
</Button>
|
||||
</StyledLink>
|
||||
);
|
||||
};
|
||||
|
||||
export default DetailSidebarFundButton;
|
||||
@@ -1,32 +0,0 @@
|
||||
import React from 'react';
|
||||
import styled from '@emotion/styled';
|
||||
|
||||
import Box from '../../muiComponents/Box';
|
||||
import Heading from '../../muiComponents/Heading';
|
||||
import { Theme } from '../../design-tokens/theme';
|
||||
|
||||
interface Props {
|
||||
packageName: string;
|
||||
description?: string;
|
||||
version: string;
|
||||
isLatest: boolean;
|
||||
}
|
||||
|
||||
const StyledHeading = styled(Heading)({
|
||||
fontSize: '1rem',
|
||||
fontWeight: 700,
|
||||
});
|
||||
|
||||
const StyledBoxVersion = styled(Box)<{ theme?: Theme }>(({ theme }) => ({
|
||||
color: theme && theme.palette.text.secondary,
|
||||
}));
|
||||
|
||||
const DetailSidebarTitle: React.FC<Props> = ({ description, packageName, version, isLatest }) => (
|
||||
<Box className={'detail-info'} display="flex" flexDirection="column" marginBottom="8px">
|
||||
<StyledHeading>{packageName}</StyledHeading>
|
||||
{description && <div>{description}</div>}
|
||||
<StyledBoxVersion>{`${isLatest ? 'Latest v' : 'v'}${version}`}</StyledBoxVersion>
|
||||
</Box>
|
||||
);
|
||||
|
||||
export default DetailSidebarTitle;
|
||||
24
src/components/DetailSidebar/styles.ts
Normal file
24
src/components/DetailSidebar/styles.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import styled from '@emotion/styled';
|
||||
|
||||
import ListItem from '../../muiComponents/ListItem';
|
||||
import ListItemText from '../../muiComponents/ListItemText';
|
||||
|
||||
export const TitleListItem = styled(ListItem)({
|
||||
paddingLeft: 0,
|
||||
paddingRight: 0,
|
||||
paddingBottom: 0,
|
||||
});
|
||||
|
||||
export const TitleListItemText = styled(ListItemText)({
|
||||
paddingLeft: 0,
|
||||
paddingRight: 0,
|
||||
paddingTop: '8px',
|
||||
});
|
||||
|
||||
export const PackageDescription = styled('span')({
|
||||
display: 'block',
|
||||
});
|
||||
|
||||
export const PackageVersion = styled('span')({
|
||||
display: 'block',
|
||||
});
|
||||
@@ -1,9 +1,10 @@
|
||||
import React from 'react';
|
||||
import { mount } from 'enzyme';
|
||||
|
||||
import { mount } from '../../utils/test-enzyme';
|
||||
import { DetailContextProvider } from '../../pages/Version';
|
||||
|
||||
import Developers, { DeveloperType, Fab } from './Developers';
|
||||
import Developers, { DevelopersType } from './Developers';
|
||||
import { Fab } from './styles';
|
||||
|
||||
describe('test Developers', () => {
|
||||
const packageMeta = {
|
||||
@@ -34,13 +35,14 @@ describe('test Developers', () => {
|
||||
};
|
||||
|
||||
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={DeveloperType.MAINTAINERS} />
|
||||
<Developers type={type} />
|
||||
</DetailContextProvider>
|
||||
);
|
||||
|
||||
@@ -48,10 +50,11 @@ describe('test Developers', () => {
|
||||
});
|
||||
|
||||
test('should render the component for maintainers with items', () => {
|
||||
const type: DevelopersType = 'maintainers';
|
||||
const wrapper = mount(
|
||||
// @ts-ignore
|
||||
<DetailContextProvider value={{ packageMeta }}>
|
||||
<Developers type={DeveloperType.MAINTAINERS} />
|
||||
<Developers type={type} />
|
||||
</DetailContextProvider>
|
||||
);
|
||||
|
||||
@@ -59,10 +62,11 @@ describe('test Developers', () => {
|
||||
});
|
||||
|
||||
test('should render the component for contributors with items', () => {
|
||||
const type: DevelopersType = 'contributors';
|
||||
const wrapper = mount(
|
||||
// @ts-ignore
|
||||
<DetailContextProvider value={{ packageMeta }}>
|
||||
<Developers type={DeveloperType.CONTRIBUTORS} />
|
||||
<Developers type={type} />
|
||||
</DetailContextProvider>
|
||||
);
|
||||
|
||||
@@ -70,6 +74,7 @@ describe('test Developers', () => {
|
||||
});
|
||||
|
||||
test('should test onClick the component avatar', () => {
|
||||
const type: DevelopersType = 'contributors';
|
||||
const packageMeta = {
|
||||
latest: {
|
||||
packageName: 'foo',
|
||||
@@ -90,7 +95,7 @@ describe('test Developers', () => {
|
||||
const wrapper = mount(
|
||||
// @ts-ignore
|
||||
<DetailContextProvider value={{ packageMeta }}>
|
||||
<Developers type={DeveloperType.CONTRIBUTORS} visibleMax={1} />
|
||||
<Developers type={type} visibleMax={1} />
|
||||
</DetailContextProvider>
|
||||
);
|
||||
|
||||
|
||||
@@ -1,89 +1,60 @@
|
||||
import React, { useState, useCallback, useContext, useEffect, useMemo } from 'react';
|
||||
import React, { FC, Fragment } from 'react';
|
||||
import Add from '@material-ui/icons/Add';
|
||||
import styled from '@emotion/styled';
|
||||
|
||||
import { DetailContext } from '../../pages/Version';
|
||||
import Tooltip from '../../muiComponents/Tooltip';
|
||||
import Avatar from '../../muiComponents/Avatar';
|
||||
import Box from '../../muiComponents/Box';
|
||||
import Text from '../../muiComponents/Text';
|
||||
import FloatingActionButton from '../../muiComponents/FloatingActionButton';
|
||||
import { Theme } from '../../design-tokens/theme';
|
||||
import { AvatarTooltip } from '../AvatarTooltip';
|
||||
|
||||
import getUniqueDeveloperValues from './get-unique-developer-values';
|
||||
import { Details, StyledText, Content, Fab } from './styles';
|
||||
|
||||
export const Fab = styled(FloatingActionButton)<{ theme?: Theme }>(props => ({
|
||||
backgroundColor: props.theme && props.theme.palette.primary.main,
|
||||
color: props.theme && props.theme.palette.white,
|
||||
}));
|
||||
|
||||
export enum DeveloperType {
|
||||
CONTRIBUTORS = 'contributors',
|
||||
MAINTAINERS = 'maintainers',
|
||||
}
|
||||
export type DevelopersType = 'contributors' | 'maintainers';
|
||||
|
||||
interface Props {
|
||||
type: DeveloperType;
|
||||
type: DevelopersType;
|
||||
visibleMax?: number;
|
||||
}
|
||||
|
||||
export const StyledText = styled(Text)<{ theme?: Theme }>(({ theme }) => ({
|
||||
fontWeight: theme && theme.fontWeight.bold,
|
||||
marginBottom: '10px',
|
||||
textTransform: 'capitalize',
|
||||
}));
|
||||
|
||||
const StyledBox = styled(Box)({
|
||||
'> *': {
|
||||
margin: 5,
|
||||
},
|
||||
});
|
||||
|
||||
export const VISIBLE_MAX = 6;
|
||||
|
||||
const Developers: React.FC<Props> = ({ type, visibleMax = VISIBLE_MAX }) => {
|
||||
const detailContext = useContext(DetailContext);
|
||||
const Developers: FC<Props> = ({ type, visibleMax }) => {
|
||||
const [visibleDevs, setVisibleDevs] = React.useState<number>(visibleMax || VISIBLE_MAX);
|
||||
const { packageMeta } = React.useContext(DetailContext);
|
||||
|
||||
if (!detailContext) {
|
||||
throw Error("The app's detail Context was not correct used");
|
||||
const handleLoadMore = (): void => {
|
||||
setVisibleDevs(visibleDevs + VISIBLE_MAX);
|
||||
};
|
||||
|
||||
const renderDeveloperDetails = ({ name, avatar, email }, packageMeta): JSX.Element => {
|
||||
const { name: packageName, version } = packageMeta.latest;
|
||||
|
||||
return <AvatarTooltip avatar={avatar} email={email} name={name} packageName={packageName} version={version} />;
|
||||
};
|
||||
|
||||
const renderDevelopers = (developers, packageMeta): JSX.Element => {
|
||||
const listVisibleDevelopers = developers.slice(0, visibleDevs);
|
||||
|
||||
return (
|
||||
<Fragment>
|
||||
<StyledText variant={'subtitle1'}>{type}</StyledText>
|
||||
<Content>
|
||||
{listVisibleDevelopers.map(developer => (
|
||||
<Details key={developer.email}>{renderDeveloperDetails(developer, packageMeta)}</Details>
|
||||
))}
|
||||
{visibleDevs < developers.length && (
|
||||
<Fab onClick={handleLoadMore} size="small">
|
||||
<Add />
|
||||
</Fab>
|
||||
)}
|
||||
</Content>
|
||||
</Fragment>
|
||||
);
|
||||
};
|
||||
|
||||
const developerList = packageMeta && packageMeta.latest[type];
|
||||
if (!developerList || developerList.length === 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const developers = useMemo(() => getUniqueDeveloperValues(detailContext.packageMeta?.latest[type]), [
|
||||
detailContext.packageMeta,
|
||||
type,
|
||||
]);
|
||||
|
||||
const [visibleDevelopersMax, setVisibleDevelopersMax] = useState(visibleMax);
|
||||
const [visibleDevelopers, setVisibleDevelopers] = useState(developers);
|
||||
|
||||
useEffect(() => {
|
||||
if (!developers) return;
|
||||
setVisibleDevelopers(developers.slice(0, visibleDevelopersMax));
|
||||
}, [developers, visibleDevelopersMax]);
|
||||
|
||||
const handleSetVisibleDevelopersMax = useCallback(() => {
|
||||
setVisibleDevelopersMax(visibleDevelopersMax + VISIBLE_MAX);
|
||||
}, [visibleDevelopersMax]);
|
||||
|
||||
if (!visibleDevelopers || !developers) return null;
|
||||
|
||||
return (
|
||||
<>
|
||||
<StyledText variant={'subtitle1'}>{type}</StyledText>
|
||||
<StyledBox display="flex" flexWrap="wrap" margin="10px 0 10px 0">
|
||||
{visibleDevelopers.map(visibleDeveloper => (
|
||||
<Tooltip key={visibleDeveloper.email} title={visibleDeveloper.name}>
|
||||
<Avatar alt={visibleDeveloper.name} src={visibleDeveloper.avatar} />
|
||||
</Tooltip>
|
||||
))}
|
||||
{visibleDevelopersMax < developers.length && (
|
||||
<Fab onClick={handleSetVisibleDevelopersMax} size="small">
|
||||
<Add />
|
||||
</Fab>
|
||||
)}
|
||||
</StyledBox>
|
||||
</>
|
||||
);
|
||||
return renderDevelopers(developerList, packageMeta);
|
||||
};
|
||||
|
||||
export default Developers;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,12 +0,0 @@
|
||||
import { Developer } from '../../../types/packageMeta';
|
||||
|
||||
function getUniqueDeveloperValues(developers?: Array<Developer>): undefined | Array<Developer> {
|
||||
if (!developers) return;
|
||||
return developers.reduce(
|
||||
(accumulator: Array<Developer>, current: Developer) =>
|
||||
accumulator.some(developer => developer.email === current.email) ? accumulator : [...accumulator, current],
|
||||
[]
|
||||
);
|
||||
}
|
||||
|
||||
export default getUniqueDeveloperValues;
|
||||
@@ -1 +1 @@
|
||||
export { default, DeveloperType } from './Developers';
|
||||
export { default } from './Developers';
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import styled from '@emotion/styled';
|
||||
|
||||
import colors from '../../utils/styles/colors';
|
||||
import { fontWeight } from '../../utils/styles/sizes';
|
||||
import Text from '../../muiComponents/Text';
|
||||
import FloatingActionButton from '../../muiComponents/FloatingActionButton';
|
||||
import { Theme } from '../../design-tokens/theme';
|
||||
|
||||
export const Details = styled('span')({
|
||||
display: 'flex',
|
||||
@@ -19,13 +20,13 @@ export const Content = styled('div')({
|
||||
},
|
||||
});
|
||||
|
||||
export const StyledText = styled(Text)<{ theme?: Theme }>(props => ({
|
||||
fontWeight: props.theme && props.theme.fontWeight.bold,
|
||||
export const StyledText = styled(Text)({
|
||||
fontWeight: fontWeight.bold,
|
||||
marginBottom: '10px',
|
||||
textTransform: 'capitalize',
|
||||
}));
|
||||
});
|
||||
|
||||
export const Fab = styled(FloatingActionButton)<{ theme?: Theme }>(props => ({
|
||||
backgroundColor: props.theme && props.theme.palette.primary.main,
|
||||
color: props.theme && props.theme.palette.white,
|
||||
}));
|
||||
export const Fab = styled(FloatingActionButton)({
|
||||
backgroundColor: colors.primary,
|
||||
color: colors.white,
|
||||
});
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import React from 'react';
|
||||
import { mount } from 'enzyme';
|
||||
|
||||
import { mount } from '../../utils/test-enzyme';
|
||||
import { DetailContext } from '../../pages/Version';
|
||||
|
||||
import Dist from './Dist';
|
||||
|
||||
@@ -10,6 +10,8 @@ import { StyledText, DistListItem, DistChips } from './styles';
|
||||
const DistChip: FC<{ name: string }> = ({ name, children }) =>
|
||||
children ? (
|
||||
<DistChips
|
||||
// lint rule conflicting with prettier
|
||||
/* eslint-disable react/jsx-wrap-multilines */
|
||||
label={
|
||||
<>
|
||||
<b>{name}</b>
|
||||
@@ -17,6 +19,7 @@ const DistChip: FC<{ name: string }> = ({ name, children }) =>
|
||||
{children}
|
||||
</>
|
||||
}
|
||||
/* eslint-enable */
|
||||
/>
|
||||
) : null;
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`<Dist /> component should render the component in default state 1`] = `"<ul class=\\"MuiList-root MuiList-padding MuiList-subheader\\"><h6 class=\\"MuiTypography-root css-1na337r-StyledText estxrtg0 MuiTypography-subtitle1\\">Latest Distribution</h6><div class=\\"MuiButtonBase-root MuiListItem-root css-1mms18p-DistListItem estxrtg1 MuiListItem-gutters MuiListItem-button\\" tabindex=\\"0\\" role=\\"button\\" aria-disabled=\\"false\\"><div class=\\"MuiChip-root css-e2le7v-DistChips estxrtg2\\"><span class=\\"MuiChip-label\\"><b>file count</b>: 7</span></div><div class=\\"MuiChip-root css-e2le7v-DistChips estxrtg2\\"><span class=\\"MuiChip-label\\"><b>size</b>: 10.00 Bytes</span></div><span class=\\"MuiTouchRipple-root\\"></span></div></ul>"`;
|
||||
exports[`<Dist /> component should render the component in default state 1`] = `"<ul class=\\"MuiList-root MuiList-padding MuiList-subheader\\"><h6 class=\\"MuiTypography-root css-b8upko estxrtg0 MuiTypography-subtitle1\\">Latest Distribution</h6><div class=\\"MuiButtonBase-root MuiListItem-root css-1huthg8 estxrtg1 MuiListItem-gutters MuiListItem-button\\" tabindex=\\"0\\" role=\\"button\\" aria-disabled=\\"false\\"><div class=\\"MuiChip-root css-42zb18 estxrtg2\\"><span class=\\"MuiChip-label\\"><b>file count</b>: 7</span></div><div class=\\"MuiChip-root css-42zb18 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-1na337r-StyledText estxrtg0 MuiTypography-subtitle1\\">Latest Distribution</h6><div class=\\"MuiButtonBase-root MuiListItem-root css-1mms18p-DistListItem estxrtg1 MuiListItem-gutters MuiListItem-button\\" tabindex=\\"0\\" role=\\"button\\" aria-disabled=\\"false\\"><div class=\\"MuiChip-root css-e2le7v-DistChips estxrtg2\\"><span class=\\"MuiChip-label\\"><b>file count</b>: 7</span></div><div class=\\"MuiChip-root css-e2le7v-DistChips estxrtg2\\"><span class=\\"MuiChip-label\\"><b>size</b>: 10.00 Bytes</span></div><div class=\\"MuiChip-root css-e2le7v-DistChips estxrtg2\\"><span class=\\"MuiChip-label\\"><b>license</b>: MIT</span></div><span class=\\"MuiTouchRipple-root\\"></span></div></ul>"`;
|
||||
exports[`<Dist /> component should render the component with license as object 1`] = `"<ul class=\\"MuiList-root MuiList-padding MuiList-subheader\\"><h6 class=\\"MuiTypography-root css-b8upko estxrtg0 MuiTypography-subtitle1\\">Latest Distribution</h6><div class=\\"MuiButtonBase-root MuiListItem-root css-1huthg8 estxrtg1 MuiListItem-gutters MuiListItem-button\\" tabindex=\\"0\\" role=\\"button\\" aria-disabled=\\"false\\"><div class=\\"MuiChip-root css-42zb18 estxrtg2\\"><span class=\\"MuiChip-label\\"><b>file count</b>: 7</span></div><div class=\\"MuiChip-root css-42zb18 estxrtg2\\"><span class=\\"MuiChip-label\\"><b>size</b>: 10.00 Bytes</span></div><div class=\\"MuiChip-root css-42zb18 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-1na337r-StyledText estxrtg0 MuiTypography-subtitle1\\">Latest Distribution</h6><div class=\\"MuiButtonBase-root MuiListItem-root css-1mms18p-DistListItem estxrtg1 MuiListItem-gutters MuiListItem-button\\" tabindex=\\"0\\" role=\\"button\\" aria-disabled=\\"false\\"><div class=\\"MuiChip-root css-e2le7v-DistChips estxrtg2\\"><span class=\\"MuiChip-label\\"><b>file count</b>: 7</span></div><div class=\\"MuiChip-root css-e2le7v-DistChips estxrtg2\\"><span class=\\"MuiChip-label\\"><b>size</b>: 10.00 Bytes</span></div><div class=\\"MuiChip-root css-e2le7v-DistChips 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-1huthg8 estxrtg1 MuiListItem-gutters MuiListItem-button\\" tabindex=\\"0\\" role=\\"button\\" aria-disabled=\\"false\\"><div class=\\"MuiChip-root css-42zb18 estxrtg2\\"><span class=\\"MuiChip-label\\"><b>file count</b>: 7</span></div><div class=\\"MuiChip-root css-42zb18 estxrtg2\\"><span class=\\"MuiChip-label\\"><b>size</b>: 10.00 Bytes</span></div><div class=\\"MuiChip-root css-42zb18 estxrtg2\\"><span class=\\"MuiChip-label\\"><b>license</b>: MIT</span></div><span class=\\"MuiTouchRipple-root\\"></span></div></ul>"`;
|
||||
|
||||
@@ -1,15 +1,16 @@
|
||||
import styled from '@emotion/styled';
|
||||
|
||||
import colors from '../../utils/styles/colors';
|
||||
import { fontWeight } from '../../utils/styles/sizes';
|
||||
import ListItem from '../../muiComponents/ListItem';
|
||||
import Text from '../../muiComponents/Text';
|
||||
import FloatingActionButton from '../../muiComponents/FloatingActionButton';
|
||||
import Chip from '../../muiComponents/Chip';
|
||||
import { Theme } from '../../design-tokens/theme';
|
||||
|
||||
export const StyledText = styled(Text)<{ theme?: Theme }>(props => ({
|
||||
fontWeight: props.theme && props.theme.fontWeight.bold,
|
||||
export const StyledText = styled(Text)({
|
||||
fontWeight: fontWeight.bold,
|
||||
textTransform: 'capitalize',
|
||||
}));
|
||||
});
|
||||
|
||||
export const DistListItem = styled(ListItem)({
|
||||
paddingLeft: 0,
|
||||
@@ -17,11 +18,11 @@ export const DistListItem = styled(ListItem)({
|
||||
});
|
||||
|
||||
export const DistChips = styled(Chip)({
|
||||
marginRight: 5,
|
||||
marginRight: '5px',
|
||||
textTransform: 'capitalize',
|
||||
});
|
||||
|
||||
export const DownloadButton = styled(FloatingActionButton)<{ theme?: Theme }>(props => ({
|
||||
backgroundColor: props.theme && props.theme.palette.primary.main,
|
||||
color: props.theme && props.theme.palette.white,
|
||||
}));
|
||||
export const DownloadButton = styled(FloatingActionButton)({
|
||||
backgroundColor: colors.primary,
|
||||
color: colors.white,
|
||||
});
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import React from 'react';
|
||||
import { mount } from 'enzyme';
|
||||
|
||||
import { mount } from '../../utils/test-enzyme';
|
||||
import { DetailContext } from '../../pages/Version';
|
||||
import { PackageMetaInterface } from '../../../types/packageMeta';
|
||||
|
||||
|
||||
@@ -13,12 +13,13 @@ import node from './img/node.png';
|
||||
const Engine: React.FC = () => {
|
||||
const { packageMeta } = useContext(DetailContext);
|
||||
|
||||
const engines = packageMeta?.latest?.engines;
|
||||
const engines = packageMeta && packageMeta.latest && packageMeta.latest.engines;
|
||||
|
||||
if (!engines || (!engines.node && !engines.npm)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/* eslint-disable react/jsx-max-depth */
|
||||
return (
|
||||
<Grid container={true}>
|
||||
{engines.node && (
|
||||
@@ -44,6 +45,7 @@ const Engine: React.FC = () => {
|
||||
)}
|
||||
</Grid>
|
||||
);
|
||||
/* eslint-enable react/jsx-max-depth */
|
||||
};
|
||||
|
||||
export default Engine;
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`<Engines /> component should render the component in default state 1`] = `"<div class=\\"MuiGrid-root MuiGrid-container\\"><div class=\\"MuiGrid-root MuiGrid-item MuiGrid-grid-xs-6\\"><ul class=\\"MuiList-root MuiList-padding MuiList-subheader\\"><h6 class=\\"MuiTypography-root css-1na337r-StyledText et66bt70 MuiTypography-subtitle1\\">node JS</h6><div class=\\"MuiButtonBase-root MuiListItem-root css-18b06t0-EngineListItem et66bt71 MuiListItem-gutters MuiListItem-button\\" tabindex=\\"0\\" role=\\"button\\" aria-disabled=\\"false\\"><div class=\\"MuiAvatar-root MuiAvatar-circle MuiAvatar-colorDefault\\"><svg class=\\"MuiSvgIcon-root MuiAvatar-fallback\\" focusable=\\"false\\" viewBox=\\"0 0 24 24\\" aria-hidden=\\"true\\" role=\\"presentation\\"><path d=\\"M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4z\\"></path></svg></div><div class=\\"MuiListItemText-root\\"><span class=\\"MuiTypography-root MuiListItemText-primary MuiTypography-body1\\">>= 0.1.98</span></div><span class=\\"MuiTouchRipple-root\\"></span></div></ul></div><div class=\\"MuiGrid-root MuiGrid-item MuiGrid-grid-xs-6\\"><ul class=\\"MuiList-root MuiList-padding MuiList-subheader\\"><h6 class=\\"MuiTypography-root css-1na337r-StyledText et66bt70 MuiTypography-subtitle1\\">NPM version</h6><div class=\\"MuiButtonBase-root MuiListItem-root css-18b06t0-EngineListItem et66bt71 MuiListItem-gutters MuiListItem-button\\" tabindex=\\"0\\" role=\\"button\\" aria-disabled=\\"false\\"><div class=\\"MuiAvatar-root MuiAvatar-circle MuiAvatar-colorDefault\\"><svg class=\\"MuiSvgIcon-root MuiAvatar-fallback\\" focusable=\\"false\\" viewBox=\\"0 0 24 24\\" aria-hidden=\\"true\\" role=\\"presentation\\"><path d=\\"M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4z\\"></path></svg></div><div class=\\"MuiListItemText-root\\"><span class=\\"MuiTypography-root MuiListItemText-primary MuiTypography-body1\\">>3</span></div><span class=\\"MuiTouchRipple-root\\"></span></div></ul></div></div>"`;
|
||||
exports[`<Engines /> component should render the component in default state 1`] = `"<div class=\\"MuiGrid-root MuiGrid-container\\"><div class=\\"MuiGrid-root MuiGrid-item MuiGrid-grid-xs-6\\"><ul class=\\"MuiList-root MuiList-padding MuiList-subheader\\"><h6 class=\\"MuiTypography-root css-b8upko et66bt70 MuiTypography-subtitle1\\">node JS</h6><div class=\\"MuiButtonBase-root MuiListItem-root css-131yq1t et66bt71 MuiListItem-gutters MuiListItem-button\\" tabindex=\\"0\\" role=\\"button\\" aria-disabled=\\"false\\"><div class=\\"MuiAvatar-root MuiAvatar-circle MuiAvatar-colorDefault\\"></div><div class=\\"MuiListItemText-root\\"><span class=\\"MuiTypography-root MuiListItemText-primary MuiTypography-body1\\">>= 0.1.98</span></div><span class=\\"MuiTouchRipple-root\\"></span></div></ul></div><div class=\\"MuiGrid-root MuiGrid-item MuiGrid-grid-xs-6\\"><ul class=\\"MuiList-root MuiList-padding MuiList-subheader\\"><h6 class=\\"MuiTypography-root css-b8upko et66bt70 MuiTypography-subtitle1\\">NPM version</h6><div class=\\"MuiButtonBase-root MuiListItem-root css-131yq1t et66bt71 MuiListItem-gutters MuiListItem-button\\" tabindex=\\"0\\" role=\\"button\\" aria-disabled=\\"false\\"><div class=\\"MuiAvatar-root MuiAvatar-circle MuiAvatar-colorDefault\\"></div><div class=\\"MuiListItemText-root\\"><span class=\\"MuiTypography-root MuiListItemText-primary MuiTypography-body1\\">>3</span></div><span class=\\"MuiTouchRipple-root\\"></span></div></ul></div></div>"`;
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import styled from '@emotion/styled';
|
||||
|
||||
import { fontWeight } from '../../utils/styles/sizes';
|
||||
import ListItem from '../../muiComponents/ListItem';
|
||||
import Text from '../../muiComponents/Text';
|
||||
import { Theme } from '../../design-tokens/theme';
|
||||
|
||||
export const StyledText = styled(Text)<{ theme?: Theme }>(props => ({
|
||||
fontWeight: props.theme && props.theme.fontWeight.bold,
|
||||
export const StyledText = styled(Text)({
|
||||
fontWeight: fontWeight.bold,
|
||||
textTransform: 'capitalize',
|
||||
}));
|
||||
});
|
||||
|
||||
export const EngineListItem = styled(ListItem)({
|
||||
paddingLeft: 0,
|
||||
|
||||
@@ -1,20 +1,21 @@
|
||||
import React from 'react';
|
||||
|
||||
import { render } from '../../utils/test-react-testing-library';
|
||||
import { mount, ReactWrapper } from 'enzyme';
|
||||
|
||||
import Footer from './Footer';
|
||||
|
||||
describe('<Footer /> component', () => {
|
||||
beforeAll(() => {
|
||||
window.VERDACCIO_VERSION = 'v.1.0.0';
|
||||
});
|
||||
jest.mock('../../../package.json', () => ({
|
||||
version: '4.0.0-alpha.3',
|
||||
}));
|
||||
|
||||
afterAll(() => {
|
||||
describe('<Footer /> component', () => {
|
||||
let wrapper: ReactWrapper;
|
||||
beforeEach(() => {
|
||||
window.VERDACCIO_VERSION = 'v.1.0.0';
|
||||
wrapper = mount(<Footer />);
|
||||
delete window.VERDACCIO_VERSION;
|
||||
});
|
||||
|
||||
test('should load the initial state of Footer component', () => {
|
||||
const { container } = render(<Footer />);
|
||||
expect(container.firstChild).toMatchSnapshot();
|
||||
expect(wrapper.html()).toMatchSnapshot();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,274 +1,3 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`<Footer /> component should load the initial state of Footer component 1`] = `
|
||||
.emotion-38 {
|
||||
background: #f9f9f9;
|
||||
border-top: 1px solid #e3e3e3;
|
||||
color: #999999;
|
||||
font-size: 14px;
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.emotion-36 {
|
||||
display: -webkit-box;
|
||||
display: -webkit-flex;
|
||||
display: -ms-flexbox;
|
||||
display: flex;
|
||||
-webkit-align-items: center;
|
||||
-webkit-box-align: center;
|
||||
-ms-flex-align: center;
|
||||
align-items: center;
|
||||
-webkit-box-pack: end;
|
||||
-webkit-justify-content: flex-end;
|
||||
-ms-flex-pack: end;
|
||||
justify-content: flex-end;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
@media (min-width:768px) {
|
||||
.emotion-36 {
|
||||
min-width: 400px;
|
||||
max-width: 800px;
|
||||
margin: auto;
|
||||
-webkit-box-pack: justify;
|
||||
-webkit-justify-content: space-between;
|
||||
-ms-flex-pack: justify;
|
||||
justify-content: space-between;
|
||||
}
|
||||
}
|
||||
|
||||
@media (min-width:1024px) {
|
||||
.emotion-36 {
|
||||
max-width: 1240px;
|
||||
}
|
||||
}
|
||||
|
||||
.emotion-27 {
|
||||
-webkit-align-items: center;
|
||||
-webkit-box-align: center;
|
||||
-ms-flex-align: center;
|
||||
align-items: center;
|
||||
display: none;
|
||||
}
|
||||
|
||||
@media (min-width:768px) {
|
||||
.emotion-27 {
|
||||
display: -webkit-box;
|
||||
display: -webkit-flex;
|
||||
display: -ms-flexbox;
|
||||
display: flex;
|
||||
}
|
||||
}
|
||||
|
||||
.emotion-0 {
|
||||
color: #e25555;
|
||||
padding: 0 5px;
|
||||
}
|
||||
|
||||
.emotion-25 {
|
||||
position: relative;
|
||||
height: 18px;
|
||||
}
|
||||
|
||||
.emotion-25:hover .emotion-24 {
|
||||
visibility: visible;
|
||||
}
|
||||
|
||||
.emotion-3 {
|
||||
box-sizing: initial;
|
||||
display: inline-block;
|
||||
cursor: default;
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
padding: 0 10px;
|
||||
}
|
||||
|
||||
.emotion-23 {
|
||||
position: absolute;
|
||||
background: #d3dddd;
|
||||
padding: 1px 4px;
|
||||
border-radius: 3px;
|
||||
height: 20px;
|
||||
display: -webkit-inline-box;
|
||||
display: -webkit-inline-flex;
|
||||
display: -ms-inline-flexbox;
|
||||
display: inline-flex;
|
||||
-webkit-align-items: center;
|
||||
-webkit-box-align: center;
|
||||
-ms-flex-align: center;
|
||||
align-items: center;
|
||||
visibility: hidden;
|
||||
top: -2px;
|
||||
}
|
||||
|
||||
.emotion-23:before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
top: 29%;
|
||||
left: -4px;
|
||||
margin-left: -5px;
|
||||
border: 5px solid;
|
||||
border-color: #d3dddd transparent transparent transparent;
|
||||
-webkit-transform: rotate(90deg);
|
||||
-ms-transform: rotate(90deg);
|
||||
transform: rotate(90deg);
|
||||
}
|
||||
|
||||
.emotion-6 {
|
||||
box-sizing: initial;
|
||||
display: inline-block;
|
||||
cursor: default;
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
padding: 0 5px;
|
||||
}
|
||||
|
||||
.emotion-34 {
|
||||
-webkit-align-items: center;
|
||||
-webkit-box-align: center;
|
||||
-ms-flex-align: center;
|
||||
align-items: center;
|
||||
display: none;
|
||||
display: -webkit-box;
|
||||
display: -webkit-flex;
|
||||
display: -ms-flexbox;
|
||||
display: flex;
|
||||
}
|
||||
|
||||
@media (min-width:768px) {
|
||||
.emotion-34 {
|
||||
display: -webkit-box;
|
||||
display: -webkit-flex;
|
||||
display: -ms-flexbox;
|
||||
display: flex;
|
||||
}
|
||||
}
|
||||
|
||||
.emotion-32 {
|
||||
box-sizing: initial;
|
||||
display: inline-block;
|
||||
cursor: pointer;
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
padding: 0 5px;
|
||||
}
|
||||
|
||||
.emotion-29 {
|
||||
width: 100%;
|
||||
height: auto;
|
||||
}
|
||||
|
||||
<div
|
||||
class="emotion-38 emotion-39"
|
||||
>
|
||||
<div
|
||||
class="emotion-36 emotion-37"
|
||||
>
|
||||
<div
|
||||
class="emotion-27 emotion-28"
|
||||
>
|
||||
Made with
|
||||
<span
|
||||
class="emotion-0 emotion-1"
|
||||
>
|
||||
♥
|
||||
</span>
|
||||
on
|
||||
<span
|
||||
class="emotion-25 emotion-26"
|
||||
>
|
||||
<svg
|
||||
class="emotion-2 emotion-3 emotion-4"
|
||||
>
|
||||
<title>
|
||||
Earth
|
||||
</title>
|
||||
<use
|
||||
xlink:href="[object Object]#earth"
|
||||
/>
|
||||
</svg>
|
||||
<span
|
||||
class="emotion-23 emotion-24"
|
||||
>
|
||||
<svg
|
||||
class="emotion-5 emotion-6 emotion-4"
|
||||
>
|
||||
<title>
|
||||
Spain
|
||||
</title>
|
||||
<use
|
||||
xlink:href="[object Object]#spain"
|
||||
/>
|
||||
</svg>
|
||||
<svg
|
||||
class="emotion-5 emotion-6 emotion-4"
|
||||
>
|
||||
<title>
|
||||
Nicaragua
|
||||
</title>
|
||||
<use
|
||||
xlink:href="[object Object]#nicaragua"
|
||||
/>
|
||||
</svg>
|
||||
<svg
|
||||
class="emotion-5 emotion-6 emotion-4"
|
||||
>
|
||||
<title>
|
||||
India
|
||||
</title>
|
||||
<use
|
||||
xlink:href="[object Object]#india"
|
||||
/>
|
||||
</svg>
|
||||
<svg
|
||||
class="emotion-5 emotion-6 emotion-4"
|
||||
>
|
||||
<title>
|
||||
Brazil
|
||||
</title>
|
||||
<use
|
||||
xlink:href="[object Object]#brazil"
|
||||
/>
|
||||
</svg>
|
||||
<svg
|
||||
class="emotion-5 emotion-6 emotion-4"
|
||||
>
|
||||
<title>
|
||||
China
|
||||
</title>
|
||||
<use
|
||||
xlink:href="[object Object]#china"
|
||||
/>
|
||||
</svg>
|
||||
<svg
|
||||
class="emotion-5 emotion-6 emotion-4"
|
||||
>
|
||||
<title>
|
||||
Austria
|
||||
</title>
|
||||
<use
|
||||
xlink:href="[object Object]#austria"
|
||||
/>
|
||||
</svg>
|
||||
</span>
|
||||
</span>
|
||||
</div>
|
||||
<div
|
||||
class="emotion-34 emotion-35"
|
||||
>
|
||||
Powered by
|
||||
<span
|
||||
class="emotion-5 emotion-32 emotion-33"
|
||||
title="Verdaccio"
|
||||
>
|
||||
<img
|
||||
alt="Verdaccio"
|
||||
class="emotion-29 emotion-30"
|
||||
src="[object Object]"
|
||||
/>
|
||||
</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-151fgib ek145dl0\\"><title>Earth</title><use xlink:href=\\"[object Object]#earth\\"></use></svg><span class=\\"css-8631ip ezbsl486\\"><svg class=\\"ezbsl488 css-1ah96gu ek145dl0\\"><title>Spain</title><use xlink:href=\\"[object Object]#spain\\"></use></svg><svg class=\\"ezbsl488 css-1ah96gu ek145dl0\\"><title>Nicaragua</title><use xlink:href=\\"[object Object]#nicaragua\\"></use></svg><svg class=\\"ezbsl488 css-1ah96gu ek145dl0\\"><title>India</title><use xlink:href=\\"[object Object]#india\\"></use></svg><svg class=\\"ezbsl488 css-1ah96gu ek145dl0\\"><title>Brazil</title><use xlink:href=\\"[object Object]#brazil\\"></use></svg><svg class=\\"ezbsl488 css-1ah96gu ek145dl0\\"><title>China</title><use xlink:href=\\"[object Object]#china\\"></use></svg><svg class=\\"ezbsl488 css-1ah96gu 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-ommwhu ek145dl1\\" name=\\"verdaccio\\" title=\\"Verdaccio\\"><img alt=\\"Verdaccio\\" src=\\"[object Object]\\" class=\\"css-1ncdhax ek145dl2\\"></span>/ v.1.0.0</div></div></div>"`;
|
||||
|
||||
@@ -1,87 +1,111 @@
|
||||
import { css } from '@emotion/core';
|
||||
import styled from '@emotion/styled';
|
||||
|
||||
import mq from '../../utils/styles/media';
|
||||
import Icon from '../Icon/Icon';
|
||||
import { Theme } from '../../design-tokens/theme';
|
||||
import colors from '../../utils/styles/colors';
|
||||
|
||||
export const Wrapper = styled('div')<{ theme?: Theme }>(props => ({
|
||||
background: props.theme && props.theme.palette.snow,
|
||||
borderTop: `1px solid ${props.theme && props.theme.palette.greyGainsboro}`,
|
||||
color: props.theme && props.theme.palette.nobel01,
|
||||
fontSize: '14px',
|
||||
padding: '20px',
|
||||
}));
|
||||
export const Wrapper = styled('div')({
|
||||
'&&': {
|
||||
background: colors.snow,
|
||||
borderTop: `1px solid ${colors.greyGainsboro}`,
|
||||
color: colors.nobel01,
|
||||
fontSize: '14px',
|
||||
padding: '20px',
|
||||
},
|
||||
});
|
||||
|
||||
export const Inner = styled('div')<{ theme?: Theme }>(({ theme }) => ({
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
justifyContent: 'flex-end',
|
||||
width: '100%',
|
||||
[`@media (min-width: ${theme && theme.breakPoints.medium}px)`]: {
|
||||
minWidth: 400,
|
||||
maxWidth: 800,
|
||||
margin: 'auto',
|
||||
justifyContent: 'space-between',
|
||||
},
|
||||
[`@media (min-width: ${theme && theme.breakPoints.large}px)`]: {
|
||||
maxWidth: 1240,
|
||||
},
|
||||
}));
|
||||
export const Inner = styled('div')`
|
||||
&& {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: flex-end;
|
||||
width: 100%;
|
||||
${() => {
|
||||
return mq.medium(css`
|
||||
min-width: 400px;
|
||||
max-width: 800px;
|
||||
margin: auto;
|
||||
justify-content: space-between;
|
||||
`);
|
||||
}};
|
||||
${() => {
|
||||
return mq.large(css`
|
||||
max-width: 1240px;
|
||||
`);
|
||||
}};
|
||||
}
|
||||
`;
|
||||
|
||||
export const Left = styled('div')<{ theme?: Theme }>(({ theme }) => ({
|
||||
alignItems: 'center',
|
||||
display: 'none',
|
||||
[`@media (min-width: ${theme && theme.breakPoints.medium}px)`]: {
|
||||
display: 'flex',
|
||||
},
|
||||
}));
|
||||
export const Left = styled('div')`
|
||||
&& {
|
||||
align-items: center;
|
||||
display: none;
|
||||
${() => {
|
||||
return mq.medium(css`
|
||||
display: flex;
|
||||
`);
|
||||
}};
|
||||
}
|
||||
`;
|
||||
|
||||
export const Right = styled(Left)({
|
||||
display: 'flex',
|
||||
'&&': {
|
||||
display: 'flex',
|
||||
},
|
||||
});
|
||||
|
||||
export const ToolTip = styled('span')({
|
||||
'&&': {
|
||||
position: 'relative',
|
||||
height: '18px',
|
||||
},
|
||||
});
|
||||
|
||||
export const Earth = styled(Icon)({
|
||||
padding: '0 10px',
|
||||
});
|
||||
|
||||
export const Flags = styled('span')<{ theme?: Theme }>(props => ({
|
||||
position: 'absolute',
|
||||
background: props.theme && props.theme.palette.greyAthens,
|
||||
padding: '1px 4px',
|
||||
borderRadius: 3,
|
||||
height: 20,
|
||||
display: 'inline-flex',
|
||||
alignItems: 'center',
|
||||
visibility: 'hidden',
|
||||
top: -2,
|
||||
':before': {
|
||||
content: "''",
|
||||
position: 'absolute',
|
||||
top: '29%',
|
||||
left: -4,
|
||||
marginLeft: -5,
|
||||
border: '5px solid',
|
||||
borderColor: `${props.theme && props.theme.palette.greyAthens} transparent transparent transparent`,
|
||||
transform: 'rotate(90deg)',
|
||||
},
|
||||
}));
|
||||
|
||||
export const ToolTip = styled('span')({
|
||||
position: 'relative',
|
||||
height: '18px',
|
||||
':hover': {
|
||||
[`${Flags}`]: {
|
||||
visibility: 'visible',
|
||||
},
|
||||
'&&': {
|
||||
padding: '0 10px',
|
||||
},
|
||||
});
|
||||
|
||||
export const Love = styled('span')<{ theme?: Theme }>(props => ({
|
||||
color: props.theme && props.theme.palette.love,
|
||||
padding: '0 5px',
|
||||
}));
|
||||
export const Flags = styled('span')`
|
||||
&& {
|
||||
position: absolute;
|
||||
background: ${colors.greyAthens};
|
||||
padding: 1px 4px;
|
||||
border-radius: 3px;
|
||||
height: 20px;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
visibility: hidden;
|
||||
top: -2px;
|
||||
:before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
top: 29%;
|
||||
left: -4px;
|
||||
margin-left: -5px;
|
||||
border: 5px solid;
|
||||
border-color: ${colors.greyAthens} transparent transparent transparent;
|
||||
transform: rotate(90deg);
|
||||
}
|
||||
${/* sc-selector */ ToolTip}:hover & {
|
||||
visibility: visible;
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
export const Love = styled('span')({
|
||||
'&&': {
|
||||
color: colors.love,
|
||||
padding: '0 5px',
|
||||
},
|
||||
});
|
||||
|
||||
export const Flag = styled(Icon)({
|
||||
padding: '0 5px',
|
||||
'&&': {
|
||||
padding: '0 5px',
|
||||
},
|
||||
});
|
||||
|
||||
export const Logo = Flag;
|
||||
|
||||
@@ -1,16 +1,15 @@
|
||||
import React from 'react';
|
||||
import { BrowserRouter as Router } from 'react-router-dom';
|
||||
|
||||
import { render, fireEvent, waitForElement, waitForElementToBeRemoved } from '../../utils/test-react-testing-library';
|
||||
import { AppContextProvider } from '../../App';
|
||||
import { render, fireEvent, waitForElementToBeRemoved, waitForElement } from '@testing-library/react';
|
||||
|
||||
import Header from './Header';
|
||||
|
||||
const props = {
|
||||
user: {
|
||||
username: 'verddacio-user',
|
||||
},
|
||||
packages: [],
|
||||
const headerProps = {
|
||||
username: 'verddacio-user',
|
||||
scope: 'test scope',
|
||||
withoutSearch: true,
|
||||
handleToggleLoginModal: jest.fn(),
|
||||
handleLogout: jest.fn(),
|
||||
};
|
||||
|
||||
/* eslint-disable react/jsx-no-bind*/
|
||||
@@ -18,70 +17,82 @@ describe('<Header /> component with logged in state', () => {
|
||||
test('should load the component in logged out state', () => {
|
||||
const { container, queryByTestId, getByText } = render(
|
||||
<Router>
|
||||
<AppContextProvider>
|
||||
<Header />
|
||||
</AppContextProvider>
|
||||
<Header
|
||||
onLogout={headerProps.handleLogout}
|
||||
onToggleLoginModal={headerProps.handleToggleLoginModal}
|
||||
scope={headerProps.scope}
|
||||
/>
|
||||
</Router>
|
||||
);
|
||||
|
||||
expect(container.firstChild).toMatchSnapshot();
|
||||
expect(queryByTestId('header--menu-accountcircle')).toBeNull();
|
||||
expect(queryByTestId('header--menu-acountcircle')).toBeNull();
|
||||
expect(getByText('Login')).toBeTruthy();
|
||||
});
|
||||
|
||||
test('should load the component in logged in state', () => {
|
||||
const { container, getByTestId, queryByText } = render(
|
||||
<Router>
|
||||
<AppContextProvider user={props.user}>
|
||||
<Header />
|
||||
</AppContextProvider>
|
||||
<Header
|
||||
onLogout={headerProps.handleLogout}
|
||||
onToggleLoginModal={headerProps.handleToggleLoginModal}
|
||||
scope={headerProps.scope}
|
||||
username={headerProps.username}
|
||||
/>
|
||||
</Router>
|
||||
);
|
||||
|
||||
expect(container.firstChild).toMatchSnapshot();
|
||||
expect(getByTestId('header--menu-accountcircle')).toBeTruthy();
|
||||
expect(getByTestId('header--menu-acountcircle')).toBeTruthy();
|
||||
expect(queryByText('Login')).toBeNull();
|
||||
});
|
||||
|
||||
test('should open login dialog', async () => {
|
||||
const { getByText } = render(
|
||||
<Router>
|
||||
<AppContextProvider>
|
||||
<Header />
|
||||
</AppContextProvider>
|
||||
<Header
|
||||
onLogout={headerProps.handleLogout}
|
||||
onToggleLoginModal={headerProps.handleToggleLoginModal}
|
||||
scope={headerProps.scope}
|
||||
/>
|
||||
</Router>
|
||||
);
|
||||
|
||||
const loginBtn = getByText('Login');
|
||||
fireEvent.click(loginBtn);
|
||||
const loginDialog = await waitForElement(() => getByText('Sign in'));
|
||||
expect(loginDialog).toBeTruthy();
|
||||
expect(headerProps.handleToggleLoginModal).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
test('should logout the user', async () => {
|
||||
const { getByText, getByTestId } = render(
|
||||
<Router>
|
||||
<AppContextProvider user={props.user}>
|
||||
<Header />
|
||||
</AppContextProvider>
|
||||
<Header
|
||||
onLogout={headerProps.handleLogout}
|
||||
onToggleLoginModal={headerProps.handleToggleLoginModal}
|
||||
scope={headerProps.scope}
|
||||
username={headerProps.username}
|
||||
/>
|
||||
</Router>
|
||||
);
|
||||
|
||||
const headerMenuAccountCircle = getByTestId('header--menu-accountcircle');
|
||||
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(getByText('Login')).toBeTruthy();
|
||||
expect(headerProps.handleLogout).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
test("The question icon should open a new tab of verdaccio's website - installation doc", () => {
|
||||
test("The question icon should open a new tab of verdaccio's website - installation doc", async () => {
|
||||
const { getByTestId } = render(
|
||||
<Router>
|
||||
<AppContextProvider user={props.user}>
|
||||
<Header />
|
||||
</AppContextProvider>
|
||||
<Header
|
||||
onLogout={headerProps.handleLogout}
|
||||
onToggleLoginModal={headerProps.handleToggleLoginModal}
|
||||
scope={headerProps.scope}
|
||||
username={headerProps.username}
|
||||
/>
|
||||
</Router>
|
||||
);
|
||||
|
||||
@@ -92,9 +103,12 @@ describe('<Header /> component with logged in state', () => {
|
||||
test('should open the registrationInfo modal when clicking on the info icon', async () => {
|
||||
const { getByTestId } = render(
|
||||
<Router>
|
||||
<AppContextProvider user={props.user}>
|
||||
<Header />
|
||||
</AppContextProvider>
|
||||
<Header
|
||||
onLogout={headerProps.handleLogout}
|
||||
onToggleLoginModal={headerProps.handleToggleLoginModal}
|
||||
scope={headerProps.scope}
|
||||
username={headerProps.username}
|
||||
/>
|
||||
</Router>
|
||||
);
|
||||
|
||||
@@ -109,9 +123,12 @@ describe('<Header /> component with logged in state', () => {
|
||||
test('should close the registrationInfo modal when clicking on the button close', async () => {
|
||||
const { getByTestId, getByText, queryByTestId } = render(
|
||||
<Router>
|
||||
<AppContextProvider user={props.user}>
|
||||
<Header />
|
||||
</AppContextProvider>
|
||||
<Header
|
||||
onLogout={headerProps.handleLogout}
|
||||
onToggleLoginModal={headerProps.handleToggleLoginModal}
|
||||
scope={headerProps.scope}
|
||||
username={headerProps.username}
|
||||
/>
|
||||
</Router>
|
||||
);
|
||||
|
||||
@@ -126,6 +143,6 @@ describe('<Header /> component with logged in state', () => {
|
||||
queryByTestId('registryInfo--dialog')
|
||||
);
|
||||
expect(hasRegistrationInfoModalBeenRemoved).toBeTruthy();
|
||||
test.todo('autocompletion should display suggestions according to the type value');
|
||||
});
|
||||
test.todo('autocompletion should display suggestions according to the type value');
|
||||
});
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
import React, { useState, useContext } from 'react';
|
||||
import React, { useState } from 'react';
|
||||
|
||||
import storage from '../../utils/storage';
|
||||
import Search from '../Search';
|
||||
import { getRegistryURL } from '../../utils/url';
|
||||
import Button from '../../muiComponents/Button';
|
||||
import AppContext from '../../App/AppContext';
|
||||
import LoginDialog from '../LoginDialog';
|
||||
import Search from '../Search';
|
||||
|
||||
import { NavBar, InnerNavBar, MobileNavBar, InnerMobileNavBar } from './styles';
|
||||
import HeaderLeft from './HeaderLeft';
|
||||
@@ -13,44 +10,31 @@ import HeaderRight from './HeaderRight';
|
||||
import HeaderInfoDialog from './HeaderInfoDialog';
|
||||
|
||||
interface Props {
|
||||
logo?: string;
|
||||
username?: string;
|
||||
onLogout: () => void;
|
||||
onToggleLoginModal: () => void;
|
||||
scope: string;
|
||||
withoutSearch?: boolean;
|
||||
}
|
||||
|
||||
/* eslint-disable react/jsx-max-depth */
|
||||
/* eslint-disable react/jsx-no-bind*/
|
||||
const Header: React.FC<Props> = ({ withoutSearch }) => {
|
||||
const appContext = useContext(AppContext);
|
||||
const Header: React.FC<Props> = ({ logo, withoutSearch, username, onLogout, onToggleLoginModal, scope }) => {
|
||||
const [isInfoDialogOpen, setOpenInfoDialog] = useState();
|
||||
const [showMobileNavBar, setShowMobileNavBar] = useState();
|
||||
const [showLoginModal, setShowLoginModal] = useState(false);
|
||||
|
||||
if (!appContext) {
|
||||
throw Error('The app Context was not correct used');
|
||||
}
|
||||
|
||||
const { user, scope, setUser } = appContext;
|
||||
const logo = window.VERDACCIO_LOGO;
|
||||
|
||||
/**
|
||||
* Logouts user
|
||||
* Required by: <Header />
|
||||
*/
|
||||
const handleLogout = () => {
|
||||
storage.removeItem('username');
|
||||
storage.removeItem('token');
|
||||
setUser(undefined);
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<NavBar data-testid="header" position="static">
|
||||
<NavBar position="static">
|
||||
<InnerNavBar>
|
||||
<HeaderLeft logo={logo} />
|
||||
<HeaderRight
|
||||
onLogout={handleLogout}
|
||||
onLogout={onLogout}
|
||||
onOpenRegistryInfoDialog={() => setOpenInfoDialog(true)}
|
||||
onToggleLogin={() => setShowLoginModal(!showLoginModal)}
|
||||
onToggleLogin={onToggleLoginModal}
|
||||
onToggleMobileNav={() => setShowMobileNavBar(!showMobileNavBar)}
|
||||
username={user && user.username}
|
||||
username={username}
|
||||
withoutSearch={withoutSearch}
|
||||
/>
|
||||
</InnerNavBar>
|
||||
@@ -71,7 +55,6 @@ const Header: React.FC<Props> = ({ withoutSearch }) => {
|
||||
</Button>
|
||||
</MobileNavBar>
|
||||
)}
|
||||
{!user && <LoginDialog onClose={() => setShowLoginModal(false)} open={showLoginModal} />}
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -11,7 +11,7 @@ interface Props {
|
||||
const HeaderGreetings: React.FC<Props> = ({ username }) => (
|
||||
<>
|
||||
<Greetings>{'Hi,'}</Greetings>
|
||||
<Label capitalize={true} data-testid="greetings-label" text={username} weight="bold" />
|
||||
<Label capitalize={true} text={username} weight="bold" />
|
||||
</>
|
||||
);
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import React from 'react';
|
||||
import styled from '@emotion/styled';
|
||||
import { css } from 'emotion';
|
||||
import { Link } from 'react-router-dom';
|
||||
|
||||
import Search from '../Search/';
|
||||
@@ -12,15 +12,15 @@ interface Props {
|
||||
logo?: string;
|
||||
}
|
||||
|
||||
const StyledLink = styled(Link)({
|
||||
marginRight: '1em',
|
||||
});
|
||||
|
||||
const HeaderLeft: React.FC<Props> = ({ withoutSearch = false, logo }) => (
|
||||
<LeftSide>
|
||||
<StyledLink to={'/'}>
|
||||
<Link
|
||||
className={css`
|
||||
margin-right: 1em;
|
||||
`}
|
||||
to={'/'}>
|
||||
<HeaderLogo logo={logo} />
|
||||
</StyledLink>
|
||||
</Link>
|
||||
{!withoutSearch && (
|
||||
<SearchWrapper>
|
||||
<Search />
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import React from 'react';
|
||||
import styled from '@emotion/styled';
|
||||
|
||||
import Logo from '../Logo';
|
||||
|
||||
@@ -9,14 +8,7 @@ interface Props {
|
||||
|
||||
const HeaderLogo: React.FC<Props> = ({ logo }) => {
|
||||
if (logo) {
|
||||
const Wrapper = styled('div')({
|
||||
fontSize: 0,
|
||||
});
|
||||
return (
|
||||
<Wrapper>
|
||||
<img alt="logo" height="40px" src={logo} />
|
||||
</Wrapper>
|
||||
);
|
||||
return <img alt="logo" height="40px" src={logo} />;
|
||||
}
|
||||
|
||||
return <Logo />;
|
||||
|
||||
@@ -16,6 +16,7 @@ interface Props {
|
||||
onLoggedInMenuClose: () => void;
|
||||
}
|
||||
|
||||
/* eslint-disable react/jsx-max-depth */
|
||||
const HeaderMenu: React.FC<Props> = ({
|
||||
onLogout,
|
||||
username,
|
||||
@@ -27,7 +28,7 @@ const HeaderMenu: React.FC<Props> = ({
|
||||
<>
|
||||
<IconButton
|
||||
color="inherit"
|
||||
data-testid="header--menu-accountcircle"
|
||||
data-testid="header--menu-acountcircle"
|
||||
id="header--button-account"
|
||||
onClick={onLoggedInMenu}>
|
||||
<AccountCircle />
|
||||
@@ -47,7 +48,7 @@ const HeaderMenu: React.FC<Props> = ({
|
||||
<MenuItem disabled={true}>
|
||||
<HeaderGreetings username={username} />
|
||||
</MenuItem>
|
||||
<MenuItem button={true} data-testid="header--button-logout" id="header--button-logout" onClick={onLogout}>
|
||||
<MenuItem button={true} id="header--button-logout" onClick={onLogout}>
|
||||
{'Logout'}
|
||||
</MenuItem>
|
||||
</Menu>
|
||||
|
||||
@@ -53,7 +53,7 @@ const HeaderRight: React.FC<Props> = ({
|
||||
};
|
||||
|
||||
return (
|
||||
<RightSide data-testid="header-right">
|
||||
<RightSide>
|
||||
{!withoutSearch && (
|
||||
<HeaderToolTip onClick={onToggleMobileNav} title={'Search packages'} tooltipIconType={'search'} />
|
||||
)}
|
||||
|
||||
@@ -1,167 +1,28 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`<Header /> component with logged in state should load the component in logged in state 1`] = `
|
||||
.emotion-24 {
|
||||
background-color: #4b5e40;
|
||||
min-height: 60px;
|
||||
display: -webkit-box;
|
||||
display: -webkit-flex;
|
||||
display: -ms-flexbox;
|
||||
display: flex;
|
||||
-webkit-box-pack: center;
|
||||
-webkit-justify-content: center;
|
||||
-ms-flex-pack: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
@media (min-width:768px) {
|
||||
.emotion-24 .emotion-13 {
|
||||
display: -webkit-box;
|
||||
display: -webkit-flex;
|
||||
display: -ms-flexbox;
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.emotion-24 .emotion-17 {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.emotion-24 .e1jf5lit4 {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
@media (min-width:1024px) {
|
||||
.emotion-24 .emotion-23 {
|
||||
padding: 0 20px;
|
||||
}
|
||||
|
||||
@media (min-width:1275px) {
|
||||
.emotion-24 .emotion-23 {
|
||||
max-width: 1240px;
|
||||
width: 100%;
|
||||
margin: 0 auto;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.emotion-22 {
|
||||
-webkit-box-pack: justify;
|
||||
-webkit-justify-content: space-between;
|
||||
-ms-flex-pack: justify;
|
||||
justify-content: space-between;
|
||||
-webkit-align-items: center;
|
||||
-webkit-box-align: center;
|
||||
-ms-flex-align: center;
|
||||
align-items: center;
|
||||
padding: 0 15px;
|
||||
}
|
||||
|
||||
.emotion-14 {
|
||||
display: -webkit-box;
|
||||
display: -webkit-flex;
|
||||
display: -ms-flexbox;
|
||||
display: flex;
|
||||
padding: 0;
|
||||
-webkit-flex: 1;
|
||||
-ms-flex: 1;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.emotion-2 {
|
||||
margin-right: 1em;
|
||||
}
|
||||
|
||||
.emotion-0 {
|
||||
display: inline-block;
|
||||
vertical-align: middle;
|
||||
box-sizing: border-box;
|
||||
background-position: center;
|
||||
background-size: contain;
|
||||
background-image: url([object Object]);
|
||||
background-repeat: no-repeat;
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
}
|
||||
|
||||
.emotion-12 {
|
||||
display: none;
|
||||
max-width: 393px;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.emotion-10 {
|
||||
width: 100%;
|
||||
height: 32px;
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.emotion-6 .MuiInputBase-root:before {
|
||||
content: '';
|
||||
border: none;
|
||||
}
|
||||
|
||||
.emotion-6 .MuiInputBase-root:after {
|
||||
border-color: #fff;
|
||||
}
|
||||
|
||||
.emotion-6 .MuiInputBase-root:hover:before {
|
||||
content: none;
|
||||
}
|
||||
|
||||
.emotion-6 .MuiInputBase-input {
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.emotion-4 {
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.emotion-8 {
|
||||
max-height: 500px;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.emotion-20 {
|
||||
display: -webkit-box;
|
||||
display: -webkit-flex;
|
||||
display: -ms-flexbox;
|
||||
display: flex;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.emotion-16 {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.emotion-18 {
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
<header
|
||||
class="MuiPaper-root MuiPaper-elevation4 MuiAppBar-root MuiAppBar-positionStatic emotion-24 emotion-25 MuiAppBar-colorPrimary"
|
||||
data-testid="header"
|
||||
class="MuiPaper-root MuiPaper-elevation4 MuiAppBar-root MuiAppBar-positionStatic css-rfunvc emotion-9 MuiAppBar-colorPrimary"
|
||||
>
|
||||
<div
|
||||
class="MuiToolbar-root MuiToolbar-regular emotion-22 emotion-23 MuiToolbar-gutters"
|
||||
class="MuiToolbar-root MuiToolbar-regular css-1bjere7 emotion-8 MuiToolbar-gutters"
|
||||
>
|
||||
<div
|
||||
class="MuiToolbar-root MuiToolbar-regular emotion-14 emotion-15 MuiToolbar-gutters"
|
||||
class="MuiToolbar-root MuiToolbar-regular css-i5xjw9 emotion-4 MuiToolbar-gutters"
|
||||
>
|
||||
<a
|
||||
class="emotion-2 emotion-3"
|
||||
class="css-1dk30lc"
|
||||
href="/"
|
||||
>
|
||||
<div
|
||||
class="emotion-0 emotion-1"
|
||||
class="css-1sifsqk emotion-0"
|
||||
/>
|
||||
</a>
|
||||
<div
|
||||
class="emotion-12 emotion-13"
|
||||
class="css-12prohx emotion-3"
|
||||
>
|
||||
<div
|
||||
class="emotion-10 emotion-11"
|
||||
class="css-1crzyyo emotion-2"
|
||||
>
|
||||
<div
|
||||
aria-expanded="false"
|
||||
@@ -173,13 +34,13 @@ exports[`<Header /> component with logged in state should load the component in
|
||||
<div
|
||||
aria-autocomplete="list"
|
||||
aria-controls="react-autowhatever-1"
|
||||
class="MuiFormControl-root MuiTextField-root react-autosuggest__input emotion-6 emotion-7 MuiFormControl-fullWidth"
|
||||
class="MuiFormControl-root MuiTextField-root react-autosuggest__input MuiFormControl-fullWidth"
|
||||
>
|
||||
<div
|
||||
class="MuiInputBase-root MuiInput-root MuiInput-underline MuiInputBase-fullWidth MuiInput-fullWidth MuiInputBase-formControl MuiInput-formControl MuiInputBase-adornedStart"
|
||||
class="MuiInputBase-root MuiInput-root css-n9ojyg MuiInput-underline MuiInputBase-fullWidth MuiInput-fullWidth MuiInputBase-formControl MuiInput-formControl MuiInputBase-adornedStart"
|
||||
>
|
||||
<div
|
||||
class="MuiInputAdornment-root emotion-4 emotion-5 MuiInputAdornment-positionStart"
|
||||
class="MuiInputAdornment-root css-fvu7gn MuiInputAdornment-positionStart"
|
||||
>
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
@@ -196,7 +57,7 @@ exports[`<Header /> component with logged in state should load the component in
|
||||
<input
|
||||
aria-invalid="false"
|
||||
autocomplete="off"
|
||||
class="MuiInputBase-input MuiInput-input MuiInputBase-inputAdornedStart"
|
||||
class="MuiInputBase-input MuiInput-input css-hodoyq MuiInputBase-inputAdornedStart"
|
||||
placeholder="Search Packages"
|
||||
type="text"
|
||||
value=""
|
||||
@@ -204,7 +65,7 @@ exports[`<Header /> component with logged in state should load the component in
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="MuiPaper-root MuiPaper-elevation1 react-autosuggest__suggestions-container emotion-8 emotion-9"
|
||||
class="MuiPaper-root MuiPaper-elevation1 react-autosuggest__suggestions-container css-cfo6a emotion-1"
|
||||
id="react-autowhatever-1"
|
||||
role="listbox"
|
||||
/>
|
||||
@@ -213,11 +74,10 @@ exports[`<Header /> component with logged in state should load the component in
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="MuiToolbar-root MuiToolbar-regular emotion-20 emotion-21 MuiToolbar-gutters"
|
||||
data-testid="header-right"
|
||||
class="MuiToolbar-root MuiToolbar-regular css-1qii1b7 emotion-7 MuiToolbar-gutters"
|
||||
>
|
||||
<button
|
||||
class="MuiButtonBase-root MuiIconButton-root emotion-16 emotion-17 MuiIconButton-colorInherit"
|
||||
class="MuiButtonBase-root MuiIconButton-root css-13o7eu2 emotion-5 MuiIconButton-colorInherit"
|
||||
tabindex="0"
|
||||
type="button"
|
||||
>
|
||||
@@ -241,7 +101,7 @@ exports[`<Header /> component with logged in state should load the component in
|
||||
/>
|
||||
</button>
|
||||
<a
|
||||
class="emotion-18 emotion-19"
|
||||
class="css-kbn7if emotion-6"
|
||||
data-testid="header--tooltip-documentation"
|
||||
href="https://verdaccio.org/docs/en/installation"
|
||||
rel="noopener noreferrer"
|
||||
@@ -304,7 +164,7 @@ exports[`<Header /> component with logged in state should load the component in
|
||||
</button>
|
||||
<button
|
||||
class="MuiButtonBase-root MuiIconButton-root MuiIconButton-colorInherit"
|
||||
data-testid="header--menu-accountcircle"
|
||||
data-testid="header--menu-acountcircle"
|
||||
id="header--button-account"
|
||||
tabindex="0"
|
||||
type="button"
|
||||
@@ -334,167 +194,28 @@ exports[`<Header /> component with logged in state should load the component in
|
||||
`;
|
||||
|
||||
exports[`<Header /> component with logged in state should load the component in logged out state 1`] = `
|
||||
.emotion-24 {
|
||||
background-color: #4b5e40;
|
||||
min-height: 60px;
|
||||
display: -webkit-box;
|
||||
display: -webkit-flex;
|
||||
display: -ms-flexbox;
|
||||
display: flex;
|
||||
-webkit-box-pack: center;
|
||||
-webkit-justify-content: center;
|
||||
-ms-flex-pack: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
@media (min-width:768px) {
|
||||
.emotion-24 .emotion-13 {
|
||||
display: -webkit-box;
|
||||
display: -webkit-flex;
|
||||
display: -ms-flexbox;
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.emotion-24 .emotion-17 {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.emotion-24 .e1jf5lit4 {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
@media (min-width:1024px) {
|
||||
.emotion-24 .emotion-23 {
|
||||
padding: 0 20px;
|
||||
}
|
||||
|
||||
@media (min-width:1275px) {
|
||||
.emotion-24 .emotion-23 {
|
||||
max-width: 1240px;
|
||||
width: 100%;
|
||||
margin: 0 auto;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.emotion-22 {
|
||||
-webkit-box-pack: justify;
|
||||
-webkit-justify-content: space-between;
|
||||
-ms-flex-pack: justify;
|
||||
justify-content: space-between;
|
||||
-webkit-align-items: center;
|
||||
-webkit-box-align: center;
|
||||
-ms-flex-align: center;
|
||||
align-items: center;
|
||||
padding: 0 15px;
|
||||
}
|
||||
|
||||
.emotion-14 {
|
||||
display: -webkit-box;
|
||||
display: -webkit-flex;
|
||||
display: -ms-flexbox;
|
||||
display: flex;
|
||||
padding: 0;
|
||||
-webkit-flex: 1;
|
||||
-ms-flex: 1;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.emotion-2 {
|
||||
margin-right: 1em;
|
||||
}
|
||||
|
||||
.emotion-0 {
|
||||
display: inline-block;
|
||||
vertical-align: middle;
|
||||
box-sizing: border-box;
|
||||
background-position: center;
|
||||
background-size: contain;
|
||||
background-image: url([object Object]);
|
||||
background-repeat: no-repeat;
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
}
|
||||
|
||||
.emotion-12 {
|
||||
display: none;
|
||||
max-width: 393px;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.emotion-10 {
|
||||
width: 100%;
|
||||
height: 32px;
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.emotion-6 .MuiInputBase-root:before {
|
||||
content: '';
|
||||
border: none;
|
||||
}
|
||||
|
||||
.emotion-6 .MuiInputBase-root:after {
|
||||
border-color: #fff;
|
||||
}
|
||||
|
||||
.emotion-6 .MuiInputBase-root:hover:before {
|
||||
content: none;
|
||||
}
|
||||
|
||||
.emotion-6 .MuiInputBase-input {
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.emotion-4 {
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.emotion-8 {
|
||||
max-height: 500px;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.emotion-20 {
|
||||
display: -webkit-box;
|
||||
display: -webkit-flex;
|
||||
display: -ms-flexbox;
|
||||
display: flex;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.emotion-16 {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.emotion-18 {
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
<header
|
||||
class="MuiPaper-root MuiPaper-elevation4 MuiAppBar-root MuiAppBar-positionStatic emotion-24 emotion-25 MuiAppBar-colorPrimary"
|
||||
data-testid="header"
|
||||
class="MuiPaper-root MuiPaper-elevation4 MuiAppBar-root MuiAppBar-positionStatic css-rfunvc emotion-9 MuiAppBar-colorPrimary"
|
||||
>
|
||||
<div
|
||||
class="MuiToolbar-root MuiToolbar-regular emotion-22 emotion-23 MuiToolbar-gutters"
|
||||
class="MuiToolbar-root MuiToolbar-regular css-1bjere7 emotion-8 MuiToolbar-gutters"
|
||||
>
|
||||
<div
|
||||
class="MuiToolbar-root MuiToolbar-regular emotion-14 emotion-15 MuiToolbar-gutters"
|
||||
class="MuiToolbar-root MuiToolbar-regular css-i5xjw9 emotion-4 MuiToolbar-gutters"
|
||||
>
|
||||
<a
|
||||
class="emotion-2 emotion-3"
|
||||
class="css-1dk30lc"
|
||||
href="/"
|
||||
>
|
||||
<div
|
||||
class="emotion-0 emotion-1"
|
||||
class="css-1sifsqk emotion-0"
|
||||
/>
|
||||
</a>
|
||||
<div
|
||||
class="emotion-12 emotion-13"
|
||||
class="css-12prohx emotion-3"
|
||||
>
|
||||
<div
|
||||
class="emotion-10 emotion-11"
|
||||
class="css-1crzyyo emotion-2"
|
||||
>
|
||||
<div
|
||||
aria-expanded="false"
|
||||
@@ -506,13 +227,13 @@ exports[`<Header /> component with logged in state should load the component in
|
||||
<div
|
||||
aria-autocomplete="list"
|
||||
aria-controls="react-autowhatever-1"
|
||||
class="MuiFormControl-root MuiTextField-root react-autosuggest__input emotion-6 emotion-7 MuiFormControl-fullWidth"
|
||||
class="MuiFormControl-root MuiTextField-root react-autosuggest__input MuiFormControl-fullWidth"
|
||||
>
|
||||
<div
|
||||
class="MuiInputBase-root MuiInput-root MuiInput-underline MuiInputBase-fullWidth MuiInput-fullWidth MuiInputBase-formControl MuiInput-formControl MuiInputBase-adornedStart"
|
||||
class="MuiInputBase-root MuiInput-root css-n9ojyg MuiInput-underline MuiInputBase-fullWidth MuiInput-fullWidth MuiInputBase-formControl MuiInput-formControl MuiInputBase-adornedStart"
|
||||
>
|
||||
<div
|
||||
class="MuiInputAdornment-root emotion-4 emotion-5 MuiInputAdornment-positionStart"
|
||||
class="MuiInputAdornment-root css-fvu7gn MuiInputAdornment-positionStart"
|
||||
>
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
@@ -529,7 +250,7 @@ exports[`<Header /> component with logged in state should load the component in
|
||||
<input
|
||||
aria-invalid="false"
|
||||
autocomplete="off"
|
||||
class="MuiInputBase-input MuiInput-input MuiInputBase-inputAdornedStart"
|
||||
class="MuiInputBase-input MuiInput-input css-hodoyq MuiInputBase-inputAdornedStart"
|
||||
placeholder="Search Packages"
|
||||
type="text"
|
||||
value=""
|
||||
@@ -537,7 +258,7 @@ exports[`<Header /> component with logged in state should load the component in
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="MuiPaper-root MuiPaper-elevation1 react-autosuggest__suggestions-container emotion-8 emotion-9"
|
||||
class="MuiPaper-root MuiPaper-elevation1 react-autosuggest__suggestions-container css-cfo6a emotion-1"
|
||||
id="react-autowhatever-1"
|
||||
role="listbox"
|
||||
/>
|
||||
@@ -546,11 +267,10 @@ exports[`<Header /> component with logged in state should load the component in
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="MuiToolbar-root MuiToolbar-regular emotion-20 emotion-21 MuiToolbar-gutters"
|
||||
data-testid="header-right"
|
||||
class="MuiToolbar-root MuiToolbar-regular css-1qii1b7 emotion-7 MuiToolbar-gutters"
|
||||
>
|
||||
<button
|
||||
class="MuiButtonBase-root MuiIconButton-root emotion-16 emotion-17 MuiIconButton-colorInherit"
|
||||
class="MuiButtonBase-root MuiIconButton-root css-13o7eu2 emotion-5 MuiIconButton-colorInherit"
|
||||
tabindex="0"
|
||||
type="button"
|
||||
>
|
||||
@@ -574,7 +294,7 @@ exports[`<Header /> component with logged in state should load the component in
|
||||
/>
|
||||
</button>
|
||||
<a
|
||||
class="emotion-18 emotion-19"
|
||||
class="css-kbn7if emotion-6"
|
||||
data-testid="header--tooltip-documentation"
|
||||
href="https://verdaccio.org/docs/en/installation"
|
||||
rel="noopener noreferrer"
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import styled from '@emotion/styled';
|
||||
import { css } from '@emotion/core';
|
||||
|
||||
import { Theme } from '../../design-tokens/theme';
|
||||
import colors from '../../utils/styles/colors';
|
||||
import mq from '../../utils/styles/media';
|
||||
import IconButton from '../../muiComponents/IconButton';
|
||||
import AppBar from '../../muiComponents/AppBar';
|
||||
import Toolbar from '../../muiComponents/Toolbar';
|
||||
@@ -26,63 +27,68 @@ export const LeftSide = styled(RightSide)({
|
||||
flex: 1,
|
||||
});
|
||||
|
||||
export const MobileNavBar = styled('div')<{ theme?: Theme }>(props => ({
|
||||
export const MobileNavBar = styled('div')({
|
||||
alignItems: 'center',
|
||||
display: 'flex',
|
||||
borderBottom: `1px solid ${props.theme && props.theme.palette.greyLight}`,
|
||||
borderBottom: `1px solid ${colors.greyLight}`,
|
||||
padding: '8px',
|
||||
position: 'relative',
|
||||
}));
|
||||
});
|
||||
|
||||
export const InnerMobileNavBar = styled('div')<{ theme?: Theme }>(props => ({
|
||||
export const InnerMobileNavBar = styled('div')({
|
||||
borderRadius: '4px',
|
||||
backgroundColor: props.theme && props.theme.palette.greyLight,
|
||||
color: props.theme && props.theme.palette.white,
|
||||
backgroundColor: colors.greyLight,
|
||||
color: colors.white,
|
||||
width: '100%',
|
||||
padding: '0 5px',
|
||||
margin: '0 10px 0 0',
|
||||
}));
|
||||
});
|
||||
|
||||
export const IconSearchButton = styled(IconButton)({
|
||||
display: 'block',
|
||||
});
|
||||
|
||||
export const SearchWrapper = styled('div')({
|
||||
display: 'none',
|
||||
// display: 'none',
|
||||
maxWidth: '393px',
|
||||
width: '100%',
|
||||
});
|
||||
|
||||
export const NavBar = styled(AppBar)<{ theme?: Theme }>(({ theme }) => ({
|
||||
backgroundColor: theme && theme.palette.primary.main,
|
||||
minHeight: 60,
|
||||
display: 'flex',
|
||||
justifyContent: 'center',
|
||||
[`@media (min-width: ${theme && theme.breakPoints.medium}px)`]: css`
|
||||
${SearchWrapper} {
|
||||
display: flex;
|
||||
}
|
||||
${IconSearchButton} {
|
||||
display: none;
|
||||
}
|
||||
${MobileNavBar} {
|
||||
display: none;
|
||||
}
|
||||
`,
|
||||
[`@media (min-width: ${theme && theme.breakPoints.large}px)`]: css`
|
||||
${InnerNavBar} {
|
||||
padding: 0 20px;
|
||||
}
|
||||
`,
|
||||
[`@media (min-width: ${theme && theme.breakPoints.xlarge}px)`]: css`
|
||||
${InnerNavBar} {
|
||||
max-width: 1240px;
|
||||
width: 100%;
|
||||
margin: 0 auto;
|
||||
}
|
||||
`,
|
||||
}));
|
||||
export const NavBar = styled(AppBar)`
|
||||
&& {
|
||||
background-color: ${colors.primary};
|
||||
min-height: 60px;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
${() =>
|
||||
mq.medium(css`
|
||||
${SearchWrapper} {
|
||||
display: flex;
|
||||
}
|
||||
${IconSearchButton} {
|
||||
display: none;
|
||||
}
|
||||
${MobileNavBar} {
|
||||
display: none;
|
||||
}
|
||||
`)};
|
||||
${() =>
|
||||
mq.large(css`
|
||||
${InnerNavBar} {
|
||||
padding: 0 20px;
|
||||
}
|
||||
`)};
|
||||
${() =>
|
||||
mq.xlarge(css`
|
||||
${InnerNavBar} {
|
||||
max-width: 1240px;
|
||||
width: 100%;
|
||||
margin: 0 auto;
|
||||
}
|
||||
`)};
|
||||
}
|
||||
`;
|
||||
|
||||
export const StyledLink = styled(Link)<{ theme?: Theme }>(props => ({
|
||||
color: props.theme && props.theme.palette.white,
|
||||
}));
|
||||
export const StyledLink = styled(Link)({
|
||||
color: 'white',
|
||||
});
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
import React from 'react';
|
||||
|
||||
import { render } from '../../utils/test-react-testing-library';
|
||||
import { mount } from 'enzyme';
|
||||
|
||||
import Help from './Help';
|
||||
|
||||
describe('<Help /> component', () => {
|
||||
test('should load the component in default state', () => {
|
||||
const { container } = render(<Help />);
|
||||
expect(container.firstChild).toMatchSnapshot();
|
||||
test('should render the component in default state', () => {
|
||||
const wrapper = mount(<Help />);
|
||||
expect(wrapper.html()).toMatchSnapshot();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,159 +1,3 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`<Help /> component should load the component in default state 1`] = `
|
||||
.emotion-14 {
|
||||
width: 600px;
|
||||
margin: auto;
|
||||
}
|
||||
|
||||
.emotion-0 {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.emotion-6 {
|
||||
display: -webkit-box;
|
||||
display: -webkit-flex;
|
||||
display: -ms-flexbox;
|
||||
display: flex;
|
||||
-webkit-align-items: center;
|
||||
-webkit-box-align: center;
|
||||
-ms-flex-align: center;
|
||||
align-items: center;
|
||||
-webkit-box-pack: justify;
|
||||
-webkit-justify-content: space-between;
|
||||
-ms-flex-pack: justify;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.emotion-2 {
|
||||
display: inline-block;
|
||||
text-overflow: ellipsis;
|
||||
overflow: hidden;
|
||||
white-space: nowrap;
|
||||
height: 21px;
|
||||
font-size: 1rem;
|
||||
}
|
||||
|
||||
<div
|
||||
class="MuiPaper-root MuiPaper-elevation1 MuiCard-root emotion-14 emotion-15 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 emotion-0 emotion-1 MuiTypography-h6 MuiTypography-colorTextSecondary MuiTypography-gutterBottom"
|
||||
>
|
||||
To publish your first package just:
|
||||
</h6>
|
||||
<p
|
||||
class="MuiTypography-root MuiTypography-body1"
|
||||
>
|
||||
1. Login
|
||||
</p>
|
||||
<div
|
||||
class="emotion-6 emotion-7"
|
||||
>
|
||||
<span
|
||||
class="emotion-2 emotion-3"
|
||||
>
|
||||
npm adduser --registry http://localhost
|
||||
</span>
|
||||
<button
|
||||
class="MuiButtonBase-root MuiIconButton-root emotion-4 emotion-5"
|
||||
tabindex="0"
|
||||
title="Copy to Clipboard"
|
||||
type="button"
|
||||
>
|
||||
<span
|
||||
class="MuiIconButton-label"
|
||||
>
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
class="MuiSvgIcon-root"
|
||||
focusable="false"
|
||||
role="presentation"
|
||||
viewBox="0 0 24 24"
|
||||
>
|
||||
<path
|
||||
d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm-1 4l6 6v10c0 1.1-.9 2-2 2H7.99C6.89 23 6 22.1 6 21l.01-14c0-1.1.89-2 1.99-2h7zm-1 7h5.5L14 6.5V12z"
|
||||
/>
|
||||
</svg>
|
||||
</span>
|
||||
<span
|
||||
class="MuiTouchRipple-root"
|
||||
/>
|
||||
</button>
|
||||
</div>
|
||||
<p
|
||||
class="MuiTypography-root MuiTypography-body1"
|
||||
>
|
||||
2. Publish
|
||||
</p>
|
||||
<div
|
||||
class="emotion-6 emotion-7"
|
||||
>
|
||||
<span
|
||||
class="emotion-2 emotion-3"
|
||||
>
|
||||
npm publish --registry http://localhost
|
||||
</span>
|
||||
<button
|
||||
class="MuiButtonBase-root MuiIconButton-root emotion-4 emotion-5"
|
||||
tabindex="0"
|
||||
title="Copy to Clipboard"
|
||||
type="button"
|
||||
>
|
||||
<span
|
||||
class="MuiIconButton-label"
|
||||
>
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
class="MuiSvgIcon-root"
|
||||
focusable="false"
|
||||
role="presentation"
|
||||
viewBox="0 0 24 24"
|
||||
>
|
||||
<path
|
||||
d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm-1 4l6 6v10c0 1.1-.9 2-2 2H7.99C6.89 23 6 22.1 6 21l.01-14c0-1.1.89-2 1.99-2h7zm-1 7h5.5L14 6.5V12z"
|
||||
/>
|
||||
</svg>
|
||||
</span>
|
||||
<span
|
||||
class="MuiTouchRipple-root"
|
||||
/>
|
||||
</button>
|
||||
</div>
|
||||
<p
|
||||
class="MuiTypography-root MuiTypography-body2"
|
||||
>
|
||||
3. Refresh this page.
|
||||
</p>
|
||||
</div>
|
||||
<div
|
||||
class="MuiCardActions-root MuiCardActions-spacing"
|
||||
>
|
||||
<a
|
||||
aria-disabled="false"
|
||||
class="MuiButtonBase-root MuiButton-root MuiButton-text MuiButton-textPrimary MuiButton-textSizeSmall MuiButton-sizeSmall"
|
||||
href="https://verdaccio.org/docs/en/installation"
|
||||
tabindex="0"
|
||||
>
|
||||
<span
|
||||
class="MuiButton-label"
|
||||
>
|
||||
Learn More
|
||||
</span>
|
||||
<span
|
||||
class="MuiTouchRipple-root"
|
||||
/>
|
||||
</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>"`;
|
||||
|
||||
@@ -4,10 +4,14 @@ import { default as Typography } from '../../muiComponents/Heading';
|
||||
import Card from '../../muiComponents/Card';
|
||||
|
||||
export const CardStyled = styled(Card)({
|
||||
width: 600,
|
||||
margin: 'auto',
|
||||
'&&': {
|
||||
width: '600px',
|
||||
margin: 'auto',
|
||||
},
|
||||
});
|
||||
|
||||
export const HelpTitle = styled(Typography)({
|
||||
marginBottom: 20,
|
||||
'&&': {
|
||||
marginBottom: '20px',
|
||||
},
|
||||
});
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import React from 'react';
|
||||
|
||||
import { render } from '../../utils/test-react-testing-library';
|
||||
import { shallow } from 'enzyme';
|
||||
|
||||
import Icon from './Icon';
|
||||
|
||||
@@ -9,7 +8,7 @@ describe('<Icon /> component', () => {
|
||||
name: 'austria',
|
||||
};
|
||||
test('should render the component in default state', () => {
|
||||
const { container } = render(<Icon name={props.name} />);
|
||||
expect(container.firstChild).toMatchSnapshot();
|
||||
const wrapper = shallow(<Icon name={props.name} />);
|
||||
expect(wrapper.html()).toMatchSnapshot();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -63,11 +63,10 @@ export interface Props {
|
||||
modifiers?: null | undefined;
|
||||
}
|
||||
|
||||
/* eslint-disable verdaccio/jsx-spread */
|
||||
const Icon: React.FC<Props> = ({ className, name, size = 'sm', img = false, pointer = false, ...props }) => {
|
||||
const title = capitalize(name.toString());
|
||||
return img ? (
|
||||
<ImgWrapper className={className} 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]} />
|
||||
</ImgWrapper>
|
||||
) : (
|
||||
|
||||
@@ -1,22 +1,3 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`<Icon /> component should render the component in default state 1`] = `
|
||||
.emotion-0 {
|
||||
box-sizing: initial;
|
||||
display: inline-block;
|
||||
cursor: default;
|
||||
width: 14px;
|
||||
height: 16px;
|
||||
}
|
||||
|
||||
<svg
|
||||
class="emotion-0 emotion-1"
|
||||
>
|
||||
<title>
|
||||
Austria
|
||||
</title>
|
||||
<use
|
||||
xlink:href="[object Object]#austria"
|
||||
/>
|
||||
</svg>
|
||||
`;
|
||||
exports[`<Icon /> component should render the component in default state 1`] = `"<svg class=\\"css-j2zgvv ek145dl0\\"><title>Austria</title><use xlink:href=\\"[object Object]#austria\\"></use></svg>"`;
|
||||
|
||||
@@ -1,42 +1,45 @@
|
||||
import { css } from '@emotion/core';
|
||||
import styled from '@emotion/styled';
|
||||
import { Breakpoint } from '@material-ui/core/styles/createBreakpoints';
|
||||
import { DetailedHTMLProps, HTMLAttributes } from 'react';
|
||||
|
||||
const getSize = (size: Breakpoint): { width: number; height: number } => {
|
||||
const getSize = (size: Breakpoint): string => {
|
||||
switch (size) {
|
||||
case 'md':
|
||||
return {
|
||||
width: 18,
|
||||
height: 18,
|
||||
};
|
||||
return `
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
`;
|
||||
default:
|
||||
return {
|
||||
width: 14,
|
||||
height: 16,
|
||||
};
|
||||
return `
|
||||
width: 14px;
|
||||
height: 16px;
|
||||
`;
|
||||
}
|
||||
};
|
||||
|
||||
interface CommonStyleProps {
|
||||
size: Breakpoint;
|
||||
pointer?: boolean;
|
||||
}
|
||||
const commonStyle = ({ size = 'sm', pointer }: CommonStyleProps): object => ({
|
||||
display: 'inline-block',
|
||||
cursor: pointer ? 'pointer' : 'default',
|
||||
...getSize(size),
|
||||
});
|
||||
const commonStyle = ({ size = 'sm' as Breakpoint, pointer, modifiers = null }) => css`
|
||||
&& {
|
||||
display: inline-block;
|
||||
cursor: ${pointer ? 'pointer' : 'Developers'};
|
||||
${getSize(size)};
|
||||
${modifiers && modifiers};
|
||||
}
|
||||
`;
|
||||
|
||||
export const Svg = styled('svg')<CommonStyleProps>(props => ({
|
||||
boxSizing: 'initial',
|
||||
...commonStyle(props),
|
||||
}));
|
||||
export const Svg = styled('svg')`
|
||||
${commonStyle};
|
||||
box-sizing: initial;
|
||||
`;
|
||||
|
||||
export const ImgWrapper = styled('span')<CommonStyleProps>(props => ({
|
||||
boxSizing: 'initial',
|
||||
...commonStyle(props),
|
||||
}));
|
||||
export const ImgWrapper = styled('span')`
|
||||
${commonStyle};
|
||||
box-sizing: initial;
|
||||
`;
|
||||
|
||||
export const Img = styled('img')({
|
||||
width: '100%',
|
||||
height: 'auto',
|
||||
'&&': {
|
||||
width: '100%',
|
||||
height: 'auto',
|
||||
},
|
||||
});
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import React from 'react';
|
||||
import { render } from '@testing-library/react';
|
||||
|
||||
import { render } from '../../utils/test-react-testing-library';
|
||||
import { DetailContext, DetailContextProps } from '../../pages/Version';
|
||||
|
||||
import data from './__partials__/data.json';
|
||||
|
||||
@@ -2,16 +2,16 @@ import React, { useContext } from 'react';
|
||||
import styled from '@emotion/styled';
|
||||
|
||||
import { DetailContext } from '../../pages/Version';
|
||||
import { fontWeight } from '../../utils/styles/sizes';
|
||||
import Text from '../../muiComponents/Text';
|
||||
import List from '../../muiComponents/List';
|
||||
import { Theme } from '../../design-tokens/theme';
|
||||
|
||||
import InstallListItem, { DependencyManager } from './InstallListItem';
|
||||
|
||||
const StyledText = styled(Text)<{ theme?: Theme }>(props => ({
|
||||
fontWeight: props.theme && props.theme.fontWeight.bold,
|
||||
const StyledText = styled(Text)({
|
||||
fontWeight: fontWeight.bold,
|
||||
textTransform: 'capitalize',
|
||||
}));
|
||||
});
|
||||
|
||||
const Install: React.FC = () => {
|
||||
const detailContext = useContext(DetailContext);
|
||||
|
||||
@@ -26,9 +26,6 @@ const InstallListItemText = styled(ListItemText)({
|
||||
const PackageMangerAvatar = styled(Avatar)({
|
||||
borderRadius: '0px',
|
||||
padding: '0',
|
||||
img: {
|
||||
backgroundColor: 'transparent',
|
||||
},
|
||||
});
|
||||
|
||||
export enum DependencyManager {
|
||||
|
||||
@@ -1,75 +1,24 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`<Install /> renders correctly 1`] = `
|
||||
.emotion-0 {
|
||||
font-weight: 700;
|
||||
text-transform: capitalize;
|
||||
}
|
||||
|
||||
.emotion-12 {
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.emotion-12:hover {
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
.emotion-2 {
|
||||
border-radius: 0px;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.emotion-2 img {
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
.emotion-10 {
|
||||
padding: 0 10px;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.emotion-8 {
|
||||
display: -webkit-box;
|
||||
display: -webkit-flex;
|
||||
display: -ms-flexbox;
|
||||
display: flex;
|
||||
-webkit-align-items: center;
|
||||
-webkit-box-align: center;
|
||||
-ms-flex-align: center;
|
||||
align-items: center;
|
||||
-webkit-box-pack: justify;
|
||||
-webkit-justify-content: space-between;
|
||||
-ms-flex-pack: justify;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.emotion-4 {
|
||||
display: inline-block;
|
||||
text-overflow: ellipsis;
|
||||
overflow: hidden;
|
||||
white-space: nowrap;
|
||||
height: 21px;
|
||||
font-size: 1rem;
|
||||
}
|
||||
|
||||
<ul
|
||||
class="MuiList-root MuiList-padding MuiList-subheader"
|
||||
data-testid="installList"
|
||||
>
|
||||
<h6
|
||||
class="MuiTypography-root emotion-0 emotion-1 MuiTypography-subtitle1"
|
||||
class="MuiTypography-root css-b8upko emotion-0 MuiTypography-subtitle1"
|
||||
>
|
||||
Installation
|
||||
</h6>
|
||||
<div
|
||||
aria-disabled="false"
|
||||
class="MuiButtonBase-root MuiListItem-root emotion-12 emotion-13 MuiListItem-gutters MuiListItem-button"
|
||||
class="MuiButtonBase-root MuiListItem-root css-zw46c6 emotion-6 MuiListItem-gutters MuiListItem-button"
|
||||
data-testid="installListItem-npm"
|
||||
role="button"
|
||||
tabindex="0"
|
||||
>
|
||||
<div
|
||||
class="MuiAvatar-root MuiAvatar-circle emotion-2 emotion-3"
|
||||
class="MuiAvatar-root MuiAvatar-circle css-19top7x emotion-1"
|
||||
>
|
||||
<img
|
||||
alt="npm"
|
||||
@@ -78,21 +27,21 @@ exports[`<Install /> renders correctly 1`] = `
|
||||
/>
|
||||
</div>
|
||||
<div
|
||||
class="MuiListItemText-root emotion-10 emotion-11 MuiListItemText-multiline"
|
||||
class="MuiListItemText-root css-fipixf emotion-5 MuiListItemText-multiline"
|
||||
>
|
||||
<span
|
||||
class="MuiTypography-root MuiListItemText-primary MuiTypography-body1"
|
||||
>
|
||||
<div
|
||||
class="emotion-8 emotion-9"
|
||||
class="css-1mta3t8 emotion-4"
|
||||
>
|
||||
<span
|
||||
class="emotion-4 emotion-5"
|
||||
class="css-lh0wgu emotion-2"
|
||||
>
|
||||
npm install foo
|
||||
</span>
|
||||
<button
|
||||
class="MuiButtonBase-root MuiIconButton-root emotion-6 emotion-7"
|
||||
class="MuiButtonBase-root MuiIconButton-root css-0 emotion-3"
|
||||
tabindex="0"
|
||||
title="Copy to Clipboard"
|
||||
type="button"
|
||||
@@ -130,13 +79,13 @@ exports[`<Install /> renders correctly 1`] = `
|
||||
</div>
|
||||
<div
|
||||
aria-disabled="false"
|
||||
class="MuiButtonBase-root MuiListItem-root emotion-12 emotion-13 MuiListItem-gutters MuiListItem-button"
|
||||
class="MuiButtonBase-root MuiListItem-root css-zw46c6 emotion-6 MuiListItem-gutters MuiListItem-button"
|
||||
data-testid="installListItem-yarn"
|
||||
role="button"
|
||||
tabindex="0"
|
||||
>
|
||||
<div
|
||||
class="MuiAvatar-root MuiAvatar-circle emotion-2 emotion-3"
|
||||
class="MuiAvatar-root MuiAvatar-circle css-19top7x emotion-1"
|
||||
>
|
||||
<img
|
||||
alt="yarn"
|
||||
@@ -145,21 +94,21 @@ exports[`<Install /> renders correctly 1`] = `
|
||||
/>
|
||||
</div>
|
||||
<div
|
||||
class="MuiListItemText-root emotion-10 emotion-11 MuiListItemText-multiline"
|
||||
class="MuiListItemText-root css-fipixf emotion-5 MuiListItemText-multiline"
|
||||
>
|
||||
<span
|
||||
class="MuiTypography-root MuiListItemText-primary MuiTypography-body1"
|
||||
>
|
||||
<div
|
||||
class="emotion-8 emotion-9"
|
||||
class="css-1mta3t8 emotion-4"
|
||||
>
|
||||
<span
|
||||
class="emotion-4 emotion-5"
|
||||
class="css-lh0wgu emotion-2"
|
||||
>
|
||||
yarn add foo
|
||||
</span>
|
||||
<button
|
||||
class="MuiButtonBase-root MuiIconButton-root emotion-6 emotion-7"
|
||||
class="MuiButtonBase-root MuiIconButton-root css-0 emotion-3"
|
||||
tabindex="0"
|
||||
title="Copy to Clipboard"
|
||||
type="button"
|
||||
@@ -197,13 +146,13 @@ exports[`<Install /> renders correctly 1`] = `
|
||||
</div>
|
||||
<div
|
||||
aria-disabled="false"
|
||||
class="MuiButtonBase-root MuiListItem-root emotion-12 emotion-13 MuiListItem-gutters MuiListItem-button"
|
||||
class="MuiButtonBase-root MuiListItem-root css-zw46c6 emotion-6 MuiListItem-gutters MuiListItem-button"
|
||||
data-testid="installListItem-pnpm"
|
||||
role="button"
|
||||
tabindex="0"
|
||||
>
|
||||
<div
|
||||
class="MuiAvatar-root MuiAvatar-circle emotion-2 emotion-3"
|
||||
class="MuiAvatar-root MuiAvatar-circle css-19top7x emotion-1"
|
||||
>
|
||||
<img
|
||||
alt="pnpm"
|
||||
@@ -212,21 +161,21 @@ exports[`<Install /> renders correctly 1`] = `
|
||||
/>
|
||||
</div>
|
||||
<div
|
||||
class="MuiListItemText-root emotion-10 emotion-11 MuiListItemText-multiline"
|
||||
class="MuiListItemText-root css-fipixf emotion-5 MuiListItemText-multiline"
|
||||
>
|
||||
<span
|
||||
class="MuiTypography-root MuiListItemText-primary MuiTypography-body1"
|
||||
>
|
||||
<div
|
||||
class="emotion-8 emotion-9"
|
||||
class="css-1mta3t8 emotion-4"
|
||||
>
|
||||
<span
|
||||
class="emotion-4 emotion-5"
|
||||
class="css-lh0wgu emotion-2"
|
||||
>
|
||||
pnpm install foo
|
||||
</span>
|
||||
<button
|
||||
class="MuiButtonBase-root MuiIconButton-root emotion-6 emotion-7"
|
||||
class="MuiButtonBase-root MuiIconButton-root css-0 emotion-3"
|
||||
tabindex="0"
|
||||
title="Copy to Clipboard"
|
||||
type="button"
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import React from 'react';
|
||||
|
||||
import { render } from '../../utils/test-react-testing-library';
|
||||
import { mount } from 'enzyme';
|
||||
|
||||
import Label from './Label';
|
||||
|
||||
@@ -9,7 +8,7 @@ describe('<Label /> component', () => {
|
||||
text: 'test',
|
||||
};
|
||||
test('should render the component in default state', () => {
|
||||
const { container } = render(<Label text={props.text} />);
|
||||
expect(container.firstChild).toMatchSnapshot();
|
||||
const wrapper = mount(<Label text={props.text} />);
|
||||
expect(wrapper.html()).toMatchSnapshot();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,23 +1,25 @@
|
||||
import React from 'react';
|
||||
import styled from '@emotion/styled';
|
||||
|
||||
import { Theme } from '../../design-tokens/theme';
|
||||
import { fontWeight } from '../../utils/styles/sizes';
|
||||
|
||||
interface Props {
|
||||
text: string;
|
||||
capitalize?: boolean;
|
||||
weight?: string;
|
||||
modifiers?: null | undefined;
|
||||
}
|
||||
|
||||
interface WrapperProps {
|
||||
capitalize: boolean;
|
||||
weight: string;
|
||||
modifiers?: null;
|
||||
}
|
||||
|
||||
const Wrapper = styled('div')<WrapperProps & { theme?: Theme }>(props => ({
|
||||
fontWeight: props.theme && props.theme.fontWeight[props.weight],
|
||||
textTransform: props.capitalize ? 'capitalize' : 'none',
|
||||
}));
|
||||
const Wrapper = styled('div')`
|
||||
font-weight: ${({ weight }: WrapperProps) => fontWeight[weight]};
|
||||
text-transform: ${({ capitalize }: WrapperProps) => (capitalize ? 'capitalize' : 'none')};
|
||||
${({ modifiers }: WrapperProps) => modifiers};
|
||||
`;
|
||||
|
||||
const Label: React.FC<Props> = ({ text = '', capitalize = false, weight = 'regular', ...props }) => {
|
||||
return (
|
||||
|
||||
@@ -1,14 +1,3 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`<Label /> component should render the component in default state 1`] = `
|
||||
.emotion-0 {
|
||||
font-weight: 400;
|
||||
text-transform: none;
|
||||
}
|
||||
|
||||
<div
|
||||
class="emotion-0 emotion-1"
|
||||
>
|
||||
test
|
||||
</div>
|
||||
`;
|
||||
exports[`<Label /> component should render the component in default state 1`] = `"<div class=\\"css-1xfhjjm esyufg60\\">test</div>"`;
|
||||
|
||||
@@ -1,29 +1,33 @@
|
||||
import styled from '@emotion/styled';
|
||||
import { css } from '@emotion/core';
|
||||
import styled from '@emotion/styled';
|
||||
|
||||
import { Theme } from '../../design-tokens/theme';
|
||||
import colors from '../../utils/styles/colors';
|
||||
|
||||
export const Content = styled('div')<{ theme?: Theme }>(props => ({
|
||||
backgroundColor: props.theme && props.theme.palette.white,
|
||||
flex: 1,
|
||||
display: 'flex',
|
||||
position: 'relative',
|
||||
flexDirection: 'column',
|
||||
}));
|
||||
export const Content = styled('div')({
|
||||
'&&': {
|
||||
backgroundColor: colors.white,
|
||||
flex: 1,
|
||||
display: 'flex',
|
||||
position: 'relative',
|
||||
flexDirection: 'column',
|
||||
},
|
||||
});
|
||||
|
||||
interface ContainerProps {
|
||||
isLoading: boolean;
|
||||
}
|
||||
|
||||
export const Container = styled('div')<ContainerProps>(props => ({
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
minHeight: '100vh',
|
||||
overflow: 'hidden',
|
||||
...(props.isLoading &&
|
||||
css`
|
||||
${Content} {
|
||||
background-color: #f5f6f8;
|
||||
}
|
||||
`),
|
||||
}));
|
||||
export const Container = styled('div')`
|
||||
&& {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
min-height: 100vh;
|
||||
overflow: hidden;
|
||||
${({ isLoading }: ContainerProps) =>
|
||||
isLoading &&
|
||||
css`
|
||||
${Content} {
|
||||
background-color: #f5f6f8;
|
||||
}
|
||||
`}
|
||||
`;
|
||||
|
||||
@@ -7,26 +7,20 @@ interface Props extends Pick<TextProps, 'variant'> {
|
||||
external?: boolean;
|
||||
className?: string;
|
||||
to: string;
|
||||
children?: React.ReactNode;
|
||||
}
|
||||
|
||||
type LinkRef = HTMLAnchorElement;
|
||||
|
||||
/* eslint-disable verdaccio/jsx-spread */
|
||||
const Link = React.forwardRef<LinkRef, Props>(function Link(
|
||||
{ external, to, children, variant, className, ...props },
|
||||
ref
|
||||
) {
|
||||
const Link: React.FC<Props> = ({ external, to, children, variant, className, ...props }) => {
|
||||
const LinkTextContent = <Text variant={variant}>{children}</Text>;
|
||||
return external ? (
|
||||
<a className={className} href={to} ref={ref} rel="noopener noreferrer" target="_blank" {...props}>
|
||||
<a className={className} href={to} rel="noopener noreferrer" target="_blank" {...props}>
|
||||
{LinkTextContent}
|
||||
</a>
|
||||
) : (
|
||||
<RouterLink className={className} innerRef={ref} to={to} {...props}>
|
||||
<RouterLink className={className} to={to} {...props}>
|
||||
{LinkTextContent}
|
||||
</RouterLink>
|
||||
);
|
||||
});
|
||||
};
|
||||
|
||||
export default Link;
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
import React from 'react';
|
||||
|
||||
import { render } from '../../utils/test-react-testing-library';
|
||||
import { shallow } from 'enzyme';
|
||||
|
||||
import Loading from './Loading';
|
||||
|
||||
describe('<Loading /> component', () => {
|
||||
test('should render the component in default state', () => {
|
||||
const { container } = render(<Loading />);
|
||||
expect(container.firstChild).toMatchSnapshot();
|
||||
const wrapper = shallow(<Loading />);
|
||||
expect(wrapper.html()).toMatchSnapshot();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,86 +1,3 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`<Loading /> component should render the component in default state 1`] = `
|
||||
.emotion-8 {
|
||||
-webkit-transform: translate(-50%,-50%);
|
||||
-ms-transform: translate(-50%,-50%);
|
||||
transform: translate(-50%,-50%);
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
position: absolute;
|
||||
}
|
||||
|
||||
.emotion-2 {
|
||||
margin: 0 0 30px 0;
|
||||
border-radius: 25px;
|
||||
box-shadow: 0 10px 20px 0 rgba(69,58,100,0.2);
|
||||
background: #f7f8f6;
|
||||
}
|
||||
|
||||
.emotion-0 {
|
||||
display: inline-block;
|
||||
vertical-align: middle;
|
||||
box-sizing: border-box;
|
||||
background-position: center;
|
||||
background-size: contain;
|
||||
background-image: url([object Object]);
|
||||
background-repeat: no-repeat;
|
||||
width: 90px;
|
||||
height: 90px;
|
||||
}
|
||||
|
||||
.emotion-6 {
|
||||
display: -webkit-box;
|
||||
display: -webkit-flex;
|
||||
display: -ms-flexbox;
|
||||
display: flex;
|
||||
-webkit-align-items: center;
|
||||
-webkit-box-align: center;
|
||||
-ms-flex-align: center;
|
||||
align-items: center;
|
||||
-webkit-box-pack: center;
|
||||
-webkit-justify-content: center;
|
||||
-ms-flex-pack: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.emotion-4 {
|
||||
color: #4b5e40;
|
||||
}
|
||||
|
||||
<div
|
||||
class="emotion-8 emotion-9"
|
||||
data-testid="loading"
|
||||
>
|
||||
<div
|
||||
class="emotion-2 emotion-3"
|
||||
>
|
||||
<div
|
||||
class="emotion-0 emotion-1"
|
||||
/>
|
||||
</div>
|
||||
<div
|
||||
class="emotion-6 emotion-7"
|
||||
>
|
||||
<div
|
||||
class="MuiCircularProgress-root emotion-4 emotion-5 MuiCircularProgress-colorPrimary MuiCircularProgress-indeterminate"
|
||||
role="progressbar"
|
||||
style="width: 50px; height: 50px;"
|
||||
>
|
||||
<svg
|
||||
class="MuiCircularProgress-svg"
|
||||
viewBox="22 22 44 44"
|
||||
>
|
||||
<circle
|
||||
class="MuiCircularProgress-circle MuiCircularProgress-circleIndeterminate"
|
||||
cx="44"
|
||||
cy="44"
|
||||
fill="none"
|
||||
r="20.2"
|
||||
stroke-width="3.6"
|
||||
/>
|
||||
</svg>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
exports[`<Loading /> component should render the component in default state 1`] = `"<div data-testid=\\"loading\\" class=\\"css-1221txa eimgwje0\\"><div class=\\"css-bxochs eimgwje1\\"><div class=\\"css-ge0nak em793ed0\\"></div></div><div class=\\"css-vqrgi e1ag4h8b0\\"><div class=\\"MuiCircularProgress-root css-15gl0ho e1ag4h8b1 MuiCircularProgress-colorPrimary MuiCircularProgress-indeterminate\\" style=\\"width:50px;height:50px\\" role=\\"progressbar\\"><svg class=\\"MuiCircularProgress-svg\\" viewBox=\\"22 22 44 44\\"><circle class=\\"MuiCircularProgress-circle MuiCircularProgress-circleIndeterminate\\" cx=\\"44\\" cy=\\"44\\" r=\\"20.2\\" fill=\\"none\\" stroke-width=\\"3.6\\"></circle></svg></div></div></div>"`;
|
||||
|
||||
@@ -1,15 +1,19 @@
|
||||
import styled from '@emotion/styled';
|
||||
|
||||
export const Wrapper = styled('div')({
|
||||
transform: 'translate(-50%, -50%)',
|
||||
top: '50%',
|
||||
left: '50%',
|
||||
position: 'absolute',
|
||||
});
|
||||
export const Wrapper = styled('div')`
|
||||
&& {
|
||||
transform: translate(-50%, -50%);
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
position: absolute;
|
||||
}
|
||||
`;
|
||||
|
||||
export const Badge = styled('div')({
|
||||
margin: '0 0 30px 0',
|
||||
borderRadius: 25,
|
||||
boxShadow: '0 10px 20px 0 rgba(69, 58, 100, 0.2)',
|
||||
background: '#f7f8f6',
|
||||
});
|
||||
export const Badge = styled('div')`
|
||||
&& {
|
||||
margin: 0 0 30px 0;
|
||||
border-radius: 25px;
|
||||
box-shadow: 0 10px 20px 0 rgba(69, 58, 100, 0.2);
|
||||
background: #f7f8f6;
|
||||
}
|
||||
`;
|
||||
|
||||
126
src/components/Login/Login.test.tsx
Normal file
126
src/components/Login/Login.test.tsx
Normal file
@@ -0,0 +1,126 @@
|
||||
/**
|
||||
* @prettier
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import { mount } from 'enzyme';
|
||||
|
||||
import LoginModal from './Login';
|
||||
|
||||
const eventUsername = {
|
||||
target: {
|
||||
value: 'xyz',
|
||||
},
|
||||
};
|
||||
|
||||
const eventPassword = {
|
||||
target: {
|
||||
value: '1234',
|
||||
},
|
||||
};
|
||||
|
||||
const event = {
|
||||
preventDefault: jest.fn(),
|
||||
};
|
||||
|
||||
describe('<LoginModal />', () => {
|
||||
test('should load the component in default state', () => {
|
||||
const wrapper = mount(<LoginModal />);
|
||||
expect(wrapper.html()).toMatchSnapshot();
|
||||
});
|
||||
|
||||
test('should load the component with props', () => {
|
||||
const props = {
|
||||
visibility: true,
|
||||
error: {
|
||||
type: 'error',
|
||||
title: 'Error Title',
|
||||
description: 'Error Description',
|
||||
},
|
||||
onCancel: () => {},
|
||||
onSubmit: () => {},
|
||||
};
|
||||
const wrapper = mount(<LoginModal {...props} />);
|
||||
expect(wrapper.html()).toMatchSnapshot();
|
||||
});
|
||||
|
||||
test('onCancel: should close the login modal', () => {
|
||||
const props = {
|
||||
visibility: true,
|
||||
error: {
|
||||
type: 'error',
|
||||
title: 'Error Title',
|
||||
description: 'Error Description',
|
||||
},
|
||||
onCancel: jest.fn(),
|
||||
onSubmit: () => {},
|
||||
};
|
||||
const wrapper = mount(<LoginModal {...props} />);
|
||||
wrapper.find('button[id="login--form-cancel"]').simulate('click');
|
||||
expect(props.onCancel).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
test('setCredentials - should set username and password in state', () => {
|
||||
const props = {
|
||||
visibility: true,
|
||||
onCancel: () => {},
|
||||
onSubmit: () => {},
|
||||
};
|
||||
const wrapper = mount<LoginModal>(<LoginModal {...props} />);
|
||||
const { setCredentials } = wrapper.instance();
|
||||
|
||||
expect(setCredentials('username', eventUsername)).toBeUndefined();
|
||||
expect(wrapper.state('form').username.value).toEqual('xyz');
|
||||
|
||||
expect(setCredentials('password', eventPassword)).toBeUndefined();
|
||||
expect(wrapper.state('form').password.value).toEqual('1234');
|
||||
});
|
||||
|
||||
test('validateCredentials: should validate credentials', async () => {
|
||||
const props = {
|
||||
visibility: true,
|
||||
onCancel: () => {},
|
||||
onSubmit: jest.fn(),
|
||||
};
|
||||
|
||||
const wrapper = mount<LoginModal>(<LoginModal {...props} />);
|
||||
const instance = wrapper.instance();
|
||||
|
||||
instance.submitCredentials = jest.fn();
|
||||
const { handleValidateCredentials, setCredentials, submitCredentials } = instance;
|
||||
|
||||
expect(setCredentials('username', eventUsername)).toBeUndefined();
|
||||
expect(wrapper.state('form').username.value).toEqual('xyz');
|
||||
|
||||
expect(setCredentials('password', eventPassword)).toBeUndefined();
|
||||
expect(wrapper.state('form').password.value).toEqual('1234');
|
||||
|
||||
handleValidateCredentials(event);
|
||||
expect(event.preventDefault).toHaveBeenCalled();
|
||||
expect(wrapper.state('form').username.pristine).toEqual(false);
|
||||
expect(wrapper.state('form').password.pristine).toEqual(false);
|
||||
|
||||
expect(submitCredentials).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
test('submitCredentials: should submit credentials', async () => {
|
||||
const props = {
|
||||
onSubmit: jest.fn(),
|
||||
};
|
||||
|
||||
const wrapper = mount<LoginModal>(<LoginModal {...props} />);
|
||||
const { setCredentials, submitCredentials } = wrapper.instance();
|
||||
expect(setCredentials('username', eventUsername)).toBeUndefined();
|
||||
expect(wrapper.state('form').username.value).toEqual('xyz');
|
||||
|
||||
expect(setCredentials('password', eventPassword)).toBeUndefined();
|
||||
expect(wrapper.state('form').password.value).toEqual('1234');
|
||||
|
||||
await submitCredentials();
|
||||
expect(props.onSubmit).toHaveBeenCalledWith('xyz', '1234');
|
||||
expect(wrapper.state('form').username.value).toEqual('');
|
||||
expect(wrapper.state('form').username.pristine).toEqual(true);
|
||||
expect(wrapper.state('form').password.value).toEqual('');
|
||||
expect(wrapper.state('form').password.pristine).toEqual(true);
|
||||
});
|
||||
});
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user