mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
[Index Management] Disable certain actions for serverless (#161528)
This commit is contained in:
parent
2e049ce7f2
commit
7c333cdc33
10 changed files with 58 additions and 11 deletions
|
@ -36,6 +36,9 @@ xpack.remote_clusters.enabled: false
|
|||
xpack.snapshot_restore.enabled: false
|
||||
xpack.license_management.enabled: false
|
||||
|
||||
# Disable index management actions from the UI
|
||||
xpack.index_management.enableIndexActions: false
|
||||
|
||||
# Keep deeplinks visible so that they are shown in the sidenav
|
||||
dev_tools.deeplinks.navLinkStatus: visible
|
||||
management.deeplinks.navLinkStatus: visible
|
||||
|
|
|
@ -232,6 +232,7 @@ export default function ({ getService }: PluginFunctionalProviderContext) {
|
|||
'xpack.graph.savePolicy (alternatives)',
|
||||
'xpack.ilm.ui.enabled (boolean)',
|
||||
'xpack.index_management.ui.enabled (boolean)',
|
||||
'xpack.index_management.enableIndexActions (boolean)',
|
||||
'xpack.infra.sources.default.fields.message (array)',
|
||||
/**
|
||||
* xpack.infra.logs is conditional and will resolve to an object of properties
|
||||
|
|
|
@ -225,7 +225,9 @@ describe('<IndexManagementHome />', () => {
|
|||
]);
|
||||
httpRequestsMockHelpers.setReloadIndicesResponse({ indexNames: [indexNameA, indexNameB] });
|
||||
|
||||
testBed = await setup(httpSetup);
|
||||
testBed = await setup(httpSetup, {
|
||||
enableIndexActions: true,
|
||||
});
|
||||
const { component, find } = testBed;
|
||||
|
||||
component.update();
|
||||
|
@ -268,7 +270,9 @@ describe('<IndexManagementHome />', () => {
|
|||
});
|
||||
|
||||
test('should be able to open a closed index', async () => {
|
||||
testBed = await setup(httpSetup);
|
||||
testBed = await setup(httpSetup, {
|
||||
enableIndexActions: true,
|
||||
});
|
||||
const { component, find, actions } = testBed;
|
||||
|
||||
component.update();
|
||||
|
|
|
@ -144,7 +144,7 @@ const getActionMenuButtons = (rendered) => {
|
|||
describe('index table', () => {
|
||||
const { httpSetup, httpRequestsMockHelpers } = initHttpRequests();
|
||||
|
||||
beforeEach(() => {
|
||||
const setupMockComponent = (dependenciesOverride) => {
|
||||
// Mock initialization of services
|
||||
const services = {
|
||||
extensionsService: new ExtensionsService(),
|
||||
|
@ -168,12 +168,13 @@ describe('index table', () => {
|
|||
},
|
||||
plugins: {},
|
||||
url: urlServiceMock,
|
||||
enableIndexActions: true,
|
||||
};
|
||||
|
||||
component = (
|
||||
<Provider store={store}>
|
||||
<MemoryRouter initialEntries={[`${BASE_PATH}indices`]}>
|
||||
<AppContextProvider value={appDependencies}>
|
||||
<AppContextProvider value={{ ...appDependencies, ...dependenciesOverride }}>
|
||||
<AppWithoutRouter />
|
||||
</AppContextProvider>
|
||||
</MemoryRouter>
|
||||
|
@ -181,6 +182,11 @@ describe('index table', () => {
|
|||
);
|
||||
|
||||
store.dispatch(loadIndicesSuccess({ indices }));
|
||||
};
|
||||
|
||||
beforeEach(() => {
|
||||
// Mock initialization of services
|
||||
setupMockComponent();
|
||||
|
||||
httpRequestsMockHelpers.setLoadIndicesResponse(indices);
|
||||
httpRequestsMockHelpers.setReloadIndicesResponse(indices);
|
||||
|
@ -506,4 +512,25 @@ describe('index table', () => {
|
|||
rendered.update();
|
||||
testEditor(rendered, 'editIndexMenuButton');
|
||||
});
|
||||
|
||||
describe('Common index actions', () => {
|
||||
beforeEach(() => {
|
||||
// Mock initialization of services
|
||||
setupMockComponent({ enableIndexActions: false });
|
||||
});
|
||||
|
||||
test('Common index actions should be hidden when feature is turned off', async () => {
|
||||
const rendered = mountWithIntl(component);
|
||||
await runAllPromises();
|
||||
rendered.update();
|
||||
|
||||
expect(findTestSubject(rendered, 'showStatsIndexMenuButton').length).toBe(0);
|
||||
expect(findTestSubject(rendered, 'closeIndexMenuButton').length).toBe(0);
|
||||
expect(findTestSubject(rendered, 'forcemergeIndexMenuButton').length).toBe(0);
|
||||
expect(findTestSubject(rendered, 'refreshIndexMenuButton').length).toBe(0);
|
||||
expect(findTestSubject(rendered, 'clearCacheIndexMenuButton').length).toBe(0);
|
||||
expect(findTestSubject(rendered, 'flushIndexMenuButton').length).toBe(0);
|
||||
expect(findTestSubject(rendered, 'unfreezeIndexMenuButton').length).toBe(0);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -25,7 +25,7 @@ import type { SettingsStart } from '@kbn/core-ui-settings-browser';
|
|||
import { ExtensionsService } from '../services';
|
||||
import { UiMetricService, NotificationService, HttpService } from './services';
|
||||
|
||||
const AppContext = createContext<AppDependencies | undefined>(undefined);
|
||||
export const AppContext = createContext<AppDependencies | undefined>(undefined);
|
||||
|
||||
export interface AppDependencies {
|
||||
core: {
|
||||
|
@ -52,6 +52,7 @@ export interface AppDependencies {
|
|||
docLinks: DocLinksStart;
|
||||
kibanaVersion: SemVer;
|
||||
theme$: Observable<CoreTheme>;
|
||||
enableIndexActions: boolean;
|
||||
}
|
||||
|
||||
export const AppContextProvider = ({
|
||||
|
|
|
@ -52,7 +52,8 @@ export async function mountManagementSection(
|
|||
params: ManagementAppMountParams,
|
||||
extensionsService: ExtensionsService,
|
||||
isFleetEnabled: boolean,
|
||||
kibanaVersion: SemVer
|
||||
kibanaVersion: SemVer,
|
||||
enableIndexActions: boolean
|
||||
) {
|
||||
const { element, setBreadcrumbs, history, theme$ } = params;
|
||||
const [core, startDependencies] = await coreSetup.getStartServices();
|
||||
|
@ -94,6 +95,7 @@ export async function mountManagementSection(
|
|||
uiMetricService,
|
||||
extensionsService,
|
||||
},
|
||||
enableIndexActions,
|
||||
history,
|
||||
setBreadcrumbs,
|
||||
uiSettings,
|
||||
|
|
|
@ -25,9 +25,11 @@ import {
|
|||
|
||||
import { flattenPanelTree } from '../../../../lib/flatten_panel_tree';
|
||||
import { INDEX_OPEN } from '../../../../../../common/constants';
|
||||
import { AppContextConsumer } from '../../../../app_context';
|
||||
import { AppContextConsumer, AppContext } from '../../../../app_context';
|
||||
|
||||
export class IndexActionsContextMenu extends Component {
|
||||
static contextType = AppContext;
|
||||
|
||||
constructor(props) {
|
||||
super(props);
|
||||
|
||||
|
@ -47,6 +49,8 @@ export class IndexActionsContextMenu extends Component {
|
|||
this.setState({ isActionConfirmed });
|
||||
};
|
||||
panels({ services: { extensionsService }, core: { getUrlForApp } }) {
|
||||
const { enableIndexActions } = this.context;
|
||||
|
||||
const {
|
||||
closeIndices,
|
||||
openIndices,
|
||||
|
@ -94,7 +98,7 @@ export class IndexActionsContextMenu extends Component {
|
|||
this.closePopoverAndExecute(showMapping);
|
||||
},
|
||||
});
|
||||
if (allOpen) {
|
||||
if (allOpen && enableIndexActions) {
|
||||
items.push({
|
||||
'data-test-subj': 'showStatsIndexMenuButton',
|
||||
name: i18n.translate('xpack.idxMgmt.indexActionsMenu.showIndexStatsLabel', {
|
||||
|
@ -118,7 +122,7 @@ export class IndexActionsContextMenu extends Component {
|
|||
},
|
||||
});
|
||||
}
|
||||
if (allOpen) {
|
||||
if (allOpen && enableIndexActions) {
|
||||
items.push({
|
||||
'data-test-subj': 'closeIndexMenuButton',
|
||||
name: i18n.translate('xpack.idxMgmt.indexActionsMenu.closeIndexLabel', {
|
||||
|
@ -187,7 +191,7 @@ export class IndexActionsContextMenu extends Component {
|
|||
},
|
||||
});
|
||||
}
|
||||
} else {
|
||||
} else if (!allOpen && enableIndexActions) {
|
||||
items.push({
|
||||
'data-test-subj': 'openIndexMenuButton',
|
||||
name: i18n.translate('xpack.idxMgmt.indexActionsMenu.openIndexLabel', {
|
||||
|
|
|
@ -38,6 +38,7 @@ export class IndexMgmtUIPlugin {
|
|||
): IndexManagementPluginSetup {
|
||||
const {
|
||||
ui: { enabled: isIndexManagementUiEnabled },
|
||||
enableIndexActions,
|
||||
} = this.ctx.config.get<ClientConfigType>();
|
||||
|
||||
if (isIndexManagementUiEnabled) {
|
||||
|
@ -55,7 +56,8 @@ export class IndexMgmtUIPlugin {
|
|||
params,
|
||||
this.extensionsService,
|
||||
Boolean(fleet),
|
||||
kibanaVersion
|
||||
kibanaVersion,
|
||||
enableIndexActions
|
||||
);
|
||||
},
|
||||
});
|
||||
|
|
|
@ -28,4 +28,5 @@ export interface ClientConfigType {
|
|||
ui: {
|
||||
enabled: boolean;
|
||||
};
|
||||
enableIndexActions: boolean;
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ const schemaLatest = schema.object(
|
|||
ui: schema.object({
|
||||
enabled: schema.boolean({ defaultValue: true }),
|
||||
}),
|
||||
enableIndexActions: schema.boolean({ defaultValue: true }),
|
||||
},
|
||||
{ defaultValue: undefined }
|
||||
);
|
||||
|
@ -29,6 +30,7 @@ const schemaLatest = schema.object(
|
|||
const configLatest: PluginConfigDescriptor<IndexManagementConfig> = {
|
||||
exposeToBrowser: {
|
||||
ui: true,
|
||||
enableIndexActions: true,
|
||||
},
|
||||
schema: schemaLatest,
|
||||
deprecations: () => [],
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue