mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
[Guided onboarding] Change the saved objects' type to hidden (#148983)
## Summary Making the saved objects hidden will prevent other plugins accidentally updating the guided onboarding data directly via the SO client. This was recommended by the Core team and I think it should be safe to change the type since there should not be any existing SO in deployments prior to 8.7 yet.
This commit is contained in:
parent
8705a6a77b
commit
867a55274c
3 changed files with 15 additions and 5 deletions
|
@ -9,6 +9,7 @@
|
|||
import { IRouter, SavedObjectsClient } from '@kbn/core/server';
|
||||
import { API_BASE_PATH } from '../../common';
|
||||
import { findAllGuides } from '../helpers';
|
||||
import { guideStateSavedObjectsType } from '../saved_objects';
|
||||
|
||||
export const registerGetGuideStateRoute = (router: IRouter) => {
|
||||
// Fetch all guides state
|
||||
|
@ -19,7 +20,9 @@ export const registerGetGuideStateRoute = (router: IRouter) => {
|
|||
},
|
||||
async (context, request, response) => {
|
||||
const coreContext = await context.core;
|
||||
const soClient = coreContext.savedObjects.client as SavedObjectsClient;
|
||||
const soClient = coreContext.savedObjects.getClient({
|
||||
includedHiddenTypes: [guideStateSavedObjectsType],
|
||||
}) as SavedObjectsClient;
|
||||
|
||||
const existingGuides = await findAllGuides(soClient);
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
import { IRouter, SavedObjectsClient } from '@kbn/core/server';
|
||||
import { schema } from '@kbn/config-schema';
|
||||
import { GuideState } from '@kbn/guided-onboarding';
|
||||
import { guideStateSavedObjectsType, pluginStateSavedObjectsType } from '../saved_objects';
|
||||
import { getPluginState, updatePluginStatus } from '../helpers/plugin_state_utils';
|
||||
import { API_BASE_PATH } from '../../common';
|
||||
import { updateGuideState } from '../helpers';
|
||||
|
@ -21,7 +22,9 @@ export const registerGetPluginStateRoute = (router: IRouter) => {
|
|||
},
|
||||
async (context, request, response) => {
|
||||
const coreContext = await context.core;
|
||||
const savedObjectsClient = coreContext.savedObjects.client as SavedObjectsClient;
|
||||
const savedObjectsClient = coreContext.savedObjects.getClient({
|
||||
includedHiddenTypes: [pluginStateSavedObjectsType, guideStateSavedObjectsType],
|
||||
}) as SavedObjectsClient;
|
||||
const pluginState = await getPluginState(savedObjectsClient);
|
||||
return response.ok({
|
||||
body: {
|
||||
|
@ -59,7 +62,9 @@ export const registerPutPluginStateRoute = (router: IRouter) => {
|
|||
const { status, guide } = request.body as { status?: string; guide?: GuideState };
|
||||
|
||||
const coreContext = await context.core;
|
||||
const savedObjectsClient = coreContext.savedObjects.client as SavedObjectsClient;
|
||||
const savedObjectsClient = coreContext.savedObjects.getClient({
|
||||
includedHiddenTypes: [pluginStateSavedObjectsType, guideStateSavedObjectsType],
|
||||
}) as SavedObjectsClient;
|
||||
|
||||
if (status) {
|
||||
await updatePluginStatus(savedObjectsClient, status);
|
||||
|
|
|
@ -12,7 +12,8 @@ export const guideStateSavedObjectsType = 'guided-onboarding-guide-state';
|
|||
|
||||
export const guideStateSavedObjects: SavedObjectsType = {
|
||||
name: guideStateSavedObjectsType,
|
||||
hidden: false,
|
||||
// hidden SO can't be changed by the SO client except when explicitly declared
|
||||
hidden: true,
|
||||
// make it available in all spaces for now https://github.com/elastic/kibana/issues/144227
|
||||
namespaceType: 'agnostic',
|
||||
mappings: {
|
||||
|
@ -33,7 +34,8 @@ export const pluginStateSavedObjectsId = 'guided-onboarding-plugin-state-id';
|
|||
|
||||
export const pluginStateSavedObjects: SavedObjectsType = {
|
||||
name: pluginStateSavedObjectsType,
|
||||
hidden: false,
|
||||
// hidden SO can't be changed by the SO client except when explicitly declared
|
||||
hidden: true,
|
||||
// make it available in all spaces for now https://github.com/elastic/kibana/issues/144227
|
||||
namespaceType: 'agnostic',
|
||||
mappings: {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue