mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Plugins: Show latest commit date at plugin details right panel (#95333)
* get last commit info from backend * change last commit date type * fix tests * add tests to check lastCommitDate
This commit is contained in:
parent
61929b785a
commit
3e1046ee2e
@ -17,7 +17,6 @@ import {
|
|||||||
export async function getPluginDetails(id: string): Promise<CatalogPluginDetails> {
|
export async function getPluginDetails(id: string): Promise<CatalogPluginDetails> {
|
||||||
const remote = await getRemotePlugin(id);
|
const remote = await getRemotePlugin(id);
|
||||||
const isPublished = Boolean(remote);
|
const isPublished = Boolean(remote);
|
||||||
|
|
||||||
const [localPlugins, versions, localReadme, localChangelog] = await Promise.all([
|
const [localPlugins, versions, localReadme, localChangelog] = await Promise.all([
|
||||||
getLocalPlugins(),
|
getLocalPlugins(),
|
||||||
getPluginVersions(id, isPublished),
|
getPluginVersions(id, isPublished),
|
||||||
@ -36,6 +35,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,
|
||||||
|
lastCommitDate: remote?.lastCommitDate,
|
||||||
changelog: remote?.changelog || localChangelog,
|
changelog: remote?.changelog || localChangelog,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -46,9 +46,23 @@ export function PluginDetailsRightPanel(props: Props): React.ReactElement | null
|
|||||||
{plugin.updatedAt && (
|
{plugin.updatedAt && (
|
||||||
<Stack direction="column" gap={0.5}>
|
<Stack direction="column" gap={0.5}>
|
||||||
<Text color="secondary">
|
<Text color="secondary">
|
||||||
<Trans i18nKey="plugins.details.labels.updatedAt">Last updated: </Trans>
|
<Trans i18nKey="plugins.details.labels.updatedAt">Last updated:</Trans>
|
||||||
</Text>{' '}
|
</Text>{' '}
|
||||||
<Text>{formatDate(new Date(plugin.updatedAt))}</Text>
|
<Text>{formatDate(new Date(plugin.updatedAt), { day: 'numeric', month: 'short', year: 'numeric' })}</Text>
|
||||||
|
</Stack>
|
||||||
|
)}
|
||||||
|
{plugin?.details?.lastCommitDate && (
|
||||||
|
<Stack direction="column" gap={0.5}>
|
||||||
|
<Text color="secondary">
|
||||||
|
<Trans i18nKey="plugins.details.labels.lastCommitDate">Last commit date:</Trans>
|
||||||
|
</Text>{' '}
|
||||||
|
<Text>
|
||||||
|
{formatDate(new Date(plugin.details.lastCommitDate), {
|
||||||
|
day: 'numeric',
|
||||||
|
month: 'short',
|
||||||
|
year: 'numeric',
|
||||||
|
})}
|
||||||
|
</Text>
|
||||||
</Stack>
|
</Stack>
|
||||||
)}
|
)}
|
||||||
</Stack>
|
</Stack>
|
||||||
|
@ -917,7 +917,7 @@ describe('Plugin details page', () => {
|
|||||||
const updatedAt = '2023-10-26T16:54:55.000Z';
|
const updatedAt = '2023-10-26T16:54:55.000Z';
|
||||||
const { queryByText } = renderPluginDetails({ id, updatedAt });
|
const { queryByText } = renderPluginDetails({ id, updatedAt });
|
||||||
expect(queryByText('Last updated:')).toBeVisible();
|
expect(queryByText('Last updated:')).toBeVisible();
|
||||||
expect(queryByText('10/26/2023')).toBeVisible();
|
expect(queryByText('Oct 26, 2023')).toBeVisible();
|
||||||
expect(queryByText('Report a concern')).toBeVisible();
|
expect(queryByText('Report a concern')).toBeVisible();
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -928,6 +928,21 @@ describe('Plugin details page', () => {
|
|||||||
expect(queryByText('Last updated:')).toBeNull();
|
expect(queryByText('Last updated:')).toBeNull();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should display last commit date information', async () => {
|
||||||
|
const id = 'right-panel-test-plugin';
|
||||||
|
const lastCommitDate = '2023-10-26T16:54:55.000Z';
|
||||||
|
const { queryByText } = renderPluginDetails({ id, details: { lastCommitDate, links: [] } });
|
||||||
|
expect(queryByText('Last commit date:')).toBeVisible();
|
||||||
|
expect(queryByText('Oct 26, 2023')).toBeVisible();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should not display last commit date if there is no lastCommit data', async () => {
|
||||||
|
const id = 'right-panel-test-plugin';
|
||||||
|
const lastCommitDate = undefined;
|
||||||
|
const { queryByText } = renderPluginDetails({ id, details: { lastCommitDate, links: [] } });
|
||||||
|
expect(queryByText('Last commit date:')).toBeNull();
|
||||||
|
});
|
||||||
|
|
||||||
it('should not display Report Abuse if the plugin is Core', async () => {
|
it('should not display Report Abuse if the plugin is Core', async () => {
|
||||||
const id = 'right-panel-test-plugin';
|
const id = 'right-panel-test-plugin';
|
||||||
const isCore = true;
|
const isCore = true;
|
||||||
|
@ -78,6 +78,7 @@ export interface CatalogPluginDetails {
|
|||||||
statusContext?: string;
|
statusContext?: string;
|
||||||
iam?: IdentityAccessManagement;
|
iam?: IdentityAccessManagement;
|
||||||
changelog?: string;
|
changelog?: string;
|
||||||
|
lastCommitDate?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface CatalogPluginInfo {
|
export interface CatalogPluginInfo {
|
||||||
@ -139,6 +140,7 @@ export type RemotePlugin = {
|
|||||||
versionSignedByOrgName: string;
|
versionSignedByOrgName: string;
|
||||||
versionStatus: string;
|
versionStatus: string;
|
||||||
angularDetected?: boolean;
|
angularDetected?: boolean;
|
||||||
|
lastCommitDate?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
// The available status codes on GCOM are available here:
|
// The available status codes on GCOM are available here:
|
||||||
|
@ -2178,12 +2178,13 @@
|
|||||||
"downloads": "Downloads",
|
"downloads": "Downloads",
|
||||||
"from": "From",
|
"from": "From",
|
||||||
"installedVersion": "Installed version: ",
|
"installedVersion": "Installed version: ",
|
||||||
|
"lastCommitDate": "Last commit date:",
|
||||||
"latestVersion": "Latest version: ",
|
"latestVersion": "Latest version: ",
|
||||||
"links": "Links ",
|
"links": "Links ",
|
||||||
"reportAbuse": "Report a concern ",
|
"reportAbuse": "Report a concern ",
|
||||||
"signature": "Signature",
|
"signature": "Signature",
|
||||||
"status": "Status",
|
"status": "Status",
|
||||||
"updatedAt": "Last updated: ",
|
"updatedAt": "Last updated:",
|
||||||
"version": "Version"
|
"version": "Version"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -2178,12 +2178,13 @@
|
|||||||
"downloads": "Đőŵʼnľőäđş",
|
"downloads": "Đőŵʼnľőäđş",
|
||||||
"from": "Fřőm",
|
"from": "Fřőm",
|
||||||
"installedVersion": "Ĩʼnşŧäľľęđ vęřşįőʼn: ",
|
"installedVersion": "Ĩʼnşŧäľľęđ vęřşįőʼn: ",
|
||||||
|
"lastCommitDate": "Ŀäşŧ čőmmįŧ đäŧę:",
|
||||||
"latestVersion": "Ŀäŧęşŧ vęřşįőʼn: ",
|
"latestVersion": "Ŀäŧęşŧ vęřşįőʼn: ",
|
||||||
"links": "Ŀįʼnĸş ",
|
"links": "Ŀįʼnĸş ",
|
||||||
"reportAbuse": "Ŗępőřŧ ä čőʼnčęřʼn ",
|
"reportAbuse": "Ŗępőřŧ ä čőʼnčęřʼn ",
|
||||||
"signature": "Ŝįģʼnäŧūřę",
|
"signature": "Ŝįģʼnäŧūřę",
|
||||||
"status": "Ŝŧäŧūş",
|
"status": "Ŝŧäŧūş",
|
||||||
"updatedAt": "Ŀäşŧ ūpđäŧęđ: ",
|
"updatedAt": "Ŀäşŧ ūpđäŧęđ:",
|
||||||
"version": "Vęřşįőʼn"
|
"version": "Vęřşįőʼn"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user