Plugins: Improve plugin details UX for core plugins (#99830)

This commit is contained in:
Hugo Kiyodi Oshiro
2025-02-13 11:07:24 +01:00
committed by GitHub
parent 293f514854
commit 95ee93a0d8
6 changed files with 36 additions and 4 deletions

View File

@@ -94,6 +94,7 @@ async function getPluginVersions(id: string, isPublished: boolean): Promise<Vers
return (versions.items || []).map((v) => ({
version: v.version,
createdAt: v.createdAt,
updatedAt: v.updatedAt,
isCompatible: v.isCompatible,
grafanaDependency: v.grafanaDependency,
angularDetected: v.angularDetected,

View File

@@ -57,6 +57,7 @@ const plugin: CatalogPlugin = {
],
grafanaDependency: '>=9.0.0',
statusContext: 'stable',
changelog: 'Test changelog',
},
angularDetected: false,
isFullyInstalled: true,
@@ -154,4 +155,28 @@ describe('PluginDetailsPage', () => {
render(<PluginDetailsPage pluginId={plugin.id} />);
expect(screen.getByRole('tab', { name: 'Data source connections' })).toBeVisible();
});
it('should not show version and changelog tabs when plugin is core', () => {
mockUseGetSingle.mockReturnValue({ ...plugin, isCore: true });
render(<PluginDetailsPage pluginId={plugin.id} />);
expect(screen.queryByRole('tab', { name: 'Version history' })).not.toBeInTheDocument();
expect(screen.queryByRole('tab', { name: 'Changelog' })).not.toBeInTheDocument();
});
it('should not show last version in plugin details panel when plugin is core', () => {
config.featureToggles.pluginsDetailsRightPanel = true;
window.matchMedia = jest.fn().mockImplementation((query) => ({
matches: query !== '(max-width: 600px)',
media: query,
onchange: null,
addEventListener: jest.fn(),
removeEventListener: jest.fn(),
dispatchEvent: jest.fn(),
}));
mockUseGetSingle.mockReturnValue({ ...plugin, isCore: true, latestVersion: '1.2.0' });
render(<PluginDetailsPage pluginId={plugin.id} />);
expect(screen.queryByText('Latest Version:')).not.toBeInTheDocument();
});
});

View File

@@ -96,7 +96,7 @@ export const VersionList = ({ pluginId, versions = [], installedVersion, disable
{/* Last updated */}
<td className={isInstalledVersion ? styles.currentVersion : ''}>
{dateTimeFormatTimeAgo(version.createdAt)}
{dateTimeFormatTimeAgo(version.updatedAt || version.createdAt)}
</td>
{/* Dependency */}
<td className={isInstalledVersion ? styles.currentVersion : ''}>{version.grafanaDependency || 'N/A'}</td>

View File

@@ -42,7 +42,8 @@ export const usePluginDetailsTabs = (
const navModelChildren = useMemo(() => {
const canConfigurePlugins = plugin && contextSrv.hasPermissionInMetadata(AccessControlAction.PluginsWrite, plugin);
const navModelChildren: NavModelItem[] = [];
if (isPublished) {
// currently the versions available of core plugins are not consistent
if (isPublished && !plugin?.isCore) {
navModelChildren.push({
text: PluginTabLabels.VERSIONS,
id: PluginTabIds.VERSIONS,
@@ -51,7 +52,8 @@ export const usePluginDetailsTabs = (
active: PluginTabIds.VERSIONS === currentPageId,
});
}
if (isPublished && plugin?.details?.changelog) {
// currently there is not changelog available for core plugins
if (isPublished && plugin?.details?.changelog && !plugin.isCore) {
navModelChildren.push({
text: PluginTabLabels.CHANGELOG,
id: PluginTabIds.CHANGELOG,

View File

@@ -53,7 +53,10 @@ export const usePluginInfo = (plugin?: CatalogPlugin): PageInfoItem[] => {
latestVersionValue = latestVersion;
}
addInfo('latestVersion', latestVersionValue);
// latest versions of core plugins are not consistent
if (!plugin.isCore) {
addInfo('latestVersion', latestVersionValue);
}
}
if (Boolean(plugin.orgName)) {

View File

@@ -216,6 +216,7 @@ export interface Build {
export interface Version {
version: string;
createdAt: string;
updatedAt?: string;
isCompatible: boolean;
grafanaDependency: string | null;
angularDetected?: boolean;