forked from sombochea/verdaccio-ui
Merge branch 'master' into juanpicado-patch-1
This commit is contained in:
commit
521e11a453
@ -12,7 +12,8 @@
|
|||||||
"jest",
|
"jest",
|
||||||
"prettier",
|
"prettier",
|
||||||
"verdaccio",
|
"verdaccio",
|
||||||
"jsx-a11y"
|
"jsx-a11y",
|
||||||
|
"codeceptjs"
|
||||||
],
|
],
|
||||||
"settings": {
|
"settings": {
|
||||||
"react": {
|
"react": {
|
||||||
@ -119,6 +120,7 @@
|
|||||||
},
|
},
|
||||||
"env": {
|
"env": {
|
||||||
"browser": true,
|
"browser": true,
|
||||||
"jest/globals": true
|
"jest/globals": true,
|
||||||
|
"codeceptjs/codeceptjs": true,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
"no-descending-specificity": [true, { "severity": "warning" }],
|
"no-descending-specificity": [true, { "severity": "warning" }],
|
||||||
"no-duplicate-at-import-rules": true,
|
"no-duplicate-at-import-rules": true,
|
||||||
"no-duplicate-selectors": true,
|
"no-duplicate-selectors": true,
|
||||||
|
"no-empty-source": null,
|
||||||
"no-extra-semicolons": true,
|
"no-extra-semicolons": true,
|
||||||
"no-invalid-double-slash-comments": true,
|
"no-invalid-double-slash-comments": true,
|
||||||
"property-no-unknown": true,
|
"property-no-unknown": true,
|
||||||
|
42
CHANGELOG.md
42
CHANGELOG.md
@ -2,6 +2,48 @@
|
|||||||
|
|
||||||
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
||||||
|
|
||||||
|
<a name="0.2.2"></a>
|
||||||
|
## [0.2.2](https://github.com/verdaccio/ui/compare/v0.2.1...v0.2.2) (2019-07-29)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* css repetition is not closed in Logo component ([ec243b1](https://github.com/verdaccio/ui/commit/ec243b1))
|
||||||
|
* localhost domain download tarball button ([cca2c3c](https://github.com/verdaccio/ui/commit/cca2c3c))
|
||||||
|
* proxy webpack setting ([5c484bb](https://github.com/verdaccio/ui/commit/5c484bb))
|
||||||
|
* token were not being send it ([fd74c52](https://github.com/verdaccio/ui/commit/fd74c52))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<a name="0.2.1"></a>
|
||||||
|
## [0.2.1](https://github.com/verdaccio/ui/compare/v0.2.0...v0.2.1) (2019-07-10)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* [@typescript-eslint](https://github.com/typescript-eslint)/explicit-function-return-type ([31c11f2](https://github.com/verdaccio/ui/commit/31c11f2))
|
||||||
|
* [@typescript-eslint](https://github.com/typescript-eslint)/explicit-member-accessibility ([55f50e9](https://github.com/verdaccio/ui/commit/55f50e9))
|
||||||
|
* [@typescript-eslint](https://github.com/typescript-eslint)/no-explicit-any ([2f28ade](https://github.com/verdaccio/ui/commit/2f28ade))
|
||||||
|
* [@typescript-eslint](https://github.com/typescript-eslint)/no-explicit-any ([6eec4f4](https://github.com/verdaccio/ui/commit/6eec4f4))
|
||||||
|
* [@typescript-eslint](https://github.com/typescript-eslint)/no-explicit-any ([ec8ed12](https://github.com/verdaccio/ui/commit/ec8ed12))
|
||||||
|
* [@typescript-eslint](https://github.com/typescript-eslint)/no-explicit-any for file-size.ts ([b683b68](https://github.com/verdaccio/ui/commit/b683b68))
|
||||||
|
* add missing global font-family ([c57f9dd](https://github.com/verdaccio/ui/commit/c57f9dd))
|
||||||
|
* added packageMeta type ([3c54b11](https://github.com/verdaccio/ui/commit/3c54b11))
|
||||||
|
* container breakpoint ([60b7161](https://github.com/verdaccio/ui/commit/60b7161))
|
||||||
|
* incorrect logos styles ([fdad635](https://github.com/verdaccio/ui/commit/fdad635)), closes [#47](https://github.com/verdaccio/ui/issues/47)
|
||||||
|
* logo component styled ([210bcf3](https://github.com/verdaccio/ui/commit/210bcf3))
|
||||||
|
* remove any types and added additional component state interfaces ([116055c](https://github.com/verdaccio/ui/commit/116055c))
|
||||||
|
* remove token from AppState ([78b4c3f](https://github.com/verdaccio/ui/commit/78b4c3f))
|
||||||
|
* remove undefined error ([d1ed3e7](https://github.com/verdaccio/ui/commit/d1ed3e7))
|
||||||
|
* support deprecated license object properties ([b2e420d](https://github.com/verdaccio/ui/commit/b2e420d))
|
||||||
|
* type lint for login ([91e603e](https://github.com/verdaccio/ui/commit/91e603e))
|
||||||
|
* typescript warnings - prefer-rest-params ([e33570b](https://github.com/verdaccio/ui/commit/e33570b))
|
||||||
|
* update snapshot for verdaccio/jsx-no-style ([e7d145f](https://github.com/verdaccio/ui/commit/e7d145f))
|
||||||
|
* updated type to fix unit test ([7cab3f2](https://github.com/verdaccio/ui/commit/7cab3f2))
|
||||||
|
* verdaccio/jsx-no-style ([55b1402](https://github.com/verdaccio/ui/commit/55b1402))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<a name="0.2.0"></a>
|
<a name="0.2.0"></a>
|
||||||
# [0.2.0](https://github.com/verdaccio/ui/compare/v0.1.11...v0.2.0) (2019-06-20)
|
# [0.2.0](https://github.com/verdaccio/ui/compare/v0.1.11...v0.2.0) (2019-06-20)
|
||||||
|
|
||||||
|
21
codecept.conf.js
Normal file
21
codecept.conf.js
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
exports.config = {
|
||||||
|
tests: './test/acceptance/*_test.js',
|
||||||
|
output: './test/acceptance/output',
|
||||||
|
helpers: {
|
||||||
|
Puppeteer: {
|
||||||
|
url: 'http://localhost:8080',
|
||||||
|
// "show": true,
|
||||||
|
chrome: {
|
||||||
|
// headless: false
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
include: {
|
||||||
|
I: './test/acceptance/steps_file.js',
|
||||||
|
},
|
||||||
|
smartWait: 30000,
|
||||||
|
bootstrap: null,
|
||||||
|
plugins: {},
|
||||||
|
mocha: {},
|
||||||
|
name: '@verdaccio/ui-theme',
|
||||||
|
};
|
@ -39,8 +39,8 @@ const register = (url, method = 'get', options = {}) => {
|
|||||||
* Bind API methods
|
* Bind API methods
|
||||||
*/
|
*/
|
||||||
class API {
|
class API {
|
||||||
request() {
|
public request(...rest) {
|
||||||
return register.call(null, ...arguments);
|
return register.call(null, ...rest);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,6 +2,6 @@
|
|||||||
* Mock response for logo api
|
* Mock response for logo api
|
||||||
* @returns {promise}
|
* @returns {promise}
|
||||||
*/
|
*/
|
||||||
export default function() {
|
export default function<T>(): Promise<T> {
|
||||||
return Promise.resolve('http://localhost/-/static/logo.png');
|
return Promise.resolve('http://localhost/-/static/logo.png');
|
||||||
}
|
}
|
||||||
|
60
package.json
60
package.json
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@verdaccio/ui-theme",
|
"name": "@verdaccio/ui-theme",
|
||||||
"version": "0.2.0",
|
"version": "0.2.2",
|
||||||
"description": "Verdaccio User Interface",
|
"description": "Verdaccio User Interface",
|
||||||
"author": {
|
"author": {
|
||||||
"name": "Verdaccio Core Team"
|
"name": "Verdaccio Core Team"
|
||||||
@ -11,44 +11,47 @@
|
|||||||
},
|
},
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@commitlint/cli": "8.0.0",
|
"@commitlint/cli": "8.1.0",
|
||||||
"@commitlint/config-conventional": "8.0.0",
|
"@commitlint/config-conventional": "8.1.0",
|
||||||
"@material-ui/core": "3.9.3",
|
"@material-ui/core": "3.9.3",
|
||||||
"@material-ui/icons": "3.0.2",
|
"@material-ui/icons": "3.0.2",
|
||||||
"@octokit/rest": "16.23.2",
|
"@octokit/rest": "16.28.7",
|
||||||
"@types/enzyme": "3.9.3",
|
"@types/enzyme": "3.10.3",
|
||||||
"@types/lodash": "4.14.134",
|
"@types/lodash": "4.14.136",
|
||||||
"@types/material-ui": "0.21.6",
|
"@types/material-ui": "0.21.6",
|
||||||
"@types/node": "12.0.8",
|
"@types/node": "12.6.9",
|
||||||
"@types/react": "16.8.16",
|
"@types/react": "16.8.24",
|
||||||
"@types/react-dom": "16.8.4",
|
"@types/react-dom": "16.8.5",
|
||||||
"@types/react-router-dom": "4.3.2",
|
"@types/react-router-dom": "4.3.4",
|
||||||
"@verdaccio/babel-preset": "0.2.1",
|
"@types/validator": "10.11.2",
|
||||||
"@verdaccio/eslint-config": "0.0.1",
|
"@verdaccio/babel-preset": "2.0.0",
|
||||||
"@verdaccio/types": "6.1.0",
|
"@verdaccio/eslint-config": "2.0.0",
|
||||||
|
"@verdaccio/types": "8.0.0-next.2",
|
||||||
"autosuggest-highlight": "3.1.1",
|
"autosuggest-highlight": "3.1.1",
|
||||||
"babel-loader": "8.0.6",
|
"babel-loader": "8.0.6",
|
||||||
"bundlesize": "0.17.2",
|
"bundlesize": "0.18.0",
|
||||||
|
"codeceptjs": "2.1.0",
|
||||||
"codecov": "3.5.0",
|
"codecov": "3.5.0",
|
||||||
"concurrently": "4.1.0",
|
"concurrently": "4.1.1",
|
||||||
"cross-env": "5.2.0",
|
"cross-env": "5.2.0",
|
||||||
"css-loader": "0.28.10",
|
"css-loader": "0.28.10",
|
||||||
"date-fns": "1.30.1",
|
"date-fns": "1.30.1",
|
||||||
"emotion": "9.2.12",
|
"emotion": "9.2.12",
|
||||||
"enzyme": "3.10.0",
|
"enzyme": "3.10.0",
|
||||||
"enzyme-adapter-react-16": "1.14.0",
|
"enzyme-adapter-react-16": "1.14.0",
|
||||||
"enzyme-to-json": "3.3.5",
|
"enzyme-to-json": "3.4.0",
|
||||||
"eslint": "5.16.0",
|
"eslint": "5.16.0",
|
||||||
|
"eslint-plugin-codeceptjs": "1.0.0",
|
||||||
"eslint-plugin-jsx-a11y": "6.2.1",
|
"eslint-plugin-jsx-a11y": "6.2.1",
|
||||||
"eslint-plugin-prettier": "3.1.0",
|
"eslint-plugin-prettier": "3.1.0",
|
||||||
"eslint-plugin-react": "7.13.0",
|
"eslint-plugin-react": "7.13.0",
|
||||||
"eslint-plugin-verdaccio": "0.0.5",
|
"eslint-plugin-verdaccio": "2.0.0",
|
||||||
"file-loader": "2.0.0",
|
"file-loader": "2.0.0",
|
||||||
"friendly-errors-webpack-plugin": "1.7.0",
|
"friendly-errors-webpack-plugin": "1.7.0",
|
||||||
"get-stdin": "6.0.0",
|
"get-stdin": "6.0.0",
|
||||||
"github-markdown-css": "2.10.0",
|
"github-markdown-css": "2.10.0",
|
||||||
"html-webpack-plugin": "3.2.0",
|
"html-webpack-plugin": "3.2.0",
|
||||||
"husky": "2.4.1",
|
"husky": "3.0.2",
|
||||||
"identity-obj-proxy": "3.0.0",
|
"identity-obj-proxy": "3.0.0",
|
||||||
"in-publish": "2.0.0",
|
"in-publish": "2.0.0",
|
||||||
"jest": "24.8.0",
|
"jest": "24.8.0",
|
||||||
@ -60,7 +63,6 @@
|
|||||||
"localstorage-memory": "1.0.3",
|
"localstorage-memory": "1.0.3",
|
||||||
"mini-css-extract-plugin": "0.7.0",
|
"mini-css-extract-plugin": "0.7.0",
|
||||||
"node-mocks-http": "1.7.3",
|
"node-mocks-http": "1.7.3",
|
||||||
"node-sass": "4.12.0",
|
|
||||||
"normalize.css": "8.0.1",
|
"normalize.css": "8.0.1",
|
||||||
"optimize-css-assets-webpack-plugin": "5.0.1",
|
"optimize-css-assets-webpack-plugin": "5.0.1",
|
||||||
"ora": "3.4.0",
|
"ora": "3.4.0",
|
||||||
@ -76,30 +78,27 @@
|
|||||||
"react-router-dom": "4.3.1",
|
"react-router-dom": "4.3.1",
|
||||||
"resolve-url-loader": "3.0.1",
|
"resolve-url-loader": "3.0.1",
|
||||||
"rimraf": "2.6.3",
|
"rimraf": "2.6.3",
|
||||||
"sass-loader": "7.1.0",
|
|
||||||
"source-map-loader": "0.2.4",
|
"source-map-loader": "0.2.4",
|
||||||
"standard-version": "4.4.0",
|
"standard-version": "4.4.0",
|
||||||
"style-loader": "0.23.1",
|
"style-loader": "0.23.1",
|
||||||
"stylelint": "10.1.0",
|
"stylelint": "10.1.0",
|
||||||
"stylelint-config-recommended": "2.2.0",
|
"stylelint-config-recommended": "2.2.0",
|
||||||
"stylelint-config-recommended-scss": "3.3.0",
|
|
||||||
"stylelint-config-styled-components": "0.1.1",
|
"stylelint-config-styled-components": "0.1.1",
|
||||||
"stylelint-processor-styled-components": "1.8.0",
|
"stylelint-processor-styled-components": "1.8.0",
|
||||||
"stylelint-scss": "3.8.0",
|
|
||||||
"stylelint-webpack-plugin": "0.10.5",
|
"stylelint-webpack-plugin": "0.10.5",
|
||||||
"supertest": "4.0.2",
|
"supertest": "4.0.2",
|
||||||
"typeface-roboto": "0.0.54",
|
"typeface-roboto": "0.0.54",
|
||||||
"typescript": "3.4.5",
|
"typescript": "3.5.3",
|
||||||
"url-loader": "1.1.2",
|
"url-loader": "1.1.2",
|
||||||
"validator": "10.11.0",
|
"validator": "10.11.0",
|
||||||
"verdaccio": "4.0.3",
|
"verdaccio": "4.2.0",
|
||||||
"verdaccio-auth-memory": "0.0.4",
|
"verdaccio-auth-memory": "1.1.5",
|
||||||
"verdaccio-memory": "2.0.0",
|
"verdaccio-memory": "2.0.0",
|
||||||
"webpack": "4.20.2",
|
"webpack": "4.20.2",
|
||||||
"webpack-bundle-analyzer": "3.3.2",
|
"webpack-bundle-analyzer": "3.3.2",
|
||||||
"webpack-bundle-size-analyzer": "3.0.0",
|
"webpack-bundle-size-analyzer": "3.0.0",
|
||||||
"webpack-cli": "3.2.3",
|
"webpack-cli": "3.3.6",
|
||||||
"webpack-dev-server": "3.2.1",
|
"webpack-dev-server": "3.7.2",
|
||||||
"webpack-merge": "4.2.1",
|
"webpack-merge": "4.2.1",
|
||||||
"whatwg-fetch": "3.0.0",
|
"whatwg-fetch": "3.0.0",
|
||||||
"xss": "1.0.6"
|
"xss": "1.0.6"
|
||||||
@ -139,7 +138,10 @@
|
|||||||
"type-check": "tsc --noEmit",
|
"type-check": "tsc --noEmit",
|
||||||
"type-check:watch": "npm run type-check -- --watch",
|
"type-check:watch": "npm run type-check -- --watch",
|
||||||
"release": "standard-version -a -s",
|
"release": "standard-version -a -s",
|
||||||
"test": "cross-env NODE_ENV=test BABEL_ENV=test TZ=UTC jest --config ./jest/jest.config.js --maxWorkers 2",
|
"test:clean": "npx jest --clearCache",
|
||||||
|
"test:acceptance": "codeceptjs run --steps",
|
||||||
|
"test:acceptance:server": "concurrently --kill-others \"npm run verdaccio:server\" \"npm run test:acceptance\"",
|
||||||
|
"test": "cross-env NODE_ENV=test BABEL_ENV=test TZ=UTC jest --config ./jest/jest.config.js --maxWorkers 2 --passWithNoTests",
|
||||||
"test:size": "bundlesize",
|
"test:size": "bundlesize",
|
||||||
"lint": "npm run lint:js && npm run lint:css",
|
"lint": "npm run lint:js && npm run lint:css",
|
||||||
"lint:js": "npm run type-check && eslint . --ext .js,.ts,.tsx",
|
"lint:js": "npm run type-check && eslint . --ext .js,.ts,.tsx",
|
||||||
@ -160,7 +162,7 @@
|
|||||||
},
|
},
|
||||||
"husky": {
|
"husky": {
|
||||||
"hooks": {
|
"hooks": {
|
||||||
"pre-commit": "commitlint -e $GIT_PARAMS"
|
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
1
partials/storage/.verdaccio-db.json
Normal file
1
partials/storage/.verdaccio-db.json
Normal file
@ -0,0 +1 @@
|
|||||||
|
{"list":["vue","jquery"],"secret":"3bb332943c7086716a35dea44754b43b956ee655af1fe61866fbdaf38486836c"}
|
BIN
partials/storage/jquery/jquery-1.5.1.tgz
Normal file
BIN
partials/storage/jquery/jquery-1.5.1.tgz
Normal file
Binary file not shown.
4919
partials/storage/jquery/package.json
Normal file
4919
partials/storage/jquery/package.json
Normal file
File diff suppressed because it is too large
Load Diff
25169
partials/storage/vue/package.json
Normal file
25169
partials/storage/vue/package.json
Normal file
File diff suppressed because one or more lines are too long
@ -7,7 +7,7 @@ import { generateTokenWithTimeRange } from '../../jest/unit/components/__mocks__
|
|||||||
|
|
||||||
jest.mock('../utils/storage', () => {
|
jest.mock('../utils/storage', () => {
|
||||||
class LocalStorageMock {
|
class LocalStorageMock {
|
||||||
store: object;
|
private store: object;
|
||||||
public constructor() {
|
public constructor() {
|
||||||
this.store = {};
|
this.store = {};
|
||||||
}
|
}
|
||||||
@ -43,7 +43,7 @@ describe('App', () => {
|
|||||||
expect(wrapper.state().showLoginModal).toBeFalsy();
|
expect(wrapper.state().showLoginModal).toBeFalsy();
|
||||||
handleToggleLoginModal();
|
handleToggleLoginModal();
|
||||||
expect(wrapper.state('showLoginModal')).toBeTruthy();
|
expect(wrapper.state('showLoginModal')).toBeTruthy();
|
||||||
expect(wrapper.state('error')).toEqual({});
|
expect(wrapper.state('error')).toEqual(undefined);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('isUserAlreadyLoggedIn: token already available in storage', async () => {
|
test('isUserAlreadyLoggedIn: token already available in storage', async () => {
|
||||||
@ -71,7 +71,6 @@ describe('App', () => {
|
|||||||
await handleDoLogin('sam', '1234');
|
await handleDoLogin('sam', '1234');
|
||||||
const result = {
|
const result = {
|
||||||
username: 'sam',
|
username: 'sam',
|
||||||
token: 'TEST_TOKEN',
|
|
||||||
};
|
};
|
||||||
expect(wrapper.state('isUserLoggedIn')).toBeTruthy();
|
expect(wrapper.state('isUserLoggedIn')).toBeTruthy();
|
||||||
expect(wrapper.state('showLoginModal')).toBeFalsy();
|
expect(wrapper.state('showLoginModal')).toBeFalsy();
|
||||||
|
@ -10,18 +10,30 @@ import Header from '../components/Header';
|
|||||||
import { Container, Content } from '../components/Layout';
|
import { Container, Content } from '../components/Layout';
|
||||||
import RouterApp from '../router';
|
import RouterApp from '../router';
|
||||||
import API from '../utils/api';
|
import API from '../utils/api';
|
||||||
import '../styles/typeface-roboto.scss';
|
import '../styles/typeface-roboto.css';
|
||||||
import '../styles/main.scss';
|
import '../utils/styles/global';
|
||||||
import 'normalize.css';
|
import 'normalize.css';
|
||||||
import Footer from '../components/Footer';
|
import Footer from '../components/Footer';
|
||||||
|
import { FormError } from 'src/components/Login/Login';
|
||||||
|
|
||||||
export const AppContext = React.createContext<null>(null);
|
export const AppContext = React.createContext<{}>({});
|
||||||
export const AppContextProvider = AppContext.Provider;
|
export const AppContextProvider = AppContext.Provider;
|
||||||
export const AppContextConsumer = AppContext.Consumer;
|
export const AppContextConsumer = AppContext.Consumer;
|
||||||
|
|
||||||
export default class App extends Component<any, any> {
|
export interface AppStateInterface {
|
||||||
public state = {
|
error?: FormError;
|
||||||
error: {},
|
logoUrl: string;
|
||||||
|
user: {
|
||||||
|
username?: string;
|
||||||
|
};
|
||||||
|
scope: string;
|
||||||
|
showLoginModal: boolean;
|
||||||
|
isUserLoggedIn: boolean;
|
||||||
|
packages: [];
|
||||||
|
isLoading: boolean;
|
||||||
|
}
|
||||||
|
export default class App extends Component<{}, AppStateInterface> {
|
||||||
|
public state: AppStateInterface = {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
logoUrl: window.VERDACCIO_LOGO,
|
logoUrl: window.VERDACCIO_LOGO,
|
||||||
user: {},
|
user: {},
|
||||||
@ -49,18 +61,12 @@ export default class App extends Component<any, any> {
|
|||||||
public render(): React.ReactElement<HTMLDivElement> {
|
public render(): React.ReactElement<HTMLDivElement> {
|
||||||
const { isLoading, isUserLoggedIn, packages, logoUrl, user, scope } = this.state;
|
const { isLoading, isUserLoggedIn, packages, logoUrl, user, scope } = this.state;
|
||||||
|
|
||||||
const context: any = { isUserLoggedIn, packages, logoUrl, user, scope };
|
const context = { isUserLoggedIn, packages, logoUrl, user, scope };
|
||||||
|
|
||||||
return (
|
return (
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
<Container isLoading={isLoading}>
|
<Container isLoading={isLoading}>
|
||||||
{isLoading ? (
|
{isLoading ? <Loading /> : <AppContextProvider value={context}>{this.renderContent()}</AppContextProvider>}
|
||||||
<Loading />
|
|
||||||
) : (
|
|
||||||
<>
|
|
||||||
<AppContextProvider value={context}>{this.renderContent()}</AppContextProvider>
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
{this.renderLoginModal()}
|
{this.renderLoginModal()}
|
||||||
</Container>
|
</Container>
|
||||||
);
|
);
|
||||||
@ -74,7 +80,7 @@ export default class App extends Component<any, any> {
|
|||||||
this.handleLogout();
|
this.handleLogout();
|
||||||
} else {
|
} else {
|
||||||
this.setState({
|
this.setState({
|
||||||
user: { username, token },
|
user: { username },
|
||||||
isUserLoggedIn: true,
|
isUserLoggedIn: true,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -112,7 +118,6 @@ export default class App extends Component<any, any> {
|
|||||||
this.setState(prevState => ({
|
this.setState(prevState => ({
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
showLoginModal: !prevState.showLoginModal,
|
showLoginModal: !prevState.showLoginModal,
|
||||||
error: {},
|
|
||||||
}));
|
}));
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -127,7 +132,7 @@ export default class App extends Component<any, any> {
|
|||||||
if (username && token) {
|
if (username && token) {
|
||||||
storage.setItem('username', username);
|
storage.setItem('username', username);
|
||||||
storage.setItem('token', token);
|
storage.setItem('token', token);
|
||||||
this.setLoggedUser(username, token);
|
this.setLoggedUser(username);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
@ -138,11 +143,10 @@ export default class App extends Component<any, any> {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
public setLoggedUser = (username, token) => {
|
public setLoggedUser = username => {
|
||||||
this.setState({
|
this.setState({
|
||||||
user: {
|
user: {
|
||||||
username,
|
username,
|
||||||
token,
|
|
||||||
},
|
},
|
||||||
isUserLoggedIn: true, // close login modal after successful login
|
isUserLoggedIn: true, // close login modal after successful login
|
||||||
showLoginModal: false, // set isUserLoggedIn to true
|
showLoginModal: false, // set isUserLoggedIn to true
|
||||||
|
@ -1,16 +0,0 @@
|
|||||||
@import './styles/variables';
|
|
||||||
|
|
||||||
.alertError {
|
|
||||||
background-color: $red !important;
|
|
||||||
min-width: inherit !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
.alertErrorMsg {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.alertIcon {
|
|
||||||
opacity: 0.9;
|
|
||||||
margin-right: 8px;
|
|
||||||
}
|
|
17
src/App/styles.ts
Normal file
17
src/App/styles.ts
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
import { css } from 'emotion';
|
||||||
|
import colors from '../utils/styles/colors';
|
||||||
|
|
||||||
|
export const alertError = css({
|
||||||
|
backgroundColor: `${colors.red} !important`,
|
||||||
|
minWidth: 'inherit !important',
|
||||||
|
});
|
||||||
|
|
||||||
|
export const alertErrorMsg = css({
|
||||||
|
display: 'flex',
|
||||||
|
alignItems: 'center',
|
||||||
|
});
|
||||||
|
|
||||||
|
export const alertIcon = css({
|
||||||
|
opacity: 0.9,
|
||||||
|
marginRight: '8px',
|
||||||
|
});
|
73
src/components/ActionBar/ActionBar.test.tsx
Normal file
73
src/components/ActionBar/ActionBar.test.tsx
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import { mount, shallow } from 'enzyme';
|
||||||
|
|
||||||
|
describe('<ActionBar /> component', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
jest.resetModules();
|
||||||
|
});
|
||||||
|
|
||||||
|
test('should render the component in default state', () => {
|
||||||
|
const packageMeta = {
|
||||||
|
latest: {
|
||||||
|
homepage: 'https://verdaccio.tld',
|
||||||
|
bugs: {
|
||||||
|
url: 'https://verdaccio.tld/bugs',
|
||||||
|
},
|
||||||
|
dist: {
|
||||||
|
tarball: 'https://verdaccio.tld/download',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
jest.doMock('../../pages/version/Version', () => ({
|
||||||
|
DetailContextConsumer: component => {
|
||||||
|
return component.children({ packageMeta });
|
||||||
|
},
|
||||||
|
}));
|
||||||
|
|
||||||
|
const ActionBar = require('./ActionBar').default;
|
||||||
|
const wrapper = shallow(<ActionBar />);
|
||||||
|
expect(wrapper.html()).toMatchSnapshot();
|
||||||
|
});
|
||||||
|
|
||||||
|
test('when there is no action bar data', () => {
|
||||||
|
const packageMeta = {
|
||||||
|
latest: {},
|
||||||
|
};
|
||||||
|
|
||||||
|
jest.doMock('../../pages/version/Version', () => ({
|
||||||
|
DetailContextConsumer: component => {
|
||||||
|
return component.children({ packageMeta });
|
||||||
|
},
|
||||||
|
}));
|
||||||
|
|
||||||
|
const ActionBar = require('./ActionBar').default;
|
||||||
|
const wrapper = shallow(<ActionBar />);
|
||||||
|
// FIXME: this only renders the DetailContextConsumer, thus
|
||||||
|
// the wrapper will be always empty
|
||||||
|
expect(wrapper.html()).toEqual('');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('when there is a button to download a tarball', () => {
|
||||||
|
const packageMeta = {
|
||||||
|
latest: {
|
||||||
|
dist: {
|
||||||
|
tarball: 'http://localhost:8080/bootstrap/-/bootstrap-4.3.1.tgz',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
jest.doMock('../../pages/version/Version', () => ({
|
||||||
|
DetailContextConsumer: component => {
|
||||||
|
return component.children({ packageMeta });
|
||||||
|
},
|
||||||
|
}));
|
||||||
|
|
||||||
|
const ActionBar = require('./ActionBar').default;
|
||||||
|
const wrapper = mount(<ActionBar />);
|
||||||
|
expect(wrapper.html()).toMatchSnapshot();
|
||||||
|
|
||||||
|
const button = wrapper.find('button');
|
||||||
|
expect(button).toHaveLength(1);
|
||||||
|
});
|
||||||
|
});
|
@ -8,7 +8,25 @@ import Tooltip from '@material-ui/core/Tooltip';
|
|||||||
|
|
||||||
import { DetailContextConsumer, VersionPageConsumerProps } from '../../pages/version/Version';
|
import { DetailContextConsumer, VersionPageConsumerProps } from '../../pages/version/Version';
|
||||||
import { Fab, ActionListItem } from './styles';
|
import { Fab, ActionListItem } from './styles';
|
||||||
import { isURL } from '../../utils/url';
|
import { isURL, extractFileName, downloadFile } from '../../utils/url';
|
||||||
|
import api from '../../utils/api';
|
||||||
|
|
||||||
|
export interface Action {
|
||||||
|
icon: string;
|
||||||
|
title: string;
|
||||||
|
handler?: Function;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function downloadHandler(link: string): Promise<void> {
|
||||||
|
const fileStream: Blob = await api.request(link, 'GET', {
|
||||||
|
headers: {
|
||||||
|
['accept']: 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3',
|
||||||
|
},
|
||||||
|
credentials: 'include',
|
||||||
|
});
|
||||||
|
const fileName = extractFileName(link);
|
||||||
|
downloadFile(fileStream, fileName);
|
||||||
|
}
|
||||||
|
|
||||||
const ACTIONS = {
|
const ACTIONS = {
|
||||||
homepage: {
|
homepage: {
|
||||||
@ -22,10 +40,11 @@ const ACTIONS = {
|
|||||||
tarball: {
|
tarball: {
|
||||||
icon: <DownloadIcon />,
|
icon: <DownloadIcon />,
|
||||||
title: 'Download tarball',
|
title: 'Download tarball',
|
||||||
|
handler: downloadHandler,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
class ActionBar extends Component<any, any> {
|
class ActionBar extends Component {
|
||||||
public render(): ReactElement<HTMLElement> {
|
public render(): ReactElement<HTMLElement> {
|
||||||
return (
|
return (
|
||||||
<DetailContextConsumer>
|
<DetailContextConsumer>
|
||||||
@ -36,7 +55,7 @@ class ActionBar extends Component<any, any> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private renderIconsWithLink(link: string, component: any): ReactElement<HTMLElement> {
|
private renderIconsWithLink(link: string, component: JSX.Element): ReactElement<HTMLElement> {
|
||||||
return (
|
return (
|
||||||
<a href={link} target={'_blank'}>
|
<a href={link} target={'_blank'}>
|
||||||
{component}
|
{component}
|
||||||
@ -44,7 +63,7 @@ class ActionBar extends Component<any, any> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private renderActionBarListItems = packageMeta => {
|
private renderActionBar = ({ packageMeta }) => {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
const { latest: { bugs: { url: issue } = {}, homepage, dist: { tarball } = {} } = {} } = packageMeta;
|
const { latest: { bugs: { url: issue } = {}, homepage, dist: { tarball } = {} } = {} } = packageMeta;
|
||||||
|
|
||||||
@ -54,29 +73,47 @@ class ActionBar extends Component<any, any> {
|
|||||||
tarball,
|
tarball,
|
||||||
};
|
};
|
||||||
|
|
||||||
const renderList = Object.keys(actionsMap).reduce((component, value, key) => {
|
const renderList = Object.keys(actionsMap).reduce((component: React.ReactElement[], value, key) => {
|
||||||
const link = actionsMap[value];
|
const link = actionsMap[value];
|
||||||
if (link && isURL(link)) {
|
if (link && isURL(link)) {
|
||||||
const fab = <Fab size={'small'}>{ACTIONS[value]['icon']}</Fab>;
|
const actionItem: Action = ACTIONS[value];
|
||||||
component.push(
|
if (actionItem.handler) {
|
||||||
// @ts-ignore
|
const fab = (
|
||||||
<Tooltip key={key} title={ACTIONS[value]['title']}>
|
<Tooltip key={key} title={actionItem['title']}>
|
||||||
<>{this.renderIconsWithLink(link, fab)}</>
|
<Fab
|
||||||
</Tooltip>
|
/* eslint-disable react/jsx-no-bind */
|
||||||
);
|
onClick={() => {
|
||||||
|
/* eslint-disable @typescript-eslint/no-non-null-assertion */
|
||||||
|
actionItem.handler!(link);
|
||||||
|
}}
|
||||||
|
size={'small'}>
|
||||||
|
{actionItem['icon']}
|
||||||
|
</Fab>
|
||||||
|
</Tooltip>
|
||||||
|
);
|
||||||
|
component.push(fab);
|
||||||
|
} else {
|
||||||
|
const fab = <Fab size={'small'}>{actionItem['icon']}</Fab>;
|
||||||
|
component.push(
|
||||||
|
// @ts-ignore
|
||||||
|
<Tooltip key={key} title={actionItem['title']}>
|
||||||
|
<>{this.renderIconsWithLink(link, fab)}</>
|
||||||
|
</Tooltip>
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return component;
|
return component;
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
return (
|
if (renderList.length > 0) {
|
||||||
<>
|
return (
|
||||||
<ActionListItem alignItems={'flex-start'}>{renderList}</ActionListItem>
|
<List>
|
||||||
</>
|
<ActionListItem alignItems={'flex-start'}>{renderList}</ActionListItem>
|
||||||
);
|
</List>
|
||||||
};
|
);
|
||||||
|
}
|
||||||
|
|
||||||
private renderActionBar = ({ packageMeta = {} }) => {
|
return null;
|
||||||
return <List>{this.renderActionBarListItems(packageMeta)}</List>;
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,5 @@
|
|||||||
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||||
|
|
||||||
|
exports[`<ActionBar /> component should render the component in default state 1`] = `"<ul class=\\"MuiList-root-1 MuiList-padding-2\\"><li class=\\"MuiListItem-root-5 MuiListItem-default-8 MuiListItem-gutters-13 MuiListItem-alignItemsFlexStart-10 css-9q3x3c eux6shq0\\"><a href=\\"https://verdaccio.tld\\" target=\\"_blank\\"><button class=\\"MuiButtonBase-root-35 MuiFab-root-25 MuiFab-sizeSmall-33 css-96oxa0 eux6shq1\\" tabindex=\\"0\\" type=\\"button\\"><span class=\\"MuiFab-label-26\\"><svg class=\\"MuiSvgIcon-root-38\\" focusable=\\"false\\" viewBox=\\"0 0 24 24\\" aria-hidden=\\"true\\" role=\\"presentation\\"><path d=\\"M10 20v-6h4v6h5v-8h3L12 3 2 12h3v8z\\"></path><path fill=\\"none\\" d=\\"M0 0h24v24H0z\\"></path></svg></span></button></a><a href=\\"https://verdaccio.tld/bugs\\" target=\\"_blank\\"><button class=\\"MuiButtonBase-root-35 MuiFab-root-25 MuiFab-sizeSmall-33 css-96oxa0 eux6shq1\\" tabindex=\\"0\\" type=\\"button\\"><span class=\\"MuiFab-label-26\\"><svg class=\\"MuiSvgIcon-root-38\\" focusable=\\"false\\" viewBox=\\"0 0 24 24\\" aria-hidden=\\"true\\" role=\\"presentation\\"><path fill=\\"none\\" d=\\"M0 0h24v24H0z\\"></path><path d=\\"M20 8h-2.81c-.45-.78-1.07-1.45-1.82-1.96L17 4.41 15.59 3l-2.17 2.17C12.96 5.06 12.49 5 12 5c-.49 0-.96.06-1.41.17L8.41 3 7 4.41l1.62 1.63C7.88 6.55 7.26 7.22 6.81 8H4v2h2.09c-.05.33-.09.66-.09 1v1H4v2h2v1c0 .34.04.67.09 1H4v2h2.81c1.04 1.79 2.97 3 5.19 3s4.15-1.21 5.19-3H20v-2h-2.09c.05-.33.09-.66.09-1v-1h2v-2h-2v-1c0-.34-.04-.67-.09-1H20V8zm-6 8h-4v-2h4v2zm0-4h-4v-2h4v2z\\"></path></svg></span></button></a><button class=\\"MuiButtonBase-root-35 MuiFab-root-25 MuiFab-sizeSmall-33 css-96oxa0 eux6shq1\\" tabindex=\\"0\\" type=\\"button\\" title=\\"Download tarball\\"><span class=\\"MuiFab-label-26\\"><svg class=\\"MuiSvgIcon-root-38\\" focusable=\\"false\\" viewBox=\\"0 0 24 24\\" aria-hidden=\\"true\\" role=\\"presentation\\"><path fill=\\"none\\" d=\\"M0 0h24v24H0z\\"></path><path d=\\"M19.35 10.04C18.67 6.59 15.64 4 12 4 9.11 4 6.6 5.64 5.35 8.04 2.34 8.36 0 10.91 0 14c0 3.31 2.69 6 6 6h13c2.76 0 5-2.24 5-5 0-2.64-2.05-4.78-4.65-4.96zM17 13l-5 5-5-5h3V9h4v4h3z\\"></path></svg></span></button></li></ul>"`;
|
||||||
|
|
||||||
|
exports[`<ActionBar /> component when there is a button to download a tarball 1`] = `"<ul class=\\"MuiList-root-47 MuiList-padding-48\\"><li class=\\"MuiListItem-root-51 MuiListItem-default-54 MuiListItem-gutters-59 MuiListItem-alignItemsFlexStart-56 css-9q3x3c eux6shq0\\"><button class=\\"MuiButtonBase-root-81 MuiFab-root-71 MuiFab-sizeSmall-79 css-96oxa0 eux6shq1\\" tabindex=\\"0\\" type=\\"button\\" title=\\"Download tarball\\"><span class=\\"MuiFab-label-72\\"><svg class=\\"MuiSvgIcon-root-84\\" focusable=\\"false\\" viewBox=\\"0 0 24 24\\" aria-hidden=\\"true\\" role=\\"presentation\\"><path fill=\\"none\\" d=\\"M0 0h24v24H0z\\"></path><path d=\\"M19.35 10.04C18.67 6.59 15.64 4 12 4 9.11 4 6.6 5.64 5.35 8.04 2.34 8.36 0 10.91 0 14c0 3.31 2.69 6 6 6h13c2.76 0 5-2.24 5-5 0-2.64-2.05-4.78-4.65-4.96zM17 13l-5 5-5-5h3V9h4v4h3z\\"></path></svg></span><span class=\\"MuiTouchRipple-root-93\\"></span></button></li></ul>"`;
|
@ -4,18 +4,18 @@ import ListItem from '@material-ui/core/ListItem';
|
|||||||
|
|
||||||
import colors from '../../utils/styles/colors';
|
import colors from '../../utils/styles/colors';
|
||||||
|
|
||||||
export const ActionListItem = styled(ListItem)`
|
export const ActionListItem = styled(ListItem)({
|
||||||
&& {
|
'&&': {
|
||||||
padding-top: 0;
|
paddingTop: 0,
|
||||||
padding-left: 0;
|
paddingLeft: 0,
|
||||||
padding-right: 0;
|
paddingRight: 0,
|
||||||
}
|
},
|
||||||
`;
|
});
|
||||||
|
|
||||||
export const Fab = styled(MuiFab)`
|
export const Fab = styled(MuiFab)({
|
||||||
&& {
|
'&&': {
|
||||||
background-color: ${colors.primary};
|
backgroundColor: colors.primary,
|
||||||
color: ${colors.white};
|
color: colors.white,
|
||||||
margin-right: 10px;
|
marginRight: '10px',
|
||||||
}
|
},
|
||||||
`;
|
});
|
||||||
|
@ -1,10 +1,75 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { shallow } from 'enzyme';
|
import { shallow } from 'enzyme';
|
||||||
|
|
||||||
import Author from './Author';
|
|
||||||
|
|
||||||
describe('<Author /> component', () => {
|
describe('<Author /> component', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
jest.resetModules();
|
||||||
|
});
|
||||||
|
|
||||||
test('should render the component in default state', () => {
|
test('should render the component in default state', () => {
|
||||||
|
const packageMeta = {
|
||||||
|
latest: {
|
||||||
|
name: 'verdaccio',
|
||||||
|
version: '4.0.0',
|
||||||
|
author: {
|
||||||
|
name: 'verdaccio user',
|
||||||
|
email: 'verdaccio.user@verdaccio.org',
|
||||||
|
url: '',
|
||||||
|
avatar: 'https://www.gravatar.com/avatar/000000',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
jest.doMock('../../pages/version/Version', () => ({
|
||||||
|
DetailContextConsumer: component => {
|
||||||
|
return component.children({ packageMeta });
|
||||||
|
},
|
||||||
|
}));
|
||||||
|
|
||||||
|
const Author = require('./Author').default;
|
||||||
|
const wrapper = shallow(<Author />);
|
||||||
|
expect(wrapper.html()).toMatchSnapshot();
|
||||||
|
});
|
||||||
|
|
||||||
|
test('should render the component when there is no author information available', () => {
|
||||||
|
const packageMeta = {
|
||||||
|
latest: {
|
||||||
|
name: 'verdaccio',
|
||||||
|
version: '4.0.0',
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
jest.doMock('../../pages/version/Version', () => ({
|
||||||
|
DetailContextConsumer: component => {
|
||||||
|
return component.children({ packageMeta });
|
||||||
|
},
|
||||||
|
}));
|
||||||
|
|
||||||
|
const Author = require('./Author').default;
|
||||||
|
const wrapper = shallow(<Author />);
|
||||||
|
expect(wrapper.html()).toEqual('');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('should render the component when there is no author email', () => {
|
||||||
|
const packageMeta = {
|
||||||
|
latest: {
|
||||||
|
name: 'verdaccio',
|
||||||
|
version: '4.0.0',
|
||||||
|
author: {
|
||||||
|
name: 'verdaccio user',
|
||||||
|
url: '',
|
||||||
|
avatar: 'https://www.gravatar.com/avatar/000000',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
jest.doMock('../../pages/version/Version', () => ({
|
||||||
|
DetailContextConsumer: component => {
|
||||||
|
return component.children({ packageMeta });
|
||||||
|
},
|
||||||
|
}));
|
||||||
|
|
||||||
|
const Author = require('./Author').default;
|
||||||
const wrapper = shallow(<Author />);
|
const wrapper = shallow(<Author />);
|
||||||
expect(wrapper.html()).toMatchSnapshot();
|
expect(wrapper.html()).toMatchSnapshot();
|
||||||
});
|
});
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import React, { Component, ReactNode } from 'react';
|
import React, { Component, ReactNode, ReactElement } from 'react';
|
||||||
|
|
||||||
import Avatar from '@material-ui/core/Avatar';
|
import Avatar from '@material-ui/core/Avatar';
|
||||||
import List from '@material-ui/core/List';
|
import List from '@material-ui/core/List';
|
||||||
@ -8,18 +8,18 @@ import { DetailContextConsumer } from '../../pages/version/Version';
|
|||||||
import { Heading, AuthorListItem } from './styles';
|
import { Heading, AuthorListItem } from './styles';
|
||||||
import { isEmail } from '../../utils/url';
|
import { isEmail } from '../../utils/url';
|
||||||
|
|
||||||
class Authors extends Component<any, any> {
|
class Authors extends Component {
|
||||||
render() {
|
public render(): ReactElement<HTMLElement> {
|
||||||
return (
|
return (
|
||||||
<DetailContextConsumer>
|
<DetailContextConsumer>
|
||||||
{(context: any) => {
|
{context => {
|
||||||
return context && context.packageMeta && this.renderAuthor(context.packageMeta);
|
return context && context.packageMeta && this.renderAuthor(context.packageMeta);
|
||||||
}}
|
}}
|
||||||
</DetailContextConsumer>
|
</DetailContextConsumer>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
renderLinkForMail(email: string, avatarComponent: ReactNode, packageName: string, version: string) {
|
public renderLinkForMail(email: string, avatarComponent: ReactNode, packageName: string, version: string): ReactElement<HTMLElement> | ReactNode {
|
||||||
if (!email || isEmail(email) === false) {
|
if (!email || isEmail(email) === false) {
|
||||||
return avatarComponent;
|
return avatarComponent;
|
||||||
}
|
}
|
||||||
@ -31,7 +31,7 @@ class Authors extends Component<any, any> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
renderAuthor = packageMeta => {
|
public renderAuthor = packageMeta => {
|
||||||
const { author, name: packageName, version } = packageMeta.latest;
|
const { author, name: packageName, version } = packageMeta.latest;
|
||||||
|
|
||||||
if (!author) {
|
if (!author) {
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||||
|
|
||||||
exports[`<Author /> component should render the component in default state 1`] = `""`;
|
exports[`<Author /> component should render the component in default state 1`] = `"<ul class=\\"MuiList-root-1 MuiList-padding-2 MuiList-subheader-4\\"><h3 class=\\"MuiTypography-root-5 MuiTypography-subheading-12 css-hyrz44 e1xuehjw0\\">Author</h3><li class=\\"MuiListItem-root-41 MuiListItem-default-44 MuiListItem-gutters-49 css-z8a2h0 e1xuehjw1\\"><a href=\\"mailto:verdaccio.user@verdaccio.org?subject=verdaccio@4.0.0\\" target=\\"_top\\"><div class=\\"MuiAvatar-root-53\\"><img alt=\\"verdaccio user\\" src=\\"https://www.gravatar.com/avatar/000000\\" class=\\"MuiAvatar-img-55\\"/></div></a><div class=\\"MuiListItemText-root-56\\"><span class=\\"MuiTypography-root-5 MuiTypography-subheading-12 MuiListItemText-primary-59\\">verdaccio user</span></div></li></ul>"`;
|
||||||
|
|
||||||
|
exports[`<Author /> component should render the component when there is no author email 1`] = `"<ul class=\\"MuiList-root-62 MuiList-padding-63 MuiList-subheader-65\\"><h3 class=\\"MuiTypography-root-66 MuiTypography-subheading-73 css-hyrz44 e1xuehjw0\\">Author</h3><li class=\\"MuiListItem-root-102 MuiListItem-default-105 MuiListItem-gutters-110 css-z8a2h0 e1xuehjw1\\"><div class=\\"MuiAvatar-root-114\\"><img alt=\\"verdaccio user\\" src=\\"https://www.gravatar.com/avatar/000000\\" class=\\"MuiAvatar-img-116\\"/></div><div class=\\"MuiListItemText-root-117\\"><span class=\\"MuiTypography-root-66 MuiTypography-subheading-73 MuiListItemText-primary-120\\">verdaccio user</span></div></li></ul>"`;
|
||||||
|
@ -2,15 +2,15 @@ import styled from 'react-emotion';
|
|||||||
import ListItem from '@material-ui/core/ListItem';
|
import ListItem from '@material-ui/core/ListItem';
|
||||||
import Typography from '@material-ui/core/Typography';
|
import Typography from '@material-ui/core/Typography';
|
||||||
|
|
||||||
export const Heading = styled(Typography)`
|
export const Heading = styled(Typography)({
|
||||||
&& {
|
'&&': {
|
||||||
font-weight: 700;
|
fontWeight: 700,
|
||||||
text-transform: capitalize;
|
textTransform: 'capitalize',
|
||||||
}
|
},
|
||||||
`;
|
});
|
||||||
export const AuthorListItem = styled(ListItem)`
|
export const AuthorListItem = styled(ListItem)({
|
||||||
&& {
|
'&&': {
|
||||||
padding-left: 0;
|
paddingLeft: 0,
|
||||||
padding-right: 0;
|
paddingRight: 0,
|
||||||
}
|
},
|
||||||
`;
|
});
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import React, { KeyboardEvent } from 'react';
|
import React, { KeyboardEvent } from 'react';
|
||||||
|
import { css } from 'emotion';
|
||||||
import Autosuggest from 'react-autosuggest';
|
import Autosuggest from 'react-autosuggest';
|
||||||
import match from 'autosuggest-highlight/match';
|
import match from 'autosuggest-highlight/match';
|
||||||
import parse from 'autosuggest-highlight/parse';
|
import parse from 'autosuggest-highlight/parse';
|
||||||
@ -7,8 +8,8 @@ import MenuItem from '@material-ui/core/MenuItem';
|
|||||||
import { fontWeight } from '../../utils/styles/sizes';
|
import { fontWeight } from '../../utils/styles/sizes';
|
||||||
import { Wrapper, InputField, SuggestionContainer } from './styles';
|
import { Wrapper, InputField, SuggestionContainer } from './styles';
|
||||||
|
|
||||||
export interface Props {
|
interface Props {
|
||||||
suggestions: any[];
|
suggestions: unknown[];
|
||||||
suggestionsLoading?: boolean;
|
suggestionsLoading?: boolean;
|
||||||
suggestionsLoaded?: boolean;
|
suggestionsLoaded?: boolean;
|
||||||
suggestionsError?: boolean;
|
suggestionsError?: boolean;
|
||||||
@ -16,17 +17,17 @@ export interface Props {
|
|||||||
color?: string;
|
color?: string;
|
||||||
value?: string;
|
value?: string;
|
||||||
placeholder?: string;
|
placeholder?: string;
|
||||||
startAdornment?: any;
|
startAdornment?: JSX.Element;
|
||||||
disableUnderline?: boolean;
|
disableUnderline?: boolean;
|
||||||
onChange?: (event: KeyboardEvent<HTMLInputElement>, { newValue, method }: { newValue: string; method: string }) => void;
|
onChange?: (event: KeyboardEvent<HTMLInputElement>, { newValue, method }: { newValue: string; method: string }) => void;
|
||||||
onSuggestionsFetch?: ({ value: string }) => Promise<void>;
|
onSuggestionsFetch?: ({ value: string }) => Promise<void>;
|
||||||
onCleanSuggestions?: () => void;
|
onCleanSuggestions?: () => void;
|
||||||
onClick?: (event: KeyboardEvent<HTMLInputElement>, { suggestionValue, method }: { suggestionValue: any[]; method: string }) => void;
|
onClick?: (event: KeyboardEvent<HTMLInputElement>, { suggestionValue, method }: { suggestionValue: string[]; method: string }) => void;
|
||||||
onKeyDown?: (event: KeyboardEvent<HTMLInputElement>) => void;
|
onKeyDown?: (event: KeyboardEvent<HTMLInputElement>) => void;
|
||||||
onBlur?: (event: KeyboardEvent<HTMLInputElement>) => void;
|
onBlur?: (event: KeyboardEvent<HTMLInputElement>) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
const renderInputComponent = inputProps => {
|
const renderInputComponent = (inputProps): JSX.Element => {
|
||||||
const { ref, startAdornment, disableUnderline, onKeyDown, ...others } = inputProps;
|
const { ref, startAdornment, disableUnderline, onKeyDown, ...others } = inputProps;
|
||||||
return (
|
return (
|
||||||
<InputField
|
<InputField
|
||||||
@ -46,19 +47,21 @@ const renderInputComponent = inputProps => {
|
|||||||
|
|
||||||
const getSuggestionValue = (suggestion): string => suggestion.name;
|
const getSuggestionValue = (suggestion): string => suggestion.name;
|
||||||
|
|
||||||
const renderSuggestion = (suggestion, { query, isHighlighted }) => {
|
const renderSuggestion = (suggestion, { query, isHighlighted }): JSX.Element => {
|
||||||
const matches = match(suggestion.name, query);
|
const matches = match(suggestion.name, query);
|
||||||
const parts = parse(suggestion.name, matches);
|
const parts = parse(suggestion.name, matches);
|
||||||
return (
|
return (
|
||||||
<MenuItem component="div" selected={isHighlighted}>
|
<MenuItem component="div" selected={isHighlighted}>
|
||||||
<div>
|
<div>
|
||||||
{parts.map((part, index) => {
|
{parts.map((part, index) => {
|
||||||
return part.highlight ? (
|
const fw = part.highlight ? fontWeight.semiBold : fontWeight.light;
|
||||||
<a href={suggestion.link} key={String(index)} style={{ fontWeight: fontWeight.semiBold }}>
|
return (
|
||||||
{part.text}
|
<a
|
||||||
</a>
|
className={css`
|
||||||
) : (
|
font-weight: ${fw};
|
||||||
<a href={suggestion.link} key={String(index)} style={{ fontWeight: fontWeight.light }}>
|
`}
|
||||||
|
href={suggestion.link}
|
||||||
|
key={String(index)}>
|
||||||
{part.text}
|
{part.text}
|
||||||
</a>
|
</a>
|
||||||
);
|
);
|
||||||
@ -68,7 +71,7 @@ const renderSuggestion = (suggestion, { query, isHighlighted }) => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const renderMessage = message => {
|
const renderMessage = (message): JSX.Element => {
|
||||||
return (
|
return (
|
||||||
<MenuItem component="div" selected={false}>
|
<MenuItem component="div" selected={false}>
|
||||||
<div>{message}</div>
|
<div>{message}</div>
|
||||||
@ -98,7 +101,7 @@ const AutoComplete = ({
|
|||||||
suggestionsLoading = false,
|
suggestionsLoading = false,
|
||||||
suggestionsLoaded = false,
|
suggestionsLoaded = false,
|
||||||
suggestionsError = false,
|
suggestionsError = false,
|
||||||
}: Props) => {
|
}: Props): JSX.Element => {
|
||||||
const autosuggestProps = {
|
const autosuggestProps = {
|
||||||
renderInputComponent,
|
renderInputComponent,
|
||||||
suggestions,
|
suggestions,
|
||||||
@ -119,7 +122,7 @@ const AutoComplete = ({
|
|||||||
};
|
};
|
||||||
|
|
||||||
// this format avoid arrow function eslint rule
|
// this format avoid arrow function eslint rule
|
||||||
function renderSuggestionsContainer({ containerProps, children, query }) {
|
function renderSuggestionsContainer({ containerProps, children, query }): JSX.Element {
|
||||||
return (
|
return (
|
||||||
<SuggestionContainer {...containerProps} square={true}>
|
<SuggestionContainer {...containerProps} square={true}>
|
||||||
{suggestionsLoaded && children === null && query && renderMessage(SUGGESTIONS_RESPONSE.NO_RESULT)}
|
{suggestionsLoaded && children === null && query && renderMessage(SUGGESTIONS_RESPONSE.NO_RESULT)}
|
||||||
|
@ -8,14 +8,14 @@ export interface InputFieldProps {
|
|||||||
color: string;
|
color: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const Wrapper = styled('div')`
|
export const Wrapper = styled('div')({
|
||||||
&& {
|
'&&': {
|
||||||
width: 100%;
|
width: '100%',
|
||||||
height: 32px;
|
height: '32px',
|
||||||
position: relative;
|
position: 'relative',
|
||||||
z-index: 1;
|
zIndex: 1,
|
||||||
}
|
},
|
||||||
`;
|
});
|
||||||
|
|
||||||
export const InputField: React.FC<InputFieldProps> = ({ color, ...others }) => (
|
export const InputField: React.FC<InputFieldProps> = ({ color, ...others }) => (
|
||||||
<TextField
|
<TextField
|
||||||
@ -51,9 +51,9 @@ export const InputField: React.FC<InputFieldProps> = ({ color, ...others }) => (
|
|||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|
||||||
export const SuggestionContainer = styled(Paper)`
|
export const SuggestionContainer = styled(Paper)({
|
||||||
&& {
|
'&&': {
|
||||||
max-height: 500px;
|
maxHeight: '500px',
|
||||||
overflow-y: auto;
|
overflowY: 'auto',
|
||||||
}
|
},
|
||||||
`;
|
});
|
||||||
|
@ -12,7 +12,7 @@ interface Props {
|
|||||||
children?: React.ReactNode;
|
children?: React.ReactNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
const renderText: React.FC<any> = (text: string, children: React.ReactNode): React.ReactElement<HTMLElement> => {
|
const renderText = (text, children): JSX.Element => {
|
||||||
if (children) {
|
if (children) {
|
||||||
return <ClipBoardCopyText>{children}</ClipBoardCopyText>;
|
return <ClipBoardCopyText>{children}</ClipBoardCopyText>;
|
||||||
}
|
}
|
||||||
|
@ -1,26 +1,26 @@
|
|||||||
import IconButton from '@material-ui/core/IconButton';
|
import IconButton from '@material-ui/core/IconButton';
|
||||||
import styled from 'react-emotion';
|
import styled from 'react-emotion';
|
||||||
|
|
||||||
export const ClipBoardCopy = styled('div')`
|
export const ClipBoardCopy = styled('div')({
|
||||||
&& {
|
'&&': {
|
||||||
display: flex;
|
display: 'flex',
|
||||||
align-items: center;
|
alignItems: 'center',
|
||||||
justify-content: space-between;
|
justifyContent: 'space-between',
|
||||||
}
|
},
|
||||||
`;
|
});
|
||||||
|
|
||||||
export const ClipBoardCopyText = styled('span')`
|
export const ClipBoardCopyText = styled('span')({
|
||||||
&& {
|
'&&': {
|
||||||
display: inline-block;
|
display: 'inline-block',
|
||||||
text-overflow: ellipsis;
|
textOverflow: 'ellipsis',
|
||||||
overflow: hidden;
|
overflow: 'hidden',
|
||||||
white-space: nowrap;
|
whiteSpace: 'nowrap',
|
||||||
height: 21px;
|
height: '21px',
|
||||||
}
|
},
|
||||||
`;
|
});
|
||||||
|
|
||||||
export const CopyIcon = styled(IconButton)`
|
export const CopyIcon = styled(IconButton)({
|
||||||
&& {
|
'&&': {
|
||||||
margin: 0 0 0 10px;
|
margin: '0 0 0 10px',
|
||||||
}
|
},
|
||||||
`;
|
});
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import React, { Component, Fragment, ReactElement } from 'react';
|
import React, { Component, Fragment, ReactElement } from 'react';
|
||||||
import { withRouter } from 'react-router-dom';
|
import { withRouter, RouteComponentProps } from 'react-router-dom';
|
||||||
import CardContent from '@material-ui/core/CardContent';
|
import CardContent from '@material-ui/core/CardContent';
|
||||||
|
|
||||||
import { DetailContextConsumer, VersionPageConsumerProps } from '../../pages/version/Version';
|
import { DetailContextConsumer, VersionPageConsumerProps } from '../../pages/version/Version';
|
||||||
@ -7,8 +7,19 @@ import { DetailContextConsumer, VersionPageConsumerProps } from '../../pages/ver
|
|||||||
import { CardWrap, Heading, Tags, Tag } from './styles';
|
import { CardWrap, Heading, Tags, Tag } from './styles';
|
||||||
import NoItems from '../NoItems';
|
import NoItems from '../NoItems';
|
||||||
|
|
||||||
class DepDetail extends Component<any, any> {
|
type DepDetailProps = {
|
||||||
constructor(props: any) {
|
name: string;
|
||||||
|
version: string;
|
||||||
|
onLoading?: () => void;
|
||||||
|
} & RouteComponentProps;
|
||||||
|
|
||||||
|
interface DepDetailState {
|
||||||
|
name: string;
|
||||||
|
version: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
class DepDetail extends Component<DepDetailProps, DepDetailState> {
|
||||||
|
constructor(props: DepDetailProps) {
|
||||||
super(props);
|
super(props);
|
||||||
const { name, version } = this.props;
|
const { name, version } = this.props;
|
||||||
|
|
||||||
@ -28,21 +39,21 @@ class DepDetail extends Component<any, any> {
|
|||||||
const { name } = this.state;
|
const { name } = this.state;
|
||||||
const { onLoading, history } = this.props;
|
const { onLoading, history } = this.props;
|
||||||
|
|
||||||
onLoading();
|
onLoading && onLoading();
|
||||||
history.push(`/-/web/detail/${name}`);
|
history.push(`/-/web/detail/${name}`);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
const WrapperDependencyDetail = withRouter(DepDetail);
|
const WrapperDependencyDetail = withRouter(DepDetail);
|
||||||
|
|
||||||
class DependencyBlock extends Component<any, any> {
|
class DependencyBlock extends Component<{ title: string; dependencies: [] }> {
|
||||||
public render(): ReactElement<HTMLElement> {
|
public render(): ReactElement<HTMLElement> {
|
||||||
const { dependencies, title } = this.props;
|
const { dependencies, title } = this.props;
|
||||||
const deps = Object.entries(dependencies);
|
const deps = Object.entries(dependencies) as [];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<DetailContextConsumer>
|
<DetailContextConsumer>
|
||||||
{({ enableLoading }: any) => {
|
{({ enableLoading }) => {
|
||||||
return (
|
return (
|
||||||
<CardWrap>
|
<CardWrap>
|
||||||
<CardContent>
|
<CardContent>
|
||||||
@ -56,15 +67,15 @@ class DependencyBlock extends Component<any, any> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private renderTags = (deps: any, enableLoading: any) =>
|
private renderTags = (deps: [], enableLoading?: () => void) =>
|
||||||
deps.map(dep => {
|
deps.map(dep => {
|
||||||
const [name, version] = dep;
|
const [name, version] = dep as [string, string];
|
||||||
|
|
||||||
return <WrapperDependencyDetail key={name} name={name} onLoading={enableLoading} version={version} />;
|
return <WrapperDependencyDetail key={name} name={name} onLoading={enableLoading} version={version} />;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
class Dependencies extends Component<any, any> {
|
class Dependencies extends Component {
|
||||||
public state = {
|
public state = {
|
||||||
tabPosition: 0,
|
tabPosition: 0,
|
||||||
};
|
};
|
||||||
@ -79,7 +90,7 @@ class Dependencies extends Component<any, any> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private checkDependencyLength(dependency: Record<string, any> = {}): boolean {
|
private checkDependencyLength<T>(dependency: Record<string, T> = {}): boolean {
|
||||||
return Object.keys(dependency).length > 0;
|
return Object.keys(dependency).length > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,30 +3,30 @@ import Card from '@material-ui/core/Card';
|
|||||||
import Typography from '@material-ui/core/Typography';
|
import Typography from '@material-ui/core/Typography';
|
||||||
import Chip from '@material-ui/core/Chip';
|
import Chip from '@material-ui/core/Chip';
|
||||||
|
|
||||||
export const CardWrap = styled(Card)`
|
export const CardWrap = styled(Card)({
|
||||||
&& {
|
'&&': {
|
||||||
margin: 0 0 16px;
|
margin: '0 0 16px',
|
||||||
}
|
},
|
||||||
`;
|
});
|
||||||
|
|
||||||
export const Heading = styled(Typography)`
|
export const Heading = styled(Typography)({
|
||||||
&& {
|
'&&': {
|
||||||
font-weight: 700;
|
fontWeight: 700,
|
||||||
text-transform: capitalize;
|
textTransform: 'capitalize',
|
||||||
}
|
},
|
||||||
`;
|
});
|
||||||
|
|
||||||
export const Tags = styled('div')`
|
export const Tags = styled('div')({
|
||||||
&& {
|
'&&': {
|
||||||
display: flex;
|
display: 'flex',
|
||||||
justify-content: start;
|
justifyContent: 'start',
|
||||||
flex-wrap: wrap;
|
flexWrap: 'wrap',
|
||||||
margin: 0 -5px;
|
margin: '0 -5px',
|
||||||
}
|
},
|
||||||
`;
|
});
|
||||||
|
|
||||||
export const Tag = styled(Chip)`
|
export const Tag = styled(Chip)({
|
||||||
&& {
|
'&&': {
|
||||||
margin: 5px;
|
margin: '5px',
|
||||||
}
|
},
|
||||||
`;
|
});
|
||||||
|
@ -14,7 +14,7 @@ interface DetailContainerState {
|
|||||||
tabPosition: number;
|
tabPosition: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
class DetailContainer extends Component<any, DetailContainerState> {
|
class DetailContainer<P> extends Component<P, DetailContainerState> {
|
||||||
public state = {
|
public state = {
|
||||||
tabPosition: 0,
|
tabPosition: 0,
|
||||||
};
|
};
|
||||||
@ -29,7 +29,7 @@ class DetailContainer extends Component<any, DetailContainerState> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private handleChange = (event: any, tabPosition: number) => {
|
private handleChange = (event: React.ChangeEvent<{}>, tabPosition: number) => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
this.setState({ tabPosition });
|
this.setState({ tabPosition });
|
||||||
};
|
};
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import styled from 'react-emotion';
|
import styled from 'react-emotion';
|
||||||
|
|
||||||
export const Content = styled('div')`
|
export const Content = styled('div')({
|
||||||
&& {
|
'&&': {
|
||||||
padding: 15px;
|
padding: '15px',
|
||||||
}
|
},
|
||||||
`;
|
});
|
||||||
|
@ -5,26 +5,26 @@ import ListItemText from '@material-ui/core/ListItemText';
|
|||||||
|
|
||||||
import colors from '../../utils/styles/colors';
|
import colors from '../../utils/styles/colors';
|
||||||
|
|
||||||
export const TitleListItem = styled(ListItem)`
|
export const TitleListItem = styled(ListItem)({
|
||||||
&& {
|
'&&': {
|
||||||
padding-left: 0;
|
paddingLeft: 0,
|
||||||
padding-right: 0;
|
paddingRight: 0,
|
||||||
padding-bottom: 0;
|
paddingBottom: 0,
|
||||||
}
|
},
|
||||||
`;
|
});
|
||||||
|
|
||||||
export const TitleListItemText = styled(ListItemText)`
|
export const TitleListItemText = styled(ListItemText)({
|
||||||
&& {
|
'&&': {
|
||||||
padding-left: 0;
|
paddingLeft: 0,
|
||||||
padding-right: 0;
|
paddingRight: 0,
|
||||||
padding-top: 8px;
|
paddingTop: '8px',
|
||||||
}
|
},
|
||||||
`;
|
});
|
||||||
|
|
||||||
export const TitleAvatar = styled(Avatar)`
|
export const TitleAvatar = styled(Avatar)({
|
||||||
&& {
|
'&&': {
|
||||||
color: ${colors.greySuperLight};
|
color: colors.greySuperLight,
|
||||||
background-color: ${colors.primary};
|
backgroundColor: colors.primary,
|
||||||
text-transform: capitalize;
|
textTransform: 'capitalize',
|
||||||
}
|
},
|
||||||
`;
|
});
|
||||||
|
@ -11,18 +11,21 @@ import { isEmail } from '../../utils/url';
|
|||||||
interface Props {
|
interface Props {
|
||||||
type: 'contributors' | 'maintainers';
|
type: 'contributors' | 'maintainers';
|
||||||
}
|
}
|
||||||
|
interface State {
|
||||||
|
visibleDevs: number;
|
||||||
|
}
|
||||||
|
|
||||||
class Developers extends Component<Props, any> {
|
class Developers extends Component<Props, State> {
|
||||||
state = {
|
public state = {
|
||||||
visibleDevs: 6,
|
visibleDevs: 6,
|
||||||
};
|
};
|
||||||
|
|
||||||
render() {
|
public render(): JSX.Element {
|
||||||
return (
|
return (
|
||||||
<DetailContextConsumer>
|
<DetailContextConsumer>
|
||||||
{({ packageMeta }: any) => {
|
{({ packageMeta }) => {
|
||||||
const { type } = this.props;
|
const { type } = this.props;
|
||||||
const developerType = packageMeta.latest[type];
|
const developerType = packageMeta && packageMeta.latest[type];
|
||||||
if (!developerType || developerType.length === 0) return null;
|
if (!developerType || developerType.length === 0) return null;
|
||||||
return this.renderDevelopers(developerType, packageMeta);
|
return this.renderDevelopers(developerType, packageMeta);
|
||||||
}}
|
}}
|
||||||
@ -30,11 +33,11 @@ class Developers extends Component<Props, any> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
handleLoadMore = () => {
|
public handleLoadMore = () => {
|
||||||
this.setState(prev => ({ visibleDevs: prev.visibleDevs + 6 }));
|
this.setState(prev => ({ visibleDevs: prev.visibleDevs + 6 }));
|
||||||
};
|
};
|
||||||
|
|
||||||
renderDevelopers = (developers, packageMeta) => {
|
private renderDevelopers = (developers, packageMeta) => {
|
||||||
const { type } = this.props;
|
const { type } = this.props;
|
||||||
const { visibleDevs } = this.state;
|
const { visibleDevs } = this.state;
|
||||||
return (
|
return (
|
||||||
@ -54,7 +57,7 @@ class Developers extends Component<Props, any> {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
renderLinkForMail(email, avatarComponent, packageName, version) {
|
private renderLinkForMail(email, avatarComponent, packageName, version): JSX.Element {
|
||||||
if (!email || isEmail(email) === false) {
|
if (!email || isEmail(email) === false) {
|
||||||
return avatarComponent;
|
return avatarComponent;
|
||||||
}
|
}
|
||||||
@ -65,7 +68,7 @@ class Developers extends Component<Props, any> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
renderDeveloperDetails = ({ name, avatar, email }, packageMeta) => {
|
private renderDeveloperDetails = ({ name, avatar, email }, packageMeta) => {
|
||||||
const { name: packageName, version } = packageMeta.latest;
|
const { name: packageName, version } = packageMeta.latest;
|
||||||
|
|
||||||
const avatarComponent = <Avatar aria-label={name} src={avatar} />;
|
const avatarComponent = <Avatar aria-label={name} src={avatar} />;
|
||||||
|
@ -3,32 +3,32 @@ import Typography from '@material-ui/core/Typography';
|
|||||||
import { default as MuiFab } from '@material-ui/core/Fab';
|
import { default as MuiFab } from '@material-ui/core/Fab';
|
||||||
import colors from '../../utils/styles/colors';
|
import colors from '../../utils/styles/colors';
|
||||||
|
|
||||||
export const Details = styled('span')`
|
export const Details = styled('span')({
|
||||||
display: flex;
|
display: 'flex',
|
||||||
flex-direction: column;
|
flexDirection: 'column',
|
||||||
align-items: center;
|
alignItems: 'center',
|
||||||
`;
|
});
|
||||||
|
|
||||||
export const Content = styled('div')`
|
export const Content = styled('div')({
|
||||||
margin: 10px 0 10px 0;
|
margin: '10px 0 10px 0',
|
||||||
display: flex;
|
display: 'flex',
|
||||||
flex-wrap: wrap;
|
flexWrap: 'wrap',
|
||||||
> * {
|
'> *': {
|
||||||
margin: 5px;
|
margin: '5px',
|
||||||
}
|
},
|
||||||
`;
|
});
|
||||||
|
|
||||||
export const Heading = styled(Typography)`
|
export const Heading = styled(Typography)({
|
||||||
&& {
|
'&&': {
|
||||||
font-weight: 700;
|
fontWeight: 700,
|
||||||
margin-bottom: 10px;
|
marginBottom: '10px',
|
||||||
text-transform: capitalize;
|
textTransform: 'capitalize',
|
||||||
}
|
},
|
||||||
`;
|
});
|
||||||
|
|
||||||
export const Fab = styled(MuiFab)`
|
export const Fab = styled(MuiFab)({
|
||||||
&& {
|
'&&': {
|
||||||
background-color: ${colors.primary};
|
backgroundColor: colors.primary,
|
||||||
color: ${colors.white};
|
color: colors.white,
|
||||||
}
|
},
|
||||||
`;
|
});
|
||||||
|
80
src/components/Dist/Dist.test.tsx
Normal file
80
src/components/Dist/Dist.test.tsx
Normal file
@ -0,0 +1,80 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import { shallow } from 'enzyme';
|
||||||
|
|
||||||
|
describe('<Dist /> component', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
jest.resetModules();
|
||||||
|
});
|
||||||
|
|
||||||
|
test('should render the component in default state', () => {
|
||||||
|
const packageMeta = {
|
||||||
|
latest: {
|
||||||
|
name: 'verdaccio',
|
||||||
|
version: '4.0.0',
|
||||||
|
dist: {
|
||||||
|
fileCount: 7,
|
||||||
|
unpackedSize: 10,
|
||||||
|
},
|
||||||
|
license: '',
|
||||||
|
},
|
||||||
|
};
|
||||||
|
jest.doMock('../../pages/version/Version', () => ({
|
||||||
|
DetailContextConsumer: component => {
|
||||||
|
return component.children({ packageMeta });
|
||||||
|
},
|
||||||
|
}));
|
||||||
|
|
||||||
|
const Dist = require('./Dist').default;
|
||||||
|
const wrapper = shallow(<Dist />);
|
||||||
|
expect(wrapper.html()).toMatchSnapshot();
|
||||||
|
});
|
||||||
|
|
||||||
|
test('should render the component with license as string', () => {
|
||||||
|
const packageMeta = {
|
||||||
|
latest: {
|
||||||
|
name: 'verdaccio',
|
||||||
|
version: '4.0.0',
|
||||||
|
dist: {
|
||||||
|
fileCount: 7,
|
||||||
|
unpackedSize: 10,
|
||||||
|
},
|
||||||
|
license: 'MIT',
|
||||||
|
},
|
||||||
|
};
|
||||||
|
jest.doMock('../../pages/version/Version', () => ({
|
||||||
|
DetailContextConsumer: component => {
|
||||||
|
return component.children({ packageMeta });
|
||||||
|
},
|
||||||
|
}));
|
||||||
|
|
||||||
|
const Dist = require('./Dist').default;
|
||||||
|
const wrapper = shallow(<Dist />);
|
||||||
|
expect(wrapper.html()).toMatchSnapshot();
|
||||||
|
});
|
||||||
|
|
||||||
|
test('should render the component with license as object', () => {
|
||||||
|
const packageMeta = {
|
||||||
|
latest: {
|
||||||
|
name: 'verdaccio',
|
||||||
|
version: '4.0.0',
|
||||||
|
dist: {
|
||||||
|
fileCount: 7,
|
||||||
|
unpackedSize: 10,
|
||||||
|
},
|
||||||
|
license: {
|
||||||
|
type: 'MIT',
|
||||||
|
url: 'https://www.opensource.org/licenses/mit-license.php',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
jest.doMock('../../pages/version/Version', () => ({
|
||||||
|
DetailContextConsumer: component => {
|
||||||
|
return component.children({ packageMeta });
|
||||||
|
},
|
||||||
|
}));
|
||||||
|
|
||||||
|
const Dist = require('./Dist').default;
|
||||||
|
const wrapper = shallow(<Dist />);
|
||||||
|
expect(wrapper.html()).toMatchSnapshot();
|
||||||
|
});
|
||||||
|
});
|
@ -2,49 +2,48 @@ import React, { Component } from 'react';
|
|||||||
|
|
||||||
import List from '@material-ui/core/List';
|
import List from '@material-ui/core/List';
|
||||||
|
|
||||||
import { DetailContextConsumer } from '../../pages/version/Version';
|
import { DetailContextConsumer, VersionPageConsumerProps } from '../../pages/version/Version';
|
||||||
import { Heading, DistListItem, DistChips } from './styles';
|
import { Heading, DistListItem, DistChips } from './styles';
|
||||||
import fileSizeSI from '../../utils/file-size';
|
import fileSizeSI from '../../utils/file-size';
|
||||||
|
import { PackageMetaInterface } from 'types/packageMeta';
|
||||||
|
import { formatLicense } from '../../utils/package';
|
||||||
|
|
||||||
class Dist extends Component<any, any> {
|
class Dist extends Component {
|
||||||
render() {
|
public render(): JSX.Element {
|
||||||
return (
|
return (
|
||||||
<DetailContextConsumer>
|
<DetailContextConsumer>
|
||||||
{(context: any) => {
|
{(context: Partial<VersionPageConsumerProps>) => {
|
||||||
return this.renderDist(context);
|
return context && context.packageMeta && this.renderDist(context.packageMeta);
|
||||||
}}
|
}}
|
||||||
</DetailContextConsumer>
|
</DetailContextConsumer>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
renderChips(dist: any, license: string) {
|
private renderChips(dist, license: PackageMetaInterface['latest']['license']): (JSX.Element | undefined)[] {
|
||||||
const distDict = {
|
const distDict = {
|
||||||
'file-count': dist.fileCount,
|
'file-count': dist.fileCount,
|
||||||
size: dist.unpackedSize && fileSizeSI(dist.unpackedSize),
|
size: dist.unpackedSize && fileSizeSI(dist.unpackedSize),
|
||||||
license,
|
license,
|
||||||
};
|
};
|
||||||
|
|
||||||
const chipsList = Object.keys(distDict).reduce((componentList, title, key) => {
|
const chipsList = Object.keys(distDict).map((dist, key) => {
|
||||||
// @ts-ignore
|
if (!distDict[dist]) return;
|
||||||
const value = distDict[title];
|
|
||||||
if (value) {
|
const value = dist === 'license' ? formatLicense(distDict[dist]) : distDict[dist];
|
||||||
const label = (
|
const label = (
|
||||||
<span>
|
<>
|
||||||
{/* eslint-disable-next-line */}
|
{/* eslint-disable-next-line */}
|
||||||
<b>{title.split('-').join(' ')}</b>:{value}
|
<b>{dist.replace('-', ' ')}</b>: {value}
|
||||||
</span>
|
</>
|
||||||
);
|
);
|
||||||
// @ts-ignore is not assignable to parameter of type 'never'
|
return <DistChips key={key} label={label} />;
|
||||||
componentList.push(<DistChips key={key} label={label} />);
|
});
|
||||||
}
|
|
||||||
return componentList;
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
return chipsList;
|
return chipsList;
|
||||||
}
|
}
|
||||||
|
|
||||||
renderDist = ({ packageMeta }: any) => {
|
private renderDist = (packageMeta: PackageMetaInterface) => {
|
||||||
const { dist = {}, license } = packageMeta.latest;
|
const { dist, license } = packageMeta && packageMeta.latest;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<List subheader={<Heading variant="subheading">{'Latest Distribution'}</Heading>}>
|
<List subheader={<Heading variant="subheading">{'Latest Distribution'}</Heading>}>
|
||||||
|
7
src/components/Dist/__snapshots__/Dist.test.tsx.snap
Normal file
7
src/components/Dist/__snapshots__/Dist.test.tsx.snap
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||||
|
|
||||||
|
exports[`<Dist /> component should render the component in default state 1`] = `"<ul class=\\"MuiList-root-1 MuiList-padding-2 MuiList-subheader-4\\"><h3 class=\\"MuiTypography-root-5 MuiTypography-subheading-12 css-hyrz44 estxrtg0\\">Latest Distribution</h3><li class=\\"MuiListItem-root-41 MuiListItem-default-44 MuiListItem-gutters-49 css-z8a2h0 estxrtg1\\"><div role=\\"button\\" class=\\"MuiChip-root-53 css-1le6jk6 estxrtg2\\" tabindex=\\"-1\\"><span class=\\"MuiChip-label-72\\"><b>file count</b>: 7</span></div><div role=\\"button\\" class=\\"MuiChip-root-53 css-1le6jk6 estxrtg2\\" tabindex=\\"-1\\"><span class=\\"MuiChip-label-72\\"><b>size</b>: 10.00 Bytes</span></div></li></ul>"`;
|
||||||
|
|
||||||
|
exports[`<Dist /> component should render the component with license as object 1`] = `"<ul class=\\"MuiList-root-155 MuiList-padding-156 MuiList-subheader-158\\"><h3 class=\\"MuiTypography-root-159 MuiTypography-subheading-166 css-hyrz44 estxrtg0\\">Latest Distribution</h3><li class=\\"MuiListItem-root-195 MuiListItem-default-198 MuiListItem-gutters-203 css-z8a2h0 estxrtg1\\"><div role=\\"button\\" class=\\"MuiChip-root-207 css-1le6jk6 estxrtg2\\" tabindex=\\"-1\\"><span class=\\"MuiChip-label-226\\"><b>file count</b>: 7</span></div><div role=\\"button\\" class=\\"MuiChip-root-207 css-1le6jk6 estxrtg2\\" tabindex=\\"-1\\"><span class=\\"MuiChip-label-226\\"><b>size</b>: 10.00 Bytes</span></div><div role=\\"button\\" class=\\"MuiChip-root-207 css-1le6jk6 estxrtg2\\" tabindex=\\"-1\\"><span class=\\"MuiChip-label-226\\"><b>license</b>: MIT</span></div></li></ul>"`;
|
||||||
|
|
||||||
|
exports[`<Dist /> component should render the component with license as string 1`] = `"<ul class=\\"MuiList-root-78 MuiList-padding-79 MuiList-subheader-81\\"><h3 class=\\"MuiTypography-root-82 MuiTypography-subheading-89 css-hyrz44 estxrtg0\\">Latest Distribution</h3><li class=\\"MuiListItem-root-118 MuiListItem-default-121 MuiListItem-gutters-126 css-z8a2h0 estxrtg1\\"><div role=\\"button\\" class=\\"MuiChip-root-130 css-1le6jk6 estxrtg2\\" tabindex=\\"-1\\"><span class=\\"MuiChip-label-149\\"><b>file count</b>: 7</span></div><div role=\\"button\\" class=\\"MuiChip-root-130 css-1le6jk6 estxrtg2\\" tabindex=\\"-1\\"><span class=\\"MuiChip-label-149\\"><b>size</b>: 10.00 Bytes</span></div><div role=\\"button\\" class=\\"MuiChip-root-130 css-1le6jk6 estxrtg2\\" tabindex=\\"-1\\"><span class=\\"MuiChip-label-149\\"><b>license</b>: MIT</span></div></li></ul>"`;
|
@ -6,30 +6,30 @@ import Typography from '@material-ui/core/Typography';
|
|||||||
|
|
||||||
import colors from '../../utils/styles/colors';
|
import colors from '../../utils/styles/colors';
|
||||||
|
|
||||||
export const Heading = styled(Typography)`
|
export const Heading = styled(Typography)({
|
||||||
&& {
|
'&&': {
|
||||||
font-weight: 700;
|
fontWeight: 700,
|
||||||
text-transform: capitalize;
|
textTransform: 'capitalize',
|
||||||
}
|
},
|
||||||
`;
|
});
|
||||||
|
|
||||||
export const DistListItem = styled(ListItem)`
|
export const DistListItem = styled(ListItem)({
|
||||||
&& {
|
'&&': {
|
||||||
padding-left: 0;
|
paddingLeft: 0,
|
||||||
padding-right: 0;
|
paddingRight: 0,
|
||||||
}
|
},
|
||||||
`;
|
});
|
||||||
|
|
||||||
export const DistChips = styled(Chip)`
|
export const DistChips = styled(Chip)({
|
||||||
&& {
|
'&&': {
|
||||||
margin-right: 5px;
|
marginRight: '5px',
|
||||||
text-transform: capitalize;
|
textTransform: 'capitalize',
|
||||||
}
|
},
|
||||||
`;
|
});
|
||||||
|
|
||||||
export const DownloadButton = styled(MuiFab)`
|
export const DownloadButton = styled(MuiFab)({
|
||||||
&& {
|
'&&': {
|
||||||
background-color: ${colors.primary};
|
backgroundColor: colors.primary,
|
||||||
color: ${colors.white};
|
color: colors.white,
|
||||||
}
|
},
|
||||||
`;
|
});
|
||||||
|
66
src/components/Engines/Engines.test.tsx
Normal file
66
src/components/Engines/Engines.test.tsx
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import { shallow } from 'enzyme';
|
||||||
|
|
||||||
|
jest.mock('./img/node.png', () => '');
|
||||||
|
jest.mock('../Install/img/npm.svg', () => '');
|
||||||
|
|
||||||
|
describe('<Engines /> component', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
jest.resetModules();
|
||||||
|
});
|
||||||
|
|
||||||
|
test('should render the component in default state', () => {
|
||||||
|
const packageMeta = {
|
||||||
|
latest: {
|
||||||
|
engines: {
|
||||||
|
node: '>= 0.1.98',
|
||||||
|
npm: '>3',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
jest.doMock('../../pages/version/Version', () => ({
|
||||||
|
DetailContextConsumer: component => {
|
||||||
|
return component.children({ packageMeta });
|
||||||
|
},
|
||||||
|
}));
|
||||||
|
|
||||||
|
const Engines = require('./Engines').default;
|
||||||
|
const wrapper = shallow(<Engines />);
|
||||||
|
expect(wrapper.html()).toMatchSnapshot();
|
||||||
|
});
|
||||||
|
|
||||||
|
test('should render the component when there is no engine key in package meta', () => {
|
||||||
|
const packageMeta = {
|
||||||
|
latest: {},
|
||||||
|
};
|
||||||
|
|
||||||
|
jest.doMock('../../pages/version/Version', () => ({
|
||||||
|
DetailContextConsumer: component => {
|
||||||
|
return component.children({ packageMeta });
|
||||||
|
},
|
||||||
|
}));
|
||||||
|
|
||||||
|
const Engines = require('./Engines').default;
|
||||||
|
const wrapper = shallow(<Engines />);
|
||||||
|
expect(wrapper.html()).toEqual('');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('should render the component when there is no keys in engine in package meta', () => {
|
||||||
|
const packageMeta = {
|
||||||
|
latest: {
|
||||||
|
engines: {},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
jest.doMock('../../pages/version/Version', () => ({
|
||||||
|
DetailContextConsumer: component => {
|
||||||
|
return component.children({ packageMeta });
|
||||||
|
},
|
||||||
|
}));
|
||||||
|
|
||||||
|
const Engines = require('./Engines').default;
|
||||||
|
const wrapper = shallow(<Engines />);
|
||||||
|
expect(wrapper.html()).toEqual('');
|
||||||
|
});
|
||||||
|
});
|
@ -0,0 +1,3 @@
|
|||||||
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||||
|
|
||||||
|
exports[`<Engines /> component should render the component in default state 1`] = `"<div class=\\"MuiGrid-container-1\\"><div class=\\"MuiGrid-item-2 MuiGrid-grid-xs-6-35\\"><ul class=\\"MuiList-root-98 MuiList-padding-99 MuiList-subheader-101\\"><h3 class=\\"MuiTypography-root-102 MuiTypography-subheading-109 css-hyrz44 et66bt70\\">node JS</h3><li class=\\"MuiListItem-root-138 MuiListItem-default-141 MuiListItem-gutters-146 css-dt93b2 et66bt71\\"><div class=\\"MuiAvatar-root-150 MuiAvatar-colorDefault-151\\"></div><div class=\\"MuiListItemText-root-153\\"><span class=\\"MuiTypography-root-102 MuiTypography-subheading-109 MuiListItemText-primary-156\\">>= 0.1.98</span></div></li></ul></div><div class=\\"MuiGrid-item-2 MuiGrid-grid-xs-6-35\\"><ul class=\\"MuiList-root-98 MuiList-padding-99 MuiList-subheader-101\\"><h3 class=\\"MuiTypography-root-102 MuiTypography-subheading-109 css-hyrz44 et66bt70\\">NPM version</h3><li class=\\"MuiListItem-root-138 MuiListItem-default-141 MuiListItem-gutters-146 css-dt93b2 et66bt71\\"><div class=\\"MuiAvatar-root-150 MuiAvatar-colorDefault-151\\"></div><div class=\\"MuiListItemText-root-153\\"><span class=\\"MuiTypography-root-102 MuiTypography-subheading-109 MuiListItemText-primary-156\\">>3</span></div></li></ul></div></div>"`;
|
@ -2,15 +2,15 @@ import styled from 'react-emotion';
|
|||||||
import ListItem from '@material-ui/core/ListItem';
|
import ListItem from '@material-ui/core/ListItem';
|
||||||
import Typography from '@material-ui/core/Typography';
|
import Typography from '@material-ui/core/Typography';
|
||||||
|
|
||||||
export const Heading = styled(Typography)`
|
export const Heading = styled(Typography)({
|
||||||
&& {
|
'&&': {
|
||||||
font-weight: 700;
|
fontWeight: 700,
|
||||||
text-transform: capitalize;
|
textTransform: 'capitalize',
|
||||||
}
|
},
|
||||||
`;
|
});
|
||||||
|
|
||||||
export const EngineListItem = styled(ListItem)`
|
export const EngineListItem = styled(ListItem)({
|
||||||
&& {
|
'&&': {
|
||||||
padding-left: 0;
|
paddingLeft: 0,
|
||||||
}
|
},
|
||||||
`;
|
});
|
||||||
|
@ -3,7 +3,7 @@ import React from 'react';
|
|||||||
import { Wrapper, Left, Right, Earth, Flags, Love, Flag, Logo, Inner, ToolTip } from './styles';
|
import { Wrapper, Left, Right, Earth, Flags, Love, Flag, Logo, Inner, ToolTip } from './styles';
|
||||||
import { goToVerdaccioWebsite } from '../../utils/windows';
|
import { goToVerdaccioWebsite } from '../../utils/windows';
|
||||||
|
|
||||||
const renderTooltip = () => (
|
const renderTooltip = (): JSX.Element => (
|
||||||
<ToolTip>
|
<ToolTip>
|
||||||
<Earth name="earth" size="md" />
|
<Earth name="earth" size="md" />
|
||||||
<Flags>
|
<Flags>
|
||||||
@ -22,7 +22,7 @@ const ON_LABEL = 'on';
|
|||||||
const HEARTH_EMOJI = '♥';
|
const HEARTH_EMOJI = '♥';
|
||||||
|
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
const renderRight = (version = window.VERDACCIO_VERSION) => {
|
const renderRight = (version = window.VERDACCIO_VERSION): JSX.Element => {
|
||||||
return (
|
return (
|
||||||
<Right>
|
<Right>
|
||||||
{POWERED_LABEL}
|
{POWERED_LABEL}
|
||||||
@ -32,7 +32,7 @@ const renderRight = (version = window.VERDACCIO_VERSION) => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const renderLeft = () => (
|
const renderLeft = (): JSX.Element => (
|
||||||
<Left>
|
<Left>
|
||||||
{MADEWITH_LABEL}
|
{MADEWITH_LABEL}
|
||||||
<Love>{HEARTH_EMOJI}</Love>
|
<Love>{HEARTH_EMOJI}</Love>
|
||||||
|
@ -3,15 +3,15 @@ import mq from '../../utils/styles/media';
|
|||||||
import Icon from '../Icon/Icon';
|
import Icon from '../Icon/Icon';
|
||||||
import colors from '../../utils/styles/colors';
|
import colors from '../../utils/styles/colors';
|
||||||
|
|
||||||
export const Wrapper = styled('div')`
|
export const Wrapper = styled('div')({
|
||||||
&& {
|
'&&': {
|
||||||
background: ${colors.snow};
|
background: colors.snow,
|
||||||
border-top: 1px solid ${colors.greyGainsboro};
|
borderTop: `1px solid ${colors.greyGainsboro}`,
|
||||||
color: ${colors.nobel01};
|
color: colors.nobel01,
|
||||||
font-size: 14px;
|
fontSize: '14px',
|
||||||
padding: 20px;
|
padding: '20px',
|
||||||
}
|
},
|
||||||
`;
|
});
|
||||||
|
|
||||||
export const Inner = styled('div')`
|
export const Inner = styled('div')`
|
||||||
&& {
|
&& {
|
||||||
@ -50,24 +50,24 @@ export const Left = styled('div')`
|
|||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
export const Right = styled(Left)`
|
export const Right = styled(Left)({
|
||||||
&& {
|
'&&': {
|
||||||
display: flex;
|
display: 'flex',
|
||||||
}
|
},
|
||||||
`;
|
});
|
||||||
|
|
||||||
export const ToolTip = styled('span')`
|
export const ToolTip = styled('span')({
|
||||||
&& {
|
'&&': {
|
||||||
position: relative;
|
position: 'relative',
|
||||||
height: 18px;
|
height: '18px',
|
||||||
}
|
},
|
||||||
`;
|
});
|
||||||
|
|
||||||
export const Earth = styled(Icon)`
|
export const Earth = styled(Icon)({
|
||||||
&& {
|
'&&': {
|
||||||
padding: 0 10px;
|
padding: '0 10px',
|
||||||
}
|
},
|
||||||
`;
|
});
|
||||||
|
|
||||||
export const Flags = styled('span')`
|
export const Flags = styled('span')`
|
||||||
&& {
|
&& {
|
||||||
@ -96,17 +96,17 @@ export const Flags = styled('span')`
|
|||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
export const Love = styled('span')`
|
export const Love = styled('span')({
|
||||||
&& {
|
'&&': {
|
||||||
color: ${colors.love};
|
color: colors.love,
|
||||||
padding: 0 5px;
|
padding: '0 5px',
|
||||||
}
|
},
|
||||||
`;
|
});
|
||||||
|
|
||||||
export const Flag = styled(Icon)`
|
export const Flag = styled(Icon)({
|
||||||
&& {
|
'&&': {
|
||||||
padding: 0 5px;
|
padding: '0 5px',
|
||||||
}
|
},
|
||||||
`;
|
});
|
||||||
|
|
||||||
export const Logo = Flag;
|
export const Logo = Flag;
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import React, { SyntheticEvent, Component, Fragment, ReactElement } from 'react';
|
import React, { SyntheticEvent, Component, Fragment, ReactElement } from 'react';
|
||||||
import { Link } from 'react-router-dom';
|
import { Link } from 'react-router-dom';
|
||||||
|
import { css } from 'emotion';
|
||||||
|
|
||||||
import Button from '@material-ui/core/Button';
|
import Button from '@material-ui/core/Button';
|
||||||
import IconButton from '@material-ui/core/IconButton';
|
import IconButton from '@material-ui/core/IconButton';
|
||||||
@ -22,7 +23,7 @@ import RegistryInfoContent from '../RegistryInfoContent/RegistryInfoContent';
|
|||||||
import { Greetings, NavBar, InnerNavBar, MobileNavBar, InnerMobileNavBar, LeftSide, RightSide, IconSearchButton, SearchWrapper } from './styles';
|
import { Greetings, NavBar, InnerNavBar, MobileNavBar, InnerMobileNavBar, LeftSide, RightSide, IconSearchButton, SearchWrapper } from './styles';
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
logo: string;
|
logo?: string;
|
||||||
username?: string;
|
username?: string;
|
||||||
onLogout: () => void;
|
onLogout: () => void;
|
||||||
onToggleLoginModal: () => void;
|
onToggleLoginModal: () => void;
|
||||||
@ -31,7 +32,7 @@ interface Props {
|
|||||||
}
|
}
|
||||||
|
|
||||||
interface State {
|
interface State {
|
||||||
anchorEl?: any;
|
anchorEl?: null | HTMLElement | ((element: HTMLElement) => HTMLElement);
|
||||||
openInfoDialog: boolean;
|
openInfoDialog: boolean;
|
||||||
registryUrl: string;
|
registryUrl: string;
|
||||||
showMobileNavBar: boolean;
|
showMobileNavBar: boolean;
|
||||||
@ -141,7 +142,11 @@ class Header extends Component<Props, State> {
|
|||||||
const { withoutSearch = false } = this.props;
|
const { withoutSearch = false } = this.props;
|
||||||
return (
|
return (
|
||||||
<LeftSide>
|
<LeftSide>
|
||||||
<Link style={{ marginRight: '1em' }} to={'/'}>
|
<Link
|
||||||
|
className={css`
|
||||||
|
margin-right: 1em;
|
||||||
|
`}
|
||||||
|
to={'/'}>
|
||||||
{this.renderLogo()}
|
{this.renderLogo()}
|
||||||
</Link>
|
</Link>
|
||||||
{!withoutSearch && (
|
{!withoutSearch && (
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||||
|
|
||||||
exports[`<Header /> component with logged in state should load the component in logged in state 1`] = `"<div><header class=\\"MuiPaper-root-10 MuiPaper-elevation4-16 MuiAppBar-root-1 MuiAppBar-positionStatic-5 MuiAppBar-colorPrimary-8 css-rfunvc e1jf5lit8\\"><div class=\\"MuiToolbar-root-37 MuiToolbar-regular-39 MuiToolbar-gutters-38 css-1pwdmmq e1jf5lit0\\"><div class=\\"MuiToolbar-root-37 MuiToolbar-regular-39 MuiToolbar-gutters-38 css-1vacr9s e1jf5lit3\\"><a style=\\"margin-right:1em\\" href=\\"/\\"><div class=\\"css-1tnu3ib em793ed0\\"></div></a></div><div class=\\"MuiToolbar-root-37 MuiToolbar-regular-39 MuiToolbar-gutters-38 css-m61s5i e1jf5lit2\\"><a href=\\"https://verdaccio.org/docs/en/installation\\" target=\\"_blank\\" class=\\"MuiButtonBase-root-55 MuiIconButton-root-49 MuiIconButton-colorInherit-50\\" tabindex=\\"0\\" role=\\"button\\" title=\\"Documentation\\"><span class=\\"MuiIconButton-label-54\\"><svg class=\\"MuiSvgIcon-root-58\\" focusable=\\"false\\" viewBox=\\"0 0 24 24\\" aria-hidden=\\"true\\" role=\\"presentation\\"><path fill=\\"none\\" d=\\"M0 0h24v24H0z\\"></path><path d=\\"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 17h-2v-2h2v2zm2.07-7.75l-.9.92C13.45 12.9 13 13.5 13 15h-2v-.5c0-1.1.45-2.1 1.17-2.83l1.24-1.26c.37-.36.59-.86.59-1.41 0-1.1-.9-2-2-2s-2 .9-2 2H8c0-2.21 1.79-4 4-4s4 1.79 4 4c0 .88-.36 1.68-.93 2.25z\\"></path></svg></span></a><button class=\\"MuiButtonBase-root-55 MuiIconButton-root-49 MuiIconButton-colorInherit-50\\" tabindex=\\"0\\" type=\\"button\\" id=\\"header--button-registryInfo\\" title=\\"Registry Information\\"><span class=\\"MuiIconButton-label-54\\"><svg class=\\"MuiSvgIcon-root-58\\" focusable=\\"false\\" viewBox=\\"0 0 24 24\\" aria-hidden=\\"true\\" role=\\"presentation\\"><path fill=\\"none\\" d=\\"M0 0h24v24H0z\\"></path><path d=\\"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-6h2v6zm0-8h-2V7h2v2z\\"></path></svg></span></button><button class=\\"MuiButtonBase-root-55 MuiIconButton-root-49 MuiIconButton-colorInherit-50\\" tabindex=\\"0\\" type=\\"button\\" id=\\"header--button-account\\"><span class=\\"MuiIconButton-label-54\\"><svg class=\\"MuiSvgIcon-root-58\\" focusable=\\"false\\" viewBox=\\"0 0 24 24\\" aria-hidden=\\"true\\" role=\\"presentation\\"><path d=\\"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 3c1.66 0 3 1.34 3 3s-1.34 3-3 3-3-1.34-3-3 1.34-3 3-3zm0 14.2c-2.5 0-4.71-1.28-6-3.22.03-1.99 4-3.08 6-3.08 1.99 0 5.97 1.09 6 3.08-1.29 1.94-3.5 3.22-6 3.22z\\"></path><path fill=\\"none\\" d=\\"M0 0h24v24H0z\\"></path></svg></span></button></div></div></header></div>"`;
|
exports[`<Header /> component with logged in state should load the component in logged in state 1`] = `"<div><header class=\\"MuiPaper-root-10 MuiPaper-elevation4-16 MuiAppBar-root-1 MuiAppBar-positionStatic-5 MuiAppBar-colorPrimary-8 css-rfunvc e1jf5lit8\\"><div class=\\"MuiToolbar-root-37 MuiToolbar-regular-39 MuiToolbar-gutters-38 css-1pwdmmq e1jf5lit0\\"><div class=\\"MuiToolbar-root-37 MuiToolbar-regular-39 MuiToolbar-gutters-38 css-1vacr9s e1jf5lit3\\"><a class=\\"css-1dk30lc\\" href=\\"/\\"><div class=\\"css-1sifsqk em793ed0\\"></div></a></div><div class=\\"MuiToolbar-root-37 MuiToolbar-regular-39 MuiToolbar-gutters-38 css-m61s5i e1jf5lit2\\"><a href=\\"https://verdaccio.org/docs/en/installation\\" target=\\"_blank\\" class=\\"MuiButtonBase-root-55 MuiIconButton-root-49 MuiIconButton-colorInherit-50\\" tabindex=\\"0\\" role=\\"button\\" title=\\"Documentation\\"><span class=\\"MuiIconButton-label-54\\"><svg class=\\"MuiSvgIcon-root-58\\" focusable=\\"false\\" viewBox=\\"0 0 24 24\\" aria-hidden=\\"true\\" role=\\"presentation\\"><path fill=\\"none\\" d=\\"M0 0h24v24H0z\\"></path><path d=\\"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 17h-2v-2h2v2zm2.07-7.75l-.9.92C13.45 12.9 13 13.5 13 15h-2v-.5c0-1.1.45-2.1 1.17-2.83l1.24-1.26c.37-.36.59-.86.59-1.41 0-1.1-.9-2-2-2s-2 .9-2 2H8c0-2.21 1.79-4 4-4s4 1.79 4 4c0 .88-.36 1.68-.93 2.25z\\"></path></svg></span></a><button class=\\"MuiButtonBase-root-55 MuiIconButton-root-49 MuiIconButton-colorInherit-50\\" tabindex=\\"0\\" type=\\"button\\" id=\\"header--button-registryInfo\\" title=\\"Registry Information\\"><span class=\\"MuiIconButton-label-54\\"><svg class=\\"MuiSvgIcon-root-58\\" focusable=\\"false\\" viewBox=\\"0 0 24 24\\" aria-hidden=\\"true\\" role=\\"presentation\\"><path fill=\\"none\\" d=\\"M0 0h24v24H0z\\"></path><path d=\\"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-6h2v6zm0-8h-2V7h2v2z\\"></path></svg></span></button><button class=\\"MuiButtonBase-root-55 MuiIconButton-root-49 MuiIconButton-colorInherit-50\\" tabindex=\\"0\\" type=\\"button\\" id=\\"header--button-account\\"><span class=\\"MuiIconButton-label-54\\"><svg class=\\"MuiSvgIcon-root-58\\" focusable=\\"false\\" viewBox=\\"0 0 24 24\\" aria-hidden=\\"true\\" role=\\"presentation\\"><path d=\\"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 3c1.66 0 3 1.34 3 3s-1.34 3-3 3-3-1.34-3-3 1.34-3 3-3zm0 14.2c-2.5 0-4.71-1.28-6-3.22.03-1.99 4-3.08 6-3.08 1.99 0 5.97 1.09 6 3.08-1.29 1.94-3.5 3.22-6 3.22z\\"></path><path fill=\\"none\\" d=\\"M0 0h24v24H0z\\"></path></svg></span></button></div></div></header></div>"`;
|
||||||
|
|
||||||
exports[`<Header /> component with logged out state should load the component in logged out state 1`] = `"<div><header class=\\"MuiPaper-root-10 MuiPaper-elevation4-16 MuiAppBar-root-1 MuiAppBar-positionStatic-5 MuiAppBar-colorPrimary-8 css-rfunvc e1jf5lit8\\"><div class=\\"MuiToolbar-root-37 MuiToolbar-regular-39 MuiToolbar-gutters-38 css-1pwdmmq e1jf5lit0\\"><div class=\\"MuiToolbar-root-37 MuiToolbar-regular-39 MuiToolbar-gutters-38 css-1vacr9s e1jf5lit3\\"><a style=\\"margin-right:1em\\" href=\\"/\\"><div class=\\"css-1tnu3ib em793ed0\\"></div></a></div><div class=\\"MuiToolbar-root-37 MuiToolbar-regular-39 MuiToolbar-gutters-38 css-m61s5i e1jf5lit2\\"><a href=\\"https://verdaccio.org/docs/en/installation\\" target=\\"_blank\\" class=\\"MuiButtonBase-root-55 MuiIconButton-root-49 MuiIconButton-colorInherit-50\\" tabindex=\\"0\\" role=\\"button\\" title=\\"Documentation\\"><span class=\\"MuiIconButton-label-54\\"><svg class=\\"MuiSvgIcon-root-58\\" focusable=\\"false\\" viewBox=\\"0 0 24 24\\" aria-hidden=\\"true\\" role=\\"presentation\\"><path fill=\\"none\\" d=\\"M0 0h24v24H0z\\"></path><path d=\\"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 17h-2v-2h2v2zm2.07-7.75l-.9.92C13.45 12.9 13 13.5 13 15h-2v-.5c0-1.1.45-2.1 1.17-2.83l1.24-1.26c.37-.36.59-.86.59-1.41 0-1.1-.9-2-2-2s-2 .9-2 2H8c0-2.21 1.79-4 4-4s4 1.79 4 4c0 .88-.36 1.68-.93 2.25z\\"></path></svg></span></a><button class=\\"MuiButtonBase-root-55 MuiIconButton-root-49 MuiIconButton-colorInherit-50\\" tabindex=\\"0\\" type=\\"button\\" id=\\"header--button-registryInfo\\" title=\\"Registry Information\\"><span class=\\"MuiIconButton-label-54\\"><svg class=\\"MuiSvgIcon-root-58\\" focusable=\\"false\\" viewBox=\\"0 0 24 24\\" aria-hidden=\\"true\\" role=\\"presentation\\"><path fill=\\"none\\" d=\\"M0 0h24v24H0z\\"></path><path d=\\"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-6h2v6zm0-8h-2V7h2v2z\\"></path></svg></span></button><button class=\\"MuiButtonBase-root-55 MuiButton-root-85 MuiButton-text-87 MuiButton-flat-90 MuiButton-colorInherit-106\\" tabindex=\\"0\\" type=\\"button\\" id=\\"header--button-login\\"><span class=\\"MuiButton-label-86\\">Login</span></button></div></div></header></div>"`;
|
exports[`<Header /> component with logged out state should load the component in logged out state 1`] = `"<div><header class=\\"MuiPaper-root-10 MuiPaper-elevation4-16 MuiAppBar-root-1 MuiAppBar-positionStatic-5 MuiAppBar-colorPrimary-8 css-rfunvc e1jf5lit8\\"><div class=\\"MuiToolbar-root-37 MuiToolbar-regular-39 MuiToolbar-gutters-38 css-1pwdmmq e1jf5lit0\\"><div class=\\"MuiToolbar-root-37 MuiToolbar-regular-39 MuiToolbar-gutters-38 css-1vacr9s e1jf5lit3\\"><a class=\\"css-1dk30lc\\" href=\\"/\\"><div class=\\"css-1sifsqk em793ed0\\"></div></a></div><div class=\\"MuiToolbar-root-37 MuiToolbar-regular-39 MuiToolbar-gutters-38 css-m61s5i e1jf5lit2\\"><a href=\\"https://verdaccio.org/docs/en/installation\\" target=\\"_blank\\" class=\\"MuiButtonBase-root-55 MuiIconButton-root-49 MuiIconButton-colorInherit-50\\" tabindex=\\"0\\" role=\\"button\\" title=\\"Documentation\\"><span class=\\"MuiIconButton-label-54\\"><svg class=\\"MuiSvgIcon-root-58\\" focusable=\\"false\\" viewBox=\\"0 0 24 24\\" aria-hidden=\\"true\\" role=\\"presentation\\"><path fill=\\"none\\" d=\\"M0 0h24v24H0z\\"></path><path d=\\"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 17h-2v-2h2v2zm2.07-7.75l-.9.92C13.45 12.9 13 13.5 13 15h-2v-.5c0-1.1.45-2.1 1.17-2.83l1.24-1.26c.37-.36.59-.86.59-1.41 0-1.1-.9-2-2-2s-2 .9-2 2H8c0-2.21 1.79-4 4-4s4 1.79 4 4c0 .88-.36 1.68-.93 2.25z\\"></path></svg></span></a><button class=\\"MuiButtonBase-root-55 MuiIconButton-root-49 MuiIconButton-colorInherit-50\\" tabindex=\\"0\\" type=\\"button\\" id=\\"header--button-registryInfo\\" title=\\"Registry Information\\"><span class=\\"MuiIconButton-label-54\\"><svg class=\\"MuiSvgIcon-root-58\\" focusable=\\"false\\" viewBox=\\"0 0 24 24\\" aria-hidden=\\"true\\" role=\\"presentation\\"><path fill=\\"none\\" d=\\"M0 0h24v24H0z\\"></path><path d=\\"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-6h2v6zm0-8h-2V7h2v2z\\"></path></svg></span></button><button class=\\"MuiButtonBase-root-55 MuiButton-root-85 MuiButton-text-87 MuiButton-flat-90 MuiButton-colorInherit-106\\" tabindex=\\"0\\" type=\\"button\\" id=\\"header--button-login\\"><span class=\\"MuiButton-label-86\\">Login</span></button></div></div></header></div>"`;
|
||||||
|
@ -6,67 +6,67 @@ import IconButton from '@material-ui/core/IconButton';
|
|||||||
import colors from '../../utils/styles/colors';
|
import colors from '../../utils/styles/colors';
|
||||||
import mq from '../../utils/styles/media';
|
import mq from '../../utils/styles/media';
|
||||||
|
|
||||||
export const InnerNavBar = styled(Toolbar)`
|
export const InnerNavBar = styled(Toolbar)({
|
||||||
&& {
|
'&&': {
|
||||||
justify-content: space-between;
|
justifyContent: 'space-between',
|
||||||
align-items: center;
|
alignItems: 'center',
|
||||||
padding: 0 15px;
|
padding: '0 15px',
|
||||||
}
|
},
|
||||||
`;
|
});
|
||||||
|
|
||||||
export const Greetings = styled('span')`
|
export const Greetings = styled('span')({
|
||||||
&& {
|
'&&': {
|
||||||
margin: 0 5px 0 0;
|
margin: '0 5px 0 0',
|
||||||
}
|
},
|
||||||
`;
|
});
|
||||||
|
|
||||||
export const RightSide = styled(Toolbar)`
|
export const RightSide = styled(Toolbar)({
|
||||||
&& {
|
'&&': {
|
||||||
display: flex;
|
display: 'flex',
|
||||||
padding: 0;
|
padding: 0,
|
||||||
}
|
},
|
||||||
`;
|
});
|
||||||
|
|
||||||
export const LeftSide = styled(RightSide)`
|
export const LeftSide = styled(RightSide)({
|
||||||
&& {
|
'&&': {
|
||||||
flex: 1;
|
flex: 1,
|
||||||
}
|
},
|
||||||
`;
|
});
|
||||||
|
|
||||||
export const MobileNavBar = styled('div')`
|
export const MobileNavBar = styled('div')({
|
||||||
&& {
|
'&&': {
|
||||||
align-items: center;
|
alignItems: 'center',
|
||||||
display: flex;
|
display: 'flex',
|
||||||
border-bottom: 1px solid ${colors.greyLight};
|
borderBottom: `1px solid ${colors.greyLight}`,
|
||||||
padding: 8px;
|
padding: '8px',
|
||||||
position: relative;
|
position: 'relative',
|
||||||
}
|
},
|
||||||
`;
|
});
|
||||||
|
|
||||||
export const InnerMobileNavBar = styled('div')`
|
export const InnerMobileNavBar = styled('div')({
|
||||||
&& {
|
'&&': {
|
||||||
border-radius: 4px;
|
borderRadius: '4px',
|
||||||
background-color: ${colors.greyLight};
|
backgroundColor: colors.greyLight,
|
||||||
color: ${colors.white};
|
color: colors.white,
|
||||||
width: 100%;
|
width: '100%',
|
||||||
padding: 0px 5px;
|
padding: '0px 5px',
|
||||||
margin: 0 10px 0 0;
|
margin: '0 10px 0 0',
|
||||||
}
|
},
|
||||||
`;
|
});
|
||||||
|
|
||||||
export const IconSearchButton = styled(IconButton)`
|
export const IconSearchButton = styled(IconButton)({
|
||||||
&& {
|
'&&': {
|
||||||
display: block;
|
display: 'block',
|
||||||
}
|
},
|
||||||
`;
|
});
|
||||||
|
|
||||||
export const SearchWrapper = styled('div')`
|
export const SearchWrapper = styled('div')({
|
||||||
&& {
|
'&&': {
|
||||||
display: none;
|
display: 'none',
|
||||||
max-width: 393px;
|
maxWidth: '393px',
|
||||||
width: 100%;
|
width: '100%',
|
||||||
}
|
},
|
||||||
`;
|
});
|
||||||
|
|
||||||
export const NavBar = styled(AppBar)`
|
export const NavBar = styled(AppBar)`
|
||||||
&& {
|
&& {
|
||||||
|
@ -2,15 +2,15 @@ import Card from '@material-ui/core/Card';
|
|||||||
import Typography from '@material-ui/core/Typography';
|
import Typography from '@material-ui/core/Typography';
|
||||||
import styled from 'react-emotion';
|
import styled from 'react-emotion';
|
||||||
|
|
||||||
export const CardStyled = styled(Card)`
|
export const CardStyled = styled(Card)({
|
||||||
&& {
|
'&&': {
|
||||||
width: 600px;
|
width: '600px',
|
||||||
margin: auto;
|
margin: 'auto',
|
||||||
}
|
},
|
||||||
`;
|
});
|
||||||
|
|
||||||
export const HelpTitle = styled(Typography)`
|
export const HelpTitle = styled(Typography)({
|
||||||
&& {
|
'&&': {
|
||||||
margin-bottom: 20px;
|
marginBottom: '20px',
|
||||||
}
|
},
|
||||||
`;
|
});
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import React, { MouseEvent } from 'react';
|
import React, { MouseEvent } from 'react';
|
||||||
import capitalize from 'lodash/capitalize';
|
import capitalize from 'lodash/capitalize';
|
||||||
|
import { Breakpoint } from '@material-ui/core/styles/createBreakpoints';
|
||||||
|
|
||||||
import { Svg, Img, ImgWrapper } from './styles';
|
import { Svg, Img, ImgWrapper } from './styles';
|
||||||
|
|
||||||
@ -57,10 +58,10 @@ export interface Props {
|
|||||||
name: keyof IconsMap;
|
name: keyof IconsMap;
|
||||||
className?: string;
|
className?: string;
|
||||||
onClick?: (event: MouseEvent<SVGElement | HTMLSpanElement>) => void;
|
onClick?: (event: MouseEvent<SVGElement | HTMLSpanElement>) => void;
|
||||||
size?: 'sm' | 'md';
|
size?: Breakpoint;
|
||||||
pointer?: boolean;
|
pointer?: boolean;
|
||||||
img?: boolean;
|
img?: boolean;
|
||||||
modifiers?: any;
|
modifiers?: null | undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Icon: React.FC<Props> = ({ className, name, size = 'sm', img = false, pointer = false, ...props }) => {
|
const Icon: React.FC<Props> = ({ className, name, size = 'sm', img = false, pointer = false, ...props }) => {
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
import styled, { css } from 'react-emotion';
|
import styled, { css } from 'react-emotion';
|
||||||
|
import { Breakpoint } from '@material-ui/core/styles/createBreakpoints';
|
||||||
|
import { StyledOtherComponent } from 'create-emotion-styled';
|
||||||
|
import { DetailedHTMLProps, HTMLAttributes } from 'react';
|
||||||
|
|
||||||
const getSize = (size?: 'md' | 'sm') => {
|
const getSize = (size: Breakpoint): string => {
|
||||||
switch (size) {
|
switch (size) {
|
||||||
case 'md':
|
case 'md':
|
||||||
return `
|
return `
|
||||||
@ -15,7 +18,7 @@ const getSize = (size?: 'md' | 'sm') => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const commonStyle = ({ size = 'sm', pointer, modifiers }: any) => css`
|
const commonStyle = ({ size = 'sm' as Breakpoint, pointer, modifiers = null }): string => css`
|
||||||
&& {
|
&& {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
cursor: ${pointer ? 'pointer' : 'default'};
|
cursor: ${pointer ? 'pointer' : 'default'};
|
||||||
@ -30,15 +33,24 @@ export const Svg = styled('svg')`
|
|||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
export const ImgWrapper = styled('span')`
|
export const ImgWrapper: StyledOtherComponent<
|
||||||
|
{
|
||||||
|
size?: Breakpoint;
|
||||||
|
pointer: boolean;
|
||||||
|
modifiers?: null | undefined;
|
||||||
|
name?: string | unknown;
|
||||||
|
},
|
||||||
|
DetailedHTMLProps<HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>,
|
||||||
|
{}
|
||||||
|
> = styled('span')`
|
||||||
&& {
|
&& {
|
||||||
${commonStyle};
|
${commonStyle};
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
export const Img = styled('img')`
|
export const Img = styled('img')({
|
||||||
&& {
|
'&&': {
|
||||||
width: 100%;
|
width: '100%',
|
||||||
height: auto;
|
height: 'auto',
|
||||||
}
|
},
|
||||||
`;
|
});
|
||||||
|
@ -3,7 +3,7 @@ import ListItemText from '@material-ui/core/ListItemText';
|
|||||||
import React, { Component } from 'react';
|
import React, { Component } from 'react';
|
||||||
|
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
import { DetailContextConsumer } from '../../pages/version/Version';
|
import { DetailContextConsumer, VersionPageConsumerProps } from '../../pages/version/Version';
|
||||||
import CopyToClipBoard from '../CopyToClipBoard';
|
import CopyToClipBoard from '../CopyToClipBoard';
|
||||||
|
|
||||||
// logos of package managers
|
// logos of package managers
|
||||||
@ -14,17 +14,17 @@ import yarn from './img/yarn.svg';
|
|||||||
import { Heading, InstallItem, PackageMangerAvatar } from './styles';
|
import { Heading, InstallItem, PackageMangerAvatar } from './styles';
|
||||||
|
|
||||||
class Install extends Component {
|
class Install extends Component {
|
||||||
public render() {
|
public render(): JSX.Element {
|
||||||
return (
|
return (
|
||||||
<DetailContextConsumer>
|
<DetailContextConsumer>
|
||||||
{(context: any) => {
|
{(context: Partial<VersionPageConsumerProps>) => {
|
||||||
return context && context.packageName && this.renderCopyCLI(context);
|
return context && context.packageName && this.renderCopyCLI(context);
|
||||||
}}
|
}}
|
||||||
</DetailContextConsumer>
|
</DetailContextConsumer>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public renderCopyCLI = ({ packageName }: { packageName: string }) => {
|
public renderCopyCLI = ({ packageName = '' }: Partial<VersionPageConsumerProps>) => {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<List subheader={<Heading variant={'subheading'}>{'Installation'}</Heading>}>{this.renderListItems(packageName)}</List>
|
<List subheader={<Heading variant={'subheading'}>{'Installation'}</Heading>}>{this.renderListItems(packageName)}</List>
|
||||||
|
@ -3,21 +3,21 @@ import ListItem from '@material-ui/core/ListItem';
|
|||||||
import Typography from '@material-ui/core/Typography';
|
import Typography from '@material-ui/core/Typography';
|
||||||
import styled from 'react-emotion';
|
import styled from 'react-emotion';
|
||||||
|
|
||||||
export const Heading = styled(Typography)`
|
export const Heading = styled(Typography)({
|
||||||
&& {
|
'&&': {
|
||||||
font-weight: 700;
|
fontWeight: 700,
|
||||||
text-transform: capitalize;
|
textTransform: 'capitalize',
|
||||||
}
|
},
|
||||||
`;
|
});
|
||||||
|
|
||||||
export const InstallItem = styled(ListItem)`
|
export const InstallItem = styled(ListItem)({
|
||||||
&& {
|
'&&': {
|
||||||
padding: 0;
|
padding: 0,
|
||||||
}
|
},
|
||||||
`;
|
});
|
||||||
|
|
||||||
export const PackageMangerAvatar = styled(Avatar)`
|
export const PackageMangerAvatar = styled(Avatar)({
|
||||||
&& {
|
'&&': {
|
||||||
border-radius: 0px;
|
borderRadius: '0px',
|
||||||
}
|
},
|
||||||
`;
|
});
|
||||||
|
@ -6,7 +6,7 @@ interface Props {
|
|||||||
text: string;
|
text: string;
|
||||||
capitalize?: boolean;
|
capitalize?: boolean;
|
||||||
weight?: string;
|
weight?: string;
|
||||||
modifiers?: any;
|
modifiers?: null | undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Wrapper = styled('div')`
|
const Wrapper = styled('div')`
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
import styled, { css } from 'react-emotion';
|
import styled, { css } from 'react-emotion';
|
||||||
|
|
||||||
export const Content = styled('div')`
|
export const Content = styled('div')({
|
||||||
&& {
|
'&&': {
|
||||||
background-color: #ffffff;
|
backgroundColor: '#ffffff',
|
||||||
flex: 1;
|
flex: 1,
|
||||||
display: flex;
|
display: 'flex',
|
||||||
position: relative;
|
position: 'relative',
|
||||||
flex-direction: column;
|
flexDirection: 'column',
|
||||||
}
|
},
|
||||||
`;
|
});
|
||||||
|
|
||||||
export const Container = styled('div')`
|
export const Container = styled('div')`
|
||||||
&& {
|
&& {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
|
||||||
import Logo from '../Logo';
|
import Logo, { Size } from '../Logo';
|
||||||
import Spinner from '../Spinner';
|
import Spinner from '../Spinner';
|
||||||
|
|
||||||
import { Wrapper, Badge } from './styles';
|
import { Wrapper, Badge } from './styles';
|
||||||
@ -8,7 +8,7 @@ import { Wrapper, Badge } from './styles';
|
|||||||
const Loading: React.FC = () => (
|
const Loading: React.FC = () => (
|
||||||
<Wrapper>
|
<Wrapper>
|
||||||
<Badge>
|
<Badge>
|
||||||
<Logo />
|
<Logo size={Size.Big} />
|
||||||
</Badge>
|
</Badge>
|
||||||
<Spinner />
|
<Spinner />
|
||||||
</Wrapper>
|
</Wrapper>
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||||
|
|
||||||
exports[`<Loading /> component should render the component in default state 1`] = `"<div class=\\"css-1221txa eimgwje0\\"><div class=\\"css-bxochs eimgwje1\\"><div class=\\"css-1tnu3ib em793ed0\\"></div></div><div class=\\"css-vqrgi e1ag4h8b0\\"><div class=\\"MuiCircularProgress-root-1 MuiCircularProgress-colorPrimary-4 MuiCircularProgress-indeterminate-3 css-15gl0ho e1ag4h8b1\\" style=\\"width:50px;height:50px\\" role=\\"progressbar\\"><svg class=\\"MuiCircularProgress-svg-6\\" viewBox=\\"22 22 44 44\\"><circle class=\\"MuiCircularProgress-circle-7 MuiCircularProgress-circleIndeterminate-9\\" cx=\\"44\\" cy=\\"44\\" r=\\"20.2\\" fill=\\"none\\" stroke-width=\\"3.6\\"></circle></svg></div></div></div>"`;
|
exports[`<Loading /> component should render the component in default state 1`] = `"<div class=\\"css-1221txa eimgwje0\\"><div class=\\"css-bxochs eimgwje1\\"><div class=\\"css-ge0nak em793ed0\\"></div></div><div class=\\"css-vqrgi e1ag4h8b0\\"><div class=\\"MuiCircularProgress-root-1 MuiCircularProgress-colorPrimary-4 MuiCircularProgress-indeterminate-3 css-15gl0ho e1ag4h8b1\\" style=\\"width:50px;height:50px\\" role=\\"progressbar\\"><svg class=\\"MuiCircularProgress-svg-6\\" viewBox=\\"22 22 44 44\\"><circle class=\\"MuiCircularProgress-circle-7 MuiCircularProgress-circleIndeterminate-9\\" cx=\\"44\\" cy=\\"44\\" r=\\"20.2\\" fill=\\"none\\" stroke-width=\\"3.6\\"></circle></svg></div></div></div>"`;
|
||||||
|
@ -63,7 +63,6 @@ describe('<LoginModal />', () => {
|
|||||||
test('setCredentials - should set username and password in state', () => {
|
test('setCredentials - should set username and password in state', () => {
|
||||||
const props = {
|
const props = {
|
||||||
visibility: true,
|
visibility: true,
|
||||||
error: {},
|
|
||||||
onCancel: () => {},
|
onCancel: () => {},
|
||||||
onSubmit: () => {},
|
onSubmit: () => {},
|
||||||
};
|
};
|
||||||
@ -80,7 +79,6 @@ describe('<LoginModal />', () => {
|
|||||||
test('validateCredentials: should validate credentials', async () => {
|
test('validateCredentials: should validate credentials', async () => {
|
||||||
const props = {
|
const props = {
|
||||||
visibility: true,
|
visibility: true,
|
||||||
error: {},
|
|
||||||
onCancel: () => {},
|
onCancel: () => {},
|
||||||
onSubmit: jest.fn(),
|
onSubmit: jest.fn(),
|
||||||
};
|
};
|
||||||
@ -89,7 +87,7 @@ describe('<LoginModal />', () => {
|
|||||||
const instance = wrapper.instance();
|
const instance = wrapper.instance();
|
||||||
|
|
||||||
instance.submitCredentials = jest.fn();
|
instance.submitCredentials = jest.fn();
|
||||||
const { validateCredentials, setCredentials, submitCredentials } = instance;
|
const { handleValidateCredentials, setCredentials, submitCredentials } = instance;
|
||||||
|
|
||||||
expect(setCredentials('username', eventUsername)).toBeUndefined();
|
expect(setCredentials('username', eventUsername)).toBeUndefined();
|
||||||
expect(wrapper.state('form').username.value).toEqual('xyz');
|
expect(wrapper.state('form').username.value).toEqual('xyz');
|
||||||
@ -97,7 +95,7 @@ describe('<LoginModal />', () => {
|
|||||||
expect(setCredentials('password', eventPassword)).toBeUndefined();
|
expect(setCredentials('password', eventPassword)).toBeUndefined();
|
||||||
expect(wrapper.state('form').password.value).toEqual('1234');
|
expect(wrapper.state('form').password.value).toEqual('1234');
|
||||||
|
|
||||||
validateCredentials(event);
|
handleValidateCredentials(event);
|
||||||
expect(event.preventDefault).toHaveBeenCalled();
|
expect(event.preventDefault).toHaveBeenCalled();
|
||||||
expect(wrapper.state('form').username.pristine).toEqual(false);
|
expect(wrapper.state('form').username.pristine).toEqual(false);
|
||||||
expect(wrapper.state('form').password.pristine).toEqual(false);
|
expect(wrapper.state('form').password.pristine).toEqual(false);
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import React, { Component } from 'react';
|
import React, { Component } from 'react';
|
||||||
import PropTypes from 'prop-types';
|
|
||||||
import Button from '@material-ui/core/Button';
|
import Button from '@material-ui/core/Button';
|
||||||
import DialogTitle from '@material-ui/core/DialogTitle';
|
import DialogTitle from '@material-ui/core/DialogTitle';
|
||||||
import Dialog from '@material-ui/core/Dialog';
|
import Dialog from '@material-ui/core/Dialog';
|
||||||
@ -11,26 +10,39 @@ import InputLabel from '@material-ui/core/InputLabel';
|
|||||||
import Input from '@material-ui/core/Input';
|
import Input from '@material-ui/core/Input';
|
||||||
import FormControl from '@material-ui/core/FormControl';
|
import FormControl from '@material-ui/core/FormControl';
|
||||||
import FormHelperText from '@material-ui/core/FormHelperText';
|
import FormHelperText from '@material-ui/core/FormHelperText';
|
||||||
|
import { css } from 'emotion';
|
||||||
|
|
||||||
// @ts-ignore
|
import * as classes from './styles';
|
||||||
import classes from './login.scss';
|
|
||||||
|
|
||||||
export default class LoginModal extends Component<any, any> {
|
interface FormFields {
|
||||||
static propTypes = {
|
required: boolean;
|
||||||
visibility: PropTypes.bool,
|
pristine: boolean;
|
||||||
error: PropTypes.object,
|
helperText: string;
|
||||||
onCancel: PropTypes.func,
|
value: string;
|
||||||
onSubmit: PropTypes.func,
|
}
|
||||||
|
export interface FormError {
|
||||||
|
type: string;
|
||||||
|
title: string;
|
||||||
|
description: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface LoginModalProps {
|
||||||
|
visibility: boolean;
|
||||||
|
error?: FormError;
|
||||||
|
onCancel: () => void;
|
||||||
|
onSubmit: (username: string, password: string) => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface LoginModalState {
|
||||||
|
form: {
|
||||||
|
username: Partial<FormFields>;
|
||||||
|
password: Partial<FormFields>;
|
||||||
};
|
};
|
||||||
|
error?: FormError;
|
||||||
|
}
|
||||||
|
|
||||||
static defaultProps = {
|
export default class LoginModal extends Component<Partial<LoginModalProps>, LoginModalState> {
|
||||||
error: {},
|
constructor(props: LoginModalProps) {
|
||||||
onCancel: () => {},
|
|
||||||
onSubmit: () => {},
|
|
||||||
visibility: true,
|
|
||||||
};
|
|
||||||
|
|
||||||
constructor(props) {
|
|
||||||
super(props);
|
super(props);
|
||||||
this.state = {
|
this.state = {
|
||||||
form: {
|
form: {
|
||||||
@ -51,11 +63,28 @@ export default class LoginModal extends Component<any, any> {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public render(): JSX.Element {
|
||||||
|
const { visibility = true, onCancel = () => null, error } = this.props as LoginModalProps;
|
||||||
|
return (
|
||||||
|
<Dialog fullWidth={true} id={'login--form-container'} maxWidth={'xs'} onClose={onCancel} open={visibility}>
|
||||||
|
<form noValidate={true} onSubmit={this.handleValidateCredentials}>
|
||||||
|
<DialogTitle>{'Login'}</DialogTitle>
|
||||||
|
<DialogContent>
|
||||||
|
{error && this.renderLoginError(error)}
|
||||||
|
{this.renderNameField()}
|
||||||
|
{this.renderPasswordField()}
|
||||||
|
</DialogContent>
|
||||||
|
{this.renderActions()}
|
||||||
|
</form>
|
||||||
|
</Dialog>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* set login modal's username and password to current state
|
* set login modal's username and password to current state
|
||||||
* Required to login
|
* Required to login
|
||||||
*/
|
*/
|
||||||
setCredentials = (name, e) => {
|
public setCredentials = (name, e) => {
|
||||||
const { form } = this.state;
|
const { form } = this.state;
|
||||||
this.setState({
|
this.setState({
|
||||||
form: {
|
form: {
|
||||||
@ -69,15 +98,15 @@ export default class LoginModal extends Component<any, any> {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
setUsername = event => {
|
public handleUsernameChange = event => {
|
||||||
this.setCredentials('username', event);
|
this.setCredentials('username', event);
|
||||||
};
|
};
|
||||||
|
|
||||||
setPassword = event => {
|
public handlePasswordChange = event => {
|
||||||
this.setCredentials('password', event);
|
this.setCredentials('password', event);
|
||||||
};
|
};
|
||||||
|
|
||||||
validateCredentials = event => {
|
public handleValidateCredentials = event => {
|
||||||
const { form } = this.state;
|
const { form } = this.state;
|
||||||
// prevents default submit behavior
|
// prevents default submit behavior
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
@ -89,7 +118,7 @@ export default class LoginModal extends Component<any, any> {
|
|||||||
...acc,
|
...acc,
|
||||||
...{ [key]: { ...form[key], pristine: false } },
|
...{ [key]: { ...form[key], pristine: false } },
|
||||||
}),
|
}),
|
||||||
{}
|
{ username: {}, password: {} }
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
() => {
|
() => {
|
||||||
@ -100,10 +129,14 @@ export default class LoginModal extends Component<any, any> {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
submitCredentials = async () => {
|
public submitCredentials = async () => {
|
||||||
const { form } = this.state;
|
const { form } = this.state;
|
||||||
|
const username = (form.username && form.username.value) || '';
|
||||||
|
const password = (form.password && form.password.value) || '';
|
||||||
const { onSubmit } = this.props;
|
const { onSubmit } = this.props;
|
||||||
await onSubmit(form.username.value, form.password.value);
|
if (onSubmit) {
|
||||||
|
await onSubmit(username, password);
|
||||||
|
}
|
||||||
// let's wait for API response and then set
|
// let's wait for API response and then set
|
||||||
// username and password filed to empty state
|
// username and password filed to empty state
|
||||||
this.setState({
|
this.setState({
|
||||||
@ -112,12 +145,12 @@ export default class LoginModal extends Component<any, any> {
|
|||||||
...acc,
|
...acc,
|
||||||
...{ [key]: { ...form[key], value: '', pristine: true } },
|
...{ [key]: { ...form[key], value: '', pristine: true } },
|
||||||
}),
|
}),
|
||||||
{}
|
{ username: {}, password: {} }
|
||||||
),
|
),
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
renderErrorMessage(title, description) {
|
public renderErrorMessage(title, description): JSX.Element {
|
||||||
return (
|
return (
|
||||||
<span>
|
<span>
|
||||||
<div>
|
<div>
|
||||||
@ -128,7 +161,7 @@ export default class LoginModal extends Component<any, any> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
renderMessage(title, description) {
|
public renderMessage(title, description): JSX.Element {
|
||||||
return (
|
return (
|
||||||
<div className={classes.loginErrorMsg} id={'client-snackbar'}>
|
<div className={classes.loginErrorMsg} id={'client-snackbar'}>
|
||||||
<ErrorIcon className={classes.loginIcon} />
|
<ErrorIcon className={classes.loginIcon} />
|
||||||
@ -137,37 +170,43 @@ export default class LoginModal extends Component<any, any> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
renderLoginError({ type, title, description }) {
|
public renderLoginError({ type, title, description }: FormError): JSX.Element | false {
|
||||||
return type === 'error' && <SnackbarContent className={classes.loginError} message={this.renderMessage(title, description)} />;
|
return type === 'error' && <SnackbarContent className={classes.loginError} message={this.renderMessage(title, description)} />;
|
||||||
}
|
}
|
||||||
|
|
||||||
renderNameField = () => {
|
public renderNameField = () => {
|
||||||
const {
|
const {
|
||||||
form: { username },
|
form: { username },
|
||||||
} = this.state;
|
} = this.state;
|
||||||
return (
|
return (
|
||||||
<FormControl error={!username.value && !username.pristine} fullWidth={true} required={username.required}>
|
<FormControl error={!username.value && !username.pristine} fullWidth={true} required={username.required}>
|
||||||
<InputLabel htmlFor={'username'}>{'Username'}</InputLabel>
|
<InputLabel htmlFor={'username'}>{'Username'}</InputLabel>
|
||||||
<Input id={'login--form-username'} onChange={this.setUsername} placeholder={'Your username'} value={username.value} />
|
<Input id={'login--form-username'} onChange={this.handleUsernameChange} placeholder={'Your username'} value={username.value} />
|
||||||
{!username.value && !username.pristine && <FormHelperText id={'username-error'}>{username.helperText}</FormHelperText>}
|
{!username.value && !username.pristine && <FormHelperText id={'username-error'}>{username.helperText}</FormHelperText>}
|
||||||
</FormControl>
|
</FormControl>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
renderPasswordField = () => {
|
public renderPasswordField = () => {
|
||||||
const {
|
const {
|
||||||
form: { password },
|
form: { password },
|
||||||
} = this.state;
|
} = this.state;
|
||||||
return (
|
return (
|
||||||
<FormControl error={!password.value && !password.pristine} fullWidth={true} required={password.required} style={{ marginTop: '8px' }}>
|
<FormControl
|
||||||
|
className={css`
|
||||||
|
margin-top: 8px;
|
||||||
|
`}
|
||||||
|
error={!password.value && !password.pristine}
|
||||||
|
fullWidth={true}
|
||||||
|
required={password.required}>
|
||||||
<InputLabel htmlFor={'password'}>{'Password'}</InputLabel>
|
<InputLabel htmlFor={'password'}>{'Password'}</InputLabel>
|
||||||
<Input id={'login--form-password'} onChange={this.setPassword} placeholder={'Your strong password'} type={'password'} value={password.value} />
|
<Input id={'login--form-password'} onChange={this.handlePasswordChange} placeholder={'Your strong password'} type={'password'} value={password.value} />
|
||||||
{!password.value && !password.pristine && <FormHelperText id={'password-error'}>{password.helperText}</FormHelperText>}
|
{!password.value && !password.pristine && <FormHelperText id={'password-error'}>{password.helperText}</FormHelperText>}
|
||||||
</FormControl>
|
</FormControl>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
renderActions = () => {
|
public renderActions = () => {
|
||||||
const {
|
const {
|
||||||
form: { username, password },
|
form: { username, password },
|
||||||
} = this.state;
|
} = this.state;
|
||||||
@ -183,21 +222,4 @@ export default class LoginModal extends Component<any, any> {
|
|||||||
</DialogActions>
|
</DialogActions>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
render() {
|
|
||||||
const { visibility, onCancel, error } = this.props;
|
|
||||||
return (
|
|
||||||
<Dialog fullWidth={true} id={'login--form-container'} maxWidth={'xs'} onClose={onCancel} open={visibility}>
|
|
||||||
<form noValidate={true} onSubmit={this.validateCredentials}>
|
|
||||||
<DialogTitle>{'Login'}</DialogTitle>
|
|
||||||
<DialogContent>
|
|
||||||
{this.renderLoginError(error)}
|
|
||||||
{this.renderNameField()}
|
|
||||||
{this.renderPasswordField()}
|
|
||||||
</DialogContent>
|
|
||||||
{this.renderActions()}
|
|
||||||
</form>
|
|
||||||
</Dialog>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||||
|
|
||||||
exports[`<LoginModal /> should load the component in default state 1`] = `"<div role=\\"dialog\\" class=\\"MuiModal-root-15 MuiDialog-root-1\\" id=\\"login--form-container\\"><div class=\\"MuiBackdrop-root-17\\" aria-hidden=\\"true\\" style=\\"opacity: 1; webkit-transition: opacity 225ms cubic-bezier(0.4, 0, 0.2, 1) 0ms; transition: opacity 225ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;\\"></div><div class=\\"MuiDialog-container-4 MuiDialog-scrollPaper-2\\" role=\\"document\\" style=\\"opacity: 1; webkit-transition: opacity 225ms cubic-bezier(0.4, 0, 0.2, 1) 0ms; transition: opacity 225ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;\\" tabindex=\\"-1\\"><div class=\\"MuiPaper-root-19 MuiPaper-elevation24-45 MuiPaper-rounded-20 MuiDialog-paper-5 MuiDialog-paperScrollPaper-6 MuiDialog-paperWidthXs-8 MuiDialog-paperFullWidth-13\\"><form novalidate=\\"\\"><div class=\\"MuiDialogTitle-root-46\\"><h2 class=\\"MuiTypography-root-47 MuiTypography-title-53\\">Login</h2></div><div class=\\"MuiDialogContent-root-83\\"><div class=\\"MuiFormControl-root-84 MuiFormControl-fullWidth-87\\"><label class=\\"MuiFormLabel-root-99 MuiFormLabel-required-104 MuiInputLabel-required-92 MuiInputLabel-root-88 MuiInputLabel-formControl-93 MuiInputLabel-animated-96\\" data-shrink=\\"false\\" for=\\"username\\">Username<span class=\\"MuiFormLabel-asterisk-105\\"> *</span></label><div class=\\"MuiInputBase-root-119 MuiInput-root-106 MuiInput-underline-110 MuiInputBase-formControl-120 MuiInput-formControl-107\\"><input aria-invalid=\\"false\\" class=\\"MuiInputBase-input-129 MuiInput-input-114\\" id=\\"login--form-username\\" placeholder=\\"Your username\\" required=\\"\\" type=\\"text\\" value=\\"\\"></div></div><div class=\\"MuiFormControl-root-84 MuiFormControl-fullWidth-87\\" style=\\"margin-top: 8px;\\"><label class=\\"MuiFormLabel-root-99 MuiFormLabel-required-104 MuiInputLabel-required-92 MuiInputLabel-root-88 MuiInputLabel-formControl-93 MuiInputLabel-animated-96\\" data-shrink=\\"false\\" for=\\"password\\">Password<span class=\\"MuiFormLabel-asterisk-105\\"> *</span></label><div class=\\"MuiInputBase-root-119 MuiInput-root-106 MuiInput-underline-110 MuiInputBase-formControl-120 MuiInput-formControl-107\\"><input aria-invalid=\\"false\\" class=\\"MuiInputBase-input-129 MuiInput-input-114 MuiInputBase-inputType-132 MuiInput-inputType-117\\" id=\\"login--form-password\\" placeholder=\\"Your strong password\\" required=\\"\\" type=\\"password\\" value=\\"\\"></div></div></div><div class=\\"MuiDialogActions-root-136 dialog-footer\\"><button class=\\"MuiButtonBase-root-164 MuiButton-root-138 MuiButton-text-140 MuiButton-flat-143 MuiButton-colorInherit-159 MuiDialogActions-action-137\\" tabindex=\\"0\\" type=\\"button\\" id=\\"login--form-cancel\\"><span class=\\"MuiButton-label-139\\">Cancel</span><span class=\\"MuiTouchRipple-root-167\\"></span></button><button class=\\"MuiButtonBase-root-164 MuiButtonBase-disabled-165 MuiButton-root-138 MuiButton-text-140 MuiButton-flat-143 MuiButton-disabled-158 MuiButton-colorInherit-159 MuiDialogActions-action-137\\" tabindex=\\"-1\\" type=\\"submit\\" disabled=\\"\\" id=\\"login--form-submit\\"><span class=\\"MuiButton-label-139\\">Login</span></button></div></form></div></div></div>"`;
|
exports[`<LoginModal /> should load the component in default state 1`] = `"<div role=\\"dialog\\" class=\\"MuiModal-root-15 MuiDialog-root-1\\" id=\\"login--form-container\\"><div class=\\"MuiBackdrop-root-17\\" aria-hidden=\\"true\\" style=\\"opacity: 1; webkit-transition: opacity 225ms cubic-bezier(0.4, 0, 0.2, 1) 0ms; transition: opacity 225ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;\\"></div><div class=\\"MuiDialog-container-4 MuiDialog-scrollPaper-2\\" role=\\"document\\" style=\\"opacity: 1; webkit-transition: opacity 225ms cubic-bezier(0.4, 0, 0.2, 1) 0ms; transition: opacity 225ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;\\" tabindex=\\"-1\\"><div class=\\"MuiPaper-root-19 MuiPaper-elevation24-45 MuiPaper-rounded-20 MuiDialog-paper-5 MuiDialog-paperScrollPaper-6 MuiDialog-paperWidthXs-8 MuiDialog-paperFullWidth-13\\"><form novalidate=\\"\\"><div class=\\"MuiDialogTitle-root-46\\"><h2 class=\\"MuiTypography-root-47 MuiTypography-title-53\\">Login</h2></div><div class=\\"MuiDialogContent-root-83\\"><div class=\\"MuiFormControl-root-84 MuiFormControl-fullWidth-87\\"><label class=\\"MuiFormLabel-root-99 MuiFormLabel-required-104 MuiInputLabel-required-92 MuiInputLabel-root-88 MuiInputLabel-formControl-93 MuiInputLabel-animated-96\\" data-shrink=\\"false\\" for=\\"username\\">Username<span class=\\"MuiFormLabel-asterisk-105\\"> *</span></label><div class=\\"MuiInputBase-root-119 MuiInput-root-106 MuiInput-underline-110 MuiInputBase-formControl-120 MuiInput-formControl-107\\"><input aria-invalid=\\"false\\" class=\\"MuiInputBase-input-129 MuiInput-input-114\\" id=\\"login--form-username\\" placeholder=\\"Your username\\" required=\\"\\" type=\\"text\\" value=\\"\\"></div></div><div class=\\"MuiFormControl-root-84 MuiFormControl-fullWidth-87 css-164r41r\\"><label class=\\"MuiFormLabel-root-99 MuiFormLabel-required-104 MuiInputLabel-required-92 MuiInputLabel-root-88 MuiInputLabel-formControl-93 MuiInputLabel-animated-96\\" data-shrink=\\"false\\" for=\\"password\\">Password<span class=\\"MuiFormLabel-asterisk-105\\"> *</span></label><div class=\\"MuiInputBase-root-119 MuiInput-root-106 MuiInput-underline-110 MuiInputBase-formControl-120 MuiInput-formControl-107\\"><input aria-invalid=\\"false\\" class=\\"MuiInputBase-input-129 MuiInput-input-114 MuiInputBase-inputType-132 MuiInput-inputType-117\\" id=\\"login--form-password\\" placeholder=\\"Your strong password\\" required=\\"\\" type=\\"password\\" value=\\"\\"></div></div></div><div class=\\"MuiDialogActions-root-136 dialog-footer\\"><button class=\\"MuiButtonBase-root-164 MuiButton-root-138 MuiButton-text-140 MuiButton-flat-143 MuiButton-colorInherit-159 MuiDialogActions-action-137\\" tabindex=\\"0\\" type=\\"button\\" id=\\"login--form-cancel\\"><span class=\\"MuiButton-label-139\\">Cancel</span><span class=\\"MuiTouchRipple-root-167\\"></span></button><button class=\\"MuiButtonBase-root-164 MuiButtonBase-disabled-165 MuiButton-root-138 MuiButton-text-140 MuiButton-flat-143 MuiButton-disabled-158 MuiButton-colorInherit-159 MuiDialogActions-action-137\\" tabindex=\\"-1\\" type=\\"submit\\" disabled=\\"\\" id=\\"login--form-submit\\"><span class=\\"MuiButton-label-139\\">Login</span></button></div></form></div></div></div>"`;
|
||||||
|
|
||||||
exports[`<LoginModal /> should load the component with props 1`] = `"<div role=\\"dialog\\" class=\\"MuiModal-root-15 MuiDialog-root-1\\" id=\\"login--form-container\\"><div class=\\"MuiBackdrop-root-17\\" aria-hidden=\\"true\\" style=\\"opacity: 1; webkit-transition: opacity 225ms cubic-bezier(0.4, 0, 0.2, 1) 0ms; transition: opacity 225ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;\\"></div><div class=\\"MuiDialog-container-4 MuiDialog-scrollPaper-2\\" role=\\"document\\" style=\\"opacity: 1; webkit-transition: opacity 225ms cubic-bezier(0.4, 0, 0.2, 1) 0ms; transition: opacity 225ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;\\" tabindex=\\"-1\\"><div class=\\"MuiPaper-root-19 MuiPaper-elevation24-45 MuiPaper-rounded-20 MuiDialog-paper-5 MuiDialog-paperScrollPaper-6 MuiDialog-paperWidthXs-8 MuiDialog-paperFullWidth-13\\"><form novalidate=\\"\\"><div class=\\"MuiDialogTitle-root-46\\"><h2 class=\\"MuiTypography-root-47 MuiTypography-title-53\\">Login</h2></div><div class=\\"MuiDialogContent-root-83\\"><div class=\\"MuiTypography-root-47 MuiTypography-body1-56 MuiPaper-root-19 MuiPaper-elevation6-27 MuiSnackbarContent-root-174 loginError\\" role=\\"alertdialog\\"><div class=\\"MuiSnackbarContent-message-175\\"><div class=\\"loginErrorMsg\\" id=\\"client-snackbar\\"><svg class=\\"MuiSvgIcon-root-177 loginIcon\\" focusable=\\"false\\" viewBox=\\"0 0 24 24\\" aria-hidden=\\"true\\" role=\\"presentation\\"><path fill=\\"none\\" d=\\"M0 0h24v24H0z\\"></path><path d=\\"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-2h2v2zm0-4h-2V7h2v6z\\"></path></svg><span><div><strong>Error Title</strong></div><div>Error Description</div></span></div></div></div><div class=\\"MuiFormControl-root-84 MuiFormControl-fullWidth-87\\"><label class=\\"MuiFormLabel-root-99 MuiFormLabel-required-104 MuiInputLabel-required-92 MuiInputLabel-root-88 MuiInputLabel-formControl-93 MuiInputLabel-animated-96\\" data-shrink=\\"false\\" for=\\"username\\">Username<span class=\\"MuiFormLabel-asterisk-105\\"> *</span></label><div class=\\"MuiInputBase-root-119 MuiInput-root-106 MuiInput-underline-110 MuiInputBase-formControl-120 MuiInput-formControl-107\\"><input aria-invalid=\\"false\\" class=\\"MuiInputBase-input-129 MuiInput-input-114\\" id=\\"login--form-username\\" placeholder=\\"Your username\\" required=\\"\\" type=\\"text\\" value=\\"\\"></div></div><div class=\\"MuiFormControl-root-84 MuiFormControl-fullWidth-87\\" style=\\"margin-top: 8px;\\"><label class=\\"MuiFormLabel-root-99 MuiFormLabel-required-104 MuiInputLabel-required-92 MuiInputLabel-root-88 MuiInputLabel-formControl-93 MuiInputLabel-animated-96\\" data-shrink=\\"false\\" for=\\"password\\">Password<span class=\\"MuiFormLabel-asterisk-105\\"> *</span></label><div class=\\"MuiInputBase-root-119 MuiInput-root-106 MuiInput-underline-110 MuiInputBase-formControl-120 MuiInput-formControl-107\\"><input aria-invalid=\\"false\\" class=\\"MuiInputBase-input-129 MuiInput-input-114 MuiInputBase-inputType-132 MuiInput-inputType-117\\" id=\\"login--form-password\\" placeholder=\\"Your strong password\\" required=\\"\\" type=\\"password\\" value=\\"\\"></div></div></div><div class=\\"MuiDialogActions-root-136 dialog-footer\\"><button class=\\"MuiButtonBase-root-164 MuiButton-root-138 MuiButton-text-140 MuiButton-flat-143 MuiButton-colorInherit-159 MuiDialogActions-action-137\\" tabindex=\\"0\\" type=\\"button\\" id=\\"login--form-cancel\\"><span class=\\"MuiButton-label-139\\">Cancel</span><span class=\\"MuiTouchRipple-root-167\\"></span></button><button class=\\"MuiButtonBase-root-164 MuiButtonBase-disabled-165 MuiButton-root-138 MuiButton-text-140 MuiButton-flat-143 MuiButton-disabled-158 MuiButton-colorInherit-159 MuiDialogActions-action-137\\" tabindex=\\"-1\\" type=\\"submit\\" disabled=\\"\\" id=\\"login--form-submit\\"><span class=\\"MuiButton-label-139\\">Login</span></button></div></form></div></div></div>"`;
|
exports[`<LoginModal /> should load the component with props 1`] = `"<div role=\\"dialog\\" class=\\"MuiModal-root-15 MuiDialog-root-1\\" id=\\"login--form-container\\"><div class=\\"MuiBackdrop-root-17\\" aria-hidden=\\"true\\" style=\\"opacity: 1; webkit-transition: opacity 225ms cubic-bezier(0.4, 0, 0.2, 1) 0ms; transition: opacity 225ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;\\"></div><div class=\\"MuiDialog-container-4 MuiDialog-scrollPaper-2\\" role=\\"document\\" style=\\"opacity: 1; webkit-transition: opacity 225ms cubic-bezier(0.4, 0, 0.2, 1) 0ms; transition: opacity 225ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;\\" tabindex=\\"-1\\"><div class=\\"MuiPaper-root-19 MuiPaper-elevation24-45 MuiPaper-rounded-20 MuiDialog-paper-5 MuiDialog-paperScrollPaper-6 MuiDialog-paperWidthXs-8 MuiDialog-paperFullWidth-13\\"><form novalidate=\\"\\"><div class=\\"MuiDialogTitle-root-46\\"><h2 class=\\"MuiTypography-root-47 MuiTypography-title-53\\">Login</h2></div><div class=\\"MuiDialogContent-root-83\\"><div class=\\"MuiTypography-root-47 MuiTypography-body1-56 MuiPaper-root-19 MuiPaper-elevation6-27 MuiSnackbarContent-root-174 css-11e09xf\\" role=\\"alertdialog\\"><div class=\\"MuiSnackbarContent-message-175\\"><div class=\\"css-70qvj9\\" id=\\"client-snackbar\\"><svg class=\\"MuiSvgIcon-root-177 css-1mbwbu9\\" focusable=\\"false\\" viewBox=\\"0 0 24 24\\" aria-hidden=\\"true\\" role=\\"presentation\\"><path fill=\\"none\\" d=\\"M0 0h24v24H0z\\"></path><path d=\\"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-2h2v2zm0-4h-2V7h2v6z\\"></path></svg><span><div><strong>Error Title</strong></div><div>Error Description</div></span></div></div></div><div class=\\"MuiFormControl-root-84 MuiFormControl-fullWidth-87\\"><label class=\\"MuiFormLabel-root-99 MuiFormLabel-required-104 MuiInputLabel-required-92 MuiInputLabel-root-88 MuiInputLabel-formControl-93 MuiInputLabel-animated-96\\" data-shrink=\\"false\\" for=\\"username\\">Username<span class=\\"MuiFormLabel-asterisk-105\\"> *</span></label><div class=\\"MuiInputBase-root-119 MuiInput-root-106 MuiInput-underline-110 MuiInputBase-formControl-120 MuiInput-formControl-107\\"><input aria-invalid=\\"false\\" class=\\"MuiInputBase-input-129 MuiInput-input-114\\" id=\\"login--form-username\\" placeholder=\\"Your username\\" required=\\"\\" type=\\"text\\" value=\\"\\"></div></div><div class=\\"MuiFormControl-root-84 MuiFormControl-fullWidth-87 css-164r41r\\"><label class=\\"MuiFormLabel-root-99 MuiFormLabel-required-104 MuiInputLabel-required-92 MuiInputLabel-root-88 MuiInputLabel-formControl-93 MuiInputLabel-animated-96\\" data-shrink=\\"false\\" for=\\"password\\">Password<span class=\\"MuiFormLabel-asterisk-105\\"> *</span></label><div class=\\"MuiInputBase-root-119 MuiInput-root-106 MuiInput-underline-110 MuiInputBase-formControl-120 MuiInput-formControl-107\\"><input aria-invalid=\\"false\\" class=\\"MuiInputBase-input-129 MuiInput-input-114 MuiInputBase-inputType-132 MuiInput-inputType-117\\" id=\\"login--form-password\\" placeholder=\\"Your strong password\\" required=\\"\\" type=\\"password\\" value=\\"\\"></div></div></div><div class=\\"MuiDialogActions-root-136 dialog-footer\\"><button class=\\"MuiButtonBase-root-164 MuiButton-root-138 MuiButton-text-140 MuiButton-flat-143 MuiButton-colorInherit-159 MuiDialogActions-action-137\\" tabindex=\\"0\\" type=\\"button\\" id=\\"login--form-cancel\\"><span class=\\"MuiButton-label-139\\">Cancel</span><span class=\\"MuiTouchRipple-root-167\\"></span></button><button class=\\"MuiButtonBase-root-164 MuiButtonBase-disabled-165 MuiButton-root-138 MuiButton-text-140 MuiButton-flat-143 MuiButton-disabled-158 MuiButton-colorInherit-159 MuiDialogActions-action-137\\" tabindex=\\"-1\\" type=\\"submit\\" disabled=\\"\\" id=\\"login--form-submit\\"><span class=\\"MuiButton-label-139\\">Login</span></button></div></form></div></div></div>"`;
|
||||||
|
@ -1,22 +0,0 @@
|
|||||||
@import '../../styles/variables';
|
|
||||||
|
|
||||||
.loginDialog {
|
|
||||||
min-width: 300px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.loginError {
|
|
||||||
background-color: $red !important;
|
|
||||||
min-width: inherit !important;
|
|
||||||
margin-bottom: 10px !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
.loginErrorMsg {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.loginIcon {
|
|
||||||
opacity: 0.9;
|
|
||||||
margin-right: 8px;
|
|
||||||
}
|
|
||||||
|
|
22
src/components/Login/styles.ts
Normal file
22
src/components/Login/styles.ts
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
import { css } from 'emotion';
|
||||||
|
import colors from '../../utils/styles/colors';
|
||||||
|
|
||||||
|
export const loginDialog = css({
|
||||||
|
minWidth: '300px',
|
||||||
|
});
|
||||||
|
|
||||||
|
export const loginError = css({
|
||||||
|
backgroundColor: `${colors.red} !important`,
|
||||||
|
minWidth: 'inherit !important',
|
||||||
|
marginBottom: '10px !important',
|
||||||
|
});
|
||||||
|
|
||||||
|
export const loginErrorMsg = css({
|
||||||
|
display: 'flex',
|
||||||
|
alignItems: 'center',
|
||||||
|
});
|
||||||
|
|
||||||
|
export const loginIcon = css({
|
||||||
|
opacity: 0.9,
|
||||||
|
marginRight: '8px',
|
||||||
|
});
|
@ -3,7 +3,16 @@ import React from 'react';
|
|||||||
import styled from 'react-emotion';
|
import styled from 'react-emotion';
|
||||||
import logo from './img/logo.svg';
|
import logo from './img/logo.svg';
|
||||||
|
|
||||||
const StyledLogo = styled.div`
|
export enum Size {
|
||||||
|
Small = '40px',
|
||||||
|
Big = '90px',
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
size?: Size;
|
||||||
|
}
|
||||||
|
|
||||||
|
const StyledLogo = styled('div')<Props>`
|
||||||
&& {
|
&& {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
@ -12,11 +21,12 @@ const StyledLogo = styled.div`
|
|||||||
background-size: contain;
|
background-size: contain;
|
||||||
background-image: url(${logo});
|
background-image: url(${logo});
|
||||||
background-repeat: no-repeat;
|
background-repeat: no-repeat;
|
||||||
width: 40px;
|
width: ${({ size }) => size};
|
||||||
height: 40px;`;
|
height: ${({ size }) => size};
|
||||||
|
}
|
||||||
const Logo: React.FC = () => {
|
`;
|
||||||
return <StyledLogo />;
|
const Logo: React.FC<Props> = ({ size = Size.Small }) => {
|
||||||
|
return <StyledLogo size={size} />;
|
||||||
};
|
};
|
||||||
|
|
||||||
export default Logo;
|
export default Logo;
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||||
|
|
||||||
exports[`<Logo /> component should render the component in default state 1`] = `"<div class=\\"css-1tnu3ib em793ed0\\"></div>"`;
|
exports[`<Logo /> component should render the component in default state 1`] = `"<div class=\\"css-1sifsqk em793ed0\\"></div>"`;
|
||||||
|
@ -1 +1 @@
|
|||||||
export { default } from './Logo';
|
export { default, Size } from './Logo';
|
||||||
|
@ -6,21 +6,22 @@ import { RouteComponentProps, withRouter } from 'react-router-dom';
|
|||||||
|
|
||||||
import PackageImg from './img/package.svg';
|
import PackageImg from './img/package.svg';
|
||||||
import { Card, EmptyPackage, Heading, Inner, List, Wrapper } from './styles';
|
import { Card, EmptyPackage, Heading, Inner, List, Wrapper } from './styles';
|
||||||
|
import { Breakpoint } from '@material-ui/core/styles/createBreakpoints';
|
||||||
|
|
||||||
export const NOT_FOUND_TEXT = "Sorry, we couldn't find it...";
|
export const NOT_FOUND_TEXT = "Sorry, we couldn't find it...";
|
||||||
|
|
||||||
export type NotFoundProps = RouteComponentProps & { width: any; history: any };
|
export type NotFoundProps = RouteComponentProps & { width: Breakpoint; history };
|
||||||
|
|
||||||
const NotFound: React.FC<NotFoundProps> = ({ history, width }) => {
|
const NotFound: React.FC<NotFoundProps> = ({ history, width }) => {
|
||||||
const handleGoTo = (to: string) => () => {
|
const handleGoTo = (to: string): (() => void | undefined) => () => {
|
||||||
history.push(to);
|
history.push(to);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleGoBack = () => () => {
|
const handleGoBack = (): ((e: React.MouseEvent<HTMLElement, MouseEvent>) => void | undefined) => () => {
|
||||||
history.goBack();
|
history.goBack();
|
||||||
};
|
};
|
||||||
|
|
||||||
const renderList = () => (
|
const renderList = (): JSX.Element => (
|
||||||
<List>
|
<List>
|
||||||
<ListItem button={true} divider={true} onClick={handleGoTo('/')}>
|
<ListItem button={true} divider={true} onClick={handleGoTo('/')}>
|
||||||
{'Home'}
|
{'Home'}
|
||||||
@ -31,7 +32,7 @@ const NotFound: React.FC<NotFoundProps> = ({ history, width }) => {
|
|||||||
</List>
|
</List>
|
||||||
);
|
);
|
||||||
|
|
||||||
const renderSubTitle = () => (
|
const renderSubTitle = (): JSX.Element => (
|
||||||
<Typography variant="subtitle1">
|
<Typography variant="subtitle1">
|
||||||
<div>{"The page you're looking for doesn't exist."}</div>
|
<div>{"The page you're looking for doesn't exist."}</div>
|
||||||
<div>{'Perhaps these links will help find what you are looking for:'}</div>
|
<div>{'Perhaps these links will help find what you are looking for:'}</div>
|
||||||
|
@ -3,39 +3,39 @@ import { default as MuiList } from '@material-ui/core/List';
|
|||||||
import Typography from '@material-ui/core/Typography';
|
import Typography from '@material-ui/core/Typography';
|
||||||
import styled from 'react-emotion';
|
import styled from 'react-emotion';
|
||||||
|
|
||||||
export const Wrapper = styled('div')`
|
export const Wrapper = styled('div')({
|
||||||
display: flex;
|
display: 'flex',
|
||||||
align-items: center;
|
alignItems: 'center',
|
||||||
flex-direction: column;
|
flexDirection: 'column',
|
||||||
justify-content: center;
|
justifyContent: 'center',
|
||||||
flex: 1;
|
flex: 1,
|
||||||
padding: 16px;
|
padding: '16px',
|
||||||
`;
|
});
|
||||||
|
|
||||||
export const Inner = styled('div')`
|
export const Inner = styled('div')({
|
||||||
max-width: 650px;
|
maxWidth: '650px',
|
||||||
display: flex;
|
display: 'flex',
|
||||||
flex-direction: column;
|
flexDirection: 'column',
|
||||||
`;
|
});
|
||||||
|
|
||||||
export const EmptyPackage = styled('img')`
|
export const EmptyPackage = styled('img')({
|
||||||
width: 150px;
|
width: '150px',
|
||||||
margin: 0 auto;
|
margin: '0 auto',
|
||||||
`;
|
});
|
||||||
|
|
||||||
export const Heading = styled(Typography)`
|
export const Heading = styled(Typography)({
|
||||||
&& {
|
'&&': {
|
||||||
color: #4b5e40;
|
color: '#4b5e40',
|
||||||
}
|
},
|
||||||
`;
|
});
|
||||||
|
|
||||||
export const List = styled(MuiList)`
|
export const List = styled(MuiList)({
|
||||||
&& {
|
'&&': {
|
||||||
padding: 0;
|
padding: 0,
|
||||||
color: #4b5e40;
|
color: '#4b5e40',
|
||||||
}
|
},
|
||||||
`;
|
});
|
||||||
|
|
||||||
export const Card = styled(MuiCard)`
|
export const Card = styled(MuiCard)({
|
||||||
margin-top: 24px;
|
marginTop: '24px',
|
||||||
`;
|
});
|
||||||
|
@ -8,7 +8,7 @@ import { WrapperLink, Description, OverviewItem } from './styles';
|
|||||||
* Generates one month back date from current time
|
* Generates one month back date from current time
|
||||||
* @return {object} date object
|
* @return {object} date object
|
||||||
*/
|
*/
|
||||||
const dateOneMonthAgo = () => new Date(1544377770747);
|
const dateOneMonthAgo = (): Date => new Date(1544377770747);
|
||||||
|
|
||||||
describe('<Package /> component', () => {
|
describe('<Package /> component', () => {
|
||||||
test.skip('should load the component', () => {
|
test.skip('should load the component', () => {
|
||||||
|
@ -6,36 +6,10 @@ import HomeIcon from '@material-ui/icons/Home';
|
|||||||
import ListItem from '@material-ui/core/ListItem';
|
import ListItem from '@material-ui/core/ListItem';
|
||||||
import Tooltip from '@material-ui/core/Tooltip';
|
import Tooltip from '@material-ui/core/Tooltip';
|
||||||
|
|
||||||
|
import { PackageMetaInterface } from 'types/packageMeta';
|
||||||
import Tag from '../Tag';
|
import Tag from '../Tag';
|
||||||
import fileSizeSI from '../../utils/file-size';
|
import fileSizeSI from '../../utils/file-size';
|
||||||
import { formatDate, formatDateDistance } from '../../utils/package';
|
import { formatDate, formatDateDistance } from '../../utils/package';
|
||||||
|
|
||||||
interface Author {
|
|
||||||
name: string;
|
|
||||||
avatar?: string;
|
|
||||||
email?: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface Bugs {
|
|
||||||
url: string;
|
|
||||||
}
|
|
||||||
interface Dist {
|
|
||||||
unpackedSize: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface Props {
|
|
||||||
name: string;
|
|
||||||
version: string;
|
|
||||||
time: string;
|
|
||||||
author: Author;
|
|
||||||
description?: string;
|
|
||||||
keywords?: string[];
|
|
||||||
license?: string | null;
|
|
||||||
homepage?: string;
|
|
||||||
bugs?: Bugs;
|
|
||||||
dist?: Dist;
|
|
||||||
}
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
Author,
|
Author,
|
||||||
Avatar,
|
Avatar,
|
||||||
@ -55,8 +29,33 @@ import {
|
|||||||
WrapperLink,
|
WrapperLink,
|
||||||
} from './styles';
|
} from './styles';
|
||||||
import { isURL } from '../../utils/url';
|
import { isURL } from '../../utils/url';
|
||||||
|
interface Author {
|
||||||
|
name: string;
|
||||||
|
avatar?: string;
|
||||||
|
email?: string;
|
||||||
|
}
|
||||||
|
|
||||||
const Package: React.FC<Props> = ({
|
interface Bugs {
|
||||||
|
url: string;
|
||||||
|
}
|
||||||
|
interface Dist {
|
||||||
|
unpackedSize: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface PackageInterface {
|
||||||
|
name: string;
|
||||||
|
version: string;
|
||||||
|
time?: number | string;
|
||||||
|
author: Author;
|
||||||
|
description?: string;
|
||||||
|
keywords?: string[];
|
||||||
|
license?: PackageMetaInterface['latest']['license'];
|
||||||
|
homepage?: string;
|
||||||
|
bugs?: Bugs;
|
||||||
|
dist?: Dist;
|
||||||
|
}
|
||||||
|
|
||||||
|
const Package: React.FC<PackageInterface> = ({
|
||||||
author: { name: authorName, avatar: authorAvatar },
|
author: { name: authorName, avatar: authorAvatar },
|
||||||
bugs,
|
bugs,
|
||||||
description,
|
description,
|
||||||
|
@ -34,57 +34,57 @@ export const OverviewItem = styled('span')`
|
|||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
export const Icon = styled(Ico)`
|
export const Icon = styled(Ico)({
|
||||||
&& {
|
'&&': {
|
||||||
margin: 2px 10px 0px 0;
|
margin: '2px 10px 0px 0',
|
||||||
fill: ${colors.greyLight2};
|
fill: colors.greyLight2,
|
||||||
}
|
},
|
||||||
`;
|
});
|
||||||
|
|
||||||
export const Published = styled('span')`
|
export const Published = styled('span')({
|
||||||
&& {
|
'&&': {
|
||||||
color: ${colors.greyLight2};
|
color: colors.greyLight2,
|
||||||
margin: 0px 5px 0px 0px;
|
margin: '0px 5px 0px 0px',
|
||||||
}
|
},
|
||||||
`;
|
});
|
||||||
|
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
export const Text = styled(Label)`
|
export const Text = styled(Label)({
|
||||||
&& {
|
'&&': {
|
||||||
font-size: 12px;
|
fontSize: '12px',
|
||||||
font-weight: 500;
|
fontWeight: 500,
|
||||||
color: ${colors.greyLight2};
|
color: colors.greyLight2,
|
||||||
}
|
},
|
||||||
`;
|
});
|
||||||
|
|
||||||
export const Details = styled('span')`
|
export const Details = styled('span')({
|
||||||
&& {
|
'&&': {
|
||||||
margin-left: 5px;
|
marginLeft: '5px',
|
||||||
line-height: 1.5;
|
lineHeight: 1.5,
|
||||||
display: flex;
|
display: 'flex',
|
||||||
flex-direction: column;
|
flexDirection: 'column',
|
||||||
}
|
},
|
||||||
`;
|
});
|
||||||
|
|
||||||
export const Author = styled('div')`
|
export const Author = styled('div')({
|
||||||
&& {
|
'&&': {
|
||||||
display: flex;
|
display: 'flex',
|
||||||
align-items: center;
|
alignItems: 'center',
|
||||||
}
|
},
|
||||||
`;
|
});
|
||||||
|
|
||||||
export const Avatar = styled(Photo)`
|
export const Avatar = styled(Photo)({
|
||||||
&& {
|
'&&': {
|
||||||
width: 20px;
|
width: '20px',
|
||||||
height: 20px;
|
height: '20px',
|
||||||
}
|
},
|
||||||
`;
|
});
|
||||||
|
|
||||||
export const WrapperLink = styled(Link)`
|
export const WrapperLink = styled(Link)({
|
||||||
&& {
|
'&&': {
|
||||||
text-decoration: none;
|
textDecoration: 'none',
|
||||||
}
|
},
|
||||||
`;
|
});
|
||||||
|
|
||||||
export const PackageTitle = styled('span')`
|
export const PackageTitle = styled('span')`
|
||||||
&& {
|
&& {
|
||||||
@ -106,31 +106,31 @@ export const PackageTitle = styled('span')`
|
|||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
export const GridRightAligned = styled(Grid)`
|
export const GridRightAligned = styled(Grid)({
|
||||||
&& {
|
'&&': {
|
||||||
text-align: right;
|
textAlign: 'right',
|
||||||
}
|
},
|
||||||
`;
|
});
|
||||||
|
|
||||||
export const PackageList = styled(List)`
|
export const PackageList = styled(List)({
|
||||||
&& {
|
'&&': {
|
||||||
padding: 12px 0 12px 0;
|
padding: '12px 0 12px 0',
|
||||||
|
|
||||||
&:hover {
|
'&:hover': {
|
||||||
background-color: ${colors.greyLight3};
|
backgroundColor: colors.greyLight3,
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
`;
|
});
|
||||||
|
|
||||||
export const IconButton = styled(MuiIconButton)`
|
export const IconButton = styled(MuiIconButton)({
|
||||||
&& {
|
'&&': {
|
||||||
padding: 6px;
|
padding: '6px',
|
||||||
|
|
||||||
svg {
|
svg: {
|
||||||
font-size: 16px;
|
fontSize: '16px',
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
`;
|
});
|
||||||
|
|
||||||
export const TagContainer = styled('span')`
|
export const TagContainer = styled('span')`
|
||||||
&& {
|
&& {
|
||||||
@ -143,20 +143,20 @@ export const TagContainer = styled('span')`
|
|||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
export const PackageListItem = styled(ListItem)`
|
export const PackageListItem = styled(ListItem)({
|
||||||
&& {
|
'&&': {
|
||||||
padding-top: 0;
|
paddingTop: 0,
|
||||||
}
|
},
|
||||||
`;
|
});
|
||||||
|
|
||||||
export const PackageListItemText = styled(ListItemText)`
|
export const PackageListItemText = styled(ListItemText)({
|
||||||
&& {
|
'&&': {
|
||||||
padding-right: 0;
|
paddingRight: 0,
|
||||||
}
|
},
|
||||||
`;
|
});
|
||||||
|
|
||||||
export const Description = styled(Typography)`
|
export const Description = styled(Typography)({
|
||||||
color: ${colors.greyDark2};
|
color: colors.greyDark2,
|
||||||
font-size: 14px;
|
fontSize: '14px',
|
||||||
padding-right: 0;
|
paddingRight: 0,
|
||||||
`;
|
});
|
||||||
|
@ -1,25 +1,20 @@
|
|||||||
import React, { Fragment } from 'react';
|
import React, { Fragment, ReactElement } from 'react';
|
||||||
import PropTypes from 'prop-types';
|
|
||||||
|
|
||||||
import Divider from '@material-ui/core/Divider';
|
import Divider from '@material-ui/core/Divider';
|
||||||
|
|
||||||
import Package from '../Package';
|
import Package from '../Package';
|
||||||
import Help from '../Help';
|
import Help from '../Help';
|
||||||
import { formatLicense } from '../../utils/package';
|
import { formatLicense } from '../../utils/package';
|
||||||
|
import { PackageInterface } from '../Package/Package';
|
||||||
|
|
||||||
// @ts-ignore
|
import * as classes from './styles';
|
||||||
import classes from './packageList.scss';
|
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
packages: any;
|
packages: PackageInterface[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export default class PackageList extends React.Component<Props, {}> {
|
export default class PackageList extends React.Component<Props, {}> {
|
||||||
static propTypes = {
|
public render(): ReactElement<HTMLElement> {
|
||||||
packages: PropTypes.array,
|
|
||||||
};
|
|
||||||
|
|
||||||
render() {
|
|
||||||
return (
|
return (
|
||||||
<div className={'package-list-items'}>
|
<div className={'package-list-items'}>
|
||||||
<div className={classes.pkgContainer}>{this.hasPackages() ? this.renderPackages() : <Help />}</div>
|
<div className={classes.pkgContainer}>{this.hasPackages() ? this.renderPackages() : <Help />}</div>
|
||||||
@ -27,20 +22,19 @@ export default class PackageList extends React.Component<Props, {}> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
hasPackages() {
|
private hasPackages(): boolean {
|
||||||
const { packages } = this.props;
|
const { packages } = this.props;
|
||||||
return packages.length > 0;
|
return packages.length > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
renderPackages = () => {
|
private renderPackages = () => {
|
||||||
return <>{this.renderList()}</>;
|
return <>{this.renderList()}</>;
|
||||||
};
|
};
|
||||||
|
|
||||||
renderList = () => {
|
private renderList = () => {
|
||||||
const { packages } = this.props;
|
const { packages } = this.props;
|
||||||
return packages.map((pkg, i) => {
|
return packages.map((pkg, i) => {
|
||||||
const { name, version, description, time, keywords, dist, homepage, bugs } = pkg;
|
const { name, version, description, time, keywords, dist, homepage, bugs, author } = pkg;
|
||||||
const author = pkg.author;
|
|
||||||
// TODO: move format license to API side.
|
// TODO: move format license to API side.
|
||||||
const license = formatLicense(pkg.license);
|
const license = formatLicense(pkg.license);
|
||||||
return (
|
return (
|
||||||
|
@ -1,12 +0,0 @@
|
|||||||
@import '../../styles/mixins';
|
|
||||||
|
|
||||||
.pkgContainer {
|
|
||||||
margin: 0;
|
|
||||||
padding: 0;
|
|
||||||
|
|
||||||
.listTitle {
|
|
||||||
font-weight: $font-weight-regular;
|
|
||||||
font-size: $font-size-xl;
|
|
||||||
margin: 0 0 10px 0;
|
|
||||||
}
|
|
||||||
}
|
|
17
src/components/PackageList/styles.ts
Normal file
17
src/components/PackageList/styles.ts
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
import { css } from 'emotion';
|
||||||
|
import { fontWeight, fontSize } from '../../utils/styles/sizes';
|
||||||
|
|
||||||
|
export const listTitle = css({
|
||||||
|
fontWeight: fontWeight.regular,
|
||||||
|
fontSize: fontSize.xl,
|
||||||
|
margin: `0 0 10px 0`,
|
||||||
|
});
|
||||||
|
|
||||||
|
export const pkgContainer = css`
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
|
||||||
|
& .listTitle {
|
||||||
|
${listTitle}
|
||||||
|
}
|
||||||
|
`;
|
@ -1,4 +1,5 @@
|
|||||||
import React, { Component } from 'react';
|
import React, { Component } from 'react';
|
||||||
|
import { css } from 'emotion';
|
||||||
|
|
||||||
import { Props, State } from './types';
|
import { Props, State } from './types';
|
||||||
import { CommandContainer } from './styles';
|
import { CommandContainer } from './styles';
|
||||||
@ -11,10 +12,15 @@ import { getCLISetRegistry, getCLIChangePassword, getCLISetConfigRegistry } from
|
|||||||
import { NODE_MANAGER } from '../../utils/constants';
|
import { NODE_MANAGER } from '../../utils/constants';
|
||||||
|
|
||||||
/* eslint react/prop-types:0 */
|
/* eslint react/prop-types:0 */
|
||||||
function TabContainer({ children }) {
|
function TabContainer({ children }): JSX.Element {
|
||||||
return (
|
return (
|
||||||
<CommandContainer>
|
<CommandContainer>
|
||||||
<Typography component="div" style={{ padding: 0, minHeight: 170 }}>
|
<Typography
|
||||||
|
className={css`
|
||||||
|
padding: 0;
|
||||||
|
min-height: 170;
|
||||||
|
`}
|
||||||
|
component="div">
|
||||||
{children}
|
{children}
|
||||||
</Typography>
|
</Typography>
|
||||||
</CommandContainer>
|
</CommandContainer>
|
||||||
@ -22,15 +28,20 @@ function TabContainer({ children }) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class RegistryInfoContent extends Component<Props, State> {
|
class RegistryInfoContent extends Component<Props, State> {
|
||||||
state = {
|
public state = {
|
||||||
tabPosition: 0,
|
tabPosition: 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
render() {
|
public render(): JSX.Element {
|
||||||
return <div>{this.renderTabs()}</div>;
|
return <div>{this.renderTabs()}</div>;
|
||||||
}
|
}
|
||||||
|
|
||||||
renderTabs() {
|
private handleChange = (event: React.ChangeEvent<{}>, tabPosition: number) => {
|
||||||
|
event.preventDefault();
|
||||||
|
this.setState({ tabPosition });
|
||||||
|
};
|
||||||
|
|
||||||
|
private renderTabs(): JSX.Element {
|
||||||
const { scope, registryUrl } = this.props;
|
const { scope, registryUrl } = this.props;
|
||||||
const { tabPosition } = this.state;
|
const { tabPosition } = this.state;
|
||||||
|
|
||||||
@ -48,7 +59,7 @@ class RegistryInfoContent extends Component<Props, State> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
renderNpmTab(scope: string, registryUrl: string) {
|
private renderNpmTab(scope: string, registryUrl: string): JSX.Element {
|
||||||
return (
|
return (
|
||||||
<React.Fragment>
|
<React.Fragment>
|
||||||
<CopyToClipBoard text={getCLISetConfigRegistry(`${NODE_MANAGER.npm} set`, scope, registryUrl)} />
|
<CopyToClipBoard text={getCLISetConfigRegistry(`${NODE_MANAGER.npm} set`, scope, registryUrl)} />
|
||||||
@ -58,7 +69,7 @@ class RegistryInfoContent extends Component<Props, State> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
renderPNpmTab(scope: string, registryUrl: string) {
|
private renderPNpmTab(scope: string, registryUrl: string): JSX.Element {
|
||||||
return (
|
return (
|
||||||
<React.Fragment>
|
<React.Fragment>
|
||||||
<CopyToClipBoard text={getCLISetConfigRegistry(`${NODE_MANAGER.pnpm} set`, scope, registryUrl)} />
|
<CopyToClipBoard text={getCLISetConfigRegistry(`${NODE_MANAGER.pnpm} set`, scope, registryUrl)} />
|
||||||
@ -68,18 +79,13 @@ class RegistryInfoContent extends Component<Props, State> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
renderYarnTab(scope: string, registryUrl: string) {
|
private renderYarnTab(scope: string, registryUrl: string): JSX.Element {
|
||||||
return (
|
return (
|
||||||
<React.Fragment>
|
<React.Fragment>
|
||||||
<CopyToClipBoard text={getCLISetConfigRegistry(`${NODE_MANAGER.yarn} config set`, scope, registryUrl)} />
|
<CopyToClipBoard text={getCLISetConfigRegistry(`${NODE_MANAGER.yarn} config set`, scope, registryUrl)} />
|
||||||
</React.Fragment>
|
</React.Fragment>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
handleChange = (event: any, tabPosition: number) => {
|
|
||||||
event.preventDefault();
|
|
||||||
this.setState({ tabPosition });
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default RegistryInfoContent;
|
export default RegistryInfoContent;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import styled from 'react-emotion';
|
import styled from 'react-emotion';
|
||||||
|
|
||||||
export const CommandContainer = styled('div')`
|
export const CommandContainer = styled('div')({
|
||||||
&& {
|
'&&': {
|
||||||
padding-top: 20px;
|
paddingTop: '20px',
|
||||||
}
|
},
|
||||||
`;
|
});
|
||||||
|
@ -8,7 +8,7 @@ import { Props } from './types';
|
|||||||
|
|
||||||
const LABEL = 'CLOSE';
|
const LABEL = 'CLOSE';
|
||||||
|
|
||||||
const RegistryInfoDialog: React.FC<Props> = ({ open = false, children, onClose }): any => (
|
const RegistryInfoDialog: React.FC<Props> = ({ open = false, children, onClose }) => (
|
||||||
<Dialog id="registryInfo--dialog-container" onClose={onClose} open={open}>
|
<Dialog id="registryInfo--dialog-container" onClose={onClose} open={open}>
|
||||||
<Title disableTypography={true}>{'Register Info'}</Title>
|
<Title disableTypography={true}>{'Register Info'}</Title>
|
||||||
<Content>{children}</Content>
|
<Content>{children}</Content>
|
||||||
|
@ -4,16 +4,16 @@ import DialogContent from '@material-ui/core/DialogContent';
|
|||||||
import colors from '../../utils/styles/colors';
|
import colors from '../../utils/styles/colors';
|
||||||
import { fontSize } from '../../utils/styles/sizes';
|
import { fontSize } from '../../utils/styles/sizes';
|
||||||
|
|
||||||
export const Title = styled(DialogTitle)`
|
export const Title = styled(DialogTitle)({
|
||||||
&& {
|
'&&': {
|
||||||
background-color: ${colors.primary};
|
backgroundColor: colors.primary,
|
||||||
color: ${colors.white};
|
color: colors.white,
|
||||||
font-size: ${fontSize.lg};
|
fontSize: fontSize.lg,
|
||||||
}
|
},
|
||||||
`;
|
});
|
||||||
|
|
||||||
export const Content = styled(DialogContent)`
|
export const Content = styled(DialogContent)({
|
||||||
&& {
|
'&&': {
|
||||||
padding: 0 24px;
|
padding: '0 24px',
|
||||||
}
|
},
|
||||||
`;
|
});
|
||||||
|
@ -1,11 +1,68 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { shallow } from 'enzyme';
|
import { shallow } from 'enzyme';
|
||||||
|
|
||||||
import Repository from './Repository';
|
jest.mock('./img/git.png', () => '');
|
||||||
|
|
||||||
describe('<Repository /> component', () => {
|
describe('<Repository /> component', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
jest.resetModules();
|
||||||
|
});
|
||||||
|
|
||||||
test('should render the component in default state', () => {
|
test('should render the component in default state', () => {
|
||||||
|
const packageMeta = {
|
||||||
|
latest: {
|
||||||
|
repository: {
|
||||||
|
type: 'git',
|
||||||
|
url: 'git+https://github.com/verdaccio/ui.git',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
jest.doMock('../../pages/version/Version', () => ({
|
||||||
|
DetailContextConsumer: component => {
|
||||||
|
return component.children({ packageMeta });
|
||||||
|
},
|
||||||
|
}));
|
||||||
|
|
||||||
|
const Repository = require('./Repository').default;
|
||||||
const wrapper = shallow(<Repository />);
|
const wrapper = shallow(<Repository />);
|
||||||
expect(wrapper.html()).toMatchSnapshot();
|
expect(wrapper.html()).toMatchSnapshot();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('should render the component in with no repository data', () => {
|
||||||
|
const packageMeta = {
|
||||||
|
latest: {},
|
||||||
|
};
|
||||||
|
|
||||||
|
jest.doMock('../../pages/version/Version', () => ({
|
||||||
|
DetailContextConsumer: component => {
|
||||||
|
return component.children({ packageMeta });
|
||||||
|
},
|
||||||
|
}));
|
||||||
|
|
||||||
|
const Repository = require('./Repository').default;
|
||||||
|
const wrapper = shallow(<Repository />);
|
||||||
|
expect(wrapper.html()).toEqual('');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('should render the component in with invalid url', () => {
|
||||||
|
const packageMeta = {
|
||||||
|
latest: {
|
||||||
|
repository: {
|
||||||
|
type: 'git',
|
||||||
|
url: 'git://github.com/verdaccio/ui.git',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
jest.doMock('../../pages/version/Version', () => ({
|
||||||
|
DetailContextConsumer: component => {
|
||||||
|
return component.children({ packageMeta });
|
||||||
|
},
|
||||||
|
}));
|
||||||
|
|
||||||
|
const Repository = require('./Repository').default;
|
||||||
|
const wrapper = shallow(<Repository />);
|
||||||
|
expect(wrapper.html()).toEqual('');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@ -13,7 +13,7 @@ import { Heading, GithubLink, RepositoryListItem } from './styles';
|
|||||||
import git from './img/git.png';
|
import git from './img/git.png';
|
||||||
import { isURL } from '../../utils/url';
|
import { isURL } from '../../utils/url';
|
||||||
|
|
||||||
class Repository extends Component<any, any> {
|
class Repository extends Component {
|
||||||
public render(): ReactElement<HTMLElement> {
|
public render(): ReactElement<HTMLElement> {
|
||||||
return (
|
return (
|
||||||
<DetailContextConsumer>
|
<DetailContextConsumer>
|
||||||
@ -33,12 +33,7 @@ class Repository extends Component<any, any> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private renderRepository = packageMeta => {
|
private renderRepository = packageMeta => {
|
||||||
const {
|
const { repository: { url = null } = {} } = packageMeta.latest;
|
||||||
repository: {
|
|
||||||
// @ts-ignore
|
|
||||||
url,
|
|
||||||
} = {},
|
|
||||||
} = packageMeta.latest;
|
|
||||||
|
|
||||||
if (!url || isURL(url) === false) {
|
if (!url || isURL(url) === false) {
|
||||||
return null;
|
return null;
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||||
|
|
||||||
exports[`<Repository /> component should render the component in default state 1`] = `""`;
|
exports[`<Repository /> component should render the component in default state 1`] = `"<ul class=\\"MuiList-root-1 MuiList-dense-3 MuiList-padding-2 MuiList-subheader-4\\"><h3 class=\\"MuiTypography-root-5 MuiTypography-subheading-12 css-hyrz44 e1wmjxnh0\\">Repository</h3><li class=\\"MuiListItem-root-41 MuiListItem-default-44 MuiListItem-dense-45 MuiListItem-gutters-49 css-z8a2h0 e1wmjxnh4\\"><div class=\\"MuiAvatar-root-53 MuiAvatar-colorDefault-54\\"></div><div class=\\"MuiListItemText-root-56 MuiListItemText-dense-58\\"><span class=\\"MuiTypography-root-5 MuiTypography-subheading-12 MuiListItemText-primary-59 MuiListItemText-textDense-61\\"><div class=\\"css-1mta3t8 eb8w2fo0\\"><span class=\\"css-1m8aenu eb8w2fo1\\"><a href=\\"git+https://github.com/verdaccio/ui.git\\" target=\\"_blank\\" class=\\"css-15gl0ho e1wmjxnh2\\">git+https://github.com/verdaccio/ui.git</a></span><button class=\\"MuiButtonBase-root-76 MuiIconButton-root-70 css-56v3u0 eb8w2fo2\\" tabindex=\\"0\\" type=\\"button\\" title=\\"Copy to Clipboard\\"><span class=\\"MuiIconButton-label-75\\"><svg class=\\"MuiSvgIcon-root-79\\" focusable=\\"false\\" viewBox=\\"0 0 24 24\\" aria-hidden=\\"true\\" role=\\"presentation\\"><path fill=\\"none\\" d=\\"M0 0h24v24H0z\\"></path><path d=\\"M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm-1 4l6 6v10c0 1.1-.9 2-2 2H7.99C6.89 23 6 22.1 6 21l.01-14c0-1.1.89-2 1.99-2h7zm-1 7h5.5L14 6.5V12z\\"></path></svg></span></button></div></span></div></li></ul>"`;
|
||||||
|
@ -6,36 +6,36 @@ import Typography from '@material-ui/core/Typography';
|
|||||||
import Github from '../../icons/GitHub';
|
import Github from '../../icons/GitHub';
|
||||||
import colors from '../../utils/styles/colors';
|
import colors from '../../utils/styles/colors';
|
||||||
|
|
||||||
export const Heading = styled(Typography)`
|
export const Heading = styled(Typography)({
|
||||||
&& {
|
'&&': {
|
||||||
font-weight: 700;
|
fontWeight: 700,
|
||||||
text-transform: capitalize;
|
textTransform: 'capitalize',
|
||||||
}
|
},
|
||||||
`;
|
});
|
||||||
|
|
||||||
export const GridRepo = styled(Grid)`
|
export const GridRepo = styled(Grid)({
|
||||||
&& {
|
'&&': {
|
||||||
align-items: center;
|
alignItems: 'center',
|
||||||
}
|
},
|
||||||
`;
|
});
|
||||||
|
|
||||||
export const GithubLink = styled('a')`
|
export const GithubLink = styled('a')({
|
||||||
&& {
|
'&&': {
|
||||||
color: ${colors.primary};
|
color: colors.primary,
|
||||||
}
|
},
|
||||||
`;
|
});
|
||||||
|
|
||||||
export const GithubLogo = styled(Github)`
|
export const GithubLogo = styled(Github)({
|
||||||
&& {
|
'&&': {
|
||||||
font-size: 40px;
|
fontSize: '40px',
|
||||||
color: ${colors.primary};
|
color: colors.primary,
|
||||||
background-color: ${colors.greySuperLight};
|
backgroundColor: colors.greySuperLight,
|
||||||
}
|
},
|
||||||
`;
|
});
|
||||||
|
|
||||||
export const RepositoryListItem = styled(ListItem)`
|
export const RepositoryListItem = styled(ListItem)({
|
||||||
&& {
|
'&&': {
|
||||||
padding-left: 0;
|
paddingLeft: 0,
|
||||||
padding-right: 0;
|
paddingRight: 0,
|
||||||
}
|
},
|
||||||
`;
|
});
|
||||||
|
@ -154,7 +154,7 @@ describe('<Search /> component test', () => {
|
|||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
jest.resetModules();
|
jest.resetModules();
|
||||||
jest.doMock('lodash/debounce', () => {
|
jest.doMock('lodash/debounce', () => {
|
||||||
return function debounceMock(fn, delay) {
|
return function debounceMock(fn) {
|
||||||
return fn;
|
return fn;
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import React, { KeyboardEvent, Component, ReactElement } from 'react';
|
import React, { KeyboardEvent, Component, ReactElement } from 'react';
|
||||||
import { withRouter, RouteComponentProps } from 'react-router-dom';
|
import { withRouter, RouteComponentProps } from 'react-router-dom';
|
||||||
|
import { css } from 'emotion';
|
||||||
|
|
||||||
import { default as IconSearch } from '@material-ui/icons/Search';
|
import { default as IconSearch } from '@material-ui/icons/Search';
|
||||||
import InputAdornment from '@material-ui/core/InputAdornment';
|
import InputAdornment from '@material-ui/core/InputAdornment';
|
||||||
@ -11,11 +12,15 @@ import colors from '../../utils/styles/colors';
|
|||||||
|
|
||||||
export interface State {
|
export interface State {
|
||||||
search: string;
|
search: string;
|
||||||
suggestions: any[];
|
suggestions: unknown[];
|
||||||
loading: boolean;
|
loading: boolean;
|
||||||
loaded: boolean;
|
loaded: boolean;
|
||||||
error: boolean;
|
error: boolean;
|
||||||
}
|
}
|
||||||
|
interface AbortControllerInterface {
|
||||||
|
signal: () => void;
|
||||||
|
abort: () => void;
|
||||||
|
}
|
||||||
|
|
||||||
export type cancelAllSearchRequests = () => void;
|
export type cancelAllSearchRequests = () => void;
|
||||||
export type handlePackagesClearRequested = () => void;
|
export type handlePackagesClearRequested = () => void;
|
||||||
@ -31,8 +36,6 @@ const CONSTANTS = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export class Search extends Component<RouteComponentProps<{}>, State> {
|
export class Search extends Component<RouteComponentProps<{}>, State> {
|
||||||
private requestList: any[];
|
|
||||||
|
|
||||||
constructor(props: RouteComponentProps<{}>) {
|
constructor(props: RouteComponentProps<{}>) {
|
||||||
super(props);
|
super(props);
|
||||||
this.state = {
|
this.state = {
|
||||||
@ -48,6 +51,28 @@ export class Search extends Component<RouteComponentProps<{}>, State> {
|
|||||||
this.requestList = [];
|
this.requestList = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public render(): ReactElement<HTMLElement> {
|
||||||
|
const { suggestions, search, loaded, loading, error } = this.state;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<AutoComplete
|
||||||
|
color={colors.white}
|
||||||
|
onBlur={this.handleOnBlur}
|
||||||
|
onChange={this.handleSearch}
|
||||||
|
onCleanSuggestions={this.handlePackagesClearRequested}
|
||||||
|
onClick={this.handleClickSearch}
|
||||||
|
onSuggestionsFetch={debounce(this.handleFetchPackages, CONSTANTS.API_DELAY)}
|
||||||
|
placeholder={CONSTANTS.PLACEHOLDER_TEXT}
|
||||||
|
startAdornment={this.getAdorment()}
|
||||||
|
suggestions={suggestions}
|
||||||
|
suggestionsError={error}
|
||||||
|
suggestionsLoaded={loaded}
|
||||||
|
suggestionsLoading={loading}
|
||||||
|
value={search}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cancel all the requests which are in pending state.
|
* Cancel all the requests which are in pending state.
|
||||||
*/
|
*/
|
||||||
@ -96,7 +121,10 @@ export class Search extends Component<RouteComponentProps<{}>, State> {
|
|||||||
/**
|
/**
|
||||||
* When an user select any package by clicking or pressing return key.
|
* When an user select any package by clicking or pressing return key.
|
||||||
*/
|
*/
|
||||||
private handleClickSearch: handleClickSearch = (event, { suggestionValue, method }: any) => {
|
private handleClickSearch = (
|
||||||
|
event: React.KeyboardEvent<HTMLInputElement>,
|
||||||
|
{ suggestionValue, method }: { suggestionValue: string[]; method: string }
|
||||||
|
): void | undefined => {
|
||||||
const { history } = this.props;
|
const { history } = this.props;
|
||||||
// stops event bubbling
|
// stops event bubbling
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
@ -141,31 +169,15 @@ export class Search extends Component<RouteComponentProps<{}>, State> {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
public render(): ReactElement<HTMLElement> {
|
private requestList: AbortControllerInterface[];
|
||||||
const { suggestions, search, loaded, loading, error } = this.state;
|
|
||||||
|
|
||||||
|
public getAdorment(): JSX.Element {
|
||||||
return (
|
return (
|
||||||
<AutoComplete
|
<InputAdornment
|
||||||
color={colors.white}
|
className={css`
|
||||||
onBlur={this.handleOnBlur}
|
color: ${colors.white};
|
||||||
onChange={this.handleSearch}
|
`}
|
||||||
onCleanSuggestions={this.handlePackagesClearRequested}
|
position={'start'}>
|
||||||
onClick={this.handleClickSearch}
|
|
||||||
onSuggestionsFetch={debounce(this.handleFetchPackages, CONSTANTS.API_DELAY)}
|
|
||||||
placeholder={CONSTANTS.PLACEHOLDER_TEXT}
|
|
||||||
startAdornment={this.getAdorment()}
|
|
||||||
suggestions={suggestions}
|
|
||||||
suggestionsError={error}
|
|
||||||
suggestionsLoaded={loaded}
|
|
||||||
suggestionsLoading={loading}
|
|
||||||
value={search}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public getAdorment(): ReactElement<HTMLElement> {
|
|
||||||
return (
|
|
||||||
<InputAdornment position={'start'} style={{ color: colors.white }}>
|
|
||||||
<IconSearch />
|
<IconSearch />
|
||||||
</InputAdornment>
|
</InputAdornment>
|
||||||
);
|
);
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||||
|
|
||||||
exports[`<Search /> component test should load the component in default state 1`] = `"<div class=\\"css-1crzyyo e1rflf270\\"><div role=\\"combobox\\" aria-haspopup=\\"listbox\\" aria-owns=\\"react-autowhatever-1\\" aria-expanded=\\"false\\" class=\\"react-autosuggest__container\\"><div class=\\"MuiFormControl-root-1 MuiFormControl-fullWidth-4 react-autosuggest__input\\" aria-autocomplete=\\"list\\" aria-controls=\\"react-autowhatever-1\\"><div class=\\"MuiInputBase-root-18 MuiInput-root-5 css-n9ojyg MuiInput-underline-9 MuiInputBase-fullWidth-27 MuiInput-fullWidth-12 MuiInputBase-formControl-19 MuiInput-formControl-6 MuiInputBase-adornedStart-22\\"><div class=\\"MuiInputAdornment-root-35 MuiInputAdornment-positionStart-37\\" style=\\"color: rgb(255, 255, 255);\\"><svg class=\\"MuiSvgIcon-root-40\\" focusable=\\"false\\" viewBox=\\"0 0 24 24\\" aria-hidden=\\"true\\" role=\\"presentation\\"><path d=\\"M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z\\"></path><path fill=\\"none\\" d=\\"M0 0h24v24H0z\\"></path></svg></div><input aria-invalid=\\"false\\" autocomplete=\\"off\\" class=\\"MuiInputBase-input-28 MuiInput-input-13 css-hodoyq MuiInputBase-inputAdornedStart-33\\" placeholder=\\"Search Packages\\" type=\\"text\\" value=\\"\\"></div></div><div class=\\"MuiPaper-root-49 MuiPaper-elevation2-53 react-autosuggest__suggestions-container css-cfo6a e1rflf271\\" id=\\"react-autowhatever-1\\" role=\\"listbox\\"></div></div></div>"`;
|
exports[`<Search /> component test should load the component in default state 1`] = `"<div class=\\"css-1crzyyo e1rflf270\\"><div role=\\"combobox\\" aria-haspopup=\\"listbox\\" aria-owns=\\"react-autowhatever-1\\" aria-expanded=\\"false\\" class=\\"react-autosuggest__container\\"><div class=\\"MuiFormControl-root-1 MuiFormControl-fullWidth-4 react-autosuggest__input\\" aria-autocomplete=\\"list\\" aria-controls=\\"react-autowhatever-1\\"><div class=\\"MuiInputBase-root-18 MuiInput-root-5 css-n9ojyg MuiInput-underline-9 MuiInputBase-fullWidth-27 MuiInput-fullWidth-12 MuiInputBase-formControl-19 MuiInput-formControl-6 MuiInputBase-adornedStart-22\\"><div class=\\"MuiInputAdornment-root-35 MuiInputAdornment-positionStart-37 css-16qv2i2\\"><svg class=\\"MuiSvgIcon-root-40\\" focusable=\\"false\\" viewBox=\\"0 0 24 24\\" aria-hidden=\\"true\\" role=\\"presentation\\"><path d=\\"M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z\\"></path><path fill=\\"none\\" d=\\"M0 0h24v24H0z\\"></path></svg></div><input aria-invalid=\\"false\\" autocomplete=\\"off\\" class=\\"MuiInputBase-input-28 MuiInput-input-13 css-hodoyq MuiInputBase-inputAdornedStart-33\\" placeholder=\\"Search Packages\\" type=\\"text\\" value=\\"\\"></div></div><div class=\\"MuiPaper-root-49 MuiPaper-elevation2-53 react-autosuggest__suggestions-container css-cfo6a e1rflf271\\" id=\\"react-autowhatever-1\\" role=\\"listbox\\"></div></div></div>"`;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import CircularProgress from '@material-ui/core/CircularProgress';
|
import CircularProgress from '@material-ui/core/CircularProgress';
|
||||||
import styled, { css, Themed } from 'react-emotion';
|
import styled, { css } from 'react-emotion';
|
||||||
|
|
||||||
import colors from '../../utils/styles/colors';
|
import colors from '../../utils/styles/colors';
|
||||||
|
|
||||||
@ -8,7 +8,7 @@ export const Wrapper = styled('div')`
|
|||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
${(props): Themed<any, object> =>
|
${props =>
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
props.centered &&
|
props.centered &&
|
||||||
css`
|
css`
|
||||||
@ -20,8 +20,8 @@ export const Wrapper = styled('div')`
|
|||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
export const Circular = styled(CircularProgress)`
|
export const Circular = styled(CircularProgress)({
|
||||||
&& {
|
'&&': {
|
||||||
color: ${colors.primary};
|
color: colors.primary,
|
||||||
}
|
},
|
||||||
`;
|
});
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
import styled from 'react-emotion';
|
import styled from 'react-emotion';
|
||||||
|
|
||||||
export const Wrapper = styled('span')`
|
export const Wrapper = styled('span')({
|
||||||
&& {
|
'&&': {
|
||||||
vertical-align: middle;
|
verticalAlign: 'middle',
|
||||||
line-height: 22px;
|
lineHeight: '22px',
|
||||||
border-radius: 2px;
|
borderRadius: '2px',
|
||||||
color: #485a3e;
|
color: '#485a3e',
|
||||||
background-color: #f3f4f2;
|
backgroundColor: '#f3f4f2',
|
||||||
padding: 0.22rem 0.4rem;
|
padding: '0.22rem 0.4rem',
|
||||||
margin: 8px 8px 0 0;
|
margin: '8px 8px 0 0',
|
||||||
}
|
},
|
||||||
`;
|
});
|
||||||
|
@ -8,7 +8,7 @@ import { formatDateDistance } from '../../utils/package';
|
|||||||
|
|
||||||
import { Heading, Spacer, ListItemText } from './styles';
|
import { Heading, Spacer, ListItemText } from './styles';
|
||||||
|
|
||||||
class UpLinks extends React.PureComponent<any> {
|
class UpLinks extends React.PureComponent<{}> {
|
||||||
public render(): ReactElement<HTMLElement> {
|
public render(): ReactElement<HTMLElement> {
|
||||||
return (
|
return (
|
||||||
<DetailContextConsumer>
|
<DetailContextConsumer>
|
||||||
|
@ -2,23 +2,23 @@ import styled from 'react-emotion';
|
|||||||
import Typography from '@material-ui/core/Typography';
|
import Typography from '@material-ui/core/Typography';
|
||||||
import { default as MuiListItemText } from '@material-ui/core/ListItemText';
|
import { default as MuiListItemText } from '@material-ui/core/ListItemText';
|
||||||
|
|
||||||
export const Heading = styled(Typography)`
|
export const Heading = styled(Typography)({
|
||||||
&& {
|
'&&': {
|
||||||
font-weight: 700;
|
fontWeight: 700,
|
||||||
}
|
},
|
||||||
`;
|
});
|
||||||
|
|
||||||
export const Spacer = styled('div')`
|
export const Spacer = styled('div')({
|
||||||
flex: 1 1 auto;
|
flex: '1 1 auto',
|
||||||
border-bottom: 1px dotted rgba(0, 0, 0, 0.2);
|
borderBottom: '1px dotted rgba(0, 0, 0, 0.2)',
|
||||||
white-space: nowrap;
|
whiteSpace: 'nowrap',
|
||||||
height: 0.5em;
|
height: '0.5em',
|
||||||
`;
|
});
|
||||||
|
|
||||||
export const ListItemText = styled(MuiListItemText)`
|
export const ListItemText = styled(MuiListItemText)({
|
||||||
&& {
|
'&&': {
|
||||||
flex: none;
|
flex: 'none',
|
||||||
color: black;
|
color: 'black',
|
||||||
opacity: 0.6;
|
opacity: 0.6,
|
||||||
}
|
},
|
||||||
`;
|
});
|
||||||
|
@ -8,7 +8,7 @@ import { DIST_TAGS } from '../../../lib/constants';
|
|||||||
|
|
||||||
const NOT_AVAILABLE = 'Not available';
|
const NOT_AVAILABLE = 'Not available';
|
||||||
|
|
||||||
class Versions extends React.PureComponent<any> {
|
class Versions extends React.PureComponent {
|
||||||
public render(): ReactElement<HTMLDivElement> {
|
public render(): ReactElement<HTMLDivElement> {
|
||||||
return (
|
return (
|
||||||
<DetailContextConsumer>
|
<DetailContextConsumer>
|
||||||
@ -19,7 +19,7 @@ class Versions extends React.PureComponent<any> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public renderPackageList = (packages: any, isVersion: boolean = false, timeMap: Record<string, any> = {}): ReactElement<HTMLDivElement> => {
|
public renderPackageList = (packages: {}, isVersion: boolean = false, timeMap: Record<string, {}> = {}): ReactElement<HTMLDivElement> => {
|
||||||
return (
|
return (
|
||||||
<List>
|
<List>
|
||||||
{Object.keys(packages)
|
{Object.keys(packages)
|
||||||
|
@ -2,23 +2,23 @@ import styled from 'react-emotion';
|
|||||||
import Typography from '@material-ui/core/Typography';
|
import Typography from '@material-ui/core/Typography';
|
||||||
import { default as MuiListItemText } from '@material-ui/core/ListItemText';
|
import { default as MuiListItemText } from '@material-ui/core/ListItemText';
|
||||||
|
|
||||||
export const Heading = styled(Typography)`
|
export const Heading = styled(Typography)({
|
||||||
&& {
|
'&&': {
|
||||||
font-weight: 700;
|
fontWeight: 700,
|
||||||
}
|
},
|
||||||
`;
|
});
|
||||||
|
|
||||||
export const Spacer = styled('div')`
|
export const Spacer = styled('div')({
|
||||||
flex: 1 1 auto;
|
flex: '1 1 auto',
|
||||||
border-bottom: 1px dotted rgba(0, 0, 0, 0.2);
|
borderBottom: '1px dotted rgba(0, 0, 0, 0.2)',
|
||||||
white-space: nowrap;
|
whiteSpace: 'nowrap',
|
||||||
height: 0.5em;
|
height: '0.5em',
|
||||||
`;
|
});
|
||||||
|
|
||||||
export const ListItemText = styled(MuiListItemText)`
|
export const ListItemText = styled(MuiListItemText)({
|
||||||
&& {
|
'&&': {
|
||||||
flex: none;
|
flex: 'none',
|
||||||
color: black;
|
color: 'black',
|
||||||
opacity: 0.6;
|
opacity: 0.6,
|
||||||
}
|
},
|
||||||
`;
|
});
|
||||||
|
@ -1,8 +0,0 @@
|
|||||||
import { createBrowserHistory } from 'history';
|
|
||||||
import { getBaseNamePath } from './utils/url';
|
|
||||||
|
|
||||||
const history = createBrowserHistory({
|
|
||||||
basename: getBaseNamePath(),
|
|
||||||
});
|
|
||||||
|
|
||||||
export default history;
|
|
@ -8,7 +8,7 @@ import App from './App';
|
|||||||
|
|
||||||
const rootNode = document.getElementById('root');
|
const rootNode = document.getElementById('root');
|
||||||
|
|
||||||
const renderApp = Component => {
|
const renderApp = (Component): void => {
|
||||||
ReactDOM.render(
|
ReactDOM.render(
|
||||||
<AppContainer>
|
<AppContainer>
|
||||||
<Component />
|
<Component />
|
||||||
|
@ -4,7 +4,7 @@ import PackageList from '../../components/PackageList';
|
|||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
isUserLoggedIn: boolean;
|
isUserLoggedIn: boolean;
|
||||||
packages: any[];
|
packages: [];
|
||||||
}
|
}
|
||||||
|
|
||||||
const Home: React.FC<Props> = ({ packages }) => (
|
const Home: React.FC<Props> = ({ packages }) => (
|
||||||
|
@ -1,16 +0,0 @@
|
|||||||
@import '../../styles/variables';
|
|
||||||
|
|
||||||
.alertError {
|
|
||||||
background-color: $red !important;
|
|
||||||
min-width: inherit !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
.alertErrorMsg {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.alertIcon {
|
|
||||||
opacity: 0.9;
|
|
||||||
margin-right: 8px;
|
|
||||||
}
|
|
@ -3,31 +3,44 @@ import Grid from '@material-ui/core/Grid';
|
|||||||
import Loading from '../../components/Loading/Loading';
|
import Loading from '../../components/Loading/Loading';
|
||||||
import DetailContainer from '../../components/DetailContainer/DetailContainer';
|
import DetailContainer from '../../components/DetailContainer/DetailContainer';
|
||||||
import DetailSidebar from '../../components/DetailSidebar/DetailSidebar';
|
import DetailSidebar from '../../components/DetailSidebar/DetailSidebar';
|
||||||
import { callDetailPage, DetailPage } from '../../utils/calls';
|
import { callDetailPage } from '../../utils/calls';
|
||||||
import { getRouterPackageName } from '../../utils/package';
|
import { getRouterPackageName } from '../../utils/package';
|
||||||
import NotFound from '../../components/NotFound';
|
import NotFound from '../../components/NotFound';
|
||||||
|
import { PackageMetaInterface } from '../../../types/packageMeta';
|
||||||
|
|
||||||
export interface DetailContextProps {
|
export interface DetailContextProps {
|
||||||
packageMeta: any;
|
packageMeta: PackageMetaInterface;
|
||||||
readMe: any;
|
readMe: string;
|
||||||
packageName: string;
|
packageName: string;
|
||||||
enableLoading: () => void;
|
enableLoading: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const DetailContext = React.createContext<DetailContextProps | null>(null);
|
export const DetailContext = React.createContext<Partial<DetailContextProps>>({});
|
||||||
|
|
||||||
export interface VersionPageConsumerProps {
|
export interface VersionPageConsumerProps {
|
||||||
packageMeta: any;
|
packageMeta: PackageMetaInterface;
|
||||||
readMe: any;
|
readMe: string;
|
||||||
packageName: any;
|
packageName: string;
|
||||||
enableLoading: any;
|
enableLoading: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const DetailContextProvider: Provider<VersionPageConsumerProps | null> = DetailContext.Provider;
|
export const DetailContextProvider: Provider<Partial<VersionPageConsumerProps>> = DetailContext.Provider;
|
||||||
export const DetailContextConsumer: Consumer<VersionPageConsumerProps | null> = DetailContext.Consumer;
|
export const DetailContextConsumer: Consumer<Partial<VersionPageConsumerProps>> = DetailContext.Consumer;
|
||||||
|
|
||||||
class VersionPage extends Component<any, any> {
|
interface PropsInterface {
|
||||||
constructor(props: any) {
|
match: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface StateInterface {
|
||||||
|
readMe: string;
|
||||||
|
packageName: string;
|
||||||
|
packageMeta: PackageMetaInterface | null;
|
||||||
|
isLoading: boolean;
|
||||||
|
notFound: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
class VersionPage extends Component<PropsInterface, Partial<StateInterface>> {
|
||||||
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
@ -39,7 +52,7 @@ class VersionPage extends Component<any, any> {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public static getDerivedStateFromProps(nextProps: any, prevState: any): any {
|
public static getDerivedStateFromProps(nextProps, prevState): { packageName?: string; isLoading: boolean; notFound?: boolean } | null {
|
||||||
const { match } = nextProps;
|
const { match } = nextProps;
|
||||||
const packageName = getRouterPackageName(match);
|
const packageName = getRouterPackageName(match);
|
||||||
|
|
||||||
@ -65,10 +78,10 @@ class VersionPage extends Component<any, any> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* eslint no-unused-vars: 0 */
|
/* eslint no-unused-vars: 0 */
|
||||||
public async componentDidUpdate(nextProps: any, prevState: any): Promise<void> {
|
public async componentDidUpdate(nextProps, prevState: StateInterface): Promise<void> {
|
||||||
const { packageName } = this.state;
|
const { packageName } = this.state;
|
||||||
if (packageName !== prevState.packageName) {
|
if (packageName !== prevState.packageName) {
|
||||||
const { readMe, packageMeta } = await callDetailPage(packageName);
|
const { readMe, packageMeta } = (await callDetailPage(packageName)) as Partial<StateInterface>;
|
||||||
this.setState({
|
this.setState({
|
||||||
readMe,
|
readMe,
|
||||||
packageMeta,
|
packageMeta,
|
||||||
@ -112,7 +125,7 @@ class VersionPage extends Component<any, any> {
|
|||||||
});
|
});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const { readMe, packageMeta } = await callDetailPage(packageName);
|
const { readMe, packageMeta } = (await callDetailPage(packageName)) as Partial<StateInterface>;
|
||||||
this.setState({
|
this.setState({
|
||||||
readMe,
|
readMe,
|
||||||
packageMeta,
|
packageMeta,
|
||||||
|
@ -3,10 +3,10 @@ import DialogTitle from '@material-ui/core/DialogTitle';
|
|||||||
import colors from '../../utils/styles/colors';
|
import colors from '../../utils/styles/colors';
|
||||||
import { fontSize } from '../../utils/styles/sizes';
|
import { fontSize } from '../../utils/styles/sizes';
|
||||||
|
|
||||||
export const Title = styled(DialogTitle)`
|
export const Title = styled(DialogTitle)({
|
||||||
&& {
|
'&&': {
|
||||||
background-color: ${colors.primary};
|
backgroundColor: colors.primary,
|
||||||
color: ${colors.white};
|
color: colors.white,
|
||||||
font-size: ${fontSize.lg};
|
fontSize: fontSize.lg,
|
||||||
}
|
},
|
||||||
`;
|
});
|
||||||
|
@ -2,17 +2,26 @@
|
|||||||
|
|
||||||
import React, { Component, ReactElement } from 'react';
|
import React, { Component, ReactElement } from 'react';
|
||||||
import { Router, Route, Switch } from 'react-router-dom';
|
import { Router, Route, Switch } from 'react-router-dom';
|
||||||
import { AppContextConsumer } from './App/App';
|
import { createBrowserHistory } from 'history';
|
||||||
|
import { AppContextConsumer, AppStateInterface } from './App/App';
|
||||||
|
|
||||||
import { asyncComponent } from './utils/asyncComponent';
|
import { asyncComponent } from './utils/asyncComponent';
|
||||||
import history from './history';
|
|
||||||
import Header from './components/Header';
|
import Header from './components/Header';
|
||||||
|
|
||||||
|
const history = createBrowserHistory({
|
||||||
|
basename: window.__VERDACCIO_BASENAME_UI_OPTIONS && window.__VERDACCIO_BASENAME_UI_OPTIONS.url_prefix,
|
||||||
|
});
|
||||||
|
|
||||||
const NotFound = asyncComponent(() => import('./components/NotFound'));
|
const NotFound = asyncComponent(() => import('./components/NotFound'));
|
||||||
const VersionPackage = asyncComponent(() => import('./pages/version/Version'));
|
const VersionPackage = asyncComponent(() => import('./pages/version/Version'));
|
||||||
const HomePage = asyncComponent(() => import('./pages/home'));
|
const HomePage = asyncComponent(() => import('./pages/home'));
|
||||||
|
|
||||||
class RouterApp extends Component<any, any> {
|
interface RouterAppProps {
|
||||||
|
onLogout: () => void;
|
||||||
|
onToggleLoginModal: () => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
class RouterApp extends Component<RouterAppProps> {
|
||||||
public render(): ReactElement<HTMLDivElement> {
|
public render(): ReactElement<HTMLDivElement> {
|
||||||
return (
|
return (
|
||||||
<Router history={history}>
|
<Router history={history}>
|
||||||
@ -34,8 +43,8 @@ class RouterApp extends Component<any, any> {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<AppContextConsumer>
|
<AppContextConsumer>
|
||||||
{function renderConsumerVersionPage({ logoUrl, scope, user }: any) {
|
{function renderConsumerVersionPage({ logoUrl, scope = '', user }: Partial<AppStateInterface>) {
|
||||||
return <Header logo={logoUrl} onLogout={onLogout} onToggleLoginModal={onToggleLoginModal} scope={scope} username={user.username} />;
|
return <Header logo={logoUrl} onLogout={onLogout} onToggleLoginModal={onToggleLoginModal} scope={scope} username={user && user.username} />;
|
||||||
}}
|
}}
|
||||||
</AppContextConsumer>
|
</AppContextConsumer>
|
||||||
);
|
);
|
||||||
@ -44,7 +53,7 @@ class RouterApp extends Component<any, any> {
|
|||||||
public renderHomePage = (): ReactElement<HTMLDivElement> => {
|
public renderHomePage = (): ReactElement<HTMLDivElement> => {
|
||||||
return (
|
return (
|
||||||
<AppContextConsumer>
|
<AppContextConsumer>
|
||||||
{function renderConsumerVersionPage({ isUserLoggedIn, packages }: any) {
|
{function renderConsumerVersionPage({ isUserLoggedIn, packages }: Partial<AppStateInterface>) {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
return <HomePage isUserLoggedIn={isUserLoggedIn} packages={packages} />;
|
return <HomePage isUserLoggedIn={isUserLoggedIn} packages={packages} />;
|
||||||
}}
|
}}
|
||||||
@ -52,10 +61,10 @@ class RouterApp extends Component<any, any> {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
public renderVersionPage = (routerProps: any): ReactElement<HTMLDivElement> => {
|
public renderVersionPage = (routerProps): ReactElement<HTMLDivElement> => {
|
||||||
return (
|
return (
|
||||||
<AppContextConsumer>
|
<AppContextConsumer>
|
||||||
{function renderConsumerVersionPage({ isUserLoggedIn }: any) {
|
{function renderConsumerVersionPage({ isUserLoggedIn }: Partial<AppStateInterface>) {
|
||||||
return <VersionPackage {...routerProps} isUserLoggedIn={isUserLoggedIn} />;
|
return <VersionPackage {...routerProps} isUserLoggedIn={isUserLoggedIn} />;
|
||||||
}}
|
}}
|
||||||
</AppContextConsumer>
|
</AppContextConsumer>
|
||||||
|
@ -1,22 +0,0 @@
|
|||||||
@import "variables";
|
|
||||||
|
|
||||||
html,
|
|
||||||
body {
|
|
||||||
height: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
body {
|
|
||||||
font-family: $font-family-base;
|
|
||||||
font-size: $font-size-base;
|
|
||||||
color: $text-color;
|
|
||||||
}
|
|
||||||
|
|
||||||
ul {
|
|
||||||
margin: 0;
|
|
||||||
padding: 0;
|
|
||||||
list-style: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
strong {
|
|
||||||
font-weight: $font-weight-semibold;
|
|
||||||
}
|
|
@ -1,47 +0,0 @@
|
|||||||
@import "variables";
|
|
||||||
@import "mixins";
|
|
||||||
|
|
||||||
:global {
|
|
||||||
.container {
|
|
||||||
padding: 15px;
|
|
||||||
flex: 1;
|
|
||||||
|
|
||||||
@include container-size;
|
|
||||||
|
|
||||||
.el-loading-spinner {
|
|
||||||
margin-top: 0 !important;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.content {
|
|
||||||
display: flex;
|
|
||||||
}
|
|
||||||
|
|
||||||
.page-full-height {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
min-height: 100vh;
|
|
||||||
overflow: hidden;
|
|
||||||
}
|
|
||||||
|
|
||||||
.el-button {
|
|
||||||
&:hover, &:focus {
|
|
||||||
color: $primary-color;
|
|
||||||
border-color: $primary-color;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.el-input__inner {
|
|
||||||
&:hover, &:focus {
|
|
||||||
border-color: $primary-color;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.el-dialog__headerbtn:hover .el-dialog__close {
|
|
||||||
color: $eclipse;
|
|
||||||
}
|
|
||||||
|
|
||||||
.package-list-items {
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,2 +0,0 @@
|
|||||||
@import "core";
|
|
||||||
@import "global";
|
|
@ -1,46 +0,0 @@
|
|||||||
@import "variables";
|
|
||||||
|
|
||||||
@mixin border($direction, $width, $style, $color) {
|
|
||||||
border-#{$direction}: $width $style $color;
|
|
||||||
}
|
|
||||||
|
|
||||||
@mixin border-bottom-default($color) {
|
|
||||||
border-bottom: 1px solid $color;
|
|
||||||
}
|
|
||||||
|
|
||||||
@mixin searchBox {
|
|
||||||
width: 100%;
|
|
||||||
font-size: $font-size-md;
|
|
||||||
line-height: $line-height-xl;
|
|
||||||
border: none;
|
|
||||||
@include border-bottom-default($grey-light);
|
|
||||||
outline: none;
|
|
||||||
|
|
||||||
&:focus {
|
|
||||||
@include border-bottom-default($grey);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@mixin ellipsis {
|
|
||||||
display: inline-block;
|
|
||||||
overflow: hidden;
|
|
||||||
text-overflow: ellipsis;
|
|
||||||
white-space: nowrap;
|
|
||||||
}
|
|
||||||
|
|
||||||
@mixin fullSize {
|
|
||||||
position: absolute;
|
|
||||||
top: 0;
|
|
||||||
left: 0;
|
|
||||||
right: 0;
|
|
||||||
bottom: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@mixin container-size {
|
|
||||||
@media screen and (min-width: $break-lg) {
|
|
||||||
max-width: $break-lg;
|
|
||||||
width: 100%;
|
|
||||||
margin-left: auto;
|
|
||||||
margin-right: auto;
|
|
||||||
}
|
|
||||||
}
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user