Plugins: Plugin details right panel improvements (#93982)

* Add installed and latest version information

* get latest changelog for changelog tab from gcom

* fix displaying signature type

* fix integration test

* add translations

* remove gcom request at local changelog method
This commit is contained in:
Yulia Shanyrova 2024-10-24 12:55:29 +02:00 committed by GitHub
parent 37f82dab49
commit 26fab52086
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 34 additions and 2 deletions

View File

@ -36,7 +36,7 @@ export async function getPluginDetails(id: string): Promise<CatalogPluginDetails
versions, versions,
statusContext: remote?.statusContext ?? '', statusContext: remote?.statusContext ?? '',
iam: remote?.json?.iam, iam: remote?.json?.iam,
changelog: localChangelog || remote?.changelog, changelog: remote?.changelog || localChangelog,
}; };
} }
@ -122,7 +122,6 @@ async function getLocalPluginChangelog(id: string): Promise<string> {
try { try {
const markdown: string = await getBackendSrv().get(`${API_ROOT}/${id}/markdown/CHANGELOG`); const markdown: string = await getBackendSrv().get(`${API_ROOT}/${id}/markdown/CHANGELOG`);
const markdownAsHtml = markdown ? renderMarkdown(markdown) : ''; const markdownAsHtml = markdown ? renderMarkdown(markdown) : '';
return markdownAsHtml; return markdownAsHtml;
} catch (error) { } catch (error) {
if (isFetchError(error)) { if (isFetchError(error)) {

View File

@ -152,6 +152,9 @@ export const getStyles = (theme: GrafanaTheme2) => ({
'& > p': { '& > p': {
margin: theme.spacing(1, 0), margin: theme.spacing(1, 0),
}, },
code: {
'white-space': 'pre-wrap',
},
}, },
a: { a: {
color: theme.colors.text.link, color: theme.colors.text.link,

View File

@ -3,6 +3,7 @@ import { Stack, Text, LinkButton, Box, TextLink } from '@grafana/ui';
import { Trans } from 'app/core/internationalization'; import { Trans } from 'app/core/internationalization';
import { formatDate } from 'app/core/internationalization/dates'; import { formatDate } from 'app/core/internationalization/dates';
import { getLatestCompatibleVersion } from '../helpers';
import { CatalogPlugin } from '../types'; import { CatalogPlugin } from '../types';
type Props = { type Props = {
@ -16,7 +17,25 @@ export function PluginDetailsRightPanel(props: Props): React.ReactElement | null
<Stack direction="column" gap={3} shrink={0} grow={0} maxWidth={'250px'}> <Stack direction="column" gap={3} shrink={0} grow={0} maxWidth={'250px'}>
<Box padding={2} borderColor="medium" borderStyle="solid"> <Box padding={2} borderColor="medium" borderStyle="solid">
<Stack direction="column" gap={2}> <Stack direction="column" gap={2}>
{plugin.isInstalled && plugin.installedVersion && (
<Stack wrap direction="column" gap={0.5}>
<Text color="secondary">
<Trans i18nKey="plugins.details.labels.installedVersion">Installed version: </Trans>
</Text>
<div>{plugin.installedVersion}</div>
</Stack>
)}
{info.map((infoItem, index) => { {info.map((infoItem, index) => {
if (infoItem.label === 'Version') {
return (
<Stack key={index} wrap direction="column" gap={0.5}>
<Text color="secondary">
<Trans i18nKey="plugins.details.labels.latestVersion">Latest version: </Trans>
</Text>
<div>{getLatestCompatibleVersion(plugin.details?.versions)?.version}</div>
</Stack>
);
}
return ( return (
<Stack key={index} wrap direction="column" gap={0.5}> <Stack key={index} wrap direction="column" gap={0.5}>
<Text color="secondary">{infoItem.label + ':'}</Text> <Text color="secondary">{infoItem.label + ':'}</Text>

View File

@ -211,6 +211,8 @@ describe('Plugins/Helpers', () => {
popularity: 0.2111, popularity: 0.2111,
publishedAt: '2016-04-06T20:23:41.000Z', publishedAt: '2016-04-06T20:23:41.000Z',
signature: 'valid', signature: 'valid',
signatureOrg: 'Alexander Zobnin',
signatureType: 'community',
type: 'app', type: 'app',
updatedAt: '2021-05-18T14:53:01.000Z', updatedAt: '2021-05-18T14:53:01.000Z',
isFullyInstalled: false, isFullyInstalled: false,

View File

@ -118,6 +118,9 @@ export function mapRemoteToCatalog(plugin: RemotePlugin, error?: PluginError): C
status, status,
angularDetected, angularDetected,
keywords, keywords,
signatureType,
versionSignatureType,
versionSignedByOrgName,
} = plugin; } = plugin;
const isDisabled = !!error || isDisabledSecretsPlugin(typeCode); const isDisabled = !!error || isDisabledSecretsPlugin(typeCode);
@ -137,6 +140,8 @@ export function mapRemoteToCatalog(plugin: RemotePlugin, error?: PluginError): C
popularity, popularity,
publishedAt, publishedAt,
signature: getPluginSignature({ remote: plugin, error }), signature: getPluginSignature({ remote: plugin, error }),
signatureType: signatureType || versionSignatureType || undefined,
signatureOrg: versionSignedByOrgName,
updatedAt, updatedAt,
hasUpdate: false, hasUpdate: false,
isPublished: true, isPublished: true,

View File

@ -2161,6 +2161,8 @@
"dependencies": "Dependencies", "dependencies": "Dependencies",
"downloads": "Downloads", "downloads": "Downloads",
"from": "From", "from": "From",
"installedVersion": "Installed version: ",
"latestVersion": "Latest version: ",
"links": "Links ", "links": "Links ",
"reportAbuse": "Report a concern ", "reportAbuse": "Report a concern ",
"signature": "Signature", "signature": "Signature",

View File

@ -2161,6 +2161,8 @@
"dependencies": "Đępęʼnđęʼnčįęş", "dependencies": "Đępęʼnđęʼnčįęş",
"downloads": "Đőŵʼnľőäđş", "downloads": "Đőŵʼnľőäđş",
"from": "Fřőm", "from": "Fřőm",
"installedVersion": "Ĩʼnşŧäľľęđ vęřşįőʼn: ",
"latestVersion": "Ŀäŧęşŧ vęřşįőʼn: ",
"links": "Ŀįʼnĸş ", "links": "Ŀįʼnĸş ",
"reportAbuse": "Ŗępőřŧ ä čőʼnčęřʼn ", "reportAbuse": "Ŗępőřŧ ä čőʼnčęřʼn ",
"signature": "Ŝįģʼnäŧūřę", "signature": "Ŝįģʼnäŧūřę",