diff --git a/config/opensearch_dashboards.yml b/config/opensearch_dashboards.yml index 9c1ba20aa5cd..af662c0c972a 100644 --- a/config/opensearch_dashboards.yml +++ b/config/opensearch_dashboards.yml @@ -151,16 +151,15 @@ # ] #vis_type_timeline.graphiteBlockedIPs: [] -# full version customized logo URL -# opensearchDashboards.branding.fullLogoUrl: "" - -# smaller version customized logo URL -# opensearchDashboards.branding.logoUrl: "" - -# customized loading logo URL -# opensearchDashboards.branding.loadingLogoUrl: "" - -# custom application title -# opensearchDashboards.branding.title: "" - - +#opensearchDashboards.branding: + #logo: + #default: "" + #darkmode: "" + #mark: + #default: "" + #darkmode: "" + #loadingLogo: + #default: "" + #darkmode: "" + #favicon: "" + #title: "" \ No newline at end of file diff --git a/src/core/public/chrome/ui/header/__snapshots__/header.test.tsx.snap b/src/core/public/chrome/ui/header/__snapshots__/header.test.tsx.snap index 8421a105e5f0..7159521708da 100644 --- a/src/core/public/chrome/ui/header/__snapshots__/header.test.tsx.snap +++ b/src/core/public/chrome/ui/header/__snapshots__/header.test.tsx.snap @@ -249,8 +249,12 @@ exports[`Header renders 1`] = ` } branding={ Object { - "fullLogoUrl": "/", - "logoUrl": "/", + "logo": Object { + "default": "/", + }, + "mark": Object { + "default": "/", + }, "title": "OpenSearch Dashboards", } } @@ -1674,8 +1678,12 @@ exports[`Header renders 1`] = ` - OpenSearch Dashboards logo +
+ OpenSearch Dashboards logo +
diff --git a/src/core/public/chrome/ui/header/branding/__snapshots__/opensearch_dashboards_custom_logo.test.tsx.snap b/src/core/public/chrome/ui/header/branding/__snapshots__/opensearch_dashboards_custom_logo.test.tsx.snap index db236fc6c534..93560dba7e56 100644 --- a/src/core/public/chrome/ui/header/branding/__snapshots__/opensearch_dashboards_custom_logo.test.tsx.snap +++ b/src/core/public/chrome/ui/header/branding/__snapshots__/opensearch_dashboards_custom_logo.test.tsx.snap @@ -2,7 +2,6 @@ exports[`Custom Logo Take in a normal full logo URL string 1`] = ` - title logo +
+ title logo +
`; @@ -222,17 +231,26 @@ exports[`Custom Logo Take in an invalid full logo URL string and a valid logo UR "timeZone": null, } } - logoUrl="/custom" + logo={Object {}} + mark={ + Object { + "default": "/", + } + } title="title" > - title logo +
+ title logo +
`; @@ -340,6 +358,8 @@ exports[`Custom Logo Take in invalid full logo URL and logo URL 1`] = ` "timeZone": null, } } + logo={Object {}} + mark={Object {}} title="title" > { it('Take in a normal full logo URL string', () => { - const branding = { fullLogoUrl: '/custom', title: 'title' }; + const branding = { + logo: { default: '/' }, + mark: {}, + title: 'title', + }; const component = mountWithIntl(); expect(component).toMatchSnapshot(); }); it('Take in an invalid full logo URL string and a valid logo URL string', () => { - const branding = { logoUrl: '/custom', title: 'title' }; + const branding = { + logo: {}, + mark: { default: '/' }, + title: 'title', + }; const component = mountWithIntl(); expect(component).toMatchSnapshot(); }); it('Take in invalid full logo URL and logo URL', () => { - const branding = { title: 'title' }; + const branding = { + logo: {}, + mark: {}, + title: 'title', + }; const component = mountWithIntl(); expect(component).toMatchSnapshot(); }); diff --git a/src/core/public/chrome/ui/header/branding/opensearch_dashboards_custom_logo.tsx b/src/core/public/chrome/ui/header/branding/opensearch_dashboards_custom_logo.tsx index ce1c4eecd859..dafc635426f9 100644 --- a/src/core/public/chrome/ui/header/branding/opensearch_dashboards_custom_logo.tsx +++ b/src/core/public/chrome/ui/header/branding/opensearch_dashboards_custom_logo.tsx @@ -40,30 +40,38 @@ import { OpenSearchDashboardsLogoDarkMode } from './opensearch_dashboards_logo_d * @param {string} title - custom title for the application */ export interface CustomLogoType { - fullLogoUrl?: string; - logoUrl?: string; - title: string; + logo: { + default?: string; + darkmode?: string; + }; + mark: { + default?: string; + darkmode?: string; + }; + title?: string; } /** * - * @param {CustomLogoType} - branding object consist of fullLogoUrl, logoUrl and title + * @param {CustomLogoType} - branding object consist of logo, mark and title * @returns A image component which is going to be rendered on the main page header bar. - * If fullLogoUrl is valid, the full logo by fullLogoUrl config will be rendered; - * if not, the logo icon by logoUrl config will be rendered; if both are not found, + * If logo default is valid, the full logo by logo default config will be rendered; + * if not, the logo icon by mark default config will be rendered; if both are not found, * the default opensearch logo will be rendered. */ export const CustomLogo = ({ ...branding }: CustomLogoType) => { - const headerLogoUrl = !branding.fullLogoUrl ? branding.logoUrl : branding.fullLogoUrl; - return !branding.fullLogoUrl && !branding.logoUrl ? ( + const headerLogoUrl = !branding.logo.default ? branding.mark.default : branding.logo.default; + return !branding.logo.default && !branding.mark.default ? ( OpenSearchDashboardsLogoDarkMode() ) : ( - {branding.title +
+ {branding.title +
); }; diff --git a/src/core/public/chrome/ui/header/header.test.tsx b/src/core/public/chrome/ui/header/header.test.tsx index 9a3ca4ece870..b9b557f29091 100644 --- a/src/core/public/chrome/ui/header/header.test.tsx +++ b/src/core/public/chrome/ui/header/header.test.tsx @@ -69,7 +69,11 @@ function mockProps() { isLocked$: new BehaviorSubject(false), loadingCount$: new BehaviorSubject(0), onIsLockedUpdate: () => {}, - branding: { fullLogoUrl: '/', logoUrl: '/', title: 'OpenSearch Dashboards' }, + branding: { + logo: { default: '/' }, + mark: { default: '/' }, + title: 'OpenSearch Dashboards', + }, }; } diff --git a/src/core/public/chrome/ui/header/header.tsx b/src/core/public/chrome/ui/header/header.tsx index 8555342503ab..178b602a97ad 100644 --- a/src/core/public/chrome/ui/header/header.tsx +++ b/src/core/public/chrome/ui/header/header.tsx @@ -87,7 +87,17 @@ export interface HeaderProps { isLocked$: Observable; loadingCount$: ReturnType; onIsLockedUpdate: OnIsLockedUpdate; - branding: { fullLogoUrl?: string; logoUrl?: string; title: string }; + branding: { + logo: { + default?: string; + darkmode?: string; + }; + mark: { + default?: string; + darkmode?: string; + }; + title?: string; + }; } export function Header({ diff --git a/src/core/public/chrome/ui/header/header_logo.scss b/src/core/public/chrome/ui/header/header_logo.scss index 81761217851f..1aa9be7e9acf 100644 --- a/src/core/public/chrome/ui/header/header_logo.scss +++ b/src/core/public/chrome/ui/header/header_logo.scss @@ -3,7 +3,7 @@ padding: 3px 3px 3px 10px; } -.logoImage{ +.logoImage { height: 100%; max-width: 100%; } \ No newline at end of file diff --git a/src/core/public/index.ts b/src/core/public/index.ts index 52b9d24e5b84..7fd3b0188574 100644 --- a/src/core/public/index.ts +++ b/src/core/public/index.ts @@ -237,9 +237,11 @@ export interface CoreSetup unknown; getBranding: () => { - fullLogoUrl?: string; - logoUrl?: string; - title: string; + mark: { + default?: string; + darkmode?: string; + }; + title?: string; }; }; /** {@link StartServicesAccessor} */ @@ -297,9 +299,11 @@ export interface CoreStart { injectedMetadata: { getInjectedVar: (name: string, defaultValue?: any) => unknown; getBranding: () => { - fullLogoUrl?: string; - logoUrl?: string; - title: string; + mark: { + default?: string; + darkmode?: string; + }; + title?: string; }; }; } diff --git a/src/core/public/injected_metadata/injected_metadata_service.ts b/src/core/public/injected_metadata/injected_metadata_service.ts index ee69c8208267..ade3494cc38c 100644 --- a/src/core/public/injected_metadata/injected_metadata_service.ts +++ b/src/core/public/injected_metadata/injected_metadata_service.ts @@ -77,9 +77,20 @@ export interface InjectedMetadataParams { }; }; branding: { - fullLogoUrl?: string; - logoUrl?: string; - title: string; + logo: { + default?: string; + darkmode?: string; + }; + mark: { + default?: string; + darkmode?: string; + }; + loadingLogo: { + default?: string; + darkmode?: string; + }; + favicon?: string; + title?: string; }; }; } @@ -186,9 +197,20 @@ export interface InjectedMetadataSetup { [key: string]: unknown; }; getBranding: () => { - fullLogoUrl?: string; - logoUrl?: string; - title: string; + logo: { + default?: string; + darkmode?: string; + }; + mark: { + default?: string; + darkmode?: string; + }; + loadingLogo: { + default?: string; + darkmode?: string; + }; + favicon?: string; + title?: string; }; } diff --git a/src/core/server/opensearch_dashboards_config.ts b/src/core/server/opensearch_dashboards_config.ts index c3f2c7821c26..ae72805ba161 100644 --- a/src/core/server/opensearch_dashboards_config.ts +++ b/src/core/server/opensearch_dashboards_config.ts @@ -53,16 +53,36 @@ export const config = { autocompleteTerminateAfter: schema.duration({ defaultValue: 100000 }), autocompleteTimeout: schema.duration({ defaultValue: 1000 }), branding: schema.object({ - fullLogoUrl: schema.string({ - defaultValue: '/', + logo: schema.object({ + default: schema.string({ + defaultValue: '/', + }), + darkmode: schema.string({ + defaultValue: '/', + }), }), - logoUrl: schema.string({ - defaultValue: '/', + mark: schema.object({ + default: schema.string({ + defaultValue: '/', + }), + darkmode: schema.string({ + defaultValue: '/', + }), }), - loadingLogoUrl: schema.string({ + loadingLogo: schema.object({ + default: schema.string({ + defaultValue: '/', + }), + darkmode: schema.string({ + defaultValue: '/', + }), + }), + favicon: schema.string({ defaultValue: '/', }), - title: schema.string({ defaultValue: '' }), + title: schema.string({ + defaultValue: '', + }), }), }), deprecations, diff --git a/src/core/server/rendering/__snapshots__/rendering_service.test.ts.snap b/src/core/server/rendering/__snapshots__/rendering_service.test.ts.snap index 762269e81086..0145922a3da6 100644 --- a/src/core/server/rendering/__snapshots__/rendering_service.test.ts.snap +++ b/src/core/server/rendering/__snapshots__/rendering_service.test.ts.snap @@ -6,6 +6,16 @@ Object { "basePath": "/mock-server-basepath", "branch": Any, "branding": Object { + "favicon": "", + "loadingLogo": Object { + "darkmode": "", + }, + "logo": Object { + "darkmode": "", + }, + "mark": Object { + "darkmode": "", + }, "title": "OpenSearch Dashboards", }, "buildNumber": Any, @@ -52,6 +62,16 @@ Object { "basePath": "/mock-server-basepath", "branch": Any, "branding": Object { + "favicon": "", + "loadingLogo": Object { + "darkmode": "", + }, + "logo": Object { + "darkmode": "", + }, + "mark": Object { + "darkmode": "", + }, "title": "OpenSearch Dashboards", }, "buildNumber": Any, @@ -98,6 +118,16 @@ Object { "basePath": "/mock-server-basepath", "branch": Any, "branding": Object { + "favicon": "", + "loadingLogo": Object { + "darkmode": "", + }, + "logo": Object { + "darkmode": "", + }, + "mark": Object { + "darkmode": "", + }, "title": "OpenSearch Dashboards", }, "buildNumber": Any, @@ -148,6 +178,16 @@ Object { "basePath": "", "branch": Any, "branding": Object { + "favicon": "", + "loadingLogo": Object { + "darkmode": "", + }, + "logo": Object { + "darkmode": "", + }, + "mark": Object { + "darkmode": "", + }, "title": "OpenSearch Dashboards", }, "buildNumber": Any, @@ -194,6 +234,16 @@ Object { "basePath": "/mock-server-basepath", "branch": Any, "branding": Object { + "favicon": "", + "loadingLogo": Object { + "darkmode": "", + }, + "logo": Object { + "darkmode": "", + }, + "mark": Object { + "darkmode": "", + }, "title": "OpenSearch Dashboards", }, "buildNumber": Any, diff --git a/src/core/server/rendering/rendering_service.tsx b/src/core/server/rendering/rendering_service.tsx index 903f63887d39..3f67b4b61331 100644 --- a/src/core/server/rendering/rendering_service.tsx +++ b/src/core/server/rendering/rendering_service.tsx @@ -65,17 +65,17 @@ export class RenderingService { .pipe(first()) .toPromise(); - const isFullLogoUrlValid = await this.checkUrlValid( - opensearchDashboardsConfig.branding.fullLogoUrl, - 'fullLogoUrl' + const isLogoDefaultValid = await this.checkUrlValid( + opensearchDashboardsConfig.branding.logo.default, + 'logo default' ); - const isLogoUrlValid = await this.checkUrlValid( - opensearchDashboardsConfig.branding.logoUrl, - 'logoUrl' + const isMarkDefaultValid = await this.checkUrlValid( + opensearchDashboardsConfig.branding.mark.default, + 'mark default' ); - const isLoadingLogoUrlValid = await this.checkUrlValid( - opensearchDashboardsConfig.branding.loadingLogoUrl, - 'loadingLogoUrl' + const isLoadingLogoDefaultValid = await this.checkUrlValid( + opensearchDashboardsConfig.branding.loadingLogo.default, + 'loadingLogo default' ); const isTitleValid = this.checkTitleValid(opensearchDashboardsConfig.branding.title, 'title'); @@ -128,13 +128,25 @@ export class RenderingService { uiSettings: settings, }, branding: { - fullLogoUrl: isFullLogoUrlValid - ? opensearchDashboardsConfig.branding.fullLogoUrl - : undefined, - logoUrl: isLogoUrlValid ? opensearchDashboardsConfig.branding.logoUrl : undefined, - loadingLogoUrl: isLoadingLogoUrlValid - ? opensearchDashboardsConfig.branding.loadingLogoUrl - : undefined, + logo: { + default: isLogoDefaultValid + ? opensearchDashboardsConfig.branding.logo.default + : undefined, + darkmode: '', + }, + mark: { + default: isMarkDefaultValid + ? opensearchDashboardsConfig.branding.mark.default + : undefined, + darkmode: '', + }, + loadingLogo: { + default: isLoadingLogoDefaultValid + ? opensearchDashboardsConfig.branding.loadingLogo.default + : undefined, + darkmode: '', + }, + favicon: '', title: isTitleValid ? opensearchDashboardsConfig.branding.title : DEFAULT_TITLE, }, }, diff --git a/src/core/server/rendering/types.ts b/src/core/server/rendering/types.ts index 98ee1ba20ae1..bebf0bda0154 100644 --- a/src/core/server/rendering/types.ts +++ b/src/core/server/rendering/types.ts @@ -75,10 +75,20 @@ export interface RenderingMetadata { }; }; branding: { - fullLogoUrl?: string; - logoUrl?: string; - loadingLogoUrl?: string; - title: string; + logo: { + default?: string; + darkmode?: string; + }; + mark: { + default?: string; + darkmode?: string; + }; + loadingLogo: { + default?: string; + darkmode?: string; + }; + favicon?: string; + title?: string; }; }; } diff --git a/src/core/server/rendering/views/__snapshots__/template.test.tsx.snap b/src/core/server/rendering/views/__snapshots__/template.test.tsx.snap index beb6ec2b2693..dbb347146ada 100644 --- a/src/core/server/rendering/views/__snapshots__/template.test.tsx.snap +++ b/src/core/server/rendering/views/__snapshots__/template.test.tsx.snap @@ -66,7 +66,7 @@ Array [ data="{\\"strictCsp\\":true}" />, ,
, ,
, ,
{ it('renders with default OpenSearch loading logo', () => { const branding = { + logo: {}, + mark: {}, + loadingLogo: {}, title: '', }; injectedMetadata.getBranding.mockReturnValue(branding); @@ -95,7 +98,9 @@ describe('Template', () => { it('renders with static logo with horizontal loading bar', () => { const branding = { - logoUrl: '/', + logo: {}, + mark: { default: '/' }, + loadingLogo: {}, title: '', }; injectedMetadata.getBranding.mockReturnValue(branding); @@ -105,8 +110,9 @@ describe('Template', () => { it('renders with customized loading logo', () => { const branding = { - logoUrl: '/', - loadingLogoUrl: '/', + logo: {}, + mark: { default: '/' }, + loadingLogo: { default: '/' }, title: '', }; injectedMetadata.getBranding.mockReturnValue(branding); diff --git a/src/core/server/rendering/views/template.tsx b/src/core/server/rendering/views/template.tsx index f3fab623615c..e54c3c628161 100644 --- a/src/core/server/rendering/views/template.tsx +++ b/src/core/server/rendering/views/template.tsx @@ -97,13 +97,13 @@ export const Template: FunctionComponent = ({ ); const renderBrandingEnabledOrDisabledLoadingBar = () => { - if (!injectedMetadata.branding.loadingLogoUrl && injectedMetadata.branding.logoUrl) { + if (!injectedMetadata.branding.loadingLogo.default && injectedMetadata.branding.mark.default) { return
; } }; const renderBrandingEnabledOrDisabledLoadingLogo = () => { - if (!injectedMetadata.branding.loadingLogoUrl && !injectedMetadata.branding.logoUrl) { + if (!injectedMetadata.branding.loadingLogo.default && !injectedMetadata.branding.mark.default) { return openSearchLogoSpinner; } else { return ( @@ -111,9 +111,9 @@ export const Template: FunctionComponent = ({ {injectedMetadata.branding.title diff --git a/src/legacy/server/config/schema.js b/src/legacy/server/config/schema.js index 89c1b6cc7553..04d5298118b4 100644 --- a/src/legacy/server/config/schema.js +++ b/src/legacy/server/config/schema.js @@ -234,9 +234,19 @@ export default () => // TODO Also allow units here like in opensearch config once this is moved to the new platform autocompleteTimeout: Joi.number().integer().min(1).default(1000), branding: Joi.object({ - fullLogoUrl: Joi.any().default('/'), - logoUrl: Joi.any().default('/'), - loadingLogoUrl: Joi.any().default('/'), + logo: Joi.object({ + default: Joi.any().default('/'), + darkmode: Joi.any().default('/'), + }), + mark: Joi.object({ + default: Joi.any().default('/'), + darkmode: Joi.any().default('/'), + }), + loadingLogo: Joi.object({ + default: Joi.any().default('/'), + darkmode: Joi.any().default('/'), + }), + favicon: Joi.any().default('/'), title: Joi.any().default(''), }), }).default(), diff --git a/src/plugins/home/public/application/components/welcome.test.tsx b/src/plugins/home/public/application/components/welcome.test.tsx index db89f8e1125d..ec9d28b0cac3 100644 --- a/src/plugins/home/public/application/components/welcome.test.tsx +++ b/src/plugins/home/public/application/components/welcome.test.tsx @@ -51,7 +51,9 @@ test('should render a Welcome screen with the telemetry disclaimer', () => { */ const branding = { - logoUrl: '/', + mark: { + default: '/', + }, title: 'OpenSearch Dashboards', }; @@ -92,6 +94,7 @@ test('fires opt-in seen when mounted', () => { test('should render a Welcome screen with the default OpenSearch Dashboards branding', () => { const defaultBranding = { + mark: {}, title: 'OpenSearch Dashboards', }; const component = shallow( @@ -102,7 +105,9 @@ test('should render a Welcome screen with the default OpenSearch Dashboards bran test('should render a Welcome screen with customized branding', () => { const customBranding = { - logoUrl: '/custom', + mark: { + default: '/custom', + }, title: 'custom title', }; const component = shallow( diff --git a/src/plugins/home/public/application/components/welcome.tsx b/src/plugins/home/public/application/components/welcome.tsx index 67f7dbb4cf38..7f5052d9f4b4 100644 --- a/src/plugins/home/public/application/components/welcome.tsx +++ b/src/plugins/home/public/application/components/welcome.tsx @@ -59,8 +59,11 @@ interface Props { onSkip: () => void; telemetry?: TelemetryPluginStart; branding: { - logoUrl?: string; - title: string; + mark: { + default?: string; + darkmode?: string; + }; + title?: string; }; } @@ -145,7 +148,8 @@ export class Welcome extends React.Component { }; private renderBrandingEnabledOrDisabledLogo = () => { - if (!this.props.branding.logoUrl) { + const mark = this.props.branding.mark.default; + if (!mark) { return ( @@ -157,9 +161,9 @@ export class Welcome extends React.Component { {this.props.branding.title
); diff --git a/src/plugins/home/public/application/opensearch_dashboards_services.ts b/src/plugins/home/public/application/opensearch_dashboards_services.ts index a14d33ee54d9..22229b8e458b 100644 --- a/src/plugins/home/public/application/opensearch_dashboards_services.ts +++ b/src/plugins/home/public/application/opensearch_dashboards_services.ts @@ -71,9 +71,11 @@ export interface HomeOpenSearchDashboardsServices { injectedMetadata: { getInjectedVar: (name: string, defaultValue?: any) => unknown; getBranding: () => { - fullLogoUrl?: string; - logoUrl?: string; - title: string; + mark: { + default?: string; + darkmode?: string; + }; + title?: string; }; }; } diff --git a/test/common/config.js b/test/common/config.js index 36b6732ea39b..2f13efb1ddf8 100644 --- a/test/common/config.js +++ b/test/common/config.js @@ -75,8 +75,8 @@ export default function () { // `--newsfeed.service.urlRoot=${servers.opensearchDashboards.protocol}://${servers.opensearchDashboards.hostname}:${servers.opensearchDashboards.port}`, // `--newsfeed.service.pathTemplate=/api/_newsfeed-FTS-external-service-simulators/opensearch-dashboards/v{VERSION}.json`, // Custom branding config - `--opensearchDashboards.branding.fullLogoUrl=https://opensearch.org/assets/brand/SVG/Logo/opensearch_logo_default.svg`, - `--opensearchDashboards.branding.logoUrl=https://opensearch.org/assets/brand/SVG/Mark/opensearch_mark_default.svg`, + `--opensearchDashboards.branding.logo.default=https://opensearch.org/assets/brand/SVG/Logo/opensearch_logo_default.svg`, + `--opensearchDashboards.branding.mark.default=https://opensearch.org/assets/brand/SVG/Mark/opensearch_mark_default.svg`, `--opensearchDashboards.branding.title=OpenSearch`, ], },