diff --git a/config/opensearch_dashboards.yml b/config/opensearch_dashboards.yml index 6bb4f63bbbde..b5b8adad9a32 100644 --- a/config/opensearch_dashboards.yml +++ b/config/opensearch_dashboards.yml @@ -237,3 +237,5 @@ #data_source.encryption.wrappingKeyName: 'changeme' #data_source.encryption.wrappingKeyNamespace: 'changeme' #data_source.encryption.wrappingKey: [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] + +#opensearchDashboards.isSurveyAllowed: true \ No newline at end of file diff --git a/src/core/public/chrome/chrome_service.tsx b/src/core/public/chrome/chrome_service.tsx index da5cbda1c92a..7302ae735264 100644 --- a/src/core/public/chrome/chrome_service.tsx +++ b/src/core/public/chrome/chrome_service.tsx @@ -262,6 +262,7 @@ export class ChromeService { onIsLockedUpdate={setIsNavDrawerLocked} isLocked$={getIsNavDrawerLocked$} branding={injectedMetadata.getBranding()} + isSurveyAllowed={injectedMetadata.getIsSurveyAllowed()} /> ), diff --git a/src/core/public/chrome/ui/header/header.test.tsx b/src/core/public/chrome/ui/header/header.test.tsx index 5f45f994c765..f7b2786cc2cc 100644 --- a/src/core/public/chrome/ui/header/header.test.tsx +++ b/src/core/public/chrome/ui/header/header.test.tsx @@ -75,6 +75,7 @@ function mockProps() { mark: { defaultUrl: '/' }, applicationTitle: 'OpenSearch Dashboards', }, + isSurveyAllowed: true, }; } diff --git a/src/core/public/chrome/ui/header/header.tsx b/src/core/public/chrome/ui/header/header.tsx index d26105914fde..bac1ebebce17 100644 --- a/src/core/public/chrome/ui/header/header.tsx +++ b/src/core/public/chrome/ui/header/header.tsx @@ -89,6 +89,7 @@ export interface HeaderProps { loadingCount$: ReturnType; onIsLockedUpdate: OnIsLockedUpdate; branding: ChromeBranding; + isSurveyAllowed: boolean; } export function Header({ @@ -99,6 +100,7 @@ export function Header({ onIsLockedUpdate, homeHref, branding, + isSurveyAllowed, ...observables }: HeaderProps) { const isVisible = useObservable(observables.isVisible$, false); @@ -220,6 +222,7 @@ export function Header({ helpSupportUrl$={observables.helpSupportUrl$} opensearchDashboardsDocLink={opensearchDashboardsDocLink} opensearchDashboardsVersion={opensearchDashboardsVersion} + isSurveyAllowed={isSurveyAllowed} /> diff --git a/src/core/public/chrome/ui/header/header_help_menu.tsx b/src/core/public/chrome/ui/header/header_help_menu.tsx index 55cf163214df..744d87663504 100644 --- a/src/core/public/chrome/ui/header/header_help_menu.tsx +++ b/src/core/public/chrome/ui/header/header_help_menu.tsx @@ -126,6 +126,7 @@ interface Props { opensearchDashboardsVersion: string; useDefaultContent?: boolean; opensearchDashboardsDocLink: string; + isSurveyAllowed: boolean; } interface State { @@ -202,8 +203,21 @@ class HeaderHelpMenuUI extends Component { opensearchDashboardsVersion, useDefaultContent, opensearchDashboardsDocLink, + isSurveyAllowed, } = this.props; const { helpExtension, helpSupportUrl } = this.state; + const opensearchSurvey = isSurveyAllowed ? ( +
+ + + + + +
+ ) : null; const defaultContent = useDefaultContent ? ( @@ -225,14 +239,7 @@ class HeaderHelpMenuUI extends Component { - - - - - + {opensearchSurvey} { getInjectedVars: jest.fn(), getOpenSearchDashboardsBuildNumber: jest.fn(), getBranding: jest.fn(), + getIsSurveyAllowed: jest.fn(), }; setupContract.getCspConfig.mockReturnValue({ warnLegacyBrowsers: true }); setupContract.getOpenSearchDashboardsVersion.mockReturnValue('opensearchDashboardsVersion'); diff --git a/src/core/public/injected_metadata/injected_metadata_service.ts b/src/core/public/injected_metadata/injected_metadata_service.ts index 0bbf4549dd01..5c37d92445e6 100644 --- a/src/core/public/injected_metadata/injected_metadata_service.ts +++ b/src/core/public/injected_metadata/injected_metadata_service.ts @@ -75,6 +75,7 @@ export interface InjectedMetadataParams { }; }; branding: Branding; + isSurveyAllowed: boolean; }; } @@ -146,6 +147,10 @@ export class InjectedMetadataService { getBranding: () => { return this.state.branding; }, + + getIsSurveyAllowed: () => { + return this.state.isSurveyAllowed; + }, }; } } @@ -180,6 +185,7 @@ export interface InjectedMetadataSetup { [key: string]: unknown; }; getBranding: () => Branding; + getIsSurveyAllowed: () => boolean; } /** @internal */ diff --git a/src/core/server/opensearch_dashboards_config.ts b/src/core/server/opensearch_dashboards_config.ts index f2c6bcdf31c5..de054039df24 100644 --- a/src/core/server/opensearch_dashboards_config.ts +++ b/src/core/server/opensearch_dashboards_config.ts @@ -85,6 +85,9 @@ export const config = { defaultValue: true, }), }), + isSurveyAllowed: schema.boolean({ + defaultValue: true, + }), }), deprecations, }; diff --git a/src/core/server/rendering/rendering_service.tsx b/src/core/server/rendering/rendering_service.tsx index 2362be550078..062d6a4fe979 100644 --- a/src/core/server/rendering/rendering_service.tsx +++ b/src/core/server/rendering/rendering_service.tsx @@ -153,6 +153,7 @@ export class RenderingService { applicationTitle: brandingAssignment.applicationTitle, useExpandedHeader: brandingAssignment.useExpandedHeader, }, + isSurveyAllowed: opensearchDashboardsConfig.isSurveyAllowed, }, }; diff --git a/src/core/server/rendering/types.ts b/src/core/server/rendering/types.ts index 79b016329f76..169245e84619 100644 --- a/src/core/server/rendering/types.ts +++ b/src/core/server/rendering/types.ts @@ -74,6 +74,7 @@ export interface RenderingMetadata { }; }; branding: Branding; + isSurveyAllowed: boolean; }; } diff --git a/src/core/server/rendering/views/template.test.tsx b/src/core/server/rendering/views/template.test.tsx index f009f12eb892..dd2d7fc73ccc 100644 --- a/src/core/server/rendering/views/template.test.tsx +++ b/src/core/server/rendering/views/template.test.tsx @@ -52,6 +52,7 @@ function mockProps() { }, }, branding: injectedMetadata.getBranding(), + isSurveyAllowed: injectedMetadata.getIsSurveyAllowed(), }, }; } diff --git a/src/legacy/server/config/schema.js b/src/legacy/server/config/schema.js index 7e7574d62009..06027ea3a16e 100644 --- a/src/legacy/server/config/schema.js +++ b/src/legacy/server/config/schema.js @@ -247,6 +247,7 @@ export default () => applicationTitle: Joi.any().default(''), useExpandedHeader: Joi.boolean().default(true), }), + isSurveyAllowed: Joi.boolean().default(true), }).default(), savedObjects: HANDLED_IN_NEW_PLATFORM,