mirror of https://github.com/rancher/dashboard.git
backport pr 15701
This commit is contained in:
parent
ed9fadb70f
commit
ea471451f8
|
|
@ -1,5 +1,7 @@
|
|||
import { IPlugin } from '@shell/core/types';
|
||||
import { PRODUCT_SETTING_NAME, SETTING_PAGE_NAME } from './constants';
|
||||
import { IF_HAVE } from '@shell/store/type-map';
|
||||
import { SCC } from '@shell/store/features';
|
||||
|
||||
// Product configuration
|
||||
export function init($plugin: IPlugin, store: any) {
|
||||
|
|
@ -9,9 +11,11 @@ export function init($plugin: IPlugin, store: any) {
|
|||
} = $plugin.DSL(store, PRODUCT_SETTING_NAME);
|
||||
|
||||
virtualType({
|
||||
labelKey: 'registration.navigation.label',
|
||||
name: SETTING_PAGE_NAME,
|
||||
route: { name: SETTING_PAGE_NAME },
|
||||
ifHave: IF_HAVE.ADMIN,
|
||||
ifFeature: SCC,
|
||||
labelKey: 'registration.navigation.label',
|
||||
name: SETTING_PAGE_NAME,
|
||||
route: { name: SETTING_PAGE_NAME },
|
||||
});
|
||||
|
||||
basicType([SETTING_PAGE_NAME]);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,40 @@
|
|||
import { SCC } from '@shell/store/features';
|
||||
const { IF_HAVE } = require('@shell/store/type-map');
|
||||
|
||||
jest.doMock('@rancher/auto-import', () => ({ importTypes: jest.fn() }), { virtual: true });
|
||||
|
||||
describe('extension: rancher-prime', () => {
|
||||
it('should enable routing for admin users with SCC feature', async() => {
|
||||
const plugin = await import('./index'); // initialized after the mock
|
||||
const virtualTypeSpy = jest.fn();
|
||||
const basicTypeSpy = jest.fn();
|
||||
const dslMock = jest.fn().mockReturnValue({
|
||||
virtualType: virtualTypeSpy,
|
||||
basicType: basicTypeSpy
|
||||
});
|
||||
|
||||
const pluginMock = {
|
||||
environment: { isPrime: true },
|
||||
addProduct: jest.fn(),
|
||||
addRoutes: jest.fn(),
|
||||
addPanel: jest.fn(),
|
||||
addNavHooks: jest.fn(),
|
||||
register: jest.fn(), // Used in installDocHandler
|
||||
metadata: {},
|
||||
DSL: dslMock
|
||||
} as any;
|
||||
|
||||
plugin.default(pluginMock); // basic extension import
|
||||
pluginMock.addProduct.mock.calls[0][0].init(pluginMock, {}); // force init to trigger as in @rancher/shell
|
||||
|
||||
expect(pluginMock.addProduct).toHaveBeenCalledWith(
|
||||
expect.objectContaining({ init: expect.any(Function) })
|
||||
);
|
||||
expect(virtualTypeSpy).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
ifHave: IF_HAVE.ADMIN,
|
||||
ifFeature: SCC
|
||||
})
|
||||
);
|
||||
});
|
||||
});
|
||||
|
|
@ -53,8 +53,8 @@ const poolRegistration = (store: Store<any>) => {
|
|||
if (store.state['managementReady']) {
|
||||
setNotification(store);
|
||||
clearInterval(id);
|
||||
attempts -= 1;
|
||||
}
|
||||
attempts -= 1;
|
||||
}, 1000);
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ export const STEVE_CACHE = create('ui-sql-cache', false);
|
|||
export const UIEXTENSION = create('uiextension', true);
|
||||
export const PROVISIONING_PRE_BOOTSTRAP = create('provisioningprebootstrap', false);
|
||||
export const SCHEDULING_CUSTOMIZATION = create(SCHEDULING_CUSTOMIZATION_FEATURE, false);
|
||||
export const SCC = create('rancher-scc-registration-extension', true);
|
||||
|
||||
// Not currently used.. no point defining ones we don't use
|
||||
// export const EMBEDDED_CLUSTER_API = create('embedded-cluster-api', true);
|
||||
|
|
|
|||
Loading…
Reference in New Issue