forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make Amsterdam an opt-in theme (elastic#212787)
## Summary This PR updates `DEFAULT_THEME_TAGS` used to determine what theme tags are bundled in Kibana by default to only include the Borealis theme, specifically `borealislight` and `borealisdark` theme tags. This change is expected to decrease bundle sizes significantly and get back to bundling a single theme, not two (4 → 2 theme tags). Now that Serverless, `9.0`, and `main` all run with Borealis, there's no risk in removing Amsterdam from the bundle and decreasing Kibana bundle sizes. We need to keep the feature flag in code for the time being to easily test future Borealis iterations. Amsterdam will still be available as an opt-in theme and is meant to be used locally when testing changes to be backported to 8.x versions that use Amsterdam. To do so, Kibana needs to be started/built with `KBN_OPTIMIZER_THEMES` environment variable set and the feature flag overridden in `kibana.dev.yml`. ```yml # config/kibana.dev.yml feature_flags.overrides.coreRendering.defaultThemeName: amsterdam ``` ```shell # Run dev server with both borealis and Amsterdam theme tags KBN_OPTIMIZER_THEMES="borealislight,borealisdark,v8light,v8dark" yarn start ``` ### Checklist Check the PR satisfies following conditions. Reviewers should verify this PR satisfies this list as well. - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios --------- Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
- Loading branch information
1 parent
14b18ac
commit 4dd8de8
Showing
12 changed files
with
169 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 0 additions & 29 deletions
29
src/core/packages/rendering/server-internal/src/bootstrap/get_theme_tag.test.ts
This file was deleted.
Oops, something went wrong.
16 changes: 0 additions & 16 deletions
16
src/core/packages/rendering/server-internal/src/bootstrap/get_theme_tag.ts
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
82 changes: 82 additions & 0 deletions
82
src/core/packages/rendering/server-internal/src/theme.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the "Elastic License | ||
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side | ||
* Public License v 1"; you may not use this file except in compliance with, at | ||
* your election, the "Elastic License 2.0", the "GNU Affero General Public | ||
* License v3.0 only", or the "Server Side Public License, v 1". | ||
*/ | ||
|
||
import { getThemeTag, isThemeBundled } from './theme'; | ||
|
||
describe('getThemeTag', () => { | ||
it('returns the correct value for name:amsterdam and darkMode:false', () => { | ||
expect( | ||
getThemeTag({ | ||
name: 'v8', | ||
darkMode: false, | ||
}) | ||
).toEqual('v8light'); | ||
}); | ||
|
||
it('returns the correct value for name:amsterdam and darkMode:true', () => { | ||
expect( | ||
getThemeTag({ | ||
name: 'v8', | ||
darkMode: true, | ||
}) | ||
).toEqual('v8dark'); | ||
}); | ||
|
||
it('returns the correct value for other other theme names and darkMode:false', () => { | ||
expect( | ||
getThemeTag({ | ||
name: 'borealis', | ||
darkMode: false, | ||
}) | ||
).toEqual('borealislight'); | ||
}); | ||
|
||
it('returns the correct value for other other theme names and darkMode:true', () => { | ||
expect( | ||
getThemeTag({ | ||
name: 'borealis', | ||
darkMode: true, | ||
}) | ||
).toEqual('borealisdark'); | ||
}); | ||
}); | ||
|
||
describe('isThemeBundled', () => { | ||
let originalKbnOptimizerThemes: any; | ||
|
||
beforeAll(() => { | ||
originalKbnOptimizerThemes = process.env.KBN_OPTIMIZER_THEMES; | ||
}); | ||
|
||
afterAll(() => { | ||
process.env.KBN_OPTIMIZER_THEMES = originalKbnOptimizerThemes; | ||
}); | ||
|
||
it('returns true when both light and dark mode theme tags are included in KBN_OPTIMIZER_THEMES', () => { | ||
process.env.KBN_OPTIMIZER_THEMES = 'v8light,v8dark,borealislight,borealisdark'; | ||
expect(isThemeBundled('amsterdam')).toEqual(true); | ||
expect(isThemeBundled('borealis')).toEqual(true); | ||
}); | ||
|
||
it('returns false when either theme tag is missing in KBN_OPTIMIZER_THEMES for given theme name', () => { | ||
process.env.KBN_OPTIMIZER_THEMES = 'v8light,borealisdark,borealisdark'; | ||
expect(isThemeBundled('amsterdam')).toEqual(false); | ||
expect(isThemeBundled('borealis')).toEqual(false); | ||
}); | ||
|
||
it('uses default themes when KBN_OPTIMIZER_THEMES is not set', () => { | ||
delete process.env.KBN_OPTIMIZER_THEMES; | ||
expect(isThemeBundled('borealis')).toEqual(true); | ||
expect(isThemeBundled('sometheme' as any)).toEqual(false); | ||
|
||
process.env.KBN_OPTIMIZER_THEMES = ''; | ||
expect(isThemeBundled('borealis')).toEqual(true); | ||
expect(isThemeBundled('sometheme' as any)).toEqual(false); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the "Elastic License | ||
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side | ||
* Public License v 1"; you may not use this file except in compliance with, at | ||
* your election, the "Elastic License 2.0", the "GNU Affero General Public | ||
* License v3.0 only", or the "Server Side Public License, v 1". | ||
*/ | ||
|
||
import { parseThemeTags, ThemeName, ThemeTag } from '@kbn/core-ui-settings-common'; | ||
|
||
export const getThemeTag = ({ name, darkMode }: { name: string; darkMode: boolean }) => { | ||
// Amsterdam theme is called `v8` internally | ||
// and should be kept this way for compatibility reasons. | ||
if (name === 'amsterdam') { | ||
name = 'v8'; | ||
} | ||
|
||
return `${name}${darkMode ? 'dark' : 'light'}`; | ||
}; | ||
|
||
/** | ||
* Check whether the theme is bundled in the current kibana build. | ||
* For a theme to be considered bundled both light and dark mode | ||
* styles must be included. | ||
*/ | ||
export const isThemeBundled = (name: ThemeName): boolean => { | ||
const bundledThemeTags = parseThemeTags(process.env.KBN_OPTIMIZER_THEMES); | ||
|
||
return ( | ||
bundledThemeTags.includes(getThemeTag({ name, darkMode: false }) as ThemeTag) && | ||
bundledThemeTags.includes(getThemeTag({ name, darkMode: true }) as ThemeTag) | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters