[Upgrade Assistant] Use config for readonly mode (#101296)
This commit is contained in:
parent
b130edfdb4
commit
03bc6bfe31
|
@ -17,7 +17,7 @@ import {
|
||||||
} from 'src/core/public/mocks';
|
} from 'src/core/public/mocks';
|
||||||
import { HttpSetup } from 'src/core/public';
|
import { HttpSetup } from 'src/core/public';
|
||||||
|
|
||||||
import { mockKibanaSemverVersion, UA_READONLY_MODE } from '../../../common/constants';
|
import { mockKibanaSemverVersion } from '../../../common/constants';
|
||||||
import { AppContextProvider } from '../../../public/application/app_context';
|
import { AppContextProvider } from '../../../public/application/app_context';
|
||||||
import { apiService } from '../../../public/application/lib/api';
|
import { apiService } from '../../../public/application/lib/api';
|
||||||
import { breadcrumbService } from '../../../public/application/lib/breadcrumbs';
|
import { breadcrumbService } from '../../../public/application/lib/breadcrumbs';
|
||||||
|
@ -40,7 +40,7 @@ export const WithAppDependencies = (Comp: any, overrides: Record<string, unknown
|
||||||
prevMajor: mockKibanaSemverVersion.major - 1,
|
prevMajor: mockKibanaSemverVersion.major - 1,
|
||||||
nextMajor: mockKibanaSemverVersion.major + 1,
|
nextMajor: mockKibanaSemverVersion.major + 1,
|
||||||
},
|
},
|
||||||
isReadOnlyMode: UA_READONLY_MODE,
|
isReadOnlyMode: false,
|
||||||
notifications: notificationServiceMock.createStartContract(),
|
notifications: notificationServiceMock.createStartContract(),
|
||||||
api: apiService,
|
api: apiService,
|
||||||
breadcrumbs: breadcrumbService,
|
breadcrumbs: breadcrumbService,
|
||||||
|
|
|
@ -9,6 +9,12 @@ import { schema, TypeOf } from '@kbn/config-schema';
|
||||||
|
|
||||||
export const configSchema = schema.object({
|
export const configSchema = schema.object({
|
||||||
enabled: schema.boolean({ defaultValue: true }),
|
enabled: schema.boolean({ defaultValue: true }),
|
||||||
|
/*
|
||||||
|
* This will default to true up until the last minor before the next major.
|
||||||
|
* In readonly mode, the user will not be able to perform any actions in the UI
|
||||||
|
* and will be presented with a message indicating as such.
|
||||||
|
*/
|
||||||
|
readonly: schema.boolean({ defaultValue: true }),
|
||||||
});
|
});
|
||||||
|
|
||||||
export type Config = TypeOf<typeof configSchema>;
|
export type Config = TypeOf<typeof configSchema>;
|
||||||
|
|
|
@ -14,13 +14,6 @@ import SemVer from 'semver/classes/semver';
|
||||||
export const mockKibanaVersion = '8.0.0';
|
export const mockKibanaVersion = '8.0.0';
|
||||||
export const mockKibanaSemverVersion = new SemVer(mockKibanaVersion);
|
export const mockKibanaSemverVersion = new SemVer(mockKibanaVersion);
|
||||||
|
|
||||||
/*
|
|
||||||
* This will be set to true up until the last minor before the next major.
|
|
||||||
* In readonly mode, the user will not be able to perform any actions in the UI
|
|
||||||
* and will be presented with a message indicating as such.
|
|
||||||
*/
|
|
||||||
export const UA_READONLY_MODE = true;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Map of 7.0 --> 8.0 index setting deprecation log messages and associated settings
|
* Map of 7.0 --> 8.0 index setting deprecation log messages and associated settings
|
||||||
* We currently only support one setting deprecation (translog retention), but the code is written
|
* We currently only support one setting deprecation (translog retention), but the code is written
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
|
|
||||||
import { CoreSetup } from 'src/core/public';
|
import { CoreSetup } from 'src/core/public';
|
||||||
import { ManagementAppMountParams } from '../../../../../src/plugins/management/public';
|
import { ManagementAppMountParams } from '../../../../../src/plugins/management/public';
|
||||||
import { UA_READONLY_MODE } from '../../common/constants';
|
|
||||||
import { renderApp } from './render_app';
|
import { renderApp } from './render_app';
|
||||||
import { KibanaVersionContext } from './app_context';
|
import { KibanaVersionContext } from './app_context';
|
||||||
import { apiService } from './lib/api';
|
import { apiService } from './lib/api';
|
||||||
|
@ -17,7 +16,8 @@ export async function mountManagementSection(
|
||||||
coreSetup: CoreSetup,
|
coreSetup: CoreSetup,
|
||||||
isCloudEnabled: boolean,
|
isCloudEnabled: boolean,
|
||||||
params: ManagementAppMountParams,
|
params: ManagementAppMountParams,
|
||||||
kibanaVersionInfo: KibanaVersionContext
|
kibanaVersionInfo: KibanaVersionContext,
|
||||||
|
readonly: boolean
|
||||||
) {
|
) {
|
||||||
const [
|
const [
|
||||||
{ i18n, docLinks, notifications, application, deprecations },
|
{ i18n, docLinks, notifications, application, deprecations },
|
||||||
|
@ -37,7 +37,7 @@ export async function mountManagementSection(
|
||||||
docLinks,
|
docLinks,
|
||||||
kibanaVersionInfo,
|
kibanaVersionInfo,
|
||||||
notifications,
|
notifications,
|
||||||
isReadOnlyMode: UA_READONLY_MODE,
|
isReadOnlyMode: readonly,
|
||||||
history,
|
history,
|
||||||
api: apiService,
|
api: apiService,
|
||||||
breadcrumbs: breadcrumbService,
|
breadcrumbs: breadcrumbService,
|
||||||
|
|
|
@ -22,7 +22,7 @@ interface Dependencies {
|
||||||
export class UpgradeAssistantUIPlugin implements Plugin {
|
export class UpgradeAssistantUIPlugin implements Plugin {
|
||||||
constructor(private ctx: PluginInitializerContext) {}
|
constructor(private ctx: PluginInitializerContext) {}
|
||||||
setup(coreSetup: CoreSetup, { cloud, management }: Dependencies) {
|
setup(coreSetup: CoreSetup, { cloud, management }: Dependencies) {
|
||||||
const { enabled } = this.ctx.config.get<Config>();
|
const { enabled, readonly } = this.ctx.config.get<Config>();
|
||||||
|
|
||||||
if (!enabled) {
|
if (!enabled) {
|
||||||
return;
|
return;
|
||||||
|
@ -61,7 +61,8 @@ export class UpgradeAssistantUIPlugin implements Plugin {
|
||||||
coreSetup,
|
coreSetup,
|
||||||
isCloudEnabled,
|
isCloudEnabled,
|
||||||
params,
|
params,
|
||||||
kibanaVersionInfo
|
kibanaVersionInfo,
|
||||||
|
readonly
|
||||||
);
|
);
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
|
|
|
@ -7,15 +7,16 @@
|
||||||
|
|
||||||
import { PluginInitializerContext, PluginConfigDescriptor } from 'src/core/server';
|
import { PluginInitializerContext, PluginConfigDescriptor } from 'src/core/server';
|
||||||
import { UpgradeAssistantServerPlugin } from './plugin';
|
import { UpgradeAssistantServerPlugin } from './plugin';
|
||||||
import { configSchema } from '../common/config';
|
import { configSchema, Config } from '../common/config';
|
||||||
|
|
||||||
export const plugin = (ctx: PluginInitializerContext) => {
|
export const plugin = (ctx: PluginInitializerContext) => {
|
||||||
return new UpgradeAssistantServerPlugin(ctx);
|
return new UpgradeAssistantServerPlugin(ctx);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const config: PluginConfigDescriptor = {
|
export const config: PluginConfigDescriptor<Config> = {
|
||||||
schema: configSchema,
|
schema: configSchema,
|
||||||
exposeToBrowser: {
|
exposeToBrowser: {
|
||||||
enabled: true,
|
enabled: true,
|
||||||
|
readonly: true,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue