mirror of
https://github.com/verdaccio/verdaccio.git
synced 2024-12-16 21:56:25 -05:00
feat: add dist-tags on ui
This commit is contained in:
parent
6dbe9e9837
commit
4f4720dafb
6 changed files with 74 additions and 3 deletions
|
@ -10,3 +10,4 @@ build/
|
||||||
*.yaml
|
*.yaml
|
||||||
Dockerfile
|
Dockerfile
|
||||||
*.rpi
|
*.rpi
|
||||||
|
*.scss
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
import { addScope, addGravatarSupport, deleteProperties, sortByName, parseReadme } from '../../../lib/utils';
|
import { addScope, addGravatarSupport, deleteProperties, sortByName, parseReadme } from '../../../lib/utils';
|
||||||
import { allow } from '../../middleware';
|
import { allow } from '../../middleware';
|
||||||
import { DIST_TAGS, HTTP_STATUS } from '../../../lib/constants';
|
import { DIST_TAGS, HEADER_TYPE, HEADERS, HTTP_STATUS } from '../../../lib/constants';
|
||||||
import type { Router } from 'express';
|
import type { Router } from 'express';
|
||||||
import type { IAuth, $ResponseExtend, $RequestExtend, $NextFunctionVer, IStorageHandler, $SidebarPackage } from '../../../../types';
|
import type { IAuth, $ResponseExtend, $RequestExtend, $NextFunctionVer, IStorageHandler, $SidebarPackage } from '../../../../types';
|
||||||
|
|
||||||
|
@ -67,7 +67,7 @@ function addPackageWebApi(route: Router, storage: IStorageHandler, auth: IAuth)
|
||||||
return next(err);
|
return next(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
res.set('Content-Type', 'text/plain');
|
res.set(HEADER_TYPE.CONTENT_TYPE, HEADERS.TEXT_PLAIN);
|
||||||
next(parseReadme(info.name, info.readme));
|
next(parseReadme(info.name, info.readme));
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
@ -19,6 +19,7 @@ export const csrPem = 'verdaccio-csr.pem';
|
||||||
export const HEADERS = {
|
export const HEADERS = {
|
||||||
JSON: 'application/json',
|
JSON: 'application/json',
|
||||||
CONTENT_TYPE: 'Content-type',
|
CONTENT_TYPE: 'Content-type',
|
||||||
|
TEXT_PLAIN: 'text/plain',
|
||||||
FORWARDED_PROTO: 'X-Forwarded-Proto',
|
FORWARDED_PROTO: 'X-Forwarded-Proto',
|
||||||
ETAG: 'ETag',
|
ETAG: 'ETag',
|
||||||
JSON_CHARSET: 'application/json; charset=utf-8',
|
JSON_CHARSET: 'application/json; charset=utf-8',
|
||||||
|
|
|
@ -2,6 +2,7 @@ import React from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import get from 'lodash/get';
|
import get from 'lodash/get';
|
||||||
import LastSync from './modules/LastSync';
|
import LastSync from './modules/LastSync';
|
||||||
|
import DistTags from './modules/DistTags';
|
||||||
import Maintainers from './modules/Maintainers';
|
import Maintainers from './modules/Maintainers';
|
||||||
import Dependencies from './modules/Dependencies';
|
import Dependencies from './modules/Dependencies';
|
||||||
import PeerDependencies from './modules/PeerDependencies';
|
import PeerDependencies from './modules/PeerDependencies';
|
||||||
|
@ -14,6 +15,7 @@ import {
|
||||||
getRecentReleases,
|
getRecentReleases,
|
||||||
} from '../../utils/package';
|
} from '../../utils/package';
|
||||||
import API from '../../utils/api';
|
import API from '../../utils/api';
|
||||||
|
import {DIST_TAGS} from '../../../lib/constants';
|
||||||
|
|
||||||
export default class PackageSidebar extends React.Component {
|
export default class PackageSidebar extends React.Component {
|
||||||
state = {};
|
state = {};
|
||||||
|
@ -61,6 +63,9 @@ export default class PackageSidebar extends React.Component {
|
||||||
);
|
);
|
||||||
const homepage = get(packageMeta, 'latest.homepage', null);
|
const homepage = get(packageMeta, 'latest.homepage', null);
|
||||||
|
|
||||||
|
// dist-tags
|
||||||
|
const distTags = packageMeta[DIST_TAGS];
|
||||||
|
|
||||||
// Lastsync component
|
// Lastsync component
|
||||||
const recentReleases = getRecentReleases(time);
|
const recentReleases = getRecentReleases(time);
|
||||||
const lastUpdated = getLastUpdatedPackageTime(_uplinks);
|
const lastUpdated = getLastUpdatedPackageTime(_uplinks);
|
||||||
|
@ -70,7 +75,7 @@ export default class PackageSidebar extends React.Component {
|
||||||
const peerDependencies = get(packageMeta, 'latest.peerDependencies', {});
|
const peerDependencies = get(packageMeta, 'latest.peerDependencies', {});
|
||||||
|
|
||||||
// Maintainers component
|
// Maintainers component
|
||||||
return (
|
return (
|
||||||
<aside className={'sidebar-info'}>
|
<aside className={'sidebar-info'}>
|
||||||
{time && (
|
{time && (
|
||||||
<LastSync
|
<LastSync
|
||||||
|
@ -78,6 +83,7 @@ export default class PackageSidebar extends React.Component {
|
||||||
recentReleases={recentReleases}
|
recentReleases={recentReleases}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
<DistTags distTags={distTags} />
|
||||||
<Infos
|
<Infos
|
||||||
homepage={homepage}
|
homepage={homepage}
|
||||||
license={license}
|
license={license}
|
||||||
|
|
|
@ -0,0 +1,50 @@
|
||||||
|
import React from 'react';
|
||||||
|
import propTypes from 'prop-types';
|
||||||
|
import Module from '../../Module';
|
||||||
|
import ModuleContentPlaceholder from '../../ModuleContentPlaceholder';
|
||||||
|
|
||||||
|
import classes from './style.scss';
|
||||||
|
|
||||||
|
const renderDistTags = (distTags) => {
|
||||||
|
|
||||||
|
const tags = Object.entries(distTags);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<ul>
|
||||||
|
{tags.map((tagItem) => {
|
||||||
|
const [tag, version] = tagItem;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<li className={'dist-tag-item'} key={tag}>
|
||||||
|
<span>{tag}</span>
|
||||||
|
<span>{version}</span>
|
||||||
|
</li>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</ul>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
const DistTags = ({distTags = {}}) => {
|
||||||
|
const hasTags = Object.keys(distTags).length > 0;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Module
|
||||||
|
className={classes.releasesModule}
|
||||||
|
description={''}
|
||||||
|
title={'Dist-Tags'}
|
||||||
|
>
|
||||||
|
{hasTags ? (
|
||||||
|
renderDistTags(distTags)
|
||||||
|
) : (
|
||||||
|
<ModuleContentPlaceholder text={'Not Available!'} />
|
||||||
|
)}
|
||||||
|
</Module>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
DistTags.propTypes = {
|
||||||
|
distTags: propTypes.array,
|
||||||
|
};
|
||||||
|
|
||||||
|
export default DistTags;
|
|
@ -0,0 +1,13 @@
|
||||||
|
@import '../../../../styles/variables';
|
||||||
|
|
||||||
|
.releasesModule {
|
||||||
|
li {
|
||||||
|
display: flex;
|
||||||
|
font-size: $font-size-sm;
|
||||||
|
line-height: $line-height-xs;
|
||||||
|
|
||||||
|
span:last-child {
|
||||||
|
margin-left: auto;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue