diff --git a/.changeset/unlucky-hairs-wonder.md b/.changeset/unlucky-hairs-wonder.md new file mode 100644 index 000000000..752433c63 --- /dev/null +++ b/.changeset/unlucky-hairs-wonder.md @@ -0,0 +1,5 @@ +--- +'@verdaccio/ui-theme': patch +--- + +feat: Display publication time on sidebar diff --git a/packages/plugins/ui-theme/src/i18n/crowdin/ui.json b/packages/plugins/ui-theme/src/i18n/crowdin/ui.json index 91950f381..2723c402f 100644 --- a/packages/plugins/ui-theme/src/i18n/crowdin/ui.json +++ b/packages/plugins/ui-theme/src/i18n/crowdin/ui.json @@ -96,7 +96,8 @@ "sidebar": { "detail": { "latest-version": "Latest v{{version}}", - "version": "v{{version}}" + "version": "v{{version}}", + "published": "Published" }, "installation": { "title": "Installation", diff --git a/packages/plugins/ui-theme/src/pages/Version/DetailContainer/Versions/VersionsHistoryList.tsx b/packages/plugins/ui-theme/src/pages/Version/DetailContainer/Versions/VersionsHistoryList.tsx index e7371ac74..2bd9d796e 100644 --- a/packages/plugins/ui-theme/src/pages/Version/DetailContainer/Versions/VersionsHistoryList.tsx +++ b/packages/plugins/ui-theme/src/pages/Version/DetailContainer/Versions/VersionsHistoryList.tsx @@ -2,7 +2,7 @@ import List from '@mui/material/List'; import ListItem from '@mui/material/ListItem'; import React from 'react'; import { useTranslation } from 'react-i18next'; -import { formatDateDistance } from 'verdaccio-ui/utils/package'; +import { formatDate, formatDateDistance } from 'verdaccio-ui/utils/package'; import { Time, Versions } from '../../../../../types/packageMeta'; import { ListItemText, Spacer, StyledLink } from './styles'; @@ -26,7 +26,7 @@ const VersionsHistoryList: React.FC = ({ versions, packageName, time }) = {version} - + {time[version] ? formatDateDistance(time[version]) : t('versions.not-available')} diff --git a/packages/plugins/ui-theme/src/pages/Version/DetailSidebar/DetailSidebar.tsx b/packages/plugins/ui-theme/src/pages/Version/DetailSidebar/DetailSidebar.tsx index 174288b8d..2d826ac6f 100644 --- a/packages/plugins/ui-theme/src/pages/Version/DetailSidebar/DetailSidebar.tsx +++ b/packages/plugins/ui-theme/src/pages/Version/DetailSidebar/DetailSidebar.tsx @@ -32,6 +32,8 @@ const DetailSidebar: React.FC = () => { const detailContext = useContext(DetailContext); const { packageMeta, packageName, packageVersion } = detailContext; const { configOptions } = useConfig(); + const version = packageVersion || packageMeta?.latest.version || ''; + const time = packageMeta?.time ? packageMeta.time[version] : ''; if (!packageMeta || !packageName) { return null; @@ -45,7 +47,8 @@ const DetailSidebar: React.FC = () => { isLatest={typeof packageVersion === 'undefined'} moduleType={getModuleType(packageMeta)} packageName={packageName} - version={packageVersion || packageMeta.latest.version} + time={time} + version={version} /> = ({ module }) => { @@ -33,6 +35,7 @@ const DetailSidebarTitle: React.FC = ({ isLatest, hasTypes, moduleType, + time, }) => { const { t } = useTranslation(); return ( @@ -47,10 +50,13 @@ const DetailSidebarTitle: React.FC = ({ {description &&
{description}
} - + {isLatest ? t('sidebar.detail.latest-version', { version }) : t('sidebar.detail.version', { version })} + {time + ? ' - ' + t('sidebar.detail.published') + ' ' + formatDateDistance(time) + : t('versions.not-available')} );