mirror of
https://github.com/grafana/grafana.git
synced 2024-11-29 20:24:18 -06:00
Plugins: Show update buttons when instance version is different (#85486)
This commit is contained in:
parent
0bdb96552a
commit
b200156a01
@ -136,6 +136,35 @@ describe('Plugins/Helpers', () => {
|
||||
config.featureToggles.managedPluginsInstall = oldFeatureTogglesManagedPluginsInstall;
|
||||
config.pluginAdminExternalManageEnabled = oldPluginAdminExternalManageEnabled;
|
||||
});
|
||||
|
||||
test('plugins should have update when instance version is different from remote version', () => {
|
||||
const oldFeatureTogglesManagedPluginsInstall = config.featureToggles.managedPluginsInstall;
|
||||
const oldPluginAdminExternalManageEnabled = config.pluginAdminExternalManageEnabled;
|
||||
|
||||
config.featureToggles.managedPluginsInstall = true;
|
||||
config.pluginAdminExternalManageEnabled = true;
|
||||
|
||||
const pluginId = 'plugin-1';
|
||||
const remotePlugin = getRemotePluginMock({ slug: pluginId, version: '1.0.0' });
|
||||
const instancePlugin = {
|
||||
pluginSlug: pluginId,
|
||||
version: '0.0.9',
|
||||
};
|
||||
|
||||
const merged = mergeLocalsAndRemotes({
|
||||
local: [],
|
||||
remote: [remotePlugin],
|
||||
instance: [instancePlugin],
|
||||
});
|
||||
const findMerged = (mergedId: string) => merged.find(({ id }) => id === mergedId);
|
||||
|
||||
expect(merged).toHaveLength(1);
|
||||
expect(findMerged(pluginId)).not.toBeUndefined();
|
||||
expect(findMerged(pluginId)?.hasUpdate).toBe(true);
|
||||
|
||||
config.featureToggles.managedPluginsInstall = oldFeatureTogglesManagedPluginsInstall;
|
||||
config.pluginAdminExternalManageEnabled = oldPluginAdminExternalManageEnabled;
|
||||
});
|
||||
});
|
||||
|
||||
describe('mergeLocalAndRemote()', () => {
|
||||
|
@ -76,6 +76,10 @@ export function mergeLocalsAndRemotes({
|
||||
catalogPlugin.hasUpdate &&
|
||||
catalogPlugin.installedVersion !== instancePlugin?.version;
|
||||
|
||||
if (instancePlugin?.version && instancePlugin?.version !== remotePlugin.version) {
|
||||
catalogPlugin.hasUpdate = true;
|
||||
}
|
||||
|
||||
catalogPlugin.isUninstallingFromInstance = Boolean(localCounterpart) && !instancesMap.has(remotePlugin.slug);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user