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

chore: sync with verdaccio master

This commit is contained in:
Juan Picado @jotadeveloper
2019-04-04 21:23:40 +02:00
parent 133a5f0171
commit 3506f32ad8
241 changed files with 57691 additions and 1932 deletions

View File

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

View File

@@ -1,22 +0,0 @@
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import PackageList from '../../components/PackageList';
class Home extends Component {
static propTypes = {
isUserLoggedIn: PropTypes.bool.isRequired,
packages: PropTypes.array.isRequired,
};
render() {
const { packages } = this.props;
return (
<div className={"container content"}>
<PackageList packages={packages} />
</div>
);
}
}
export default Home;

View File

@@ -1,138 +0,0 @@
/**
* @prettier
* @flow
*/
import React, { Component } from 'react';
import Grid from '@material-ui/core/Grid/index';
import Loading from '../../components/Loading';
import DetailContainer from '../../components/DetailContainer';
import DetailSidebar from '../../components/DetailSidebar';
import { callDetailPage } from '../../utils/calls';
import { getRouterPackageName } from '../../utils/package';
import NotFound from '../../components/NotFound';
export const DetailContext = React.createContext();
export const DetailContextProvider = DetailContext.Provider;
export const DetailContextConsumer = DetailContext.Consumer;
class VersionPage extends Component<any, any> {
constructor(props: any) {
super(props);
this.state = {
readMe: '',
packageName: getRouterPackageName(props.match),
packageMeta: null,
isLoading: true,
notFound: false,
};
}
async componentDidMount() {
await this.loadPackageInfo();
}
/* eslint no-unused-vars: 0 */
async componentDidUpdate(nextProps: any, prevState: any) {
const { packageName } = this.state;
if (packageName !== prevState.packageName) {
const { readMe, packageMeta } = await callDetailPage(packageName);
this.setState({
readMe,
packageMeta,
packageName,
notFound: false,
isLoading: false,
});
}
}
static getDerivedStateFromProps(nextProps: any, prevState: any) {
const { match } = nextProps;
const packageName = getRouterPackageName(match);
if (packageName !== prevState.packageName) {
try {
return {
packageName,
isLoading: false,
};
} catch (err) {
return {
notFound: true,
isLoading: false,
};
}
} else {
return null;
}
}
async loadPackageInfo() {
const { packageName } = this.state;
// FIXME: use utility
document.title = `Verdaccio - ${packageName}`;
this.setState({
readMe: '',
});
try {
const { readMe, packageMeta } = await callDetailPage(packageName);
this.setState({
readMe,
packageMeta,
packageName,
notFound: false,
isLoading: false,
});
} catch (err) {
this.setState({
notFound: true,
packageName,
isLoading: false,
});
}
}
enableLoading = () => {
this.setState({
isLoading: true,
});
};
render() {
const { isLoading, packageMeta, readMe, packageName } = this.state;
if (isLoading) {
return <Loading />;
} else if (!packageMeta) {
return <NotFound />;
} else {
return (
<DetailContextProvider value={{ packageMeta, readMe, packageName, enableLoading: this.enableLoading }}>
<Grid className={'container content'} container={true} spacing={0}>
<Grid item={true} xs={8}>
{this.renderDetail()}
</Grid>
<Grid item={true} xs={4}>
{this.renderSidebar()}
</Grid>
</Grid>
</DetailContextProvider>
);
}
}
renderDetail() {
return <DetailContainer />;
}
renderSidebar() {
return <DetailSidebar />;
}
}
export default VersionPage;

View File

@@ -1,17 +0,0 @@
/**
* @prettier
* @flow
*/
import styled from 'react-emotion';
import DialogTitle from '@material-ui/core/DialogTitle/index';
import colors from '../../utils/styles/colors';
import { fontSize } from '../../utils/styles/sizes';
export const Title = styled(DialogTitle)`
&& {
background-color: ${colors.primary};
color: ${colors.white};
font-size: ${fontSize.lg};
}
`;