mirror of
https://github.com/podman-desktop/podman-desktop
synced 2026-05-24 10:18:53 +00:00
feat: add a setting to enable/disable recommendations
it is hidden for now as there is no usage fixes https://github.com/containers/podman-desktop/issues/6174 Signed-off-by: Florent Benoit <fbenoit@redhat.com>
This commit is contained in:
parent
287c15d429
commit
76a2d09d76
4 changed files with 121 additions and 0 deletions
|
|
@ -160,6 +160,7 @@ import { DialogRegistry } from './dialog-registry.js';
|
|||
import type { Deferred } from './util/deferred.js';
|
||||
import type { ContextGeneralState, ResourceName } from './kubernetes-context-state.js';
|
||||
import { Updater } from '/@/plugin/updater.js';
|
||||
import { RecommendationsRegistry } from './recommendations/recommendations-registry.js';
|
||||
|
||||
type LogType = 'log' | 'warn' | 'trace' | 'debug' | 'error';
|
||||
|
||||
|
|
@ -453,6 +454,9 @@ export class PluginSystem {
|
|||
const closeBehaviorConfiguration = new CloseBehavior(configurationRegistry);
|
||||
await closeBehaviorConfiguration.init();
|
||||
|
||||
const recommendationsRegistry = new RecommendationsRegistry(configurationRegistry);
|
||||
recommendationsRegistry.init();
|
||||
|
||||
const messageBox = new MessageBox(apiSender);
|
||||
|
||||
// Don't show the tray icon options on Mac
|
||||
|
|
|
|||
|
|
@ -0,0 +1,53 @@
|
|||
/**********************************************************************
|
||||
* Copyright (C) 2024 Red Hat, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
***********************************************************************/
|
||||
|
||||
import { beforeEach, expect, test, vi } from 'vitest';
|
||||
import type { ConfigurationRegistry } from '/@/plugin/configuration-registry.js';
|
||||
import { RecommendationsRegistry } from './recommendations-registry.js';
|
||||
|
||||
let recommendationsRegistry: RecommendationsRegistry;
|
||||
|
||||
const registerConfigurationsMock = vi.fn();
|
||||
|
||||
const configurationRegistryMock = {
|
||||
registerConfigurations: registerConfigurationsMock,
|
||||
} as unknown as ConfigurationRegistry;
|
||||
|
||||
beforeEach(() => {
|
||||
recommendationsRegistry = new RecommendationsRegistry(configurationRegistryMock);
|
||||
});
|
||||
test('should register a configuration', async () => {
|
||||
// register configuration
|
||||
recommendationsRegistry.init();
|
||||
|
||||
// should be the directory provided as env var
|
||||
expect(configurationRegistryMock.registerConfigurations).toBeCalled();
|
||||
|
||||
// take first argument of first call
|
||||
const configurationNode = vi.mocked(configurationRegistryMock).registerConfigurations.mock.calls[0][0][0];
|
||||
expect(configurationNode.id).toBe('preferences.extensions');
|
||||
expect(configurationNode.title).toBe('Extensions');
|
||||
expect(configurationNode.type).toBe('object');
|
||||
expect(configurationNode.properties).toBeDefined();
|
||||
expect(configurationNode.properties?.['extensions.ignoreRecommendations']).toBeDefined();
|
||||
expect(configurationNode.properties?.['extensions.ignoreRecommendations'].description).toBe(
|
||||
'When enabled, the notifications for extension recommendations will not be shown.',
|
||||
);
|
||||
expect(configurationNode.properties?.['extensions.ignoreRecommendations'].type).toBe('boolean');
|
||||
expect(configurationNode.properties?.['extensions.ignoreRecommendations'].default).toBeFalsy();
|
||||
});
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
/**********************************************************************
|
||||
* Copyright (C) 2024 Red Hat, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
***********************************************************************/
|
||||
|
||||
import type { IConfigurationNode, IConfigurationRegistry } from '/@/plugin/configuration-registry.js';
|
||||
import { RecommendationsSettings } from './recommendations-settings.js';
|
||||
|
||||
export class RecommendationsRegistry {
|
||||
constructor(private configurationRegistry: IConfigurationRegistry) {}
|
||||
|
||||
init(): void {
|
||||
const recommendationConfiguration: IConfigurationNode = {
|
||||
id: 'preferences.extensions',
|
||||
title: 'Extensions',
|
||||
type: 'object',
|
||||
properties: {
|
||||
[RecommendationsSettings.SectionName + '.' + RecommendationsSettings.IgnoreRecommendations]: {
|
||||
description: 'When enabled, the notifications for extension recommendations will not be shown.',
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
hidden: true,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
this.configurationRegistry.registerConfigurations([recommendationConfiguration]);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
/**********************************************************************
|
||||
* Copyright (C) 2024 Red Hat, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
***********************************************************************/
|
||||
|
||||
export enum RecommendationsSettings {
|
||||
SectionName = 'extensions',
|
||||
IgnoreRecommendations = 'ignoreRecommendations',
|
||||
}
|
||||
Loading…
Reference in a new issue