Skip to content

Commit

Permalink
moved config option for allowing or disallowing by value embeddables …
Browse files Browse the repository at this point in the history
…to dashboard plugin (elastic#73870) (elastic#73961)
  • Loading branch information
ThomThomson committed Jul 31, 2020
1 parent fefbbd5 commit bc83679
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 1 deletion.
26 changes: 26 additions & 0 deletions src/plugins/dashboard/config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you 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.
*/

import { schema, TypeOf } from '@kbn/config-schema';

export const configSchema = schema.object({
allowByValueEmbeddables: schema.boolean({ defaultValue: false }),
});

export type ConfigSchema = TypeOf<typeof configSchema>;
6 changes: 6 additions & 0 deletions src/plugins/dashboard/public/plugin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ declare module '../../share/public' {

export type DashboardUrlGenerator = UrlGeneratorContract<typeof DASHBOARD_APP_URL_GENERATOR>;

interface DashboardFeatureFlagConfig {
allowByValueEmbeddables: boolean;
}

interface SetupDependencies {
data: DataPublicPluginSetup;
embeddable: EmbeddableSetup;
Expand Down Expand Up @@ -125,6 +129,7 @@ export interface DashboardStart {
embeddableType: string;
}) => void | undefined;
dashboardUrlGenerator?: DashboardUrlGenerator;
dashboardFeatureFlagConfig: DashboardFeatureFlagConfig;
DashboardContainerByValueRenderer: ReturnType<typeof createDashboardContainerByValueRenderer>;
}

Expand Down Expand Up @@ -411,6 +416,7 @@ export class DashboardPlugin
getSavedDashboardLoader: () => savedDashboardLoader,
addEmbeddableToDashboard: this.addEmbeddableToDashboard.bind(this, core),
dashboardUrlGenerator: this.dashboardUrlGenerator,
dashboardFeatureFlagConfig: this.initializerContext.config.get<DashboardFeatureFlagConfig>(),
DashboardContainerByValueRenderer: createDashboardContainerByValueRenderer({
factory: dashboardContainerFactory,
}),
Expand Down
10 changes: 9 additions & 1 deletion src/plugins/dashboard/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,16 @@
* under the License.
*/

import { PluginInitializerContext } from '../../../core/server';
import { PluginInitializerContext, PluginConfigDescriptor } from '../../../core/server';
import { DashboardPlugin } from './plugin';
import { configSchema, ConfigSchema } from '../config';

export const config: PluginConfigDescriptor<ConfigSchema> = {
exposeToBrowser: {
allowByValueEmbeddables: true,
},
schema: configSchema,
};

// This exports static code and TypeScript types,
// as well as, Kibana Platform `plugin()` initializer.
Expand Down

0 comments on commit bc83679

Please sign in to comment.