1
0
mirror of https://github.com/SomboChea/ui synced 2026-01-12 22:25:52 +07:00

Compare commits

..

4 Commits

Author SHA1 Message Date
Priscila Oliveira
8c9076d0a2 chore: update emotion dependencies 2019-11-16 00:28:36 +01:00
Priscila Oliveira
ea19a2bb47 Merge branch 'master' into refactor/migrate_autocomplete_to_mui 2019-11-15 23:20:30 +01:00
Priscila Oliveira
d9f463688d Merge branch 'master' into refactor/migrate_autocomplete_to_mui 2019-11-13 15:09:22 +01:00
Priscila Oliveira
571d9c3fa7 refactor: converting autoComplete to Mui's autocomplete 2019-11-10 16:31:29 +01:00
117 changed files with 2010 additions and 3452 deletions

View File

@@ -1,8 +1,3 @@
{
"presets": [["@verdaccio"]],
"plugins": [
"emotion",
"@babel/plugin-proposal-optional-chaining",
"@babel/plugin-proposal-nullish-coalescing-operator"
]
"presets": [["@verdaccio"]]
}

View File

@@ -1,2 +1 @@
save-prefix ""
registry "https://registry.verdaccio.org"

View File

@@ -2,20 +2,6 @@
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
### [0.3.7](https://github.com/verdaccio/ui/compare/v0.3.6...v0.3.7) (2019-11-24)
### Features
* Added Theme and migrate to emotion@10.x 🚀 ([#286](https://github.com/verdaccio/ui/issues/286)) ([111f0c5](https://github.com/verdaccio/ui/commit/111f0c50e5053202ca55fe4f3f28dd30e4932240))
### Bug Fixes
* **#300:** correctly reference registry url from options ([ee74474](https://github.com/verdaccio/ui/commit/ee74474811eb609072e1678bcb90db33756dcf38)), closes [#300](https://github.com/verdaccio/ui/issues/300)
* restore lint-staged@8.2.1 ([dbaa0c4](https://github.com/verdaccio/ui/commit/dbaa0c43b8104b350e4907387f89d4e9e719741f))
* update snapshots ([fd306de](https://github.com/verdaccio/ui/commit/fd306def9535d9168dc79ab020ec288a4d5df1a8))
### [0.3.6](https://github.com/verdaccio/ui/compare/v0.3.5...v0.3.6) (2019-11-08)
### [0.3.5](https://github.com/verdaccio/ui/compare/v0.3.4...v0.3.5) (2019-11-07)

View File

@@ -1,6 +1,6 @@
{
"name": "@verdaccio/ui-theme",
"version": "0.3.7",
"version": "0.3.6",
"description": "Verdaccio User Interface",
"author": {
"name": "Verdaccio Core Team",
@@ -13,12 +13,8 @@
"homepage": "https://verdaccio.org",
"main": "index.js",
"devDependencies": {
"@babel/plugin-proposal-nullish-coalescing-operator": "7.7.4",
"@babel/plugin-proposal-optional-chaining": "7.7.4",
"@commitlint/cli": "8.2.0",
"@commitlint/config-conventional": "8.2.0",
"@emotion/core": "10.0.22",
"@emotion/styled": "10.0.23",
"@material-ui/core": "4.6.1",
"@material-ui/icons": "4.5.1",
"@octokit/rest": "16.35.0",
@@ -27,20 +23,20 @@
"@types/enzyme": "3.10.3",
"@types/jest": "24.0.23",
"@types/js-base64": "2.3.1",
"@types/lodash": "4.14.149",
"@types/node": "12.12.11",
"@types/lodash": "4.14.147",
"@types/node": "12.12.7",
"@types/react": "16.9.11",
"@types/react-autosuggest": "9.3.13",
"@types/react-dom": "16.9.4",
"@types/react-router-dom": "5.1.2",
"@types/request": "2.48.3",
"@types/validator": "12.0.0",
"@types/validator": "10.11.3",
"@types/webpack-env": "1.14.1",
"@typescript-eslint/parser": "2.8.0",
"@verdaccio/babel-preset": "8.4.2",
"@verdaccio/commons-api": "8.4.2",
"@verdaccio/eslint-config": "8.4.2",
"@verdaccio/types": "8.4.2",
"@typescript-eslint/parser": "2.7.0",
"@verdaccio/babel-preset": "8.2.0",
"@verdaccio/commons-api": "8.3.0",
"@verdaccio/eslint-config": "8.2.0",
"@verdaccio/types": "8.3.0",
"autosuggest-highlight": "3.1.1",
"babel-loader": "8.0.6",
"bundlesize": "0.18.0",
@@ -49,27 +45,26 @@
"concurrently": "5.0.0",
"cross-env": "6.0.3",
"css-loader": "3.2.0",
"date-fns": "2.8.1",
"date-fns": "2.7.0",
"detect-secrets": "1.0.5",
"emotion": "10.0.23",
"emotion-theming": "10.0.19",
"enzyme": "3.10.0",
"enzyme-adapter-react-16": "1.15.1",
"enzyme-to-json": "3.4.3",
"eslint": "6.7.0",
"eslint-plugin-codeceptjs": "1.2.0",
"eslint": "6.6.0",
"eslint-plugin-codeceptjs": "1.1.0",
"eslint-plugin-import": "2.18.2",
"eslint-plugin-jsx-a11y": "6.2.3",
"eslint-plugin-prettier": "3.1.1",
"eslint-plugin-react": "7.16.0",
"eslint-plugin-react-hooks": "2.3.0",
"eslint-plugin-verdaccio": "8.4.2",
"file-loader": "4.3.0",
"eslint-plugin-verdaccio": "8.2.0",
"file-loader": "4.2.0",
"friendly-errors-webpack-plugin": "1.7.0",
"get-stdin": "7.0.0",
"github-markdown-css": "3.0.1",
"html-webpack-plugin": "3.2.0",
"husky": "3.1.0",
"husky": "3.0.9",
"identity-obj-proxy": "3.0.0",
"in-publish": "2.0.0",
"jest": "24.9.0",
@@ -95,28 +90,28 @@
"react": "16.12.0",
"react-autosuggest": "9.4.3",
"react-dom": "16.12.0",
"react-hot-loader": "4.12.18",
"react-hot-loader": "4.12.17",
"react-router-dom": "5.1.2",
"request": "2.88.0",
"resolve-url-loader": "3.1.1",
"rimraf": "3.0.0",
"source-map-loader": "0.2.4",
"standard-version": "7.0.1",
"standard-version": "7.0.0",
"style-loader": "1.0.0",
"stylelint": "12.0.0",
"stylelint": "11.1.1",
"stylelint-config-recommended": "3.0.0",
"stylelint-config-styled-components": "0.1.1",
"stylelint-processor-styled-components": "1.8.0",
"stylelint-webpack-plugin": "1.1.0",
"stylelint-webpack-plugin": "1.0.4",
"supertest": "4.0.2",
"typeface-roboto": "0.0.75",
"typescript": "3.7.2",
"uglifyjs-webpack-plugin": "2.2.0",
"url-loader": "2.3.0",
"validator": "12.1.0",
"verdaccio": "4.3.5",
"verdaccio-auth-memory": "8.4.2",
"verdaccio-memory": "8.4.2",
"url-loader": "2.2.0",
"validator": "12.0.0",
"verdaccio": "4.3.4",
"verdaccio-auth-memory": "8.3.0",
"verdaccio-memory": "8.3.0",
"wait-on": "3.3.0",
"webpack": "4.41.2",
"webpack-bundle-analyzer": "3.6.0",
@@ -188,18 +183,24 @@
},
"husky": {
"hooks": {
"pre-commit": "lint-staged --relative",
"pre-commit": "lint-staged",
"commit-msg": "commitlint -e $GIT_PARAMS"
}
},
"lint-staged": {
"*.{js,tsx,ts}": [
"eslint . --ext .js,.ts,.tsx",
"prettier --write"
],
"*": [
"detect-secrets-launcher --baseline .secrets-baseline",
"git add"
"relative": true,
"linters": {
"*.{js,tsx,ts}": [
"eslint . --ext .js,.ts,.tsx",
"prettier --write"
],
"*": [
"detect-secrets-launcher --baseline .secrets-baseline",
"git add"
]
},
"ignore": [
"*.json"
]
},
"license": "MIT",
@@ -213,5 +214,9 @@
"url": "https://opencollective.com/verdaccio",
"logo": "https://opencollective.com/verdaccio/logo.txt"
},
"dependencies": {}
"dependencies": {
"@emotion/core": "10.0.22",
"@emotion/styled": "10.0.23",
"@material-ui/lab": "4.0.0-alpha.31"
}
}

View File

@@ -1,11 +1,11 @@
import React from 'react';
import { mount, ReactWrapper } from 'enzyme';
import { render, waitForElement, fireEvent } from '../utils/test-react-testing-library';
import storage from '../utils/storage';
// eslint-disable-next-line jest/no-mocks-import
import { generateTokenWithTimeRange } from '../../jest/unit/components/__mocks__/token';
import App from './App';
import { AppProps } from './AppContext';
jest.mock('../utils/storage', () => {
class LocalStorageMock {
@@ -30,75 +30,66 @@ jest.mock('../utils/storage', () => {
});
jest.mock('../utils/api', () => ({
// eslint-disable-next-line jest/no-mocks-import
request: require('../../jest/unit/components/__mocks__/api').default.request,
}));
/* eslint-disable react/jsx-no-bind*/
describe('<App />', () => {
test('should display the Loading component at the beginning ', () => {
const { container, queryByTestId } = render(<App />);
describe('App', () => {
let wrapper: ReactWrapper<{}, AppProps, App>;
expect(container.firstChild).toMatchSnapshot();
expect(queryByTestId('loading')).toBeTruthy();
beforeEach(() => {
wrapper = mount(<App />);
});
test('should display the Header component ', async () => {
const { container, queryByTestId } = render(<App />);
expect(container.firstChild).toMatchSnapshot();
expect(queryByTestId('loading')).toBeTruthy();
// wait for the Header component appearance and return the element
const headerElement = await waitForElement(() => queryByTestId('header'));
expect(headerElement).toBeTruthy();
});
test('handleLogout - logouts the user and clear localstorage', async () => {
storage.setItem('username', 'verdaccio');
storage.setItem('token', generateTokenWithTimeRange(24));
const { queryByTestId } = render(<App />);
// wait for the Account's circle element component appearance and return the element
const accountCircleElement = await waitForElement(() => queryByTestId('header--menu-accountcircle'));
expect(accountCircleElement).toBeTruthy();
if (accountCircleElement) {
fireEvent.click(accountCircleElement);
// wait for the Button's logout element component appearance and return the element
const buttonLogoutElement = await waitForElement(() => queryByTestId('header--button-logout'));
expect(buttonLogoutElement).toBeTruthy();
if (buttonLogoutElement) {
fireEvent.click(buttonLogoutElement);
expect(queryByTestId('greetings-label')).toBeFalsy();
}
}
test('toggleLoginModal: should toggle the value in state', () => {
const { handleToggleLoginModal } = wrapper.instance();
expect(wrapper.state().showLoginModal).toBeFalsy();
handleToggleLoginModal();
expect(wrapper.state('showLoginModal')).toBeTruthy();
expect(wrapper.state('error')).toEqual(undefined);
});
test('isUserAlreadyLoggedIn: token already available in storage', async () => {
storage.setItem('username', 'verdaccio');
storage.setItem('token', generateTokenWithTimeRange(24));
const { isUserAlreadyLoggedIn } = wrapper.instance();
const { queryByTestId, queryAllByText } = render(<App />);
isUserAlreadyLoggedIn();
// wait for the Account's circle element component appearance and return the element
const accountCircleElement = await waitForElement(() => queryByTestId('header--menu-accountcircle'));
expect(accountCircleElement).toBeTruthy();
expect(wrapper.state('user').username).toEqual('verdaccio');
});
if (accountCircleElement) {
fireEvent.click(accountCircleElement);
test('handleLogout - logouts the user and clear localstorage', async () => {
const { handleLogout } = wrapper.instance();
storage.setItem('username', 'verdaccio');
storage.setItem('token', 'xxxx.TOKEN.xxxx');
// wait for the Greeting's label element component appearance and return the element
const greetingsLabelElement = await waitForElement(() => queryByTestId('greetings-label'));
expect(greetingsLabelElement).toBeTruthy();
await handleLogout();
expect(wrapper.state('user')).toEqual({});
expect(wrapper.state('isUserLoggedIn')).toBeFalsy();
});
if (greetingsLabelElement) {
expect(queryAllByText('verdaccio')).toBeTruthy();
}
}
test('handleDoLogin - login the user successfully', async () => {
const { handleDoLogin } = wrapper.instance();
await handleDoLogin('sam', '1234');
const result = {
username: 'sam',
};
expect(wrapper.state('isUserLoggedIn')).toBeTruthy();
expect(wrapper.state('showLoginModal')).toBeFalsy();
expect(storage.getItem('username')).toEqual('sam');
expect(storage.getItem('token')).toEqual('TEST_TOKEN');
expect(wrapper.state('user')).toEqual(result);
});
test('handleDoLogin - authentication failure', async () => {
const { handleDoLogin } = wrapper.instance();
await handleDoLogin('sam', '12345');
const result = {
description: 'bad username/password, access denied',
title: 'Unable to login',
type: 'error',
};
expect(wrapper.state('user')).toEqual({});
expect(wrapper.state('error')).toEqual(result);
});
});

View File

@@ -1,106 +1,188 @@
import React, { useState, useEffect } from 'react';
import styled from '@emotion/styled';
import React, { Component, ReactElement } from 'react';
import isNil from 'lodash/isNil';
import { Router } from 'react-router-dom';
import storage from '../utils/storage';
import { isTokenExpire } from '../utils/login';
import API from '../utils/api';
import Header from '../components/Header';
import Footer from '../components/Footer';
import Box from '../muiComponents/Box';
import { makeLogin, isTokenExpire } from '../utils/login';
import Loading from '../components/Loading';
import LoginModal from '../components/Login';
import Header from '../components/Header';
import { Container, Content } from '../components/Layout';
import API from '../utils/api';
import Footer from '../components/Footer';
import StyleBaseline from '../design-tokens/StyleBaseline';
import { breakpoints } from '../utils/styles/media';
import AppContextProvider from './AppContextProvider';
import AppRoute, { history } from './AppRoute';
import AppRoute from './AppRoute';
import { AppProps, AppContextProvider } from './AppContext';
const StyledBoxContent = styled(Box)({
padding: 15,
[`@media screen and (min-width: ${breakpoints.container}px)`]: {
maxWidth: breakpoints.container,
width: '100%',
marginLeft: 'auto',
marginRight: 'auto',
},
});
/* eslint-disable react/jsx-max-depth */
/* eslint-disable @typescript-eslint/explicit-function-return-type */
/* eslint-disable react/jsx-no-bind */
/* eslint-disable react-hooks/exhaustive-deps */
const App: React.FC = () => {
const [user, setUser] = useState();
const [packages, setPackages] = useState([]);
const [isLoading, setIsLoading] = useState(true);
/**
* Logouts user
* Required by: <Header />
*/
const logout = () => {
storage.removeItem('username');
storage.removeItem('token');
setUser(undefined);
export default class App extends Component<{}, AppProps> {
public state: AppProps = {
logoUrl: window.VERDACCIO_LOGO,
user: {},
scope: window.VERDACCIO_SCOPE || '',
showLoginModal: false,
isUserLoggedIn: false,
packages: [],
isLoading: true,
};
const checkUserAlreadyLoggedIn = () => {
public componentDidMount(): void {
this.isUserAlreadyLoggedIn();
this.loadOnHandler();
}
// eslint-disable-next-line no-unused-vars
public componentDidUpdate(_: AppProps, prevState: AppProps): void {
const { isUserLoggedIn } = this.state;
if (prevState.isUserLoggedIn !== isUserLoggedIn) {
this.loadOnHandler();
}
}
public render(): React.ReactElement<HTMLDivElement> {
const { isLoading, isUserLoggedIn, packages, logoUrl, user, scope } = this.state;
const context = { isUserLoggedIn, packages, logoUrl, user, scope };
return (
<>
<StyleBaseline />
<Container isLoading={isLoading}>
{isLoading ? <Loading /> : <AppContextProvider value={context}>{this.renderContent()}</AppContextProvider>}
{this.renderLoginModal()}
</Container>
</>
);
}
public isUserAlreadyLoggedIn = () => {
// checks for token validity
const token = storage.getItem('token');
const username = storage.getItem('username');
const username: string = storage.getItem('username') as string;
if (isTokenExpire(token) || isNil(username)) {
logout();
return;
this.handleLogout();
} else {
this.setState({
user: { username },
isUserLoggedIn: true,
});
}
setUser({ username });
};
const loadOnHandler = async () => {
public loadOnHandler = async () => {
try {
const packages = await API.request('packages', 'GET');
// FIXME add correct type for package
setPackages(packages as never[]);
const packages = await API.request<any[]>('packages', 'GET');
// @ts-ignore: FIX THIS TYPE: Type 'any[]' is not assignable to type '[]'
this.setState({
packages,
isLoading: false,
});
} catch (error) {
// FIXME: add dialog
console.error({
title: 'Warning',
message: `Unable to load package list: ${error.message}`,
});
this.setLoading(false);
}
setIsLoading(false);
};
useEffect(() => {
checkUserAlreadyLoggedIn();
loadOnHandler();
}, []);
public setLoading = (isLoading: boolean) =>
this.setState({
isLoading,
});
return (
<>
<StyleBaseline />
<Box display="flex" flexDirection="column" height="100%">
{isLoading ? (
<Loading />
) : (
<>
<Router history={history}>
<AppContextProvider packages={packages} user={user}>
<Header />
<StyledBoxContent flexGrow={1}>
<AppRoute />
</StyledBoxContent>
</AppContextProvider>
</Router>
<Footer />
</>
)}
</Box>
</>
);
};
/**
* Toggles the login modal
* Required by: <LoginModal /> <Header />
*/
public handleToggleLoginModal = () => {
this.setState(prevState => ({
showLoginModal: !prevState.showLoginModal,
}));
};
export default App;
/**
* handles login
* Required by: <Header />
*/
public handleDoLogin = async (usernameValue: string, passwordValue: string) => {
const { username, token, error } = await makeLogin(usernameValue, passwordValue);
if (username && token) {
storage.setItem('username', username);
storage.setItem('token', token);
this.setLoggedUser(username);
}
if (error) {
this.setState({
user: {},
error,
});
}
};
public setLoggedUser = (username: string) => {
this.setState({
user: {
username,
},
isUserLoggedIn: true, // close login modal after successful login
showLoginModal: false, // set isUserLoggedIn to true
});
};
/**
* Logouts user
* Required by: <Header />
*/
public handleLogout = () => {
storage.removeItem('username');
storage.removeItem('token');
this.setState({
user: {},
isUserLoggedIn: false,
});
};
public renderLoginModal = (): ReactElement<HTMLElement> => {
const { error, showLoginModal } = this.state;
return (
<LoginModal
error={error}
onCancel={this.handleToggleLoginModal}
onSubmit={this.handleDoLogin}
visibility={showLoginModal}
/>
);
};
public renderContent = (): ReactElement<HTMLElement> => {
return (
<>
<Content>
<AppRoute>{this.renderHeader()}</AppRoute>
</Content>
<Footer />
</>
);
};
public renderHeader = (): ReactElement<HTMLElement> => {
const {
logoUrl,
user: { username },
scope,
} = this.state;
return (
<Header
logo={logoUrl}
onLogout={this.handleLogout}
onToggleLoginModal={this.handleToggleLoginModal}
scope={scope}
username={username}
/>
);
};
}

View File

@@ -1,23 +0,0 @@
import { createContext } from 'react';
import { FormError } from '../components/Login/Login';
export interface AppProps {
error?: FormError;
user?: User;
scope: string;
packages: any[];
}
export interface User {
username: string;
}
export interface AppContextProps extends AppProps {
setUser: (user?: User) => void;
setError: (error?: FormError) => void;
}
const AppContext = createContext<undefined | AppContextProps>(undefined);
export default AppContext;

20
src/App/AppContext.tsx Normal file
View File

@@ -0,0 +1,20 @@
import { createContext } from 'react';
import { FormError } from '../components/Login/Login';
export interface AppProps {
error?: FormError;
logoUrl: string;
user: {
username?: string;
};
scope: string;
showLoginModal: boolean;
isUserLoggedIn: boolean;
packages: [];
isLoading: boolean;
}
export const AppContext = createContext<Partial<AppProps>>({});
export const AppContextProvider = AppContext.Provider;
export const AppContextConsumer = AppContext.Consumer;

View File

@@ -1,61 +0,0 @@
import React, { useState, useEffect } from 'react';
import { FormError } from '../components/Login/Login';
import AppContext, { AppProps, User } from './AppContext';
interface Props {
packages: any[];
user?: User;
}
/* eslint-disable @typescript-eslint/explicit-function-return-type */
/* eslint-disable react-hooks/exhaustive-deps */
const AppContextProvider: React.FC<Props> = ({ children, packages, user }) => {
const [state, setState] = useState<AppProps>({
scope: window.VERDACCIO_SCOPE || '',
packages,
user,
});
useEffect(() => {
setState({
...state,
user,
});
}, [user]);
useEffect(() => {
setState({
...state,
packages,
});
}, [packages]);
const setUser = (user?: User) => {
setState({
...state,
user,
});
};
const setError = (error?: FormError) => {
setState({
...state,
error,
});
};
return (
<AppContext.Provider
value={{
...state,
setUser,
setError,
}}>
{children}
</AppContext.Provider>
);
};
export default AppContextProvider;

View File

@@ -4,7 +4,7 @@ import { createBrowserHistory } from 'history';
import Loading from '../components/Loading';
import AppContext from './AppContext';
import { AppContext } from './AppContext';
const NotFound = lazy(() => import('../components/NotFound'));
const VersionContextProvider = lazy(() => import('../pages/Version/VersionContextProvider'));
@@ -19,25 +19,19 @@ enum Route {
PACKAGE_VERSION = '/-/web/detail/:package/v/:version',
}
export const history = createBrowserHistory({
const history = createBrowserHistory({
basename: window.__VERDACCIO_BASENAME_UI_OPTIONS && window.__VERDACCIO_BASENAME_UI_OPTIONS.url_prefix,
});
/* eslint react/jsx-max-depth: 0 */
const AppRoute: React.FC = () => {
const AppRoute: React.FC = ({ children }) => {
const appContext = useContext(AppContext);
if (!appContext) {
throw Error('The app Context was not correct used');
}
const { user, packages } = appContext;
const isUserLoggedIn = user && user.username;
const { isUserLoggedIn, packages } = appContext;
return (
<Router history={history}>
<Suspense fallback={<Loading />}>
{children}
<Switch>
<ReactRouterDomRoute exact={true} path={Route.ROOT}>
<HomePage isUserLoggedIn={!!isUserLoggedIn} packages={packages || []} />

View File

@@ -1,179 +0,0 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`<App /> should display the Header component 1`] = `
.emotion-8 {
-webkit-transform: translate(-50%,-50%);
-ms-transform: translate(-50%,-50%);
transform: translate(-50%,-50%);
top: 50%;
left: 50%;
position: absolute;
}
.emotion-2 {
margin: 0 0 30px 0;
border-radius: 25px;
box-shadow: 0 10px 20px 0 rgba(69,58,100,0.2);
background: #f7f8f6;
}
.emotion-0 {
display: inline-block;
vertical-align: middle;
box-sizing: border-box;
background-position: center;
background-size: contain;
background-image: url([object Object]);
background-repeat: no-repeat;
width: 90px;
height: 90px;
}
.emotion-6 {
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
-webkit-align-items: center;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
-webkit-box-pack: center;
-webkit-justify-content: center;
-ms-flex-pack: center;
justify-content: center;
}
.emotion-4 {
color: #4b5e40;
}
<div
class="MuiBox-root MuiBox-root-215"
>
<div
class="emotion-8 emotion-9"
data-testid="loading"
>
<div
class="emotion-2 emotion-3"
>
<div
class="emotion-0 emotion-1"
/>
</div>
<div
class="emotion-6 emotion-7"
>
<div
class="MuiCircularProgress-root emotion-4 emotion-5 MuiCircularProgress-colorPrimary MuiCircularProgress-indeterminate"
role="progressbar"
style="width: 50px; height: 50px;"
>
<svg
class="MuiCircularProgress-svg"
viewBox="22 22 44 44"
>
<circle
class="MuiCircularProgress-circle MuiCircularProgress-circleIndeterminate"
cx="44"
cy="44"
fill="none"
r="20.2"
stroke-width="3.6"
/>
</svg>
</div>
</div>
</div>
</div>
`;
exports[`<App /> should display the Loading component at the beginning 1`] = `
.emotion-8 {
-webkit-transform: translate(-50%,-50%);
-ms-transform: translate(-50%,-50%);
transform: translate(-50%,-50%);
top: 50%;
left: 50%;
position: absolute;
}
.emotion-2 {
margin: 0 0 30px 0;
border-radius: 25px;
box-shadow: 0 10px 20px 0 rgba(69,58,100,0.2);
background: #f7f8f6;
}
.emotion-0 {
display: inline-block;
vertical-align: middle;
box-sizing: border-box;
background-position: center;
background-size: contain;
background-image: url([object Object]);
background-repeat: no-repeat;
width: 90px;
height: 90px;
}
.emotion-6 {
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
-webkit-align-items: center;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
-webkit-box-pack: center;
-webkit-justify-content: center;
-ms-flex-pack: center;
justify-content: center;
}
.emotion-4 {
color: #4b5e40;
}
<div
class="MuiBox-root MuiBox-root-2"
>
<div
class="emotion-8 emotion-9"
data-testid="loading"
>
<div
class="emotion-2 emotion-3"
>
<div
class="emotion-0 emotion-1"
/>
</div>
<div
class="emotion-6 emotion-7"
>
<div
class="MuiCircularProgress-root emotion-4 emotion-5 MuiCircularProgress-colorPrimary MuiCircularProgress-indeterminate"
role="progressbar"
style="width: 50px; height: 50px;"
>
<svg
class="MuiCircularProgress-svg"
viewBox="22 22 44 44"
>
<circle
class="MuiCircularProgress-circle MuiCircularProgress-circleIndeterminate"
cx="44"
cy="44"
fill="none"
r="20.2"
stroke-width="3.6"
/>
</svg>
</div>
</div>
</div>
</div>
`;

View File

@@ -1,2 +1 @@
export { default } from './App';
export { default as AppContextProvider } from './AppContextProvider';

View File

@@ -1,9 +1,9 @@
import { css } from '@emotion/core';
import { css } from 'emotion';
import { theme } from '../design-tokens/theme';
import colors from '../utils/styles/colors';
export const alertError = css({
backgroundColor: `${theme.palette.red} !important`,
backgroundColor: `${colors.red} !important`,
minWidth: 'inherit !important',
});

View File

@@ -1,6 +1,6 @@
import React from 'react';
import { mount } from 'enzyme';
import { mount } from '../../utils/test-enzyme';
import api from '../../utils/api';
import { ActionBar } from './ActionBar';

View File

@@ -2,6 +2,6 @@
exports[`<ActionBar /> component should render the component in default state 1`] = `""`;
exports[`<ActionBar /> component when there is a button to download a tarball 1`] = `"<ul class=\\"MuiList-root MuiList-padding\\"><div class=\\"MuiButtonBase-root MuiListItem-root css-l3mdff-ActionListItem eux6shq0 MuiListItem-gutters MuiListItem-button MuiListItem-alignItemsFlexStart\\" tabindex=\\"0\\" role=\\"button\\" aria-disabled=\\"false\\"><button class=\\"MuiButtonBase-root MuiFab-root css-is03ew-Fab eux6shq1 MuiFab-sizeSmall\\" tabindex=\\"0\\" type=\\"button\\" title=\\"Download tarball\\"><span class=\\"MuiFab-label\\"><svg class=\\"MuiSvgIcon-root\\" focusable=\\"false\\" viewBox=\\"0 0 24 24\\" aria-hidden=\\"true\\" role=\\"presentation\\"><path d=\\"M19.35 10.04C18.67 6.59 15.64 4 12 4 9.11 4 6.6 5.64 5.35 8.04 2.34 8.36 0 10.91 0 14c0 3.31 2.69 6 6 6h13c2.76 0 5-2.24 5-5 0-2.64-2.05-4.78-4.65-4.96zM17 13l-5 5-5-5h3V9h4v4h3z\\"></path></svg></span><span class=\\"MuiTouchRipple-root\\"></span></button><span class=\\"MuiTouchRipple-root\\"></span></div></ul>"`;
exports[`<ActionBar /> component when there is a button to download a tarball 1`] = `"<ul class=\\"MuiList-root MuiList-padding\\"><div class=\\"MuiButtonBase-root MuiListItem-root css-1br2q5z eux6shq0 MuiListItem-gutters MuiListItem-button MuiListItem-alignItemsFlexStart\\" tabindex=\\"0\\" role=\\"button\\" aria-disabled=\\"false\\"><button class=\\"MuiButtonBase-root MuiFab-root css-z6z5me eux6shq1 MuiFab-sizeSmall\\" tabindex=\\"0\\" type=\\"button\\" title=\\"Download tarball\\"><span class=\\"MuiFab-label\\"><svg class=\\"MuiSvgIcon-root\\" focusable=\\"false\\" viewBox=\\"0 0 24 24\\" aria-hidden=\\"true\\" role=\\"presentation\\"><path d=\\"M19.35 10.04C18.67 6.59 15.64 4 12 4 9.11 4 6.6 5.64 5.35 8.04 2.34 8.36 0 10.91 0 14c0 3.31 2.69 6 6 6h13c2.76 0 5-2.24 5-5 0-2.64-2.05-4.78-4.65-4.96zM17 13l-5 5-5-5h3V9h4v4h3z\\"></path></svg></span><span class=\\"MuiTouchRipple-root\\"></span></button><span class=\\"MuiTouchRipple-root\\"></span></div></ul>"`;
exports[`<ActionBar /> component when there is a button to open an issue 1`] = `"<ul class=\\"MuiList-root MuiList-padding\\"><div class=\\"MuiButtonBase-root MuiListItem-root css-l3mdff-ActionListItem eux6shq0 MuiListItem-gutters MuiListItem-button MuiListItem-alignItemsFlexStart\\" tabindex=\\"0\\" role=\\"button\\" aria-disabled=\\"false\\"><a href=\\"https://verdaccio.tld/bugs\\" target=\\"_blank\\"><button class=\\"MuiButtonBase-root MuiFab-root css-is03ew-Fab eux6shq1 MuiFab-sizeSmall\\" tabindex=\\"0\\" type=\\"button\\"><span class=\\"MuiFab-label\\"><svg class=\\"MuiSvgIcon-root\\" focusable=\\"false\\" viewBox=\\"0 0 24 24\\" aria-hidden=\\"true\\" role=\\"presentation\\"><path d=\\"M20 8h-2.81c-.45-.78-1.07-1.45-1.82-1.96L17 4.41 15.59 3l-2.17 2.17C12.96 5.06 12.49 5 12 5c-.49 0-.96.06-1.41.17L8.41 3 7 4.41l1.62 1.63C7.88 6.55 7.26 7.22 6.81 8H4v2h2.09c-.05.33-.09.66-.09 1v1H4v2h2v1c0 .34.04.67.09 1H4v2h2.81c1.04 1.79 2.97 3 5.19 3s4.15-1.21 5.19-3H20v-2h-2.09c.05-.33.09-.66.09-1v-1h2v-2h-2v-1c0-.34-.04-.67-.09-1H20V8zm-6 8h-4v-2h4v2zm0-4h-4v-2h4v2z\\"></path></svg></span><span class=\\"MuiTouchRipple-root\\"></span></button></a><span class=\\"MuiTouchRipple-root\\"></span></div></ul>"`;
exports[`<ActionBar /> component when there is a button to open an issue 1`] = `"<ul class=\\"MuiList-root MuiList-padding\\"><div class=\\"MuiButtonBase-root MuiListItem-root css-1br2q5z eux6shq0 MuiListItem-gutters MuiListItem-button MuiListItem-alignItemsFlexStart\\" tabindex=\\"0\\" role=\\"button\\" aria-disabled=\\"false\\"><a href=\\"https://verdaccio.tld/bugs\\" target=\\"_blank\\"><button class=\\"MuiButtonBase-root MuiFab-root css-z6z5me eux6shq1 MuiFab-sizeSmall\\" tabindex=\\"0\\" type=\\"button\\"><span class=\\"MuiFab-label\\"><svg class=\\"MuiSvgIcon-root\\" focusable=\\"false\\" viewBox=\\"0 0 24 24\\" aria-hidden=\\"true\\" role=\\"presentation\\"><path d=\\"M20 8h-2.81c-.45-.78-1.07-1.45-1.82-1.96L17 4.41 15.59 3l-2.17 2.17C12.96 5.06 12.49 5 12 5c-.49 0-.96.06-1.41.17L8.41 3 7 4.41l1.62 1.63C7.88 6.55 7.26 7.22 6.81 8H4v2h2.09c-.05.33-.09.66-.09 1v1H4v2h2v1c0 .34.04.67.09 1H4v2h2.81c1.04 1.79 2.97 3 5.19 3s4.15-1.21 5.19-3H20v-2h-2.09c.05-.33.09-.66.09-1v-1h2v-2h-2v-1c0-.34-.04-.67-.09-1H20V8zm-6 8h-4v-2h4v2zm0-4h-4v-2h4v2z\\"></path></svg></span><span class=\\"MuiTouchRipple-root\\"></span></button></a><span class=\\"MuiTouchRipple-root\\"></span></div></ul>"`;

View File

@@ -1,8 +1,8 @@
import styled from '@emotion/styled';
import colors from '../../utils/styles/colors';
import ListItem from '../../muiComponents/ListItem';
import FloatingActionButton from '../../muiComponents/FloatingActionButton';
import { Theme } from '../../design-tokens/theme';
export const ActionListItem = styled(ListItem)({
paddingTop: 0,
@@ -10,8 +10,8 @@ export const ActionListItem = styled(ListItem)({
paddingRight: 0,
});
export const Fab = styled(FloatingActionButton)<{ theme?: Theme }>(props => ({
backgroundColor: props.theme && props.theme.palette.primary.main,
color: props.theme && props.theme.palette.white,
export const Fab = styled(FloatingActionButton)({
backgroundColor: colors.primary,
color: colors.white,
marginRight: '10px',
}));
});

View File

@@ -1,6 +1,6 @@
import React from 'react';
import { mount } from 'enzyme';
import { mount } from '../../utils/test-enzyme';
import { DetailContext } from '../../pages/Version';
import Authors from './Author';

View File

@@ -1,5 +1,5 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`<Author /> component should render the component in default state 1`] = `"<ul class=\\"MuiList-root MuiList-padding MuiList-subheader\\"><h6 class=\\"MuiTypography-root css-1na337r-StyledText e1xuehjw0 MuiTypography-subtitle1\\">Author</h6><div class=\\"MuiButtonBase-root MuiListItem-root css-1k45khb-AuthorListItem e1xuehjw1 MuiListItem-gutters MuiListItem-button\\" tabindex=\\"0\\" role=\\"button\\" aria-disabled=\\"false\\"><a href=\\"mailto:verdaccio.user@verdaccio.org?subject=verdaccio@4.0.0\\" target=\\"_top\\"><div class=\\"MuiAvatar-root MuiAvatar-circle\\"><img alt=\\"verdaccio user\\" src=\\"https://www.gravatar.com/avatar/000000\\" class=\\"MuiAvatar-img\\"></div></a><div class=\\"MuiListItemText-root css-1cnlq5d-AuthorListItemText e1xuehjw2\\"><span class=\\"MuiTypography-root MuiListItemText-primary MuiTypography-body1\\">verdaccio user</span></div><span class=\\"MuiTouchRipple-root\\"></span></div></ul>"`;
exports[`<Author /> component should render the component in default state 1`] = `"<ul class=\\"MuiList-root MuiList-padding MuiList-subheader\\"><h6 class=\\"MuiTypography-root css-b8upko e1xuehjw0 MuiTypography-subtitle1\\">Author</h6><div class=\\"MuiButtonBase-root MuiListItem-root css-zw46c6 e1xuehjw1 MuiListItem-gutters MuiListItem-button\\" tabindex=\\"0\\" role=\\"button\\" aria-disabled=\\"false\\"><a href=\\"mailto:verdaccio.user@verdaccio.org?subject=verdaccio@4.0.0\\" target=\\"_top\\"><div class=\\"MuiAvatar-root MuiAvatar-circle\\"><img alt=\\"verdaccio user\\" src=\\"https://www.gravatar.com/avatar/000000\\" class=\\"MuiAvatar-img\\"></div></a><div class=\\"MuiListItemText-root css-fipixf e1xuehjw2\\"><span class=\\"MuiTypography-root MuiListItemText-primary MuiTypography-body1\\">verdaccio user</span></div><span class=\\"MuiTouchRipple-root\\"></span></div></ul>"`;
exports[`<Author /> component should render the component when there is no author email 1`] = `"<ul class=\\"MuiList-root MuiList-padding MuiList-subheader\\"><h6 class=\\"MuiTypography-root css-1na337r-StyledText e1xuehjw0 MuiTypography-subtitle1\\">Author</h6><div class=\\"MuiButtonBase-root MuiListItem-root css-1k45khb-AuthorListItem e1xuehjw1 MuiListItem-gutters MuiListItem-button\\" tabindex=\\"0\\" role=\\"button\\" aria-disabled=\\"false\\"><div class=\\"MuiAvatar-root MuiAvatar-circle\\"><img alt=\\"verdaccio user\\" src=\\"https://www.gravatar.com/avatar/000000\\" class=\\"MuiAvatar-img\\"></div><div class=\\"MuiListItemText-root css-1cnlq5d-AuthorListItemText e1xuehjw2\\"><span class=\\"MuiTypography-root MuiListItemText-primary MuiTypography-body1\\">verdaccio user</span></div><span class=\\"MuiTouchRipple-root\\"></span></div></ul>"`;
exports[`<Author /> component should render the component when there is no author email 1`] = `"<ul class=\\"MuiList-root MuiList-padding MuiList-subheader\\"><h6 class=\\"MuiTypography-root css-b8upko e1xuehjw0 MuiTypography-subtitle1\\">Author</h6><div class=\\"MuiButtonBase-root MuiListItem-root css-zw46c6 e1xuehjw1 MuiListItem-gutters MuiListItem-button\\" tabindex=\\"0\\" role=\\"button\\" aria-disabled=\\"false\\"><div class=\\"MuiAvatar-root MuiAvatar-circle\\"><img alt=\\"verdaccio user\\" src=\\"https://www.gravatar.com/avatar/000000\\" class=\\"MuiAvatar-img\\"></div><div class=\\"MuiListItemText-root css-fipixf e1xuehjw2\\"><span class=\\"MuiTypography-root MuiListItemText-primary MuiTypography-body1\\">verdaccio user</span></div><span class=\\"MuiTouchRipple-root\\"></span></div></ul>"`;

View File

@@ -1,5 +1,4 @@
import React, { KeyboardEvent } from 'react';
import styled from '@emotion/styled';
import Autosuggest, { SuggestionSelectedEventData, InputProps, ChangeEvent } from 'react-autosuggest';
import match from 'autosuggest-highlight/match';
import parse from 'autosuggest-highlight/parse';
@@ -9,20 +8,13 @@ import MenuItem from '../../muiComponents/MenuItem';
import { Wrapper, InputField, SuggestionContainer } from './styles';
const StyledAnchor = styled('a')<{ fw: number }>(props => ({
fontWeight: props.fw,
}));
const StyledMenuItem = styled(MenuItem)({
cursor: 'pointer',
});
interface Props {
suggestions: unknown[];
suggestionsLoading?: boolean;
suggestionsLoaded?: boolean;
suggestionsError?: boolean;
apiLoading?: boolean;
color?: string;
value?: string;
placeholder?: string;
startAdornment?: JSX.Element;
@@ -61,18 +53,23 @@ const renderSuggestion = (suggestion, { query, isHighlighted }): JSX.Element =>
const matches = match(suggestion.name, query);
const parts = parse(suggestion.name, matches);
return (
<StyledMenuItem component="div" selected={isHighlighted}>
<MenuItem component="div" selected={isHighlighted}>
<div>
{parts.map((part, index) => {
const fw = part.highlight ? fontWeight.semiBold : fontWeight.light;
return (
<StyledAnchor fw={fw} key={String(index)}>
<a
className={css`
font-weight: ${fw};
`}
href={suggestion.link}
key={String(index)}>
{part.text}
</StyledAnchor>
</a>
);
})}
</div>
</StyledMenuItem>
</MenuItem>
);
};
@@ -99,6 +96,7 @@ const AutoComplete = ({
value = '',
placeholder = '',
disableUnderline = false,
color,
onClick,
onKeyDown,
onBlur,
@@ -122,6 +120,7 @@ const AutoComplete = ({
// @ts-ignore
startAdornment,
disableUnderline,
color,
onKeyDown,
onBlur,
};
@@ -140,12 +139,7 @@ const AutoComplete = ({
return (
<Wrapper>
<Autosuggest
{...autosuggestProps}
inputProps={inputProps}
onSuggestionSelected={onClick}
renderSuggestionsContainer={renderSuggestionsContainer}
/>
<Autosuggest {...autosuggestProps} inputProps={inputProps} onSuggestionSelected={onClick} renderSuggestionsContainer={renderSuggestionsContainer} />
</Wrapper>
);
};

View File

@@ -1,44 +1,61 @@
import React from 'react';
import styled from '@emotion/styled';
import { css } from '@emotion/core';
import TextField from '../../muiComponents/TextField';
import Paper from '../../muiComponents/Paper';
import { Theme } from '../../design-tokens/theme';
export interface InputFieldProps {
color: string;
}
export const Wrapper = styled('div')({
width: '100%',
height: '32px',
position: 'relative',
zIndex: 1,
'&&': {
width: '100%',
height: '32px',
position: 'relative',
zIndex: 1,
},
});
export const StyledTextField = styled(TextField)<{ theme?: Theme }>(props => ({
'& .MuiInputBase-root': {
':before': {
content: "''",
border: 'none',
},
':after': {
borderColor: props.theme && props.theme.palette.white,
},
':hover:before': {
content: 'none',
},
},
'& .MuiInputBase-input': {
color: props.theme && props.theme.palette.white,
},
}));
/* eslint-disable verdaccio/jsx-spread */
// @ts-ignore types of color are incompatible
export const InputField: React.FC<InputFieldProps> = ({ ...others }) => <StyledTextField {...others} />;
export const InputField: React.FC<InputFieldProps> = ({ color, ...others }) => (
<TextField
{...others}
classes={{
// @ts-ignore
input: css`
&& {
${color &&
css`
color: ${color};
`};
}
`,
root: css`
&& {
&:before {
content: '';
border: none;
}
&:after {
${color &&
css`
border-color: ${color};
`};
}
&:hover:before {
content: none;
}
}
`,
}}
/>
);
export const SuggestionContainer = styled(Paper)({
maxHeight: '500px',
overflowY: 'auto',
'&&': {
maxHeight: '500px',
overflowY: 'auto',
},
});

View File

@@ -1,8 +1,7 @@
import React from 'react';
import { ReactWrapper } from 'enzyme';
import { mount, ReactWrapper } from 'enzyme';
import { copyToClipBoardUtility } from '../../utils/cli-utils';
import { mount } from '../../utils/test-enzyme';
import CopyToClipBoard from './CopyToClipBoard';
import { CopyIcon } from './styles';
@@ -17,7 +16,7 @@ describe('<CopyToClipBoard /> component', () => {
wrapper = mount(<CopyToClipBoard text={copyText} />);
});
test('should load the component in default state', () => {
test('render the component', () => {
expect(wrapper.html()).toMatchSnapshot();
});

View File

@@ -1,3 +1,3 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`<CopyToClipBoard /> component should load the component in default state 1`] = `"<div class=\\"css-1in239f-ClipBoardCopy eb8w2fo0\\"><span class=\\"css-7gar9h-ClipBoardCopyText eb8w2fo1\\">copy text</span><button class=\\"MuiButtonBase-root MuiIconButton-root css-1fs86cq-CopyIcon eb8w2fo2\\" tabindex=\\"0\\" type=\\"button\\" title=\\"Copy to Clipboard\\"><span class=\\"MuiIconButton-label\\"><svg class=\\"MuiSvgIcon-root\\" focusable=\\"false\\" viewBox=\\"0 0 24 24\\" aria-hidden=\\"true\\" role=\\"presentation\\"><path d=\\"M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm-1 4l6 6v10c0 1.1-.9 2-2 2H7.99C6.89 23 6 22.1 6 21l.01-14c0-1.1.89-2 1.99-2h7zm-1 7h5.5L14 6.5V12z\\"></path></svg></span><span class=\\"MuiTouchRipple-root\\"></span></button></div>"`;
exports[`<CopyToClipBoard /> component render the component 1`] = `"<div class=\\"css-1mta3t8 eb8w2fo0\\"><span class=\\"css-lh0wgu eb8w2fo1\\">copy text</span><button class=\\"MuiButtonBase-root MuiIconButton-root css-0 eb8w2fo2\\" tabindex=\\"0\\" type=\\"button\\" title=\\"Copy to Clipboard\\"><span class=\\"MuiIconButton-label\\"><svg class=\\"MuiSvgIcon-root\\" focusable=\\"false\\" viewBox=\\"0 0 24 24\\" aria-hidden=\\"true\\" role=\\"presentation\\"><path d=\\"M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm-1 4l6 6v10c0 1.1-.9 2-2 2H7.99C6.89 23 6 22.1 6 21l.01-14c0-1.1.89-2 1.99-2h7zm-1 7h5.5L14 6.5V12z\\"></path></svg></span><span class=\\"MuiTouchRipple-root\\"></span></button></div>"`;

View File

@@ -3,18 +3,22 @@ import styled from '@emotion/styled';
import IconButton from '../../muiComponents/IconButton';
export const ClipBoardCopy = styled('div')({
display: 'flex',
alignItems: 'center',
justifyContent: 'space-between',
'&&': {
display: 'flex',
alignItems: 'center',
justifyContent: 'space-between',
},
});
export const ClipBoardCopyText = styled('span')({
display: 'inline-block',
textOverflow: 'ellipsis',
overflow: 'hidden',
whiteSpace: 'nowrap',
height: '21px',
fontSize: '1rem',
'&&': {
display: 'inline-block',
textOverflow: 'ellipsis',
overflow: 'hidden',
whiteSpace: 'nowrap',
height: '21px',
fontSize: '1rem',
},
});
export const CopyIcon = styled(IconButton)({});

View File

@@ -1,8 +1,8 @@
import React from 'react';
import { render } from '@testing-library/react';
import { HashRouter } from 'react-router-dom';
import { DetailContextProvider } from '../../pages/Version';
import { render } from '../../utils/test-react-testing-library';
import Dependencies from './Dependencies';

View File

@@ -1,6 +1,5 @@
import React from 'react';
import { render } from '../../utils/test-react-testing-library';
import { render } from '@testing-library/react';
import DetailContainer from './DetailContainer';

View File

@@ -1,15 +1,11 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`DetailContainer renders correctly 1`] = `
.emotion-0 {
margin-bottom: 16px;
}
<div
class="MuiBox-root MuiBox-root-2"
>
<div
class="MuiTabs-root emotion-0 emotion-1"
class="MuiTabs-root css-1qm1lh emotion-0"
>
<div
class="MuiTabs-scroller MuiTabs-fixed"

View File

@@ -1,6 +1,6 @@
import React from 'react';
import { mount } from 'enzyme';
import { mount } from '../../utils/test-enzyme';
import { DetailContextProvider } from '../../pages/Version';
import Developers, { DevelopersType } from './Developers';

View File

@@ -1,57 +1,22 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`test Developers should render the component for contributors with items 1`] = `
.emotion-0 {
font-weight: 700;
margin-bottom: 10px;
text-transform: capitalize;
}
.emotion-12 {
margin: 10px 0 10px 0;
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
-webkit-flex-wrap: wrap;
-ms-flex-wrap: wrap;
flex-wrap: wrap;
}
.emotion-12 > * {
margin: 5px;
}
.emotion-8 {
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
-webkit-flex-direction: column;
-ms-flex-direction: column;
flex-direction: column;
-webkit-align-items: center;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
}
<Developers
type="contributors"
>
<StyledText
<Styled(Component)
variant="subtitle1"
>
<ForwardRef(Text)
className="emotion-0 emotion-1"
className="css-48zeoi emotion-0"
variant="subtitle1"
>
<WithStyles(ForwardRef(Typography))
className="emotion-0 emotion-1"
className="css-48zeoi emotion-0"
variant="subtitle1"
>
<ForwardRef(Typography)
className="emotion-0 emotion-1"
className="css-48zeoi emotion-0"
classes={
Object {
"alignCenter": "MuiTypography-alignCenter",
@@ -89,23 +54,23 @@ exports[`test Developers should render the component for contributors with items
variant="subtitle1"
>
<h6
className="MuiTypography-root emotion-0 emotion-1 MuiTypography-subtitle1"
className="MuiTypography-root css-48zeoi emotion-0 MuiTypography-subtitle1"
>
contributors
</h6>
</ForwardRef(Typography)>
</WithStyles(ForwardRef(Typography))>
</ForwardRef(Text)>
</StyledText>
<Content>
</Styled(Component)>
<Styled(div)>
<div
className="emotion-12 emotion-13"
className="css-mkcn9c emotion-6"
>
<Details
<Styled(span)
key="dave.methvin@gmail.com"
>
<span
className="emotion-8 emotion-9"
className="css-dvxtzn emotion-4"
>
<AvatarTooltip
email="dave.methvin@gmail.com"
@@ -199,12 +164,12 @@ exports[`test Developers should render the component for contributors with items
</ForwardRef(ToolTip)>
</AvatarTooltip>
</span>
</Details>
<Details
</Styled(span)>
<Styled(span)
key="m.goleb@gmail.com"
>
<span
className="emotion-8 emotion-9"
className="css-dvxtzn emotion-4"
>
<AvatarTooltip
email="m.goleb@gmail.com"
@@ -298,64 +263,29 @@ exports[`test Developers should render the component for contributors with items
</ForwardRef(ToolTip)>
</AvatarTooltip>
</span>
</Details>
</Styled(span)>
</div>
</Content>
</Styled(div)>
</Developers>
`;
exports[`test Developers should render the component for maintainers with items 1`] = `
.emotion-0 {
font-weight: 700;
margin-bottom: 10px;
text-transform: capitalize;
}
.emotion-12 {
margin: 10px 0 10px 0;
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
-webkit-flex-wrap: wrap;
-ms-flex-wrap: wrap;
flex-wrap: wrap;
}
.emotion-12 > * {
margin: 5px;
}
.emotion-8 {
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
-webkit-flex-direction: column;
-ms-flex-direction: column;
flex-direction: column;
-webkit-align-items: center;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
}
<Developers
type="maintainers"
>
<StyledText
<Styled(Component)
variant="subtitle1"
>
<ForwardRef(Text)
className="emotion-0 emotion-1"
className="css-48zeoi emotion-0"
variant="subtitle1"
>
<WithStyles(ForwardRef(Typography))
className="emotion-0 emotion-1"
className="css-48zeoi emotion-0"
variant="subtitle1"
>
<ForwardRef(Typography)
className="emotion-0 emotion-1"
className="css-48zeoi emotion-0"
classes={
Object {
"alignCenter": "MuiTypography-alignCenter",
@@ -393,23 +323,23 @@ exports[`test Developers should render the component for maintainers with items
variant="subtitle1"
>
<h6
className="MuiTypography-root emotion-0 emotion-1 MuiTypography-subtitle1"
className="MuiTypography-root css-48zeoi emotion-0 MuiTypography-subtitle1"
>
maintainers
</h6>
</ForwardRef(Typography)>
</WithStyles(ForwardRef(Typography))>
</ForwardRef(Text)>
</StyledText>
<Content>
</Styled(Component)>
<Styled(div)>
<div
className="emotion-12 emotion-13"
className="css-mkcn9c emotion-6"
>
<Details
<Styled(span)
key="dave.methvin@gmail.com"
>
<span
className="emotion-8 emotion-9"
className="css-dvxtzn emotion-4"
>
<AvatarTooltip
email="dave.methvin@gmail.com"
@@ -503,12 +433,12 @@ exports[`test Developers should render the component for maintainers with items
</ForwardRef(ToolTip)>
</AvatarTooltip>
</span>
</Details>
<Details
</Styled(span)>
<Styled(span)
key="m.goleb@gmail.com"
>
<span
className="emotion-8 emotion-9"
className="css-dvxtzn emotion-4"
>
<AvatarTooltip
email="m.goleb@gmail.com"
@@ -602,9 +532,9 @@ exports[`test Developers should render the component for maintainers with items
</ForwardRef(ToolTip)>
</AvatarTooltip>
</span>
</Details>
</Styled(span)>
</div>
</Content>
</Styled(div)>
</Developers>
`;

View File

@@ -1,9 +1,9 @@
import styled from '@emotion/styled';
import colors from '../../utils/styles/colors';
import { fontWeight } from '../../utils/styles/sizes';
import Text from '../../muiComponents/Text';
import FloatingActionButton from '../../muiComponents/FloatingActionButton';
import { Theme } from '../../design-tokens/theme';
export const Details = styled('span')({
display: 'flex',
@@ -26,7 +26,7 @@ export const StyledText = styled(Text)({
textTransform: 'capitalize',
});
export const Fab = styled(FloatingActionButton)<{ theme?: Theme }>(props => ({
backgroundColor: props.theme && props.theme.palette.primary.main,
color: props.theme && props.theme.palette.white,
}));
export const Fab = styled(FloatingActionButton)({
backgroundColor: colors.primary,
color: colors.white,
});

View File

@@ -1,6 +1,6 @@
import React from 'react';
import { mount } from 'enzyme';
import { mount } from '../../utils/test-enzyme';
import { DetailContext } from '../../pages/Version';
import Dist from './Dist';

View File

@@ -1,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`<Dist /> component should render the component in default state 1`] = `"<ul class=\\"MuiList-root MuiList-padding MuiList-subheader\\"><h6 class=\\"MuiTypography-root css-1na337r-StyledText estxrtg0 MuiTypography-subtitle1\\">Latest Distribution</h6><div class=\\"MuiButtonBase-root MuiListItem-root css-1mms18p-DistListItem estxrtg1 MuiListItem-gutters MuiListItem-button\\" tabindex=\\"0\\" role=\\"button\\" aria-disabled=\\"false\\"><div class=\\"MuiChip-root css-e2le7v-DistChips estxrtg2\\"><span class=\\"MuiChip-label\\"><b>file count</b>: 7</span></div><div class=\\"MuiChip-root css-e2le7v-DistChips estxrtg2\\"><span class=\\"MuiChip-label\\"><b>size</b>: 10.00 Bytes</span></div><span class=\\"MuiTouchRipple-root\\"></span></div></ul>"`;
exports[`<Dist /> component should render the component in default state 1`] = `"<ul class=\\"MuiList-root MuiList-padding MuiList-subheader\\"><h6 class=\\"MuiTypography-root css-b8upko estxrtg0 MuiTypography-subtitle1\\">Latest Distribution</h6><div class=\\"MuiButtonBase-root MuiListItem-root css-1huthg8 estxrtg1 MuiListItem-gutters MuiListItem-button\\" tabindex=\\"0\\" role=\\"button\\" aria-disabled=\\"false\\"><div class=\\"MuiChip-root css-42zb18 estxrtg2\\"><span class=\\"MuiChip-label\\"><b>file count</b>: 7</span></div><div class=\\"MuiChip-root css-42zb18 estxrtg2\\"><span class=\\"MuiChip-label\\"><b>size</b>: 10.00 Bytes</span></div><span class=\\"MuiTouchRipple-root\\"></span></div></ul>"`;
exports[`<Dist /> component should render the component with license as object 1`] = `"<ul class=\\"MuiList-root MuiList-padding MuiList-subheader\\"><h6 class=\\"MuiTypography-root css-1na337r-StyledText estxrtg0 MuiTypography-subtitle1\\">Latest Distribution</h6><div class=\\"MuiButtonBase-root MuiListItem-root css-1mms18p-DistListItem estxrtg1 MuiListItem-gutters MuiListItem-button\\" tabindex=\\"0\\" role=\\"button\\" aria-disabled=\\"false\\"><div class=\\"MuiChip-root css-e2le7v-DistChips estxrtg2\\"><span class=\\"MuiChip-label\\"><b>file count</b>: 7</span></div><div class=\\"MuiChip-root css-e2le7v-DistChips estxrtg2\\"><span class=\\"MuiChip-label\\"><b>size</b>: 10.00 Bytes</span></div><div class=\\"MuiChip-root css-e2le7v-DistChips estxrtg2\\"><span class=\\"MuiChip-label\\"><b>license</b>: MIT</span></div><span class=\\"MuiTouchRipple-root\\"></span></div></ul>"`;
exports[`<Dist /> component should render the component with license as object 1`] = `"<ul class=\\"MuiList-root MuiList-padding MuiList-subheader\\"><h6 class=\\"MuiTypography-root css-b8upko estxrtg0 MuiTypography-subtitle1\\">Latest Distribution</h6><div class=\\"MuiButtonBase-root MuiListItem-root css-1huthg8 estxrtg1 MuiListItem-gutters MuiListItem-button\\" tabindex=\\"0\\" role=\\"button\\" aria-disabled=\\"false\\"><div class=\\"MuiChip-root css-42zb18 estxrtg2\\"><span class=\\"MuiChip-label\\"><b>file count</b>: 7</span></div><div class=\\"MuiChip-root css-42zb18 estxrtg2\\"><span class=\\"MuiChip-label\\"><b>size</b>: 10.00 Bytes</span></div><div class=\\"MuiChip-root css-42zb18 estxrtg2\\"><span class=\\"MuiChip-label\\"><b>license</b>: MIT</span></div><span class=\\"MuiTouchRipple-root\\"></span></div></ul>"`;
exports[`<Dist /> component should render the component with license as string 1`] = `"<ul class=\\"MuiList-root MuiList-padding MuiList-subheader\\"><h6 class=\\"MuiTypography-root css-1na337r-StyledText estxrtg0 MuiTypography-subtitle1\\">Latest Distribution</h6><div class=\\"MuiButtonBase-root MuiListItem-root css-1mms18p-DistListItem estxrtg1 MuiListItem-gutters MuiListItem-button\\" tabindex=\\"0\\" role=\\"button\\" aria-disabled=\\"false\\"><div class=\\"MuiChip-root css-e2le7v-DistChips estxrtg2\\"><span class=\\"MuiChip-label\\"><b>file count</b>: 7</span></div><div class=\\"MuiChip-root css-e2le7v-DistChips estxrtg2\\"><span class=\\"MuiChip-label\\"><b>size</b>: 10.00 Bytes</span></div><div class=\\"MuiChip-root css-e2le7v-DistChips estxrtg2\\"><span class=\\"MuiChip-label\\"><b>license</b>: MIT</span></div><span class=\\"MuiTouchRipple-root\\"></span></div></ul>"`;
exports[`<Dist /> component should render the component with license as string 1`] = `"<ul class=\\"MuiList-root MuiList-padding MuiList-subheader\\"><h6 class=\\"MuiTypography-root css-b8upko estxrtg0 MuiTypography-subtitle1\\">Latest Distribution</h6><div class=\\"MuiButtonBase-root MuiListItem-root css-1huthg8 estxrtg1 MuiListItem-gutters MuiListItem-button\\" tabindex=\\"0\\" role=\\"button\\" aria-disabled=\\"false\\"><div class=\\"MuiChip-root css-42zb18 estxrtg2\\"><span class=\\"MuiChip-label\\"><b>file count</b>: 7</span></div><div class=\\"MuiChip-root css-42zb18 estxrtg2\\"><span class=\\"MuiChip-label\\"><b>size</b>: 10.00 Bytes</span></div><div class=\\"MuiChip-root css-42zb18 estxrtg2\\"><span class=\\"MuiChip-label\\"><b>license</b>: MIT</span></div><span class=\\"MuiTouchRipple-root\\"></span></div></ul>"`;

View File

@@ -1,6 +1,6 @@
import styled from '@emotion/styled';
import { Theme } from '../../design-tokens/theme';
import colors from '../../utils/styles/colors';
import { fontWeight } from '../../utils/styles/sizes';
import ListItem from '../../muiComponents/ListItem';
import Text from '../../muiComponents/Text';
@@ -18,11 +18,11 @@ export const DistListItem = styled(ListItem)({
});
export const DistChips = styled(Chip)({
marginRight: 5,
marginRight: '5px',
textTransform: 'capitalize',
});
export const DownloadButton = styled(FloatingActionButton)<{ theme?: Theme }>(props => ({
backgroundColor: props.theme && props.theme.palette.primary.main,
color: props.theme && props.theme.palette.white,
}));
export const DownloadButton = styled(FloatingActionButton)({
backgroundColor: colors.primary,
color: colors.white,
});

View File

@@ -1,6 +1,6 @@
import React from 'react';
import { mount } from 'enzyme';
import { mount } from '../../utils/test-enzyme';
import { DetailContext } from '../../pages/Version';
import { PackageMetaInterface } from '../../../types/packageMeta';

View File

@@ -13,7 +13,7 @@ import node from './img/node.png';
const Engine: React.FC = () => {
const { packageMeta } = useContext(DetailContext);
const engines = packageMeta?.latest?.engines;
const engines = packageMeta && packageMeta.latest && packageMeta.latest.engines;
if (!engines || (!engines.node && !engines.npm)) {
return null;

View File

@@ -1,3 +1,3 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`<Engines /> component should render the component in default state 1`] = `"<div class=\\"MuiGrid-root MuiGrid-container\\"><div class=\\"MuiGrid-root MuiGrid-item MuiGrid-grid-xs-6\\"><ul class=\\"MuiList-root MuiList-padding MuiList-subheader\\"><h6 class=\\"MuiTypography-root css-1na337r-StyledText et66bt70 MuiTypography-subtitle1\\">node JS</h6><div class=\\"MuiButtonBase-root MuiListItem-root css-18b06t0-EngineListItem et66bt71 MuiListItem-gutters MuiListItem-button\\" tabindex=\\"0\\" role=\\"button\\" aria-disabled=\\"false\\"><div class=\\"MuiAvatar-root MuiAvatar-circle MuiAvatar-colorDefault\\"></div><div class=\\"MuiListItemText-root\\"><span class=\\"MuiTypography-root MuiListItemText-primary MuiTypography-body1\\">&gt;= 0.1.98</span></div><span class=\\"MuiTouchRipple-root\\"></span></div></ul></div><div class=\\"MuiGrid-root MuiGrid-item MuiGrid-grid-xs-6\\"><ul class=\\"MuiList-root MuiList-padding MuiList-subheader\\"><h6 class=\\"MuiTypography-root css-1na337r-StyledText et66bt70 MuiTypography-subtitle1\\">NPM version</h6><div class=\\"MuiButtonBase-root MuiListItem-root css-18b06t0-EngineListItem et66bt71 MuiListItem-gutters MuiListItem-button\\" tabindex=\\"0\\" role=\\"button\\" aria-disabled=\\"false\\"><div class=\\"MuiAvatar-root MuiAvatar-circle MuiAvatar-colorDefault\\"></div><div class=\\"MuiListItemText-root\\"><span class=\\"MuiTypography-root MuiListItemText-primary MuiTypography-body1\\">&gt;3</span></div><span class=\\"MuiTouchRipple-root\\"></span></div></ul></div></div>"`;
exports[`<Engines /> component should render the component in default state 1`] = `"<div class=\\"MuiGrid-root MuiGrid-container\\"><div class=\\"MuiGrid-root MuiGrid-item MuiGrid-grid-xs-6\\"><ul class=\\"MuiList-root MuiList-padding MuiList-subheader\\"><h6 class=\\"MuiTypography-root css-b8upko et66bt70 MuiTypography-subtitle1\\">node JS</h6><div class=\\"MuiButtonBase-root MuiListItem-root css-131yq1t et66bt71 MuiListItem-gutters MuiListItem-button\\" tabindex=\\"0\\" role=\\"button\\" aria-disabled=\\"false\\"><div class=\\"MuiAvatar-root MuiAvatar-circle MuiAvatar-colorDefault\\"></div><div class=\\"MuiListItemText-root\\"><span class=\\"MuiTypography-root MuiListItemText-primary MuiTypography-body1\\">&gt;= 0.1.98</span></div><span class=\\"MuiTouchRipple-root\\"></span></div></ul></div><div class=\\"MuiGrid-root MuiGrid-item MuiGrid-grid-xs-6\\"><ul class=\\"MuiList-root MuiList-padding MuiList-subheader\\"><h6 class=\\"MuiTypography-root css-b8upko et66bt70 MuiTypography-subtitle1\\">NPM version</h6><div class=\\"MuiButtonBase-root MuiListItem-root css-131yq1t et66bt71 MuiListItem-gutters MuiListItem-button\\" tabindex=\\"0\\" role=\\"button\\" aria-disabled=\\"false\\"><div class=\\"MuiAvatar-root MuiAvatar-circle MuiAvatar-colorDefault\\"></div><div class=\\"MuiListItemText-root\\"><span class=\\"MuiTypography-root MuiListItemText-primary MuiTypography-body1\\">&gt;3</span></div><span class=\\"MuiTouchRipple-root\\"></span></div></ul></div></div>"`;

View File

@@ -1,20 +1,21 @@
import React from 'react';
import { render } from '../../utils/test-react-testing-library';
import { mount, ReactWrapper } from 'enzyme';
import Footer from './Footer';
describe('<Footer /> component', () => {
beforeAll(() => {
window.VERDACCIO_VERSION = 'v.1.0.0';
});
jest.mock('../../../package.json', () => ({
version: '4.0.0-alpha.3',
}));
afterAll(() => {
describe('<Footer /> component', () => {
let wrapper: ReactWrapper;
beforeEach(() => {
window.VERDACCIO_VERSION = 'v.1.0.0';
wrapper = mount(<Footer />);
delete window.VERDACCIO_VERSION;
});
test('should load the initial state of Footer component', () => {
const { container } = render(<Footer />);
expect(container.firstChild).toMatchSnapshot();
expect(wrapper.html()).toMatchSnapshot();
});
});

View File

@@ -1,274 +1,3 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`<Footer /> component should load the initial state of Footer component 1`] = `
.emotion-38 {
background: #f9f9f9;
border-top: 1px solid #e3e3e3;
color: #999999;
font-size: 14px;
padding: 20px;
}
.emotion-36 {
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
-webkit-align-items: center;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
-webkit-box-pack: end;
-webkit-justify-content: flex-end;
-ms-flex-pack: end;
justify-content: flex-end;
width: 100%;
}
@media (min-width:768px) {
.emotion-36 {
min-width: 400px;
max-width: 800px;
margin: auto;
-webkit-box-pack: justify;
-webkit-justify-content: space-between;
-ms-flex-pack: justify;
justify-content: space-between;
}
}
@media (min-width:1024px) {
.emotion-36 {
max-width: 1240px;
}
}
.emotion-27 {
-webkit-align-items: center;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
display: none;
}
@media (min-width:768px) {
.emotion-27 {
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
}
}
.emotion-0 {
color: #e25555;
padding: 0 5px;
}
.emotion-25 {
position: relative;
height: 18px;
}
.emotion-25:hover .emotion-24 {
visibility: visible;
}
.emotion-3 {
box-sizing: initial;
display: inline-block;
cursor: default;
width: 18px;
height: 18px;
padding: 0 10px;
}
.emotion-23 {
position: absolute;
background: #d3dddd;
padding: 1px 4px;
border-radius: 3px;
height: 20px;
display: -webkit-inline-box;
display: -webkit-inline-flex;
display: -ms-inline-flexbox;
display: inline-flex;
-webkit-align-items: center;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
visibility: hidden;
top: -2px;
}
.emotion-23:before {
content: '';
position: absolute;
top: 29%;
left: -4px;
margin-left: -5px;
border: 5px solid;
border-color: #d3dddd transparent transparent transparent;
-webkit-transform: rotate(90deg);
-ms-transform: rotate(90deg);
transform: rotate(90deg);
}
.emotion-6 {
box-sizing: initial;
display: inline-block;
cursor: default;
width: 18px;
height: 18px;
padding: 0 5px;
}
.emotion-34 {
-webkit-align-items: center;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
display: none;
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
}
@media (min-width:768px) {
.emotion-34 {
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
}
}
.emotion-32 {
box-sizing: initial;
display: inline-block;
cursor: pointer;
width: 18px;
height: 18px;
padding: 0 5px;
}
.emotion-29 {
width: 100%;
height: auto;
}
<div
class="emotion-38 emotion-39"
>
<div
class="emotion-36 emotion-37"
>
<div
class="emotion-27 emotion-28"
>
Made with
<span
class="emotion-0 emotion-1"
>
♥
</span>
on
<span
class="emotion-25 emotion-26"
>
<svg
class="emotion-2 emotion-3 emotion-4"
>
<title>
Earth
</title>
<use
xlink:href="[object Object]#earth"
/>
</svg>
<span
class="emotion-23 emotion-24"
>
<svg
class="emotion-5 emotion-6 emotion-4"
>
<title>
Spain
</title>
<use
xlink:href="[object Object]#spain"
/>
</svg>
<svg
class="emotion-5 emotion-6 emotion-4"
>
<title>
Nicaragua
</title>
<use
xlink:href="[object Object]#nicaragua"
/>
</svg>
<svg
class="emotion-5 emotion-6 emotion-4"
>
<title>
India
</title>
<use
xlink:href="[object Object]#india"
/>
</svg>
<svg
class="emotion-5 emotion-6 emotion-4"
>
<title>
Brazil
</title>
<use
xlink:href="[object Object]#brazil"
/>
</svg>
<svg
class="emotion-5 emotion-6 emotion-4"
>
<title>
China
</title>
<use
xlink:href="[object Object]#china"
/>
</svg>
<svg
class="emotion-5 emotion-6 emotion-4"
>
<title>
Austria
</title>
<use
xlink:href="[object Object]#austria"
/>
</svg>
</span>
</span>
</div>
<div
class="emotion-34 emotion-35"
>
Powered by
<span
class="emotion-5 emotion-32 emotion-33"
title="Verdaccio"
>
<img
alt="Verdaccio"
class="emotion-29 emotion-30"
src="[object Object]"
/>
</span>
/ v.1.0.0
</div>
</div>
</div>
`;
exports[`<Footer /> component should load the initial state of Footer component 1`] = `"<div class=\\"css-i0nj2g ezbsl480\\"><div class=\\"css-hzfs9b ezbsl481\\"><div class=\\"css-d8nsp7 ezbsl482\\"> Made with<span class=\\"css-1so4oe0 ezbsl487\\">♥</span>on<span class=\\"css-1ie354y ezbsl484\\"><svg class=\\"ezbsl485 css-151fgib ek145dl0\\"><title>Earth</title><use xlink:href=\\"[object Object]#earth\\"></use></svg><span class=\\"css-8631ip ezbsl486\\"><svg class=\\"ezbsl488 css-1ah96gu ek145dl0\\"><title>Spain</title><use xlink:href=\\"[object Object]#spain\\"></use></svg><svg class=\\"ezbsl488 css-1ah96gu ek145dl0\\"><title>Nicaragua</title><use xlink:href=\\"[object Object]#nicaragua\\"></use></svg><svg class=\\"ezbsl488 css-1ah96gu ek145dl0\\"><title>India</title><use xlink:href=\\"[object Object]#india\\"></use></svg><svg class=\\"ezbsl488 css-1ah96gu ek145dl0\\"><title>Brazil</title><use xlink:href=\\"[object Object]#brazil\\"></use></svg><svg class=\\"ezbsl488 css-1ah96gu ek145dl0\\"><title>China</title><use xlink:href=\\"[object Object]#china\\"></use></svg><svg class=\\"ezbsl488 css-1ah96gu ek145dl0\\"><title>Austria</title><use xlink:href=\\"[object Object]#austria\\"></use></svg></span></span></div><div class=\\"css-1wbzdyy ezbsl483\\">Powered by<span class=\\"ezbsl488 css-ommwhu ek145dl1\\" name=\\"verdaccio\\" title=\\"Verdaccio\\"><img alt=\\"Verdaccio\\" src=\\"[object Object]\\" class=\\"css-1ncdhax ek145dl2\\"></span>/ v.1.0.0</div></div></div>"`;

View File

@@ -1,88 +1,111 @@
import { css } from '@emotion/core';
import styled from '@emotion/styled';
import { breakpoints } from '../../utils/styles/media';
import mq from '../../utils/styles/media';
import Icon from '../Icon/Icon';
import { Theme } from '../../design-tokens/theme';
import colors from '../../utils/styles/colors';
export const Wrapper = styled('div')<{ theme?: Theme }>(props => ({
background: props.theme && props.theme.palette.snow,
borderTop: `1px solid ${props.theme && props.theme.palette.greyGainsboro}`,
color: props.theme && props.theme.palette.nobel01,
fontSize: '14px',
padding: '20px',
}));
export const Inner = styled('div')({
display: 'flex',
alignItems: 'center',
justifyContent: 'flex-end',
width: '100%',
[`@media (min-width: ${breakpoints.medium}px)`]: {
minWidth: 400,
maxWidth: 800,
margin: 'auto',
justifyContent: 'space-between',
},
[`@media (min-width: ${breakpoints.large}px)`]: {
maxWidth: 1240,
export const Wrapper = styled('div')({
'&&': {
background: colors.snow,
borderTop: `1px solid ${colors.greyGainsboro}`,
color: colors.nobel01,
fontSize: '14px',
padding: '20px',
},
});
export const Left = styled('div')({
alignItems: 'center',
display: 'none',
[`@media (min-width: ${breakpoints.medium}px)`]: {
export const Inner = styled('div')`
&& {
display: flex;
align-items: center;
justify-content: flex-end;
width: 100%;
${() => {
return mq.medium(css`
min-width: 400px;
max-width: 800px;
margin: auto;
justify-content: space-between;
`);
}};
${() => {
return mq.large(css`
max-width: 1240px;
`);
}};
}
`;
export const Left = styled('div')`
&& {
align-items: center;
display: none;
${() => {
return mq.medium(css`
display: flex;
`);
}};
}
`;
export const Right = styled(Left)({
'&&': {
display: 'flex',
},
});
export const Right = styled(Left)({
display: 'flex',
export const ToolTip = styled('span')({
'&&': {
position: 'relative',
height: '18px',
},
});
export const Earth = styled(Icon)({
padding: '0 10px',
});
export const Flags = styled('span')<{ theme?: Theme }>(props => ({
position: 'absolute',
background: props.theme && props.theme.palette.greyAthens,
padding: '1px 4px',
borderRadius: 3,
height: 20,
display: 'inline-flex',
alignItems: 'center',
visibility: 'hidden',
top: -2,
':before': {
content: "''",
position: 'absolute',
top: '29%',
left: -4,
marginLeft: -5,
border: '5px solid',
borderColor: `${props.theme && props.theme.palette.greyAthens} transparent transparent transparent`,
transform: 'rotate(90deg)',
},
}));
export const ToolTip = styled('span')({
position: 'relative',
height: '18px',
':hover': {
[`${Flags}`]: {
visibility: 'visible',
},
'&&': {
padding: '0 10px',
},
});
export const Love = styled('span')<{ theme?: Theme }>(props => ({
color: props.theme && props.theme.palette.love,
padding: '0 5px',
}));
export const Flags = styled('span')`
&& {
position: absolute;
background: ${colors.greyAthens};
padding: 1px 4px;
border-radius: 3px;
height: 20px;
display: inline-flex;
align-items: center;
visibility: hidden;
top: -2px;
:before {
content: '';
position: absolute;
top: 29%;
left: -4px;
margin-left: -5px;
border: 5px solid;
border-color: ${colors.greyAthens} transparent transparent transparent;
transform: rotate(90deg);
}
${/* sc-selector */ ToolTip}:hover & {
visibility: visible;
}
}
`;
export const Love = styled('span')({
'&&': {
color: colors.love,
padding: '0 5px',
},
});
export const Flag = styled(Icon)({
padding: '0 5px',
'&&': {
padding: '0 5px',
},
});
export const Logo = Flag;

View File

@@ -1,16 +1,15 @@
import React from 'react';
import { BrowserRouter as Router } from 'react-router-dom';
import { render, fireEvent, waitForElement, waitForElementToBeRemoved } from '../../utils/test-react-testing-library';
import { AppContextProvider } from '../../App';
import { render, fireEvent, waitForElementToBeRemoved, waitForElement } from '@testing-library/react';
import Header from './Header';
const props = {
user: {
username: 'verddacio-user',
},
packages: [],
const headerProps = {
username: 'verddacio-user',
scope: 'test scope',
withoutSearch: true,
handleToggleLoginModal: jest.fn(),
handleLogout: jest.fn(),
};
/* eslint-disable react/jsx-no-bind*/
@@ -18,71 +17,82 @@ describe('<Header /> component with logged in state', () => {
test('should load the component in logged out state', () => {
const { container, queryByTestId, getByText } = render(
<Router>
<AppContextProvider packages={props.packages}>
<Header />
</AppContextProvider>
<Header
onLogout={headerProps.handleLogout}
onToggleLoginModal={headerProps.handleToggleLoginModal}
scope={headerProps.scope}
/>
</Router>
);
expect(container.firstChild).toMatchSnapshot();
expect(queryByTestId('header--menu-accountcircle')).toBeNull();
expect(queryByTestId('header--menu-acountcircle')).toBeNull();
expect(getByText('Login')).toBeTruthy();
});
test('should load the component in logged in state', () => {
const { container, getByTestId, queryByText } = render(
<Router>
<AppContextProvider packages={props.packages} user={props.user}>
<Header />
</AppContextProvider>
<Header
onLogout={headerProps.handleLogout}
onToggleLoginModal={headerProps.handleToggleLoginModal}
scope={headerProps.scope}
username={headerProps.username}
/>
</Router>
);
expect(container.firstChild).toMatchSnapshot();
expect(getByTestId('header--menu-accountcircle')).toBeTruthy();
expect(getByTestId('header--menu-acountcircle')).toBeTruthy();
expect(queryByText('Login')).toBeNull();
});
test('should open login dialog', async () => {
const { getByText, getByTestId } = render(
const { getByText } = render(
<Router>
<AppContextProvider packages={props.packages}>
<Header />
</AppContextProvider>
<Header
onLogout={headerProps.handleLogout}
onToggleLoginModal={headerProps.handleToggleLoginModal}
scope={headerProps.scope}
/>
</Router>
);
const loginBtn = getByText('Login');
fireEvent.click(loginBtn);
// wait for login modal appearance and return the element
const registrationInfoModal = await waitForElement(() => getByTestId('login--form-container'));
expect(registrationInfoModal).toBeTruthy();
expect(headerProps.handleToggleLoginModal).toHaveBeenCalled();
});
test('should logout the user', async () => {
const { getByText, getByTestId } = render(
<Router>
<AppContextProvider packages={props.packages} user={props.user}>
<Header />
</AppContextProvider>
<Header
onLogout={headerProps.handleLogout}
onToggleLoginModal={headerProps.handleToggleLoginModal}
scope={headerProps.scope}
username={headerProps.username}
/>
</Router>
);
const headerMenuAccountCircle = getByTestId('header--menu-accountcircle');
const headerMenuAccountCircle = getByTestId('header--menu-acountcircle');
fireEvent.click(headerMenuAccountCircle);
// wait for button Logout's appearance and return the element
const logoutBtn = await waitForElement(() => getByText('Logout'));
fireEvent.click(logoutBtn);
expect(getByText('Login')).toBeTruthy();
expect(headerProps.handleLogout).toHaveBeenCalled();
});
test("The question icon should open a new tab of verdaccio's website - installation doc", () => {
test("The question icon should open a new tab of verdaccio's website - installation doc", async () => {
const { getByTestId } = render(
<Router>
<AppContextProvider packages={props.packages} user={props.user}>
<Header />
</AppContextProvider>
<Header
onLogout={headerProps.handleLogout}
onToggleLoginModal={headerProps.handleToggleLoginModal}
scope={headerProps.scope}
username={headerProps.username}
/>
</Router>
);
@@ -93,9 +103,12 @@ describe('<Header /> component with logged in state', () => {
test('should open the registrationInfo modal when clicking on the info icon', async () => {
const { getByTestId } = render(
<Router>
<AppContextProvider packages={props.packages} user={props.user}>
<Header />
</AppContextProvider>
<Header
onLogout={headerProps.handleLogout}
onToggleLoginModal={headerProps.handleToggleLoginModal}
scope={headerProps.scope}
username={headerProps.username}
/>
</Router>
);
@@ -110,9 +123,12 @@ describe('<Header /> component with logged in state', () => {
test('should close the registrationInfo modal when clicking on the button close', async () => {
const { getByTestId, getByText, queryByTestId } = render(
<Router>
<AppContextProvider packages={props.packages} user={props.user}>
<Header />
</AppContextProvider>
<Header
onLogout={headerProps.handleLogout}
onToggleLoginModal={headerProps.handleToggleLoginModal}
scope={headerProps.scope}
username={headerProps.username}
/>
</Router>
);
@@ -127,6 +143,6 @@ describe('<Header /> component with logged in state', () => {
queryByTestId('registryInfo--dialog')
);
expect(hasRegistrationInfoModalBeenRemoved).toBeTruthy();
test.todo('autocompletion should display suggestions according to the type value');
});
test.todo('autocompletion should display suggestions according to the type value');
});

View File

@@ -1,12 +1,8 @@
import React, { useState, useContext } from 'react';
import React, { useState } from 'react';
import storage from '../../utils/storage';
import { getRegistryURL } from '../../utils/url';
import { makeLogin } from '../../utils/login';
import Button from '../../muiComponents/Button';
import AppContext from '../../App/AppContext';
import LoginModal from '../Login';
import Search from '../Search';
import { getRegistryURL } from '../../utils/url';
import Button from '../../muiComponents/Button';
import { NavBar, InnerNavBar, MobileNavBar, InnerMobileNavBar } from './styles';
import HeaderLeft from './HeaderLeft';
@@ -14,66 +10,31 @@ import HeaderRight from './HeaderRight';
import HeaderInfoDialog from './HeaderInfoDialog';
interface Props {
logo?: string;
username?: string;
onLogout: () => void;
onToggleLoginModal: () => void;
scope: string;
withoutSearch?: boolean;
}
/* eslint-disable react/jsx-max-depth */
/* eslint-disable react/jsx-no-bind*/
/* eslint-disable @typescript-eslint/explicit-function-return-type */
const Header: React.FC<Props> = ({ withoutSearch }) => {
const appContext = useContext(AppContext);
const Header: React.FC<Props> = ({ logo, withoutSearch, username, onLogout, onToggleLoginModal, scope }) => {
const [isInfoDialogOpen, setOpenInfoDialog] = useState();
const [showMobileNavBar, setShowMobileNavBar] = useState();
const [showLoginModal, setShowLoginModal] = useState(false);
if (!appContext) {
throw Error('The app Context was not correct used');
}
const { user, scope, error, setUser, setError } = appContext;
const logo = window.VERDACCIO_LOGO;
/**
* handles login
* Required by: <Header />
*/
const handleDoLogin = async (usernameValue: string, passwordValue: string) => {
const { username, token, error } = await makeLogin(usernameValue, passwordValue);
if (username && token) {
storage.setItem('username', username);
storage.setItem('token', token);
setUser({ username });
setShowLoginModal(false);
}
if (error) {
setUser(undefined);
setError(error);
}
};
/**
* Logouts user
* Required by: <Header />
*/
const handleLogout = () => {
storage.removeItem('username');
storage.removeItem('token');
setUser(undefined);
};
return (
<>
<NavBar data-testid="header" position="static">
<NavBar position="static">
<InnerNavBar>
<HeaderLeft logo={logo} />
<HeaderRight
onLogout={handleLogout}
onLogout={onLogout}
onOpenRegistryInfoDialog={() => setOpenInfoDialog(true)}
onToggleLogin={() => setShowLoginModal(!showLoginModal)}
onToggleLogin={onToggleLoginModal}
onToggleMobileNav={() => setShowMobileNavBar(!showMobileNavBar)}
username={user && user.username}
username={username}
withoutSearch={withoutSearch}
/>
</InnerNavBar>
@@ -94,12 +55,6 @@ const Header: React.FC<Props> = ({ withoutSearch }) => {
</Button>
</MobileNavBar>
)}
<LoginModal
error={error}
onCancel={() => setShowLoginModal(false)}
onSubmit={handleDoLogin}
visibility={showLoginModal}
/>
</>
);
};

View File

@@ -11,7 +11,7 @@ interface Props {
const HeaderGreetings: React.FC<Props> = ({ username }) => (
<>
<Greetings>{'Hi,'}</Greetings>
<Label capitalize={true} data-testid="greetings-label" text={username} weight="bold" />
<Label capitalize={true} text={username} weight="bold" />
</>
);

View File

@@ -1,5 +1,5 @@
import React from 'react';
import styled from '@emotion/styled';
import { css } from 'emotion';
import { Link } from 'react-router-dom';
import Search from '../Search/';
@@ -12,15 +12,15 @@ interface Props {
logo?: string;
}
const StyledLink = styled(Link)({
marginRight: '1em',
});
const HeaderLeft: React.FC<Props> = ({ withoutSearch = false, logo }) => (
<LeftSide>
<StyledLink to={'/'}>
<Link
className={css`
margin-right: 1em;
`}
to={'/'}>
<HeaderLogo logo={logo} />
</StyledLink>
</Link>
{!withoutSearch && (
<SearchWrapper>
<Search />

View File

@@ -28,7 +28,7 @@ const HeaderMenu: React.FC<Props> = ({
<>
<IconButton
color="inherit"
data-testid="header--menu-accountcircle"
data-testid="header--menu-acountcircle"
id="header--button-account"
onClick={onLoggedInMenu}>
<AccountCircle />
@@ -48,7 +48,7 @@ const HeaderMenu: React.FC<Props> = ({
<MenuItem disabled={true}>
<HeaderGreetings username={username} />
</MenuItem>
<MenuItem button={true} data-testid="header--button-logout" id="header--button-logout" onClick={onLogout}>
<MenuItem button={true} id="header--button-logout" onClick={onLogout}>
{'Logout'}
</MenuItem>
</Menu>

View File

@@ -53,7 +53,7 @@ const HeaderRight: React.FC<Props> = ({
};
return (
<RightSide data-testid="header-right">
<RightSide>
{!withoutSearch && (
<HeaderToolTip onClick={onToggleMobileNav} title={'Search packages'} tooltipIconType={'search'} />
)}

View File

@@ -1,167 +1,28 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`<Header /> component with logged in state should load the component in logged in state 1`] = `
.emotion-24 {
background-color: #4b5e40;
min-height: 60px;
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
-webkit-box-pack: center;
-webkit-justify-content: center;
-ms-flex-pack: center;
justify-content: center;
}
@media (min-width:768px) {
.emotion-24 .emotion-13 {
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
}
.emotion-24 .emotion-17 {
display: none;
}
.emotion-24 .e1jf5lit4 {
display: none;
}
}
@media (min-width:1024px) {
.emotion-24 .emotion-23 {
padding: 0 20px;
}
@media (min-width:1275px) {
.emotion-24 .emotion-23 {
max-width: 1240px;
width: 100%;
margin: 0 auto;
}
}
}
.emotion-22 {
-webkit-box-pack: justify;
-webkit-justify-content: space-between;
-ms-flex-pack: justify;
justify-content: space-between;
-webkit-align-items: center;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
padding: 0 15px;
}
.emotion-14 {
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
padding: 0;
-webkit-flex: 1;
-ms-flex: 1;
flex: 1;
}
.emotion-2 {
margin-right: 1em;
}
.emotion-0 {
display: inline-block;
vertical-align: middle;
box-sizing: border-box;
background-position: center;
background-size: contain;
background-image: url([object Object]);
background-repeat: no-repeat;
width: 40px;
height: 40px;
}
.emotion-12 {
display: none;
max-width: 393px;
width: 100%;
}
.emotion-10 {
width: 100%;
height: 32px;
position: relative;
z-index: 1;
}
.emotion-6 .MuiInputBase-root:before {
content: '';
border: none;
}
.emotion-6 .MuiInputBase-root:after {
border-color: #fff;
}
.emotion-6 .MuiInputBase-root:hover:before {
content: none;
}
.emotion-6 .MuiInputBase-input {
color: #fff;
}
.emotion-4 {
color: #fff;
}
.emotion-8 {
max-height: 500px;
overflow-y: auto;
}
.emotion-20 {
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
padding: 0;
}
.emotion-16 {
display: block;
}
.emotion-18 {
color: #fff;
}
<header
class="MuiPaper-root MuiPaper-elevation4 MuiAppBar-root MuiAppBar-positionStatic emotion-24 emotion-25 MuiAppBar-colorPrimary"
data-testid="header"
class="MuiPaper-root MuiPaper-elevation4 MuiAppBar-root MuiAppBar-positionStatic css-rfunvc emotion-9 MuiAppBar-colorPrimary"
>
<div
class="MuiToolbar-root MuiToolbar-regular emotion-22 emotion-23 MuiToolbar-gutters"
class="MuiToolbar-root MuiToolbar-regular css-1bjere7 emotion-8 MuiToolbar-gutters"
>
<div
class="MuiToolbar-root MuiToolbar-regular emotion-14 emotion-15 MuiToolbar-gutters"
class="MuiToolbar-root MuiToolbar-regular css-i5xjw9 emotion-4 MuiToolbar-gutters"
>
<a
class="emotion-2 emotion-3"
class="css-1dk30lc"
href="/"
>
<div
class="emotion-0 emotion-1"
class="css-1sifsqk emotion-0"
/>
</a>
<div
class="emotion-12 emotion-13"
class="css-12prohx emotion-3"
>
<div
class="emotion-10 emotion-11"
class="css-1crzyyo emotion-2"
>
<div
aria-expanded="false"
@@ -173,13 +34,13 @@ exports[`<Header /> component with logged in state should load the component in
<div
aria-autocomplete="list"
aria-controls="react-autowhatever-1"
class="MuiFormControl-root MuiTextField-root react-autosuggest__input emotion-6 emotion-7 MuiFormControl-fullWidth"
class="MuiFormControl-root MuiTextField-root react-autosuggest__input MuiFormControl-fullWidth"
>
<div
class="MuiInputBase-root MuiInput-root MuiInput-underline MuiInputBase-fullWidth MuiInput-fullWidth MuiInputBase-formControl MuiInput-formControl MuiInputBase-adornedStart"
class="MuiInputBase-root MuiInput-root css-n9ojyg MuiInput-underline MuiInputBase-fullWidth MuiInput-fullWidth MuiInputBase-formControl MuiInput-formControl MuiInputBase-adornedStart"
>
<div
class="MuiInputAdornment-root emotion-4 emotion-5 MuiInputAdornment-positionStart"
class="MuiInputAdornment-root css-fvu7gn MuiInputAdornment-positionStart"
>
<svg
aria-hidden="true"
@@ -196,7 +57,7 @@ exports[`<Header /> component with logged in state should load the component in
<input
aria-invalid="false"
autocomplete="off"
class="MuiInputBase-input MuiInput-input MuiInputBase-inputAdornedStart"
class="MuiInputBase-input MuiInput-input css-hodoyq MuiInputBase-inputAdornedStart"
placeholder="Search Packages"
type="text"
value=""
@@ -204,7 +65,7 @@ exports[`<Header /> component with logged in state should load the component in
</div>
</div>
<div
class="MuiPaper-root MuiPaper-elevation1 react-autosuggest__suggestions-container emotion-8 emotion-9"
class="MuiPaper-root MuiPaper-elevation1 react-autosuggest__suggestions-container css-cfo6a emotion-1"
id="react-autowhatever-1"
role="listbox"
/>
@@ -213,11 +74,10 @@ exports[`<Header /> component with logged in state should load the component in
</div>
</div>
<div
class="MuiToolbar-root MuiToolbar-regular emotion-20 emotion-21 MuiToolbar-gutters"
data-testid="header-right"
class="MuiToolbar-root MuiToolbar-regular css-1qii1b7 emotion-7 MuiToolbar-gutters"
>
<button
class="MuiButtonBase-root MuiIconButton-root emotion-16 emotion-17 MuiIconButton-colorInherit"
class="MuiButtonBase-root MuiIconButton-root css-13o7eu2 emotion-5 MuiIconButton-colorInherit"
tabindex="0"
type="button"
>
@@ -241,7 +101,7 @@ exports[`<Header /> component with logged in state should load the component in
/>
</button>
<a
class="emotion-18 emotion-19"
class="css-kbn7if emotion-6"
data-testid="header--tooltip-documentation"
href="https://verdaccio.org/docs/en/installation"
rel="noopener noreferrer"
@@ -304,7 +164,7 @@ exports[`<Header /> component with logged in state should load the component in
</button>
<button
class="MuiButtonBase-root MuiIconButton-root MuiIconButton-colorInherit"
data-testid="header--menu-accountcircle"
data-testid="header--menu-acountcircle"
id="header--button-account"
tabindex="0"
type="button"
@@ -334,167 +194,28 @@ exports[`<Header /> component with logged in state should load the component in
`;
exports[`<Header /> component with logged in state should load the component in logged out state 1`] = `
.emotion-24 {
background-color: #4b5e40;
min-height: 60px;
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
-webkit-box-pack: center;
-webkit-justify-content: center;
-ms-flex-pack: center;
justify-content: center;
}
@media (min-width:768px) {
.emotion-24 .emotion-13 {
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
}
.emotion-24 .emotion-17 {
display: none;
}
.emotion-24 .e1jf5lit4 {
display: none;
}
}
@media (min-width:1024px) {
.emotion-24 .emotion-23 {
padding: 0 20px;
}
@media (min-width:1275px) {
.emotion-24 .emotion-23 {
max-width: 1240px;
width: 100%;
margin: 0 auto;
}
}
}
.emotion-22 {
-webkit-box-pack: justify;
-webkit-justify-content: space-between;
-ms-flex-pack: justify;
justify-content: space-between;
-webkit-align-items: center;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
padding: 0 15px;
}
.emotion-14 {
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
padding: 0;
-webkit-flex: 1;
-ms-flex: 1;
flex: 1;
}
.emotion-2 {
margin-right: 1em;
}
.emotion-0 {
display: inline-block;
vertical-align: middle;
box-sizing: border-box;
background-position: center;
background-size: contain;
background-image: url([object Object]);
background-repeat: no-repeat;
width: 40px;
height: 40px;
}
.emotion-12 {
display: none;
max-width: 393px;
width: 100%;
}
.emotion-10 {
width: 100%;
height: 32px;
position: relative;
z-index: 1;
}
.emotion-6 .MuiInputBase-root:before {
content: '';
border: none;
}
.emotion-6 .MuiInputBase-root:after {
border-color: #fff;
}
.emotion-6 .MuiInputBase-root:hover:before {
content: none;
}
.emotion-6 .MuiInputBase-input {
color: #fff;
}
.emotion-4 {
color: #fff;
}
.emotion-8 {
max-height: 500px;
overflow-y: auto;
}
.emotion-20 {
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
padding: 0;
}
.emotion-16 {
display: block;
}
.emotion-18 {
color: #fff;
}
<header
class="MuiPaper-root MuiPaper-elevation4 MuiAppBar-root MuiAppBar-positionStatic emotion-24 emotion-25 MuiAppBar-colorPrimary"
data-testid="header"
class="MuiPaper-root MuiPaper-elevation4 MuiAppBar-root MuiAppBar-positionStatic css-rfunvc emotion-9 MuiAppBar-colorPrimary"
>
<div
class="MuiToolbar-root MuiToolbar-regular emotion-22 emotion-23 MuiToolbar-gutters"
class="MuiToolbar-root MuiToolbar-regular css-1bjere7 emotion-8 MuiToolbar-gutters"
>
<div
class="MuiToolbar-root MuiToolbar-regular emotion-14 emotion-15 MuiToolbar-gutters"
class="MuiToolbar-root MuiToolbar-regular css-i5xjw9 emotion-4 MuiToolbar-gutters"
>
<a
class="emotion-2 emotion-3"
class="css-1dk30lc"
href="/"
>
<div
class="emotion-0 emotion-1"
class="css-1sifsqk emotion-0"
/>
</a>
<div
class="emotion-12 emotion-13"
class="css-12prohx emotion-3"
>
<div
class="emotion-10 emotion-11"
class="css-1crzyyo emotion-2"
>
<div
aria-expanded="false"
@@ -506,13 +227,13 @@ exports[`<Header /> component with logged in state should load the component in
<div
aria-autocomplete="list"
aria-controls="react-autowhatever-1"
class="MuiFormControl-root MuiTextField-root react-autosuggest__input emotion-6 emotion-7 MuiFormControl-fullWidth"
class="MuiFormControl-root MuiTextField-root react-autosuggest__input MuiFormControl-fullWidth"
>
<div
class="MuiInputBase-root MuiInput-root MuiInput-underline MuiInputBase-fullWidth MuiInput-fullWidth MuiInputBase-formControl MuiInput-formControl MuiInputBase-adornedStart"
class="MuiInputBase-root MuiInput-root css-n9ojyg MuiInput-underline MuiInputBase-fullWidth MuiInput-fullWidth MuiInputBase-formControl MuiInput-formControl MuiInputBase-adornedStart"
>
<div
class="MuiInputAdornment-root emotion-4 emotion-5 MuiInputAdornment-positionStart"
class="MuiInputAdornment-root css-fvu7gn MuiInputAdornment-positionStart"
>
<svg
aria-hidden="true"
@@ -529,7 +250,7 @@ exports[`<Header /> component with logged in state should load the component in
<input
aria-invalid="false"
autocomplete="off"
class="MuiInputBase-input MuiInput-input MuiInputBase-inputAdornedStart"
class="MuiInputBase-input MuiInput-input css-hodoyq MuiInputBase-inputAdornedStart"
placeholder="Search Packages"
type="text"
value=""
@@ -537,7 +258,7 @@ exports[`<Header /> component with logged in state should load the component in
</div>
</div>
<div
class="MuiPaper-root MuiPaper-elevation1 react-autosuggest__suggestions-container emotion-8 emotion-9"
class="MuiPaper-root MuiPaper-elevation1 react-autosuggest__suggestions-container css-cfo6a emotion-1"
id="react-autowhatever-1"
role="listbox"
/>
@@ -546,11 +267,10 @@ exports[`<Header /> component with logged in state should load the component in
</div>
</div>
<div
class="MuiToolbar-root MuiToolbar-regular emotion-20 emotion-21 MuiToolbar-gutters"
data-testid="header-right"
class="MuiToolbar-root MuiToolbar-regular css-1qii1b7 emotion-7 MuiToolbar-gutters"
>
<button
class="MuiButtonBase-root MuiIconButton-root emotion-16 emotion-17 MuiIconButton-colorInherit"
class="MuiButtonBase-root MuiIconButton-root css-13o7eu2 emotion-5 MuiIconButton-colorInherit"
tabindex="0"
type="button"
>
@@ -574,7 +294,7 @@ exports[`<Header /> component with logged in state should load the component in
/>
</button>
<a
class="emotion-18 emotion-19"
class="css-kbn7if emotion-6"
data-testid="header--tooltip-documentation"
href="https://verdaccio.org/docs/en/installation"
rel="noopener noreferrer"

View File

@@ -1,8 +1,8 @@
import styled from '@emotion/styled';
import { css } from '@emotion/core';
import { Theme } from '../../design-tokens/theme';
import { breakpoints } from '../../utils/styles/media';
import colors from '../../utils/styles/colors';
import mq from '../../utils/styles/media';
import IconButton from '../../muiComponents/IconButton';
import AppBar from '../../muiComponents/AppBar';
import Toolbar from '../../muiComponents/Toolbar';
@@ -27,63 +27,68 @@ export const LeftSide = styled(RightSide)({
flex: 1,
});
export const MobileNavBar = styled('div')<{ theme?: Theme }>(props => ({
export const MobileNavBar = styled('div')({
alignItems: 'center',
display: 'flex',
borderBottom: `1px solid ${props.theme && props.theme.palette.greyLight}`,
borderBottom: `1px solid ${colors.greyLight}`,
padding: '8px',
position: 'relative',
}));
});
export const InnerMobileNavBar = styled('div')<{ theme?: Theme }>(props => ({
export const InnerMobileNavBar = styled('div')({
borderRadius: '4px',
backgroundColor: props.theme && props.theme.palette.greyLight,
color: props.theme && props.theme.palette.white,
backgroundColor: colors.greyLight,
color: colors.white,
width: '100%',
padding: '0 5px',
margin: '0 10px 0 0',
}));
});
export const IconSearchButton = styled(IconButton)({
display: 'block',
});
export const SearchWrapper = styled('div')({
display: 'none',
// display: 'none',
maxWidth: '393px',
width: '100%',
});
export const NavBar = styled(AppBar)<{ theme?: Theme }>(props => ({
backgroundColor: props.theme && props.theme.palette.primary.main,
minHeight: 60,
display: 'flex',
justifyContent: 'center',
[`@media (min-width: ${breakpoints.medium}px)`]: css`
${SearchWrapper} {
display: flex;
}
${IconSearchButton} {
display: none;
}
${MobileNavBar} {
display: none;
}
`,
[`@media (min-width: ${breakpoints.large}px)`]: css`
${InnerNavBar} {
padding: 0 20px;
}
`,
[`@media (min-width: ${breakpoints.xlarge}px)`]: css`
${InnerNavBar} {
max-width: 1240px;
width: 100%;
margin: 0 auto;
}
`,
}));
export const NavBar = styled(AppBar)`
&& {
background-color: ${colors.primary};
min-height: 60px;
display: flex;
justify-content: center;
${() =>
mq.medium(css`
${SearchWrapper} {
display: flex;
}
${IconSearchButton} {
display: none;
}
${MobileNavBar} {
display: none;
}
`)};
${() =>
mq.large(css`
${InnerNavBar} {
padding: 0 20px;
}
`)};
${() =>
mq.xlarge(css`
${InnerNavBar} {
max-width: 1240px;
width: 100%;
margin: 0 auto;
}
`)};
}
`;
export const StyledLink = styled(Link)<{ theme?: Theme }>(props => ({
color: props.theme && props.theme.palette.white,
}));
export const StyledLink = styled(Link)({
color: 'white',
});

View File

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

View File

@@ -1,159 +1,3 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`<Help /> component should load the component in default state 1`] = `
.emotion-14 {
width: 600px;
margin: auto;
}
.emotion-0 {
margin-bottom: 20px;
}
.emotion-6 {
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
-webkit-align-items: center;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
-webkit-box-pack: justify;
-webkit-justify-content: space-between;
-ms-flex-pack: justify;
justify-content: space-between;
}
.emotion-2 {
display: inline-block;
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
height: 21px;
font-size: 1rem;
}
<div
class="MuiPaper-root MuiPaper-elevation1 MuiCard-root emotion-14 emotion-15 MuiPaper-rounded"
id="help-card"
>
<div
class="MuiCardContent-root"
>
<h2
class="MuiTypography-root MuiTypography-h5 MuiTypography-gutterBottom"
id="help-card__title"
>
No Package Published Yet.
</h2>
<h6
class="MuiTypography-root emotion-0 emotion-1 MuiTypography-h6 MuiTypography-colorTextSecondary MuiTypography-gutterBottom"
>
To publish your first package just:
</h6>
<p
class="MuiTypography-root MuiTypography-body1"
>
1. Login
</p>
<div
class="emotion-6 emotion-7"
>
<span
class="emotion-2 emotion-3"
>
npm adduser --registry http://localhost
</span>
<button
class="MuiButtonBase-root MuiIconButton-root emotion-4 emotion-5"
tabindex="0"
title="Copy to Clipboard"
type="button"
>
<span
class="MuiIconButton-label"
>
<svg
aria-hidden="true"
class="MuiSvgIcon-root"
focusable="false"
role="presentation"
viewBox="0 0 24 24"
>
<path
d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm-1 4l6 6v10c0 1.1-.9 2-2 2H7.99C6.89 23 6 22.1 6 21l.01-14c0-1.1.89-2 1.99-2h7zm-1 7h5.5L14 6.5V12z"
/>
</svg>
</span>
<span
class="MuiTouchRipple-root"
/>
</button>
</div>
<p
class="MuiTypography-root MuiTypography-body1"
>
2. Publish
</p>
<div
class="emotion-6 emotion-7"
>
<span
class="emotion-2 emotion-3"
>
npm publish --registry http://localhost
</span>
<button
class="MuiButtonBase-root MuiIconButton-root emotion-4 emotion-5"
tabindex="0"
title="Copy to Clipboard"
type="button"
>
<span
class="MuiIconButton-label"
>
<svg
aria-hidden="true"
class="MuiSvgIcon-root"
focusable="false"
role="presentation"
viewBox="0 0 24 24"
>
<path
d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm-1 4l6 6v10c0 1.1-.9 2-2 2H7.99C6.89 23 6 22.1 6 21l.01-14c0-1.1.89-2 1.99-2h7zm-1 7h5.5L14 6.5V12z"
/>
</svg>
</span>
<span
class="MuiTouchRipple-root"
/>
</button>
</div>
<p
class="MuiTypography-root MuiTypography-body2"
>
3. Refresh this page.
</p>
</div>
<div
class="MuiCardActions-root MuiCardActions-spacing"
>
<a
aria-disabled="false"
class="MuiButtonBase-root MuiButton-root MuiButton-text MuiButton-textPrimary MuiButton-textSizeSmall MuiButton-sizeSmall"
href="https://verdaccio.org/docs/en/installation"
tabindex="0"
>
<span
class="MuiButton-label"
>
Learn More
</span>
<span
class="MuiTouchRipple-root"
/>
</a>
</div>
</div>
`;
exports[`<Help /> component should render the component in default state 1`] = `"<div class=\\"MuiPaper-root MuiPaper-elevation1 MuiCard-root css-ryznli e1wgaou60 MuiPaper-rounded\\" id=\\"help-card\\"><div class=\\"MuiCardContent-root\\"><h2 class=\\"MuiTypography-root MuiTypography-h5 MuiTypography-gutterBottom\\" id=\\"help-card__title\\">No Package Published Yet.</h2><h6 class=\\"MuiTypography-root css-zg2fwz e1wgaou61 MuiTypography-h6 MuiTypography-colorTextSecondary MuiTypography-gutterBottom\\">To publish your first package just:</h6><p class=\\"MuiTypography-root MuiTypography-body1\\">1. Login</p><div class=\\"css-1mta3t8 eb8w2fo0\\"><span class=\\"css-lh0wgu eb8w2fo1\\">npm adduser --registry http://localhost</span><button class=\\"MuiButtonBase-root MuiIconButton-root css-0 eb8w2fo2\\" tabindex=\\"0\\" type=\\"button\\" title=\\"Copy to Clipboard\\"><span class=\\"MuiIconButton-label\\"><svg class=\\"MuiSvgIcon-root\\" focusable=\\"false\\" viewBox=\\"0 0 24 24\\" aria-hidden=\\"true\\" role=\\"presentation\\"><path d=\\"M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm-1 4l6 6v10c0 1.1-.9 2-2 2H7.99C6.89 23 6 22.1 6 21l.01-14c0-1.1.89-2 1.99-2h7zm-1 7h5.5L14 6.5V12z\\"></path></svg></span><span class=\\"MuiTouchRipple-root\\"></span></button></div><p class=\\"MuiTypography-root MuiTypography-body1\\">2. Publish</p><div class=\\"css-1mta3t8 eb8w2fo0\\"><span class=\\"css-lh0wgu eb8w2fo1\\">npm publish --registry http://localhost</span><button class=\\"MuiButtonBase-root MuiIconButton-root css-0 eb8w2fo2\\" tabindex=\\"0\\" type=\\"button\\" title=\\"Copy to Clipboard\\"><span class=\\"MuiIconButton-label\\"><svg class=\\"MuiSvgIcon-root\\" focusable=\\"false\\" viewBox=\\"0 0 24 24\\" aria-hidden=\\"true\\" role=\\"presentation\\"><path d=\\"M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm-1 4l6 6v10c0 1.1-.9 2-2 2H7.99C6.89 23 6 22.1 6 21l.01-14c0-1.1.89-2 1.99-2h7zm-1 7h5.5L14 6.5V12z\\"></path></svg></span><span class=\\"MuiTouchRipple-root\\"></span></button></div><p class=\\"MuiTypography-root MuiTypography-body2\\">3. Refresh this page.</p></div><div class=\\"MuiCardActions-root MuiCardActions-spacing\\"><a class=\\"MuiButtonBase-root MuiButton-root MuiButton-text MuiButton-textPrimary MuiButton-textSizeSmall MuiButton-sizeSmall\\" tabindex=\\"0\\" aria-disabled=\\"false\\" href=\\"https://verdaccio.org/docs/en/installation\\"><span class=\\"MuiButton-label\\">Learn More</span><span class=\\"MuiTouchRipple-root\\"></span></a></div></div>"`;

View File

@@ -4,10 +4,14 @@ import { default as Typography } from '../../muiComponents/Heading';
import Card from '../../muiComponents/Card';
export const CardStyled = styled(Card)({
width: 600,
margin: 'auto',
'&&': {
width: '600px',
margin: 'auto',
},
});
export const HelpTitle = styled(Typography)({
marginBottom: 20,
'&&': {
marginBottom: '20px',
},
});

View File

@@ -1,6 +1,5 @@
import React from 'react';
import { render } from '../../utils/test-react-testing-library';
import { shallow } from 'enzyme';
import Icon from './Icon';
@@ -9,7 +8,7 @@ describe('<Icon /> component', () => {
name: 'austria',
};
test('should render the component in default state', () => {
const { container } = render(<Icon name={props.name} />);
expect(container.firstChild).toMatchSnapshot();
const wrapper = shallow(<Icon name={props.name} />);
expect(wrapper.html()).toMatchSnapshot();
});
});

View File

@@ -63,11 +63,10 @@ export interface Props {
modifiers?: null | undefined;
}
/* eslint-disable verdaccio/jsx-spread */
const Icon: React.FC<Props> = ({ className, name, size = 'sm', img = false, pointer = false, ...props }) => {
const title = capitalize(name.toString());
return img ? (
<ImgWrapper className={className} pointer={pointer} size={size} title={title} {...props}>
<ImgWrapper className={className} name={name} pointer={pointer} size={size} title={title} {...props}>
<Img alt={title} src={Icons[name]} />
</ImgWrapper>
) : (

View File

@@ -1,22 +1,3 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`<Icon /> component should render the component in default state 1`] = `
.emotion-0 {
box-sizing: initial;
display: inline-block;
cursor: default;
width: 14px;
height: 16px;
}
<svg
class="emotion-0 emotion-1"
>
<title>
Austria
</title>
<use
xlink:href="[object Object]#austria"
/>
</svg>
`;
exports[`<Icon /> component should render the component in default state 1`] = `"<svg class=\\"css-j2zgvv ek145dl0\\"><title>Austria</title><use xlink:href=\\"[object Object]#austria\\"></use></svg>"`;

View File

@@ -1,42 +1,45 @@
import { css } from '@emotion/core';
import styled from '@emotion/styled';
import { Breakpoint } from '@material-ui/core/styles/createBreakpoints';
import { DetailedHTMLProps, HTMLAttributes } from 'react';
const getSize = (size: Breakpoint): { width: number; height: number } => {
const getSize = (size: Breakpoint): string => {
switch (size) {
case 'md':
return {
width: 18,
height: 18,
};
return `
width: 18px;
height: 18px;
`;
default:
return {
width: 14,
height: 16,
};
return `
width: 14px;
height: 16px;
`;
}
};
interface CommonStyleProps {
size: Breakpoint;
pointer?: boolean;
}
const commonStyle = ({ size = 'sm', pointer }: CommonStyleProps): object => ({
display: 'inline-block',
cursor: pointer ? 'pointer' : 'default',
...getSize(size),
});
const commonStyle = ({ size = 'sm' as Breakpoint, pointer, modifiers = null }) => css`
&& {
display: inline-block;
cursor: ${pointer ? 'pointer' : 'Developers'};
${getSize(size)};
${modifiers && modifiers};
}
`;
export const Svg = styled('svg')<CommonStyleProps>(props => ({
boxSizing: 'initial',
...commonStyle(props),
}));
export const Svg = styled('svg')`
${commonStyle};
box-sizing: initial;
`;
export const ImgWrapper = styled('span')<CommonStyleProps>(props => ({
boxSizing: 'initial',
...commonStyle(props),
}));
export const ImgWrapper = styled('span')`
${commonStyle};
box-sizing: initial;
`;
export const Img = styled('img')({
width: '100%',
height: 'auto',
'&&': {
width: '100%',
height: 'auto',
},
});

View File

@@ -1,6 +1,6 @@
import React from 'react';
import { render } from '@testing-library/react';
import { render } from '../../utils/test-react-testing-library';
import { DetailContext, DetailContextProps } from '../../pages/Version';
import data from './__partials__/data.json';

View File

@@ -1,71 +1,24 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`<Install /> renders correctly 1`] = `
.emotion-0 {
font-weight: 700;
text-transform: capitalize;
}
.emotion-12 {
padding: 0;
}
.emotion-12:hover {
background-color: transparent;
}
.emotion-2 {
border-radius: 0px;
padding: 0;
}
.emotion-10 {
padding: 0 10px;
margin: 0;
}
.emotion-8 {
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
-webkit-align-items: center;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
-webkit-box-pack: justify;
-webkit-justify-content: space-between;
-ms-flex-pack: justify;
justify-content: space-between;
}
.emotion-4 {
display: inline-block;
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
height: 21px;
font-size: 1rem;
}
<ul
class="MuiList-root MuiList-padding MuiList-subheader"
data-testid="installList"
>
<h6
class="MuiTypography-root emotion-0 emotion-1 MuiTypography-subtitle1"
class="MuiTypography-root css-b8upko emotion-0 MuiTypography-subtitle1"
>
Installation
</h6>
<div
aria-disabled="false"
class="MuiButtonBase-root MuiListItem-root emotion-12 emotion-13 MuiListItem-gutters MuiListItem-button"
class="MuiButtonBase-root MuiListItem-root css-zw46c6 emotion-6 MuiListItem-gutters MuiListItem-button"
data-testid="installListItem-npm"
role="button"
tabindex="0"
>
<div
class="MuiAvatar-root MuiAvatar-circle emotion-2 emotion-3"
class="MuiAvatar-root MuiAvatar-circle css-19top7x emotion-1"
>
<img
alt="npm"
@@ -74,21 +27,21 @@ exports[`<Install /> renders correctly 1`] = `
/>
</div>
<div
class="MuiListItemText-root emotion-10 emotion-11 MuiListItemText-multiline"
class="MuiListItemText-root css-fipixf emotion-5 MuiListItemText-multiline"
>
<span
class="MuiTypography-root MuiListItemText-primary MuiTypography-body1"
>
<div
class="emotion-8 emotion-9"
class="css-1mta3t8 emotion-4"
>
<span
class="emotion-4 emotion-5"
class="css-lh0wgu emotion-2"
>
npm install foo
</span>
<button
class="MuiButtonBase-root MuiIconButton-root emotion-6 emotion-7"
class="MuiButtonBase-root MuiIconButton-root css-0 emotion-3"
tabindex="0"
title="Copy to Clipboard"
type="button"
@@ -126,13 +79,13 @@ exports[`<Install /> renders correctly 1`] = `
</div>
<div
aria-disabled="false"
class="MuiButtonBase-root MuiListItem-root emotion-12 emotion-13 MuiListItem-gutters MuiListItem-button"
class="MuiButtonBase-root MuiListItem-root css-zw46c6 emotion-6 MuiListItem-gutters MuiListItem-button"
data-testid="installListItem-yarn"
role="button"
tabindex="0"
>
<div
class="MuiAvatar-root MuiAvatar-circle emotion-2 emotion-3"
class="MuiAvatar-root MuiAvatar-circle css-19top7x emotion-1"
>
<img
alt="yarn"
@@ -141,21 +94,21 @@ exports[`<Install /> renders correctly 1`] = `
/>
</div>
<div
class="MuiListItemText-root emotion-10 emotion-11 MuiListItemText-multiline"
class="MuiListItemText-root css-fipixf emotion-5 MuiListItemText-multiline"
>
<span
class="MuiTypography-root MuiListItemText-primary MuiTypography-body1"
>
<div
class="emotion-8 emotion-9"
class="css-1mta3t8 emotion-4"
>
<span
class="emotion-4 emotion-5"
class="css-lh0wgu emotion-2"
>
yarn add foo
</span>
<button
class="MuiButtonBase-root MuiIconButton-root emotion-6 emotion-7"
class="MuiButtonBase-root MuiIconButton-root css-0 emotion-3"
tabindex="0"
title="Copy to Clipboard"
type="button"
@@ -193,13 +146,13 @@ exports[`<Install /> renders correctly 1`] = `
</div>
<div
aria-disabled="false"
class="MuiButtonBase-root MuiListItem-root emotion-12 emotion-13 MuiListItem-gutters MuiListItem-button"
class="MuiButtonBase-root MuiListItem-root css-zw46c6 emotion-6 MuiListItem-gutters MuiListItem-button"
data-testid="installListItem-pnpm"
role="button"
tabindex="0"
>
<div
class="MuiAvatar-root MuiAvatar-circle emotion-2 emotion-3"
class="MuiAvatar-root MuiAvatar-circle css-19top7x emotion-1"
>
<img
alt="pnpm"
@@ -208,21 +161,21 @@ exports[`<Install /> renders correctly 1`] = `
/>
</div>
<div
class="MuiListItemText-root emotion-10 emotion-11 MuiListItemText-multiline"
class="MuiListItemText-root css-fipixf emotion-5 MuiListItemText-multiline"
>
<span
class="MuiTypography-root MuiListItemText-primary MuiTypography-body1"
>
<div
class="emotion-8 emotion-9"
class="css-1mta3t8 emotion-4"
>
<span
class="emotion-4 emotion-5"
class="css-lh0wgu emotion-2"
>
pnpm install foo
</span>
<button
class="MuiButtonBase-root MuiIconButton-root emotion-6 emotion-7"
class="MuiButtonBase-root MuiIconButton-root css-0 emotion-3"
tabindex="0"
title="Copy to Clipboard"
type="button"

View File

@@ -1,6 +1,5 @@
import React from 'react';
import { render } from '../../utils/test-react-testing-library';
import { mount } from 'enzyme';
import Label from './Label';
@@ -9,7 +8,7 @@ describe('<Label /> component', () => {
text: 'test',
};
test('should render the component in default state', () => {
const { container } = render(<Label text={props.text} />);
expect(container.firstChild).toMatchSnapshot();
const wrapper = mount(<Label text={props.text} />);
expect(wrapper.html()).toMatchSnapshot();
});
});

View File

@@ -7,17 +7,19 @@ interface Props {
text: string;
capitalize?: boolean;
weight?: string;
modifiers?: null | undefined;
}
interface WrapperProps {
capitalize: boolean;
weight: string;
modifiers?: null;
}
const Wrapper = styled('div')<WrapperProps>(props => ({
fontWeight: fontWeight[props.weight],
textTransform: props.capitalize ? 'capitalize' : 'none',
}));
const Wrapper = styled('div')`
font-weight: ${({ weight }: WrapperProps) => fontWeight[weight]};
text-transform: ${({ capitalize }: WrapperProps) => (capitalize ? 'capitalize' : 'none')};
${({ modifiers }: WrapperProps) => modifiers};
`;
const Label: React.FC<Props> = ({ text = '', capitalize = false, weight = 'regular', ...props }) => {
return (

View File

@@ -1,14 +1,3 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`<Label /> component should render the component in default state 1`] = `
.emotion-0 {
font-weight: 400;
text-transform: none;
}
<div
class="emotion-0 emotion-1"
>
test
</div>
`;
exports[`<Label /> component should render the component in default state 1`] = `"<div class=\\"css-1xfhjjm esyufg60\\">test</div>"`;

View File

@@ -1,29 +1,33 @@
import styled from '@emotion/styled';
import { css } from '@emotion/core';
import styled from '@emotion/styled';
import { Theme } from '../../design-tokens/theme';
import colors from '../../utils/styles/colors';
export const Content = styled('div')<{ theme?: Theme }>(props => ({
backgroundColor: props.theme && props.theme.palette.white,
flex: 1,
display: 'flex',
position: 'relative',
flexDirection: 'column',
}));
export const Content = styled('div')({
'&&': {
backgroundColor: colors.white,
flex: 1,
display: 'flex',
position: 'relative',
flexDirection: 'column',
},
});
interface ContainerProps {
isLoading: boolean;
}
export const Container = styled('div')<ContainerProps>(props => ({
display: 'flex',
flexDirection: 'column',
minHeight: '100vh',
overflow: 'hidden',
...(props.isLoading &&
css`
${Content} {
background-color: #f5f6f8;
}
`),
}));
export const Container = styled('div')`
&& {
display: flex;
flex-direction: column;
min-height: 100vh;
overflow: hidden;
${({ isLoading }: ContainerProps) =>
isLoading &&
css`
${Content} {
background-color: #f5f6f8;
}
`}
`;

View File

@@ -1,12 +1,11 @@
import React from 'react';
import { render } from '../../utils/test-react-testing-library';
import { shallow } from 'enzyme';
import Loading from './Loading';
describe('<Loading /> component', () => {
test('should render the component in default state', () => {
const { container } = render(<Loading />);
expect(container.firstChild).toMatchSnapshot();
const wrapper = shallow(<Loading />);
expect(wrapper.html()).toMatchSnapshot();
});
});

View File

@@ -1,86 +1,3 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`<Loading /> component should render the component in default state 1`] = `
.emotion-8 {
-webkit-transform: translate(-50%,-50%);
-ms-transform: translate(-50%,-50%);
transform: translate(-50%,-50%);
top: 50%;
left: 50%;
position: absolute;
}
.emotion-2 {
margin: 0 0 30px 0;
border-radius: 25px;
box-shadow: 0 10px 20px 0 rgba(69,58,100,0.2);
background: #f7f8f6;
}
.emotion-0 {
display: inline-block;
vertical-align: middle;
box-sizing: border-box;
background-position: center;
background-size: contain;
background-image: url([object Object]);
background-repeat: no-repeat;
width: 90px;
height: 90px;
}
.emotion-6 {
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
-webkit-align-items: center;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
-webkit-box-pack: center;
-webkit-justify-content: center;
-ms-flex-pack: center;
justify-content: center;
}
.emotion-4 {
color: #4b5e40;
}
<div
class="emotion-8 emotion-9"
data-testid="loading"
>
<div
class="emotion-2 emotion-3"
>
<div
class="emotion-0 emotion-1"
/>
</div>
<div
class="emotion-6 emotion-7"
>
<div
class="MuiCircularProgress-root emotion-4 emotion-5 MuiCircularProgress-colorPrimary MuiCircularProgress-indeterminate"
role="progressbar"
style="width: 50px; height: 50px;"
>
<svg
class="MuiCircularProgress-svg"
viewBox="22 22 44 44"
>
<circle
class="MuiCircularProgress-circle MuiCircularProgress-circleIndeterminate"
cx="44"
cy="44"
fill="none"
r="20.2"
stroke-width="3.6"
/>
</svg>
</div>
</div>
</div>
`;
exports[`<Loading /> component should render the component in default state 1`] = `"<div data-testid=\\"loading\\" class=\\"css-1221txa eimgwje0\\"><div class=\\"css-bxochs eimgwje1\\"><div class=\\"css-ge0nak em793ed0\\"></div></div><div class=\\"css-vqrgi e1ag4h8b0\\"><div class=\\"MuiCircularProgress-root css-15gl0ho e1ag4h8b1 MuiCircularProgress-colorPrimary MuiCircularProgress-indeterminate\\" style=\\"width:50px;height:50px\\" role=\\"progressbar\\"><svg class=\\"MuiCircularProgress-svg\\" viewBox=\\"22 22 44 44\\"><circle class=\\"MuiCircularProgress-circle MuiCircularProgress-circleIndeterminate\\" cx=\\"44\\" cy=\\"44\\" r=\\"20.2\\" fill=\\"none\\" stroke-width=\\"3.6\\"></circle></svg></div></div></div>"`;

View File

@@ -1,15 +1,19 @@
import styled from '@emotion/styled';
export const Wrapper = styled('div')({
transform: 'translate(-50%, -50%)',
top: '50%',
left: '50%',
position: 'absolute',
});
export const Wrapper = styled('div')`
&& {
transform: translate(-50%, -50%);
top: 50%;
left: 50%;
position: absolute;
}
`;
export const Badge = styled('div')({
margin: '0 0 30px 0',
borderRadius: 25,
boxShadow: '0 10px 20px 0 rgba(69, 58, 100, 0.2)',
background: '#f7f8f6',
});
export const Badge = styled('div')`
&& {
margin: 0 0 30px 0;
border-radius: 25px;
box-shadow: 0 10px 20px 0 rgba(69, 58, 100, 0.2);
background: #f7f8f6;
}
`;

View File

@@ -3,8 +3,7 @@
*/
import React from 'react';
import { mount } from '../../utils/test-enzyme';
import { mount } from 'enzyme';
import LoginModal from './Login';
@@ -67,7 +66,7 @@ describe('<LoginModal />', () => {
onCancel: () => {},
onSubmit: () => {},
};
const wrapper = mount(<LoginModal {...props} />);
const wrapper = mount<LoginModal>(<LoginModal {...props} />);
const { setCredentials } = wrapper.instance();
expect(setCredentials('username', eventUsername)).toBeUndefined();
@@ -84,7 +83,7 @@ describe('<LoginModal />', () => {
onSubmit: jest.fn(),
};
const wrapper = mount(<LoginModal {...props} />);
const wrapper = mount<LoginModal>(<LoginModal {...props} />);
const instance = wrapper.instance();
instance.submitCredentials = jest.fn();
@@ -109,7 +108,7 @@ describe('<LoginModal />', () => {
onSubmit: jest.fn(),
};
const wrapper = mount(<LoginModal {...props} />);
const wrapper = mount<LoginModal>(<LoginModal {...props} />);
const { setCredentials, submitCredentials } = wrapper.instance();
expect(setCredentials('username', eventUsername)).toBeUndefined();
expect(wrapper.state('form').username.value).toEqual('xyz');

View File

@@ -1,5 +1,6 @@
import React, { Component } from 'react';
import ErrorIcon from '@material-ui/icons/Error';
import { css } from 'emotion';
import Button from '../../muiComponents/Button';
import Dialog from '../../muiComponents/Dialog';
@@ -66,13 +67,7 @@ export default class LoginModal extends Component<Partial<LoginModalProps>, Logi
public render(): JSX.Element {
const { visibility = true, onCancel = () => null, error } = this.props as LoginModalProps;
return (
<Dialog
data-testid={'login--form-container'}
fullWidth={true}
id={'login--form-container'}
maxWidth={'xs'}
onClose={onCancel}
open={visibility}>
<Dialog fullWidth={true} id={'login--form-container'} maxWidth={'xs'} onClose={onCancel} open={visibility}>
<form noValidate={true} onSubmit={this.handleValidateCredentials}>
<DialogTitle>{'Login'}</DialogTitle>
<DialogContent>
@@ -210,9 +205,9 @@ export default class LoginModal extends Component<Partial<LoginModalProps>, Logi
} = this.state;
return (
<FormControl
// className={css`
// margin-top: 8px;
// `}
className={css`
margin-top: 8px;
`}
error={!password.value && !password.pristine}
fullWidth={true}
required={password.required}>

View File

@@ -1,5 +1,5 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`<LoginModal /> should load the component in default state 1`] = `"<div role=\\"presentation\\" class=\\"MuiDialog-root\\" data-testid=\\"login--form-container\\" id=\\"login--form-container\\" style=\\"position: fixed; z-index: 1300; right: 0px; bottom: 0px; top: 0px; left: 0px;\\"><div class=\\"MuiBackdrop-root\\" aria-hidden=\\"true\\" style=\\"opacity: 1; webkit-transition: opacity 225ms cubic-bezier(0.4, 0, 0.2, 1) 0ms; transition: opacity 225ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;\\"></div><div tabindex=\\"0\\" data-test=\\"sentinelStart\\"></div><div class=\\"MuiDialog-container MuiDialog-scrollPaper\\" style=\\"opacity: 1; webkit-transition: opacity 225ms cubic-bezier(0.4, 0, 0.2, 1) 0ms; transition: opacity 225ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;\\" role=\\"none presentation\\" tabindex=\\"-1\\"><div class=\\"MuiPaper-root MuiPaper-elevation24 MuiDialog-paper MuiDialog-paperScrollPaper MuiDialog-paperWidthXs MuiDialog-paperFullWidth MuiPaper-rounded\\" role=\\"dialog\\"><form novalidate=\\"\\"><div class=\\"MuiDialogTitle-root\\"><h2 class=\\"MuiTypography-root MuiTypography-h6\\">Login</h2></div><div class=\\"MuiDialogContent-root\\"><div class=\\"MuiFormControl-root MuiFormControl-fullWidth\\"><label class=\\"MuiFormLabel-root MuiInputLabel-root MuiInputLabel-formControl MuiInputLabel-animated Mui-required Mui-required\\" data-shrink=\\"false\\" for=\\"username\\">Username<span class=\\"MuiFormLabel-asterisk MuiInputLabel-asterisk\\"> *</span></label><div class=\\"MuiInputBase-root MuiInput-root MuiInput-underline MuiInputBase-formControl MuiInput-formControl\\"><input aria-invalid=\\"false\\" id=\\"login--form-username\\" placeholder=\\"Your username\\" required=\\"\\" type=\\"text\\" class=\\"MuiInputBase-input MuiInput-input\\" value=\\"\\"></div></div><div class=\\"MuiFormControl-root MuiFormControl-fullWidth\\"><label class=\\"MuiFormLabel-root MuiInputLabel-root MuiInputLabel-formControl MuiInputLabel-animated Mui-required Mui-required\\" data-shrink=\\"false\\" for=\\"password\\">Password<span class=\\"MuiFormLabel-asterisk MuiInputLabel-asterisk\\"> *</span></label><div class=\\"MuiInputBase-root MuiInput-root MuiInput-underline MuiInputBase-formControl MuiInput-formControl\\"><input aria-invalid=\\"false\\" id=\\"login--form-password\\" placeholder=\\"Your strong password\\" required=\\"\\" type=\\"password\\" class=\\"MuiInputBase-input MuiInput-input\\" value=\\"\\"></div></div></div><div class=\\"MuiDialogActions-root dialog-footer MuiDialogActions-spacing\\"><button class=\\"MuiButtonBase-root MuiButton-root MuiButton-text MuiButton-colorInherit\\" tabindex=\\"0\\" type=\\"button\\" id=\\"login--form-cancel\\"><span class=\\"MuiButton-label\\">Cancel</span><span class=\\"MuiTouchRipple-root\\"></span></button><button class=\\"MuiButtonBase-root MuiButton-root MuiButton-text MuiButton-colorInherit Mui-disabled Mui-disabled\\" tabindex=\\"-1\\" type=\\"submit\\" disabled=\\"\\" id=\\"login--form-submit\\"><span class=\\"MuiButton-label\\">Login</span></button></div></form></div></div><div tabindex=\\"0\\" data-test=\\"sentinelEnd\\"></div></div>"`;
exports[`<LoginModal /> should load the component in default state 1`] = `"<div role=\\"presentation\\" class=\\"MuiDialog-root\\" id=\\"login--form-container\\" style=\\"position: fixed; z-index: 1300; right: 0px; bottom: 0px; top: 0px; left: 0px;\\"><div class=\\"MuiBackdrop-root\\" aria-hidden=\\"true\\" style=\\"opacity: 1; webkit-transition: opacity 225ms cubic-bezier(0.4, 0, 0.2, 1) 0ms; transition: opacity 225ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;\\"></div><div tabindex=\\"0\\" data-test=\\"sentinelStart\\"></div><div class=\\"MuiDialog-container MuiDialog-scrollPaper\\" style=\\"opacity: 1; webkit-transition: opacity 225ms cubic-bezier(0.4, 0, 0.2, 1) 0ms; transition: opacity 225ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;\\" role=\\"none presentation\\" tabindex=\\"-1\\"><div class=\\"MuiPaper-root MuiPaper-elevation24 MuiDialog-paper MuiDialog-paperScrollPaper MuiDialog-paperWidthXs MuiDialog-paperFullWidth MuiPaper-rounded\\" role=\\"dialog\\"><form novalidate=\\"\\"><div class=\\"MuiDialogTitle-root\\"><h2 class=\\"MuiTypography-root MuiTypography-h6\\">Login</h2></div><div class=\\"MuiDialogContent-root\\"><div class=\\"MuiFormControl-root MuiFormControl-fullWidth\\"><label class=\\"MuiFormLabel-root MuiInputLabel-root MuiInputLabel-formControl MuiInputLabel-animated Mui-required Mui-required\\" data-shrink=\\"false\\" for=\\"username\\">Username<span class=\\"MuiFormLabel-asterisk MuiInputLabel-asterisk\\"> *</span></label><div class=\\"MuiInputBase-root MuiInput-root MuiInput-underline MuiInputBase-formControl MuiInput-formControl\\"><input aria-invalid=\\"false\\" id=\\"login--form-username\\" placeholder=\\"Your username\\" required=\\"\\" type=\\"text\\" class=\\"MuiInputBase-input MuiInput-input\\" value=\\"\\"></div></div><div class=\\"MuiFormControl-root css-164r41r MuiFormControl-fullWidth\\"><label class=\\"MuiFormLabel-root MuiInputLabel-root MuiInputLabel-formControl MuiInputLabel-animated Mui-required Mui-required\\" data-shrink=\\"false\\" for=\\"password\\">Password<span class=\\"MuiFormLabel-asterisk MuiInputLabel-asterisk\\"> *</span></label><div class=\\"MuiInputBase-root MuiInput-root MuiInput-underline MuiInputBase-formControl MuiInput-formControl\\"><input aria-invalid=\\"false\\" id=\\"login--form-password\\" placeholder=\\"Your strong password\\" required=\\"\\" type=\\"password\\" class=\\"MuiInputBase-input MuiInput-input\\" value=\\"\\"></div></div></div><div class=\\"MuiDialogActions-root dialog-footer MuiDialogActions-spacing\\"><button class=\\"MuiButtonBase-root MuiButton-root MuiButton-text MuiButton-colorInherit\\" tabindex=\\"0\\" type=\\"button\\" id=\\"login--form-cancel\\"><span class=\\"MuiButton-label\\">Cancel</span><span class=\\"MuiTouchRipple-root\\"></span></button><button class=\\"MuiButtonBase-root MuiButton-root MuiButton-text MuiButton-colorInherit Mui-disabled Mui-disabled\\" tabindex=\\"-1\\" type=\\"submit\\" disabled=\\"\\" id=\\"login--form-submit\\"><span class=\\"MuiButton-label\\">Login</span></button></div></form></div></div><div tabindex=\\"0\\" data-test=\\"sentinelEnd\\"></div></div>"`;
exports[`<LoginModal /> should load the component with props 1`] = `"<div role=\\"presentation\\" class=\\"MuiDialog-root\\" data-testid=\\"login--form-container\\" id=\\"login--form-container\\" style=\\"position: fixed; z-index: 1300; right: 0px; bottom: 0px; top: 0px; left: 0px;\\"><div class=\\"MuiBackdrop-root\\" aria-hidden=\\"true\\" style=\\"opacity: 1; webkit-transition: opacity 225ms cubic-bezier(0.4, 0, 0.2, 1) 0ms; transition: opacity 225ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;\\"></div><div tabindex=\\"0\\" data-test=\\"sentinelStart\\"></div><div class=\\"MuiDialog-container MuiDialog-scrollPaper\\" style=\\"opacity: 1; webkit-transition: opacity 225ms cubic-bezier(0.4, 0, 0.2, 1) 0ms; transition: opacity 225ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;\\" role=\\"none presentation\\" tabindex=\\"-1\\"><div class=\\"MuiPaper-root MuiPaper-elevation24 MuiDialog-paper MuiDialog-paperScrollPaper MuiDialog-paperWidthXs MuiDialog-paperFullWidth MuiPaper-rounded\\" role=\\"dialog\\"><form novalidate=\\"\\"><div class=\\"MuiDialogTitle-root\\"><h2 class=\\"MuiTypography-root MuiTypography-h6\\">Login</h2></div><div class=\\"MuiDialogContent-root\\"><div class=\\"MuiTypography-root MuiPaper-root MuiPaper-elevation6 MuiSnackbarContent-root css-xlgaf-loginError MuiTypography-body2\\" role=\\"alert\\"><div class=\\"MuiSnackbarContent-message\\"><div class=\\"css-vvv32-loginErrorMsg\\" id=\\"client-snackbar\\"><svg class=\\"MuiSvgIcon-root css-tkvt8h-loginIcon\\" focusable=\\"false\\" viewBox=\\"0 0 24 24\\" aria-hidden=\\"true\\" role=\\"presentation\\"><path d=\\"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-2h2v2zm0-4h-2V7h2v6z\\"></path></svg><span><div><strong>Error Title</strong></div><div>Error Description</div></span></div></div></div><div class=\\"MuiFormControl-root MuiFormControl-fullWidth\\"><label class=\\"MuiFormLabel-root MuiInputLabel-root MuiInputLabel-formControl MuiInputLabel-animated Mui-required Mui-required\\" data-shrink=\\"false\\" for=\\"username\\">Username<span class=\\"MuiFormLabel-asterisk MuiInputLabel-asterisk\\"> *</span></label><div class=\\"MuiInputBase-root MuiInput-root MuiInput-underline MuiInputBase-formControl MuiInput-formControl\\"><input aria-invalid=\\"false\\" id=\\"login--form-username\\" placeholder=\\"Your username\\" required=\\"\\" type=\\"text\\" class=\\"MuiInputBase-input MuiInput-input\\" value=\\"\\"></div></div><div class=\\"MuiFormControl-root MuiFormControl-fullWidth\\"><label class=\\"MuiFormLabel-root MuiInputLabel-root MuiInputLabel-formControl MuiInputLabel-animated Mui-required Mui-required\\" data-shrink=\\"false\\" for=\\"password\\">Password<span class=\\"MuiFormLabel-asterisk MuiInputLabel-asterisk\\"> *</span></label><div class=\\"MuiInputBase-root MuiInput-root MuiInput-underline MuiInputBase-formControl MuiInput-formControl\\"><input aria-invalid=\\"false\\" id=\\"login--form-password\\" placeholder=\\"Your strong password\\" required=\\"\\" type=\\"password\\" class=\\"MuiInputBase-input MuiInput-input\\" value=\\"\\"></div></div></div><div class=\\"MuiDialogActions-root dialog-footer MuiDialogActions-spacing\\"><button class=\\"MuiButtonBase-root MuiButton-root MuiButton-text MuiButton-colorInherit\\" tabindex=\\"0\\" type=\\"button\\" id=\\"login--form-cancel\\"><span class=\\"MuiButton-label\\">Cancel</span><span class=\\"MuiTouchRipple-root\\"></span></button><button class=\\"MuiButtonBase-root MuiButton-root MuiButton-text MuiButton-colorInherit Mui-disabled Mui-disabled\\" tabindex=\\"-1\\" type=\\"submit\\" disabled=\\"\\" id=\\"login--form-submit\\"><span class=\\"MuiButton-label\\">Login</span></button></div></form></div></div><div tabindex=\\"0\\" data-test=\\"sentinelEnd\\"></div></div>"`;
exports[`<LoginModal /> should load the component with props 1`] = `"<div role=\\"presentation\\" class=\\"MuiDialog-root\\" id=\\"login--form-container\\" style=\\"position: fixed; z-index: 1300; right: 0px; bottom: 0px; top: 0px; left: 0px;\\"><div class=\\"MuiBackdrop-root\\" aria-hidden=\\"true\\" style=\\"opacity: 1; webkit-transition: opacity 225ms cubic-bezier(0.4, 0, 0.2, 1) 0ms; transition: opacity 225ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;\\"></div><div tabindex=\\"0\\" data-test=\\"sentinelStart\\"></div><div class=\\"MuiDialog-container MuiDialog-scrollPaper\\" style=\\"opacity: 1; webkit-transition: opacity 225ms cubic-bezier(0.4, 0, 0.2, 1) 0ms; transition: opacity 225ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;\\" role=\\"none presentation\\" tabindex=\\"-1\\"><div class=\\"MuiPaper-root MuiPaper-elevation24 MuiDialog-paper MuiDialog-paperScrollPaper MuiDialog-paperWidthXs MuiDialog-paperFullWidth MuiPaper-rounded\\" role=\\"dialog\\"><form novalidate=\\"\\"><div class=\\"MuiDialogTitle-root\\"><h2 class=\\"MuiTypography-root MuiTypography-h6\\">Login</h2></div><div class=\\"MuiDialogContent-root\\"><div class=\\"MuiTypography-root MuiPaper-root MuiPaper-elevation6 MuiSnackbarContent-root css-11e09xf MuiTypography-body2\\" role=\\"alert\\"><div class=\\"MuiSnackbarContent-message\\"><div class=\\"css-70qvj9\\" id=\\"client-snackbar\\"><svg class=\\"MuiSvgIcon-root css-1mbwbu9\\" focusable=\\"false\\" viewBox=\\"0 0 24 24\\" aria-hidden=\\"true\\" role=\\"presentation\\"><path d=\\"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-2h2v2zm0-4h-2V7h2v6z\\"></path></svg><span><div><strong>Error Title</strong></div><div>Error Description</div></span></div></div></div><div class=\\"MuiFormControl-root MuiFormControl-fullWidth\\"><label class=\\"MuiFormLabel-root MuiInputLabel-root MuiInputLabel-formControl MuiInputLabel-animated Mui-required Mui-required\\" data-shrink=\\"false\\" for=\\"username\\">Username<span class=\\"MuiFormLabel-asterisk MuiInputLabel-asterisk\\"> *</span></label><div class=\\"MuiInputBase-root MuiInput-root MuiInput-underline MuiInputBase-formControl MuiInput-formControl\\"><input aria-invalid=\\"false\\" id=\\"login--form-username\\" placeholder=\\"Your username\\" required=\\"\\" type=\\"text\\" class=\\"MuiInputBase-input MuiInput-input\\" value=\\"\\"></div></div><div class=\\"MuiFormControl-root css-164r41r MuiFormControl-fullWidth\\"><label class=\\"MuiFormLabel-root MuiInputLabel-root MuiInputLabel-formControl MuiInputLabel-animated Mui-required Mui-required\\" data-shrink=\\"false\\" for=\\"password\\">Password<span class=\\"MuiFormLabel-asterisk MuiInputLabel-asterisk\\"> *</span></label><div class=\\"MuiInputBase-root MuiInput-root MuiInput-underline MuiInputBase-formControl MuiInput-formControl\\"><input aria-invalid=\\"false\\" id=\\"login--form-password\\" placeholder=\\"Your strong password\\" required=\\"\\" type=\\"password\\" class=\\"MuiInputBase-input MuiInput-input\\" value=\\"\\"></div></div></div><div class=\\"MuiDialogActions-root dialog-footer MuiDialogActions-spacing\\"><button class=\\"MuiButtonBase-root MuiButton-root MuiButton-text MuiButton-colorInherit\\" tabindex=\\"0\\" type=\\"button\\" id=\\"login--form-cancel\\"><span class=\\"MuiButton-label\\">Cancel</span><span class=\\"MuiTouchRipple-root\\"></span></button><button class=\\"MuiButtonBase-root MuiButton-root MuiButton-text MuiButton-colorInherit Mui-disabled Mui-disabled\\" tabindex=\\"-1\\" type=\\"submit\\" disabled=\\"\\" id=\\"login--form-submit\\"><span class=\\"MuiButton-label\\">Login</span></button></div></form></div></div><div tabindex=\\"0\\" data-test=\\"sentinelEnd\\"></div></div>"`;

View File

@@ -1,13 +1,13 @@
import { css } from 'emotion';
import { theme } from '../../design-tokens/theme';
import colors from '../../utils/styles/colors';
export const loginDialog = css({
minWidth: '300px',
});
export const loginError = css({
backgroundColor: `${theme.palette.red} !important`,
backgroundColor: `${colors.red} !important`,
minWidth: 'inherit !important',
marginBottom: '10px !important',
});

View File

@@ -1,12 +1,11 @@
import React from 'react';
import { render } from '../../utils/test-react-testing-library';
import { shallow } from 'enzyme';
import Logo from './Logo';
describe('<Logo /> component', () => {
test('should render the component in default state', () => {
const { container } = render(<Logo />);
expect(container.firstChild).toMatchSnapshot();
const wrapper = shallow(<Logo />);
expect(wrapper.html()).toMatchSnapshot();
});
});

View File

@@ -12,18 +12,19 @@ interface Props {
size?: Size;
}
const StyledLogo = styled('div')<Props>(props => ({
display: 'inline-block',
verticalAlign: 'middle',
boxSizing: 'border-box',
backgroundPosition: 'center',
backgroundSize: 'contain',
backgroundImage: `url(${logo})`,
backgroundRepeat: ' no-repeat',
width: props.size,
height: props.size,
}));
const StyledLogo = styled('div')<Props>`
&& {
display: inline-block;
vertical-align: middle;
box-sizing: border-box;
background-position: center;
background-size: contain;
background-image: url(${logo});
background-repeat: no-repeat;
width: ${({ size }) => size};
height: ${({ size }) => size};
}
`;
const Logo: React.FC<Props> = ({ size = Size.Small }) => {
return <StyledLogo size={size} />;
};

View File

@@ -1,19 +1,3 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`<Logo /> component should render the component in default state 1`] = `
.emotion-0 {
display: inline-block;
vertical-align: middle;
box-sizing: border-box;
background-position: center;
background-size: contain;
background-image: url([object Object]);
background-repeat: no-repeat;
width: 40px;
height: 40px;
}
<div
class="emotion-0 emotion-1"
/>
`;
exports[`<Logo /> component should render the component in default state 1`] = `"<div class=\\"css-1sifsqk em793ed0\\"></div>"`;

View File

@@ -1,16 +1,25 @@
import React from 'react';
import { render } from '../../utils/test-react-testing-library';
import { shallow, mount } from 'enzyme';
import NoItems from './NoItems';
console.error = jest.fn();
describe('<NoItem /> component', () => {
const props = {
text: 'test',
};
test('should load the component in default state', () => {
const { container } = render(<NoItems text={props.text} />);
expect(container.firstChild).toMatchSnapshot();
const wrapper = shallow(<NoItems text={props.text} />);
expect(wrapper.html()).toMatchSnapshot();
});
test('should set html from props', () => {
const props = {
text: 'This is a test string',
};
const wrapper = mount(<NoItems text={props.text} />);
expect(wrapper.html()).toMatchSnapshot();
});
});

View File

@@ -1,9 +1,5 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`<NoItem /> component should load the component in default state 1`] = `
<h6
class="MuiTypography-root MuiTypography-subtitle1 MuiTypography-gutterBottom"
>
test
</h6>
`;
exports[`<NoItem /> component should load the component in default state 1`] = `"<h6 class=\\"MuiTypography-root MuiTypography-subtitle1 MuiTypography-gutterBottom\\">test</h6>"`;
exports[`<NoItem /> component should set html from props 1`] = `"<h6 class=\\"MuiTypography-root MuiTypography-subtitle1 MuiTypography-gutterBottom\\">This is a test string</h6>"`;

View File

@@ -5,8 +5,8 @@ import { useHistory } from 'react-router-dom';
import Box from '../../muiComponents/Box';
import Button from '../../muiComponents/Button';
import Heading from '../../muiComponents/Heading';
import colors from '../../utils/styles/colors';
import { spacings } from '../../utils/styles/spacings';
import { Theme } from '../../design-tokens/theme';
import PackageImg from './img/package.svg';
@@ -19,10 +19,10 @@ const EmptyPackage = styled('img')({
margin: '0 auto',
});
const StyledHeading = styled(Heading)<{ theme?: Theme }>(props => ({
color: props.theme && props.theme.palette.primary.main,
const StyledHeading = styled(Heading)({
color: colors.primary,
marginBottom: spacings.sm,
}));
});
const NotFound: React.FC = () => {
const history = useHistory();

View File

@@ -1,7 +1,6 @@
import React from 'react';
import { BrowserRouter as Router } from 'react-router-dom';
import { render, fireEvent } from '../../utils/test-react-testing-library';
import { render, fireEvent } from '@testing-library/react';
import NotFound, { GO_TO_HOME_PAGE } from './NotFound';

View File

@@ -1,27 +1,17 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`<NotFound /> component should load the component in default state 1`] = `
.emotion-0 {
width: 150px;
margin: 0 auto;
}
.emotion-2 {
color: #4b5e40;
margin-bottom: 16px;
}
<div
class="MuiBox-root MuiBox-root-2"
data-testid="404"
>
<img
alt="404 - Page not found"
class="emotion-0 emotion-1"
class="css-17y48z2 emotion-0"
src="[object Object]"
/>
<h4
class="MuiTypography-root not-found-text emotion-2 emotion-3 MuiTypography-h4"
class="MuiTypography-root not-found-text css-7pe7kh emotion-1 MuiTypography-h4"
>
Sorry, we couldn't find it...
</h4>

View File

@@ -1,6 +1,6 @@
import React from 'react';
import { shallow } from 'enzyme';
import { shallow } from '../../utils/test-enzyme';
import Tag from '../Tag';
import Package from './Package';

View File

@@ -4,6 +4,7 @@ import { Link } from 'react-router-dom';
import { breakpoints } from '../../utils/styles/media';
import Ico from '../Icon';
import Label from '../Label';
import colors from '../../utils/styles/colors';
import { fontWeight } from '../../utils/styles/sizes';
import { default as MuiIconButton } from '../../muiComponents/IconButton';
import { default as Photo } from '../../muiComponents/Avatar';
@@ -11,115 +12,147 @@ import List from '../../muiComponents/List';
import { default as Typography } from '../../muiComponents/Heading';
import Grid from '../../muiComponents/Grid';
import ListItemText from '../../muiComponents/ListItemText';
import { Theme } from '../../design-tokens/theme';
export const OverviewItem = styled('span')<{ theme?: Theme }>(props => ({
display: 'flex',
alignItems: 'center',
margin: '0 0 0 16px',
color: props.theme && props.theme.palette.greyLight2,
fontSize: 12,
[`@media (max-width: ${breakpoints.medium}px)`]: {
':nth-of-type(3)': {
display: 'none',
},
export const OverviewItem = styled('span')`
&& {
display: flex;
align-items: center;
margin: 0 0 0 16px;
color: ${colors.greyLight2};
font-size: 12px;
@media (max-width: ${breakpoints.medium}px) {
&:nth-child(3) {
display: none;
}
}
@media (max-width: ${breakpoints.small}px) {
&:nth-child(4) {
display: none;
}
}
}
`;
export const Icon = styled(Ico)({
'&&': {
margin: '2px 10px 0 0',
fill: colors.greyLight2,
},
[`@media (max-width: ${breakpoints.small}px)`]: {
':nth-of-type(4)': {
display: 'none',
},
});
export const Published = styled('span')({
'&&': {
color: colors.greyLight2,
margin: '0 5px 0 0',
},
}));
});
export const Icon = styled(Ico)<{ theme?: Theme }>(props => ({
margin: '2px 10px 0 0',
fill: props.theme && props.theme.palette.greyLight2,
}));
export const Published = styled('span')<{ theme?: Theme }>(props => ({
color: props.theme && props.theme.palette.greyLight2,
margin: '0 5px 0 0',
}));
export const Text = styled(Label)<{ theme?: Theme }>(props => ({
fontSize: '12px',
fontWeight: fontWeight.semiBold,
color: props.theme && props.theme.palette.greyLight2,
}));
export const Text = styled(Label)({
'&&': {
fontSize: '12px',
fontWeight: fontWeight.semiBold,
color: colors.greyLight2,
},
});
export const Details = styled('span')({
marginLeft: '5px',
lineHeight: 1.5,
display: 'flex',
flexDirection: 'column',
'&&': {
marginLeft: '5px',
lineHeight: 1.5,
display: 'flex',
flexDirection: 'column',
},
});
export const Author = styled('div')({
display: 'flex',
alignItems: 'center',
'&&': {
display: 'flex',
alignItems: 'center',
},
});
export const Avatar = styled(Photo)({
width: '20px',
height: '20px',
'&&': {
width: '20px',
height: '20px',
},
});
export const WrapperLink = styled(Link)({
textDecoration: 'none',
'&&': {
textDecoration: 'none',
},
});
export const PackageTitle = styled('span')<{ theme?: Theme }>(props => ({
fontWeight: 600,
fontSize: 20,
display: 'block',
marginBottom: 12,
color: props.theme && props.theme.palette.eclipse,
cursor: 'pointer',
':hover': {
color: props.theme && props.theme.palette.black,
},
[`@media (max-width: ${breakpoints.small}px)`]: {
fontSize: 14,
marginBottom: 8,
},
}));
export const PackageTitle = styled('span')`
&& {
font-weight: 600;
font-size: 20px;
display: block;
margin-bottom: 12px;
color: ${colors.eclipse};
cursor: pointer;
&:hover {
color: ${colors.black};
}
@media (max-width: ${breakpoints.small}px) {
font-size: 14px;
margin-bottom: 8px;
}
}
`;
export const GridRightAligned = styled(Grid)({
textAlign: 'right',
'&&': {
textAlign: 'right',
},
});
export const PackageList = styled(List)<{ theme?: Theme }>(props => ({
padding: '12px 0 12px 0',
':hover': {
backgroundColor: props.theme && props.theme.palette.greyLight3,
export const PackageList = styled(List)({
'&&': {
padding: '12px 0 12px 0',
'&:hover': {
backgroundColor: colors.greyLight3,
},
'> :last-child': {
paddingTop: 0,
},
},
'> :last-child': {
paddingTop: 0,
},
}));
});
export const IconButton = styled(MuiIconButton)({
padding: 6,
svg: {
fontSize: 16,
'&&': {
padding: '6px',
svg: {
fontSize: '16px',
},
},
});
export const TagContainer = styled('span')({
marginTop: 8,
marginBottom: 12,
display: 'block',
[`@media (max-width: ${breakpoints.medium}px)`]: {
display: 'none',
},
});
export const TagContainer = styled('span')`
&& {
margin-top: 8px;
margin-bottom: 12px;
display: block;
@media (max-width: ${breakpoints.medium}px) {
display: none;
}
}
`;
export const PackageListItemText = styled(ListItemText)({
paddingRight: 0,
'&&': {
paddingRight: 0,
},
});
export const Description = styled(Typography)<{ theme?: Theme }>(props => ({
color: props.theme && props.theme.palette.greyDark2,
export const Description = styled(Typography)({
color: colors.greyDark2,
fontSize: '14px',
paddingRight: 0,
}));
});

View File

@@ -1,7 +1,7 @@
import React from 'react';
import { mount } from 'enzyme';
import { BrowserRouter } from 'react-router-dom';
import { mount } from '../../utils/test-enzyme';
import Help from '../Help';
import { PackageList } from './PackageList';

View File

@@ -1,4 +1,4 @@
import { css } from 'emotion';
import { css } from '@emotion/core';
import { fontWeight, fontSize } from '../../utils/styles/sizes';

View File

@@ -1,6 +1,5 @@
import React from 'react';
import { mount } from '../../utils/test-enzyme';
import { mount } from 'enzyme';
import Readme from './Readme';

View File

@@ -1,6 +1,5 @@
import React from 'react';
import { render, cleanup, fireEvent } from '../../utils/test-react-testing-library';
import { render, cleanup, fireEvent } from '@testing-library/react';
import RegistryInfoContent from './RegistryInfoContent';

View File

@@ -47,13 +47,7 @@ const RegistryInfoContent: React.FC<Props> = props => {
return (
<>
<Tabs
data-testid={'tabs-el'}
indicatorColor="primary"
onChange={handleChange}
textColor="primary"
value={tabPosition}
variant="fullWidth">
<Tabs data-testid={'tabs-el'} indicatorColor="primary" onChange={handleChange} textColor="primary" value={tabPosition} variant="fullWidth">
<Tab data-testid={'npm-tab'} label={NODE_MANAGER.npm} />
<Tab data-testid={'pnpm-tab'} label={NODE_MANAGER.pnpm} />
<Tab data-testid={'yarn-tab'} label={NODE_MANAGER.yarn} />
@@ -70,10 +64,10 @@ const RegistryInfoContent: React.FC<Props> = props => {
return (
<CommandContainer>
<Typography
// className={css`
// padding: 0;
// min-height: 170;
// `}
className={css`
padding: 0;
min-height: 170;
`}
component="div">
{children}
</Typography>

View File

@@ -1,5 +1,7 @@
import styled from '@emotion/styled';
export const CommandContainer = styled('div')({
paddingTop: 20,
'&&': {
paddingTop: '20px',
},
});

View File

@@ -1,15 +1,15 @@
import styled from '@emotion/styled';
import colors from '../../utils/styles/colors';
import { fontSize } from '../../utils/styles/sizes';
import DialogTitle from '../../muiComponents/DialogTitle';
import DialogContent from '../../muiComponents/DialogContent';
import { Theme } from '../../design-tokens/theme';
export const Title = styled(DialogTitle)<{ theme?: Theme }>(props => ({
backgroundColor: props.theme && props.theme.palette.primary.main,
color: props.theme && props.theme.palette.white,
export const Title = styled(DialogTitle)({
backgroundColor: colors.primary,
color: colors.white,
fontSize: fontSize.lg,
}));
});
export const Content = styled(DialogContent)({
padding: '0 24px',

View File

@@ -1,6 +1,5 @@
import React from 'react';
import { mount } from '../../utils/test-enzyme';
import { mount } from 'enzyme';
import Repository from './Repository';

View File

@@ -1,3 +1,3 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`<Repository /> component should render the component in default state 1`] = `"<ul class=\\"MuiList-root MuiList-dense MuiList-padding MuiList-subheader\\"><h6 class=\\"MuiTypography-root css-1na337r-StyledText e1wmjxnh0 MuiTypography-subtitle1\\">Repository</h6><div class=\\"MuiButtonBase-root MuiListItem-root css-719o4l-RepositoryListItem e1wmjxnh4 MuiListItem-dense MuiListItem-gutters MuiListItem-button\\" tabindex=\\"0\\" role=\\"button\\" aria-disabled=\\"false\\"><div class=\\"MuiAvatar-root MuiAvatar-circle MuiAvatar-colorDefault\\"></div><div class=\\"MuiListItemText-root css-1lp4n02-RepositoryListItemText e1wmjxnh5 MuiListItemText-dense\\"><span class=\\"MuiTypography-root MuiListItemText-primary MuiTypography-body2\\"><div class=\\"css-1in239f-ClipBoardCopy eb8w2fo0\\"><span class=\\"css-7gar9h-ClipBoardCopyText eb8w2fo1\\"><a href=\\"git+https://github.com/verdaccio/ui.git\\" target=\\"_blank\\" class=\\"css-6tc7qn-GithubLink e1wmjxnh2\\">git+https://github.com/verdaccio/ui.git</a></span><button class=\\"MuiButtonBase-root MuiIconButton-root css-1fs86cq-CopyIcon eb8w2fo2\\" tabindex=\\"0\\" type=\\"button\\" title=\\"Copy to Clipboard\\"><span class=\\"MuiIconButton-label\\"><svg class=\\"MuiSvgIcon-root\\" focusable=\\"false\\" viewBox=\\"0 0 24 24\\" aria-hidden=\\"true\\" role=\\"presentation\\"><path d=\\"M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm-1 4l6 6v10c0 1.1-.9 2-2 2H7.99C6.89 23 6 22.1 6 21l.01-14c0-1.1.89-2 1.99-2h7zm-1 7h5.5L14 6.5V12z\\"></path></svg></span><span class=\\"MuiTouchRipple-root\\"></span></button></div></span></div><span class=\\"MuiTouchRipple-root\\"></span></div></ul>"`;
exports[`<Repository /> component should render the component in default state 1`] = `"<ul class=\\"MuiList-root MuiList-dense MuiList-padding MuiList-subheader\\"><h6 class=\\"MuiTypography-root css-b8upko e1wmjxnh0 MuiTypography-subtitle1\\">Repository</h6><div class=\\"MuiButtonBase-root MuiListItem-root css-xugzlj e1wmjxnh4 MuiListItem-dense MuiListItem-gutters MuiListItem-button\\" tabindex=\\"0\\" role=\\"button\\" aria-disabled=\\"false\\"><div class=\\"MuiAvatar-root MuiAvatar-circle MuiAvatar-colorDefault\\"></div><div class=\\"MuiListItemText-root css-1vhg3jx e1wmjxnh5 MuiListItemText-dense\\"><span class=\\"MuiTypography-root MuiListItemText-primary MuiTypography-body2\\"><div class=\\"css-1mta3t8 eb8w2fo0\\"><span class=\\"css-lh0wgu 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 MuiIconButton-root css-0 eb8w2fo2\\" tabindex=\\"0\\" type=\\"button\\" title=\\"Copy to Clipboard\\"><span class=\\"MuiIconButton-label\\"><svg class=\\"MuiSvgIcon-root\\" focusable=\\"false\\" viewBox=\\"0 0 24 24\\" aria-hidden=\\"true\\" role=\\"presentation\\"><path d=\\"M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm-1 4l6 6v10c0 1.1-.9 2-2 2H7.99C6.89 23 6 22.1 6 21l.01-14c0-1.1.89-2 1.99-2h7zm-1 7h5.5L14 6.5V12z\\"></path></svg></span><span class=\\"MuiTouchRipple-root\\"></span></button></div></span></div><span class=\\"MuiTouchRipple-root\\"></span></div></ul>"`;

View File

@@ -1,12 +1,12 @@
import styled from '@emotion/styled';
import Github from '../../icons/GitHub';
import colors from '../../utils/styles/colors';
import { fontWeight } from '../../utils/styles/sizes';
import Text from '../../muiComponents/Text';
import ListItem from '../../muiComponents/ListItem';
import ListItemText from '../../muiComponents/ListItemText';
import Grid from '../../muiComponents/Grid';
import { Theme } from '../../design-tokens/theme';
export const StyledText = styled(Text)({
fontWeight: fontWeight.bold,
@@ -17,24 +17,32 @@ export const GridRepo = styled(Grid)({
alignItems: 'center',
});
export const GithubLink = styled('a')<{ theme?: Theme }>(props => ({
color: props.theme && props.theme.palette.primary.main,
}));
export const GithubLink = styled('a')({
'&&': {
color: colors.primary,
},
});
export const GithubLogo = styled(Github)<{ theme?: Theme }>(props => ({
fontSize: 40,
color: props.theme && props.theme.palette.primary.main,
backgroundColor: props.theme && props.theme.palette.greySuperLight,
}));
export const GithubLogo = styled(Github)({
'&&': {
fontSize: '40px',
color: colors.primary,
backgroundColor: colors.greySuperLight,
},
});
export const RepositoryListItem = styled(ListItem)({
padding: 0,
':hover': {
'&&': {
padding: 0,
},
'&&:hover': {
backgroundColor: 'transparent',
},
});
export const RepositoryListItemText = styled(ListItemText)({
padding: '0 10px',
margin: 0,
'&&': {
padding: '0 10px',
margin: 0,
},
});

View File

@@ -1,8 +1,7 @@
import React from 'react';
import { mount, shallow } from 'enzyme';
import { BrowserRouter } from 'react-router-dom';
import { mount, shallow } from '../../utils/test-enzyme';
import Search from './Search';
const SEARCH_FILE_PATH = './Search';

View File

@@ -1,32 +1,8 @@
import React, { KeyboardEvent, Component, ReactElement } from 'react';
import { withRouter, RouteComponentProps } from 'react-router-dom';
import { SuggestionSelectedEventData, ChangeEvent } from 'react-autosuggest';
import styled from '@emotion/styled';
import { default as IconSearch } from '@material-ui/icons/Search';
import React from 'react';
import debounce from 'lodash/debounce';
import InputAdornment from '../../muiComponents/InputAdornment';
import AutoComplete from '../AutoComplete';
import AutoComplete from '../../muiComponents/AutoComplete';
import { callSearch } from '../../utils/calls';
import { Theme } from '../../design-tokens/theme';
export interface State {
search: string;
suggestions: unknown[];
loading: boolean;
loaded: boolean;
error: boolean;
}
export type cancelAllSearchRequests = () => void;
export type handlePackagesClearRequested = () => void;
export type handleSearch = (event: React.FormEvent<HTMLInputElement>, { newValue, method }: ChangeEvent) => void;
export type handleClickSearch = (
event: KeyboardEvent<HTMLInputElement>,
{ suggestionValue, method }: { suggestionValue: object[]; method: string }
) => void;
export type handleFetchPackages = ({ value: string }) => Promise<void>;
export type onBlur = (event: React.FormEvent<HTMLInputElement>) => void;
const CONSTANTS = {
API_DELAY: 300,
@@ -34,168 +10,71 @@ const CONSTANTS = {
ABORT_ERROR: 'AbortError',
};
const StyledInputAdornment = styled(InputAdornment)<{ theme?: Theme }>(props => ({
color: props.theme && props.theme.palette.white,
}));
/* eslint-disable @typescript-eslint/explicit-function-return-type */
const Search: React.FC = () => {
const [suggestions, setSuggestions] = React.useState([]);
const [isLoading, setIsLoading] = React.useState();
const [hasBeenLoaded, setHasBeenLoaded] = React.useState();
const [error, setError] = React.useState();
export class Search extends Component<RouteComponentProps<{}>, State> {
constructor(props: RouteComponentProps<{}>) {
super(props);
this.state = {
search: '',
suggestions: [],
// loading: A boolean value to indicate that request is in pending state.
loading: false,
// loaded: A boolean value to indicate that result has been loaded.
loaded: false,
// error: A boolean value to indicate API error.
error: false,
};
this.requestList = [];
}
public render(): ReactElement<HTMLElement> {
const { suggestions, search, loaded, loading, error } = this.state;
return (
<AutoComplete
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.
*/
private cancelAllSearchRequests: cancelAllSearchRequests = () => {
this.requestList.forEach(request => request.abort());
this.requestList = [];
};
/**
* Cancel all the request from list and make request list empty.
*/
private handlePackagesClearRequested: handlePackagesClearRequested = () => {
this.setState({
suggestions: [],
});
};
/**
* onChange method for the input element.
*/
private handleSearch: handleSearch = (event, { newValue, method }) => {
// stops event bubbling
event.stopPropagation();
if (method === 'type') {
const value = newValue.trim();
this.setState(
{
search: value,
loading: true,
loaded: false,
error: false,
},
() => {
/**
* A use case where User keeps adding and removing value in input field,
* so we cancel all the existing requests when input is empty.
*/
if (value.length === 0) {
this.cancelAllSearchRequests();
}
}
);
}
};
/**
* When an user select any package by clicking or pressing return key.
*/
private handleClickSearch = (
event: React.FormEvent<HTMLInputElement>,
{ suggestionValue, method }: SuggestionSelectedEventData<unknown>
): void | undefined => {
const { history } = this.props;
// stops event bubbling
event.stopPropagation();
switch (method) {
case 'click':
case 'enter':
this.setState({ search: '' });
history.push(`/-/web/detail/${suggestionValue}`);
break;
}
};
/**
* Fetch packages from API.
* For AbortController see: https://developer.mozilla.org/en-US/docs/Web/API/AbortController
*/
private handleFetchPackages: handleFetchPackages = async ({ value }) => {
const handleFetchPackages = debounce(async (value: string) => {
try {
const controller = new window.AbortController();
const signal = controller.signal;
// Keep track of search requests.
this.requestList.push(controller);
// this.requestList.push(controller);
const suggestions = await callSearch(value, signal);
// @ts-ignore
this.setState({
suggestions,
loaded: true,
});
setSuggestions(
// @ts-ignore
suggestions.map(suggestion => ({
...suggestion,
id: suggestion._id,
label: suggestion.name,
}))
);
setHasBeenLoaded(true);
} catch (error) {
/**
* AbortError is not the API error.
* It means browser has cancelled the API request.
*/
if (error.name === CONSTANTS.ABORT_ERROR) {
this.setState({ error: false, loaded: false });
setError(false);
setHasBeenLoaded(false);
} else {
this.setState({ error: true, loaded: false });
setError(true);
setHasBeenLoaded(false);
}
} finally {
this.setState({ loading: false });
setIsLoading(false);
}
};
}, CONSTANTS.API_DELAY);
private requestList: AbortController[];
public getAdorment(): JSX.Element {
return (
<StyledInputAdornment position={'start'}>
<IconSearch />
</StyledInputAdornment>
);
}
/**
* As user focuses out from input, we cancel all the request from requestList
* and set the API state parameters to default boolean values.
*/
private handleOnBlur: onBlur = event => {
const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {
// stops event bubbling
event.stopPropagation();
this.setState(
{
loaded: false,
loading: false,
error: false,
},
() => this.cancelAllSearchRequests()
);
setIsLoading(true);
setHasBeenLoaded(false);
setError(undefined);
handleFetchPackages(event.target.value);
};
}
export default withRouter(Search);
return (
<AutoComplete
// onBlur={this.handleOnBlur}
onChange={handleChange}
// onCleanSuggestions={this.handlePackagesClearRequested}
// onClick={this.handleClickSearch}
// onSuggestionsFetch={debounce(this.handleFetchPackages, CONSTANTS.API_DELAY)}
options={suggestions}
placeholder={CONSTANTS.PLACEHOLDER_TEXT}
// startAdornment={this.getAdorment()}
// suggestionsError={error}
// suggestionsLoaded={loaded}
// suggestionsLoading={loading}
// value={search}
/>
);
};
export default Search;

View File

@@ -1,3 +1,3 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`<Search /> component test should load the component in default state 1`] = `"<div class=\\"css-pnwf4z-Wrapper e1rflf270\\"><div role=\\"combobox\\" aria-haspopup=\\"listbox\\" aria-owns=\\"react-autowhatever-1\\" aria-expanded=\\"false\\" class=\\"react-autosuggest__container\\"><div class=\\"MuiFormControl-root MuiTextField-root react-autosuggest__input css-ae5nkp-StyledTextField e1rflf271 MuiFormControl-fullWidth\\" aria-autocomplete=\\"list\\" aria-controls=\\"react-autowhatever-1\\"><div class=\\"MuiInputBase-root MuiInput-root MuiInput-underline MuiInputBase-fullWidth MuiInput-fullWidth MuiInputBase-formControl MuiInput-formControl MuiInputBase-adornedStart\\"><div class=\\"MuiInputAdornment-root css-1wub48n-StyledInputAdornment e1n3ivvz0 MuiInputAdornment-positionStart\\"><svg class=\\"MuiSvgIcon-root\\" 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></svg></div><input aria-invalid=\\"false\\" autocomplete=\\"off\\" placeholder=\\"Search Packages\\" type=\\"text\\" class=\\"MuiInputBase-input MuiInput-input MuiInputBase-inputAdornedStart\\" value=\\"\\"></div></div><div class=\\"MuiPaper-root MuiPaper-elevation1 react-autosuggest__suggestions-container css-kc7cda-SuggestionContainer e1rflf272\\" 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 MuiTextField-root react-autosuggest__input MuiFormControl-fullWidth\\" aria-autocomplete=\\"list\\" aria-controls=\\"react-autowhatever-1\\"><div class=\\"MuiInputBase-root MuiInput-root css-n9ojyg MuiInput-underline MuiInputBase-fullWidth MuiInput-fullWidth MuiInputBase-formControl MuiInput-formControl MuiInputBase-adornedStart\\"><div class=\\"MuiInputAdornment-root css-fvu7gn MuiInputAdornment-positionStart\\"><svg class=\\"MuiSvgIcon-root\\" 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></svg></div><input aria-invalid=\\"false\\" autocomplete=\\"off\\" placeholder=\\"Search Packages\\" type=\\"text\\" class=\\"MuiInputBase-input MuiInput-input css-hodoyq MuiInputBase-inputAdornedStart\\" value=\\"\\"></div></div><div class=\\"MuiPaper-root MuiPaper-elevation1 react-autosuggest__suggestions-container css-cfo6a e1rflf271\\" id=\\"react-autowhatever-1\\" role=\\"listbox\\"></div></div></div>"`;

View File

@@ -1,13 +1,12 @@
import React from 'react';
import { mount } from '../../utils/test-enzyme';
import { shallow } from 'enzyme';
import Spinner from './Spinner';
import { Circular, Wrapper } from './styles';
describe('<Spinner /> component', () => {
test('should render the component in default state', () => {
const wrapper = mount(<Spinner />);
const wrapper = shallow(<Spinner />);
const wrapperComponent = wrapper.find(Wrapper);
const circular = wrapper.find(Circular);
@@ -16,7 +15,7 @@ describe('<Spinner /> component', () => {
});
test('should render the component in custom state', () => {
const wrapper = mount(<Spinner centered={true} size={10} />);
const wrapper = shallow(<Spinner centered={true} size={10} />);
const wrapperComponent = wrapper.find(Wrapper);
const circular = wrapper.find(Circular);

View File

@@ -1,3 +1,3 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`<Spinner /> component should render the component in custom state 1`] = `"<div class=\\"css-1ju0ex2-Wrapper e1ag4h8b0\\"><div class=\\"MuiCircularProgress-root css-evyw70-Circular e1ag4h8b1 MuiCircularProgress-colorPrimary MuiCircularProgress-indeterminate\\" style=\\"width: 10px; height: 10px;\\" role=\\"progressbar\\"><svg class=\\"MuiCircularProgress-svg\\" viewBox=\\"22 22 44 44\\"><circle class=\\"MuiCircularProgress-circle MuiCircularProgress-circleIndeterminate\\" cx=\\"44\\" cy=\\"44\\" r=\\"20.2\\" fill=\\"none\\" stroke-width=\\"3.6\\"></circle></svg></div></div>"`;
exports[`<Spinner /> component should render the component in custom state 1`] = `"<div class=\\"css-zo92co e1ag4h8b0\\"><div class=\\"MuiCircularProgress-root css-15gl0ho e1ag4h8b1 MuiCircularProgress-colorPrimary MuiCircularProgress-indeterminate\\" style=\\"width:10px;height:10px\\" role=\\"progressbar\\"><svg class=\\"MuiCircularProgress-svg\\" viewBox=\\"22 22 44 44\\"><circle class=\\"MuiCircularProgress-circle MuiCircularProgress-circleIndeterminate\\" cx=\\"44\\" cy=\\"44\\" r=\\"20.2\\" fill=\\"none\\" stroke-width=\\"3.6\\"></circle></svg></div></div>"`;

View File

@@ -1,24 +1,31 @@
import styled from '@emotion/styled';
import { css } from '@emotion/core';
import colors from '../../utils/styles/colors';
import CircularProgress from '../../muiComponents/CircularProgress';
import { Theme } from '../../design-tokens/theme';
interface WrapperProps {
centered: boolean;
}
export const Wrapper = styled('div')<WrapperProps>(props => ({
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
...(props.centered && {
position: 'absolute',
top: '50%',
left: '50%',
transform: 'translate(-50%, -50%)',
}),
}));
export const Wrapper = styled('div')`
&& {
display: flex;
align-items: center;
justify-content: center;
${(props: WrapperProps) =>
props.centered &&
css`
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
`};
}
`;
export const Circular = styled(CircularProgress)<{ theme?: Theme }>(props => ({
color: props.theme && props.theme.palette.primary.main,
}));
export const Circular = styled(CircularProgress)({
'&&': {
color: colors.primary,
},
});

View File

@@ -1,16 +1,15 @@
import React from 'react';
import { render } from '../../utils/test-react-testing-library';
import { shallow } from 'enzyme';
import Tag from './Tag';
describe('<Tag /> component', () => {
test('should load the component in default state', () => {
const { container } = render(
test('should render the component in default state', () => {
const wrapper = shallow(
<Tag>
<span>{'I am a child'}</span>
</Tag>
);
expect(container.firstChild).toMatchSnapshot();
expect(wrapper.html()).toMatchSnapshot();
});
});

View File

@@ -1,21 +1,3 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`<Tag /> component should load the component in default state 1`] = `
.emotion-0 {
vertical-align: middle;
line-height: 22px;
border-radius: 2px;
color: #485a3e;
background-color: #f3f4f2;
padding: 0.22rem 0.4rem;
margin: 8px 8px 0 0;
}
<span
class="emotion-0 emotion-1"
>
<span>
I am a child
</span>
</span>
`;
exports[`<Tag /> component should render the component in default state 1`] = `"<span class=\\"css-le0azu e1q9boj50\\"><span>I am a child</span></span>"`;

View File

@@ -1,11 +1,13 @@
import styled from '@emotion/styled';
export const Wrapper = styled('span')({
verticalAlign: 'middle',
lineHeight: '22px',
borderRadius: '2px',
color: '#485a3e',
backgroundColor: '#f3f4f2',
padding: '0.22rem 0.4rem',
margin: '8px 8px 0 0',
'&&': {
verticalAlign: 'middle',
lineHeight: '22px',
borderRadius: '2px',
color: '#485a3e',
backgroundColor: '#f3f4f2',
padding: '0.22rem 0.4rem',
margin: '8px 8px 0 0',
},
});

View File

@@ -1,6 +1,6 @@
import React from 'react';
import { shallow, mount } from 'enzyme';
import { mount, shallow } from '../../utils/test-enzyme';
import { DetailContext } from '../../pages/Version';
import UpLinks from './UpLinks';

View File

@@ -2,4 +2,4 @@
exports[`<UpLinks /> component should render the component when there is no uplink 1`] = `"<h6 class=\\"MuiTypography-root MuiTypography-subtitle1 MuiTypography-gutterBottom\\">verdaccio has no uplinks.</h6>"`;
exports[`<UpLinks /> component should render the component with uplinks 1`] = `"<h6 class=\\"MuiTypography-root css-5wp24z-StyledText e14i1sy10 MuiTypography-subtitle1\\">Uplinks</h6><ul class=\\"MuiList-root MuiList-padding\\"><li class=\\"MuiListItem-root MuiListItem-gutters\\"><div class=\\"MuiListItemText-root css-1pxn9ma-ListItemText e14i1sy12\\"><span class=\\"MuiTypography-root MuiListItemText-primary MuiTypography-body1\\">npmjs</span></div><div class=\\"css-t1rp47-Spacer e14i1sy11\\"></div><div class=\\"MuiListItemText-root css-1pxn9ma-ListItemText e14i1sy12\\"><span class=\\"MuiTypography-root MuiListItemText-primary MuiTypography-body1\\">over 1 year ago</span></div></li></ul>"`;
exports[`<UpLinks /> component should render the component with uplinks 1`] = `"<h6 class=\\"MuiTypography-root css-1vg6q84 e14i1sy10 MuiTypography-subtitle1\\">Uplinks</h6><ul class=\\"MuiList-root MuiList-padding\\"><li class=\\"MuiListItem-root MuiListItem-gutters\\"><div class=\\"MuiListItemText-root css-o655gb e14i1sy12\\"><span class=\\"MuiTypography-root MuiListItemText-primary MuiTypography-body1\\">npmjs</span></div><div class=\\"css-1l1cv61 e14i1sy11\\"></div><div class=\\"MuiListItemText-root css-o655gb e14i1sy12\\"><span class=\\"MuiTypography-root MuiListItemText-primary MuiTypography-body1\\">over 1 year ago</span></div></li></ul>"`;

View File

@@ -1,8 +1,8 @@
import React from 'react';
import { mount } from 'enzyme';
import { MemoryRouter } from 'react-router-dom';
import { render, cleanup } from '@testing-library/react';
import { render, cleanup } from '../../utils/test-react-testing-library';
import { mount } from '../../utils/test-enzyme';
import { DetailContext, DetailContextProps } from '../../pages/Version';
import Versions, { LABEL_CURRENT_TAGS, LABEL_VERSION_HISTORY } from './Versions';

View File

@@ -16,11 +16,6 @@ const resetStyles = makeStyles(() => ({
'html, body, #root': {
height: '100%',
},
ul: {
margin: 0,
padding: 0,
listStyle: 'none',
},
'.container': {
padding: 15,
flex: 1,

View File

@@ -1,13 +0,0 @@
import React from 'react';
import { ThemeProvider as MuiThemeProvider } from '@material-ui/core/styles';
import { ThemeProvider as EmotionThemeProvider } from 'emotion-theming';
import theme from './theme';
const ThemeProvider: React.FC = ({ children }) => (
<EmotionThemeProvider theme={theme}>
<MuiThemeProvider theme={theme}>{children}</MuiThemeProvider>
</EmotionThemeProvider>
);
export default ThemeProvider;

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