Plugins: Move raiseanissueurl from plugin object to plugin details (#101428)
* move raiseanissueurl from plugin object to plugin details * updated the test for PluginDetailsPane;
This commit is contained in:
@@ -39,6 +39,7 @@ export async function getPluginDetails(id: string): Promise<CatalogPluginDetails
|
||||
changelog: remote?.changelog || localChangelog,
|
||||
licenseUrl: remote?.licenseUrl,
|
||||
documentationUrl: remote?.documentationUrl,
|
||||
raiseAnIssueUrl: remote?.raiseAnIssueUrl,
|
||||
signatureType: local?.signatureType || (remote?.signatureType !== '' ? remote?.signatureType : undefined),
|
||||
signature: local?.signature,
|
||||
};
|
||||
|
||||
@@ -54,6 +54,22 @@ const mockPlugin: CatalogPlugin = {
|
||||
name: 'Website',
|
||||
url: 'https://test-plugin.com',
|
||||
},
|
||||
{
|
||||
name: 'Repository',
|
||||
url: 'https://github.com/grafana/test-plugin',
|
||||
},
|
||||
{
|
||||
name: 'License',
|
||||
url: 'https://github.com/grafana/test-plugin/blob/main/LICENSE',
|
||||
},
|
||||
{
|
||||
name: 'Documentation',
|
||||
url: 'https://test-plugin.com/docs',
|
||||
},
|
||||
{
|
||||
name: 'Raise issue',
|
||||
url: 'https://github.com/grafana/test-plugin/issues/new',
|
||||
},
|
||||
],
|
||||
grafanaDependency: '>=9.0.0',
|
||||
statusContext: 'stable',
|
||||
@@ -118,4 +134,20 @@ describe('PluginDetailsPanel', () => {
|
||||
const panel = screen.getByTestId('plugin-details-panel');
|
||||
expect(panel).toHaveStyle({ width: '300px' });
|
||||
});
|
||||
|
||||
it('should render license, documentation, repository, raise issue links', () => {
|
||||
render(<PluginDetailsPanel plugin={mockPlugin} pluginExtentionsInfo={mockInfo} />);
|
||||
const repositoryLink = screen.getByText('Repository');
|
||||
const licenseLink = screen.getByText('License');
|
||||
const documentationLink = screen.getByText('Documentation');
|
||||
const raiseIssueLink = screen.getByText('Raise issue');
|
||||
expect(repositoryLink).toBeInTheDocument();
|
||||
expect(repositoryLink).toHaveAttribute('href', 'https://github.com/grafana/test-plugin');
|
||||
expect(licenseLink).toBeInTheDocument();
|
||||
expect(licenseLink).toHaveAttribute('href', 'https://github.com/grafana/test-plugin/blob/main/LICENSE');
|
||||
expect(documentationLink).toBeInTheDocument();
|
||||
expect(documentationLink).toHaveAttribute('href', 'https://test-plugin.com/docs');
|
||||
expect(raiseIssueLink).toBeInTheDocument();
|
||||
expect(raiseIssueLink).toHaveAttribute('href', 'https://github.com/grafana/test-plugin/issues/new');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -99,8 +99,14 @@ export function PluginDetailsPanel(props: Props): React.ReactElement | null {
|
||||
<Trans i18nKey="plugins.details.labels.repository">Repository</Trans>
|
||||
</LinkButton>
|
||||
)}
|
||||
{plugin.raiseAnIssueUrl && (
|
||||
<LinkButton href={plugin.raiseAnIssueUrl} variant="secondary" fill="solid" icon="bug" target="_blank">
|
||||
{plugin.details?.raiseAnIssueUrl && (
|
||||
<LinkButton
|
||||
href={plugin.details?.raiseAnIssueUrl}
|
||||
variant="secondary"
|
||||
fill="solid"
|
||||
icon="bug"
|
||||
target="_blank"
|
||||
>
|
||||
<Trans i18nKey="plugins.details.labels.raiseAnIssue">Raise an issue</Trans>
|
||||
</LinkButton>
|
||||
)}
|
||||
|
||||
@@ -122,7 +122,6 @@ export function mapRemoteToCatalog(plugin: RemotePlugin, error?: PluginError): C
|
||||
versionSignatureType,
|
||||
versionSignedByOrgName,
|
||||
url,
|
||||
raiseAnIssueUrl,
|
||||
} = plugin;
|
||||
|
||||
const isDisabled = !!error || isDisabledSecretsPlugin(typeCode);
|
||||
@@ -161,7 +160,6 @@ export function mapRemoteToCatalog(plugin: RemotePlugin, error?: PluginError): C
|
||||
isFullyInstalled: isDisabled,
|
||||
latestVersion: plugin.version,
|
||||
url,
|
||||
raiseAnIssueUrl,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -178,7 +176,6 @@ export function mapLocalToCatalog(plugin: LocalPlugin, error?: PluginError): Cat
|
||||
hasUpdate,
|
||||
accessControl,
|
||||
angularDetected,
|
||||
raiseAnIssueUrl,
|
||||
} = plugin;
|
||||
|
||||
const isDisabled = !!error || isDisabledSecretsPlugin(type);
|
||||
@@ -213,7 +210,6 @@ export function mapLocalToCatalog(plugin: LocalPlugin, error?: PluginError): Cat
|
||||
isFullyInstalled: true,
|
||||
iam: plugin.iam,
|
||||
latestVersion: plugin.latestVersion,
|
||||
raiseAnIssueUrl,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -278,7 +274,6 @@ export function mapToCatalogPlugin(local?: LocalPlugin, remote?: RemotePlugin, e
|
||||
iam: local?.iam,
|
||||
latestVersion: local?.latestVersion || remote?.version || '',
|
||||
url: remote?.url || '',
|
||||
raiseAnIssueUrl: remote?.raiseAnIssueUrl || local?.raiseAnIssueUrl,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -65,7 +65,6 @@ export interface CatalogPlugin extends WithAccessControlMetadata {
|
||||
iam?: IdentityAccessManagement;
|
||||
isProvisioned?: boolean;
|
||||
url?: string;
|
||||
raiseAnIssueUrl?: string;
|
||||
}
|
||||
|
||||
export interface CatalogPluginDetails {
|
||||
@@ -83,6 +82,7 @@ export interface CatalogPluginDetails {
|
||||
lastCommitDate?: string;
|
||||
licenseUrl?: string;
|
||||
documentationUrl?: string;
|
||||
raiseAnIssueUrl?: string;
|
||||
signatureType?: PluginSignatureType;
|
||||
signature?: PluginSignatureStatus;
|
||||
}
|
||||
@@ -197,7 +197,6 @@ export type LocalPlugin = WithAccessControlMetadata & {
|
||||
dependencies: PluginDependencies;
|
||||
angularDetected: boolean;
|
||||
iam?: IdentityAccessManagement;
|
||||
raiseAnIssueUrl?: string;
|
||||
};
|
||||
|
||||
interface IdentityAccessManagement {
|
||||
|
||||
Reference in New Issue
Block a user