mirror of
https://github.com/harvester/harvester-ui-extension.git
synced 2026-11-15 13:26:15 +08:00
feat: use the SUSE Virtualization product name on Prime (#1202)
* feat: switch the product name with Rancher Prime Use a [[Harvester]] token for the product name in the translations, so Rancher 2.16 fills it from the l10n global that harvester-manager registers: SUSE Virtualization on Rancher Prime, Harvester otherwise. Rancher before 2.16 shows the tokens as written, so on those hosts (and standalone) the extension resolves them to Harvester itself. Signed-off-by: Marcelo Fukumoto <marcelo.fukumoto@suse.com> * feat: switch the standalone product name with the server flavor Standalone has no Rancher Prime, so register the [[Harvester]] l10n global from the server-flavor setting instead: SUSE Virtualization on prime, Harvester otherwise. Signed-off-by: Marcelo Fukumoto <marcelo.fukumoto@suse.com> * fix: point the network policy banner to the documentation Signed-off-by: Marcelo Fukumoto <marcelo.fukumoto@suse.com> * feat: use the SUSE theme in standalone Prime Standalone Prime kept the harvester brand and only overrode the primary colour, so the rest of the palette and the fonts didn't match Rancher Prime. Switch the ui-brand setting to suse in the store when the server flavor is prime, which makes the shell load the SUSE theme. Signed-off-by: Marcelo Fukumoto <marcelo.fukumoto@suse.com> * fix: keep the SUSE theme after a brand setting change event The watcher also reads the setting's value, so a change from the server loaded into the same object switches the brand back to suse. Signed-off-by: Marcelo Fukumoto <marcelo.fukumoto@suse.com> --------- Signed-off-by: Marcelo Fukumoto <marcelo.fukumoto@suse.com>
This commit is contained in:
@@ -57,10 +57,12 @@ import {
|
||||
} from './table-headers';
|
||||
import { ADD_ONS } from './harvester-map';
|
||||
import { registerAddonSideNav } from '../utils/dynamic-nav';
|
||||
import { setStandalonePrime } from '../utils/l10n-globals';
|
||||
import { setVendor } from '@shell/config/private-label';
|
||||
import { createCssVars } from '@shell/utils/color';
|
||||
import { CONFIGURABLE_TABLES } from '@shell/store/features';
|
||||
import { tableViewsOffFeature } from '../utils/table-views';
|
||||
import { SETTING } from '@shell/config/settings';
|
||||
import { primeBrandUpdater } from '../utils/prime-brand';
|
||||
|
||||
const TEMPLATE = HCI.VM_VERSION;
|
||||
const MONITORING_GROUP = 'Monitoring & Logging::Monitoring';
|
||||
@@ -123,27 +125,9 @@ export function init($plugin, store) {
|
||||
const [isHarvesterPrime, isDark, privateLabel] = JSON.parse(value);
|
||||
const primeLogo = isDark ? require('../assets/images/dark/suse-virtualization.svg') : require('../assets/images/suse-virtualization.svg');
|
||||
|
||||
setStandalonePrime(isHarvesterPrime);
|
||||
setVendor(privateLabel || '');
|
||||
|
||||
let primaryColorStyle = document.getElementById('harvester-prime-primary-color');
|
||||
|
||||
// set harvester prime primary color style to #4dd192 (Cyan Green)
|
||||
if (isHarvesterPrime) {
|
||||
if (!primaryColorStyle) {
|
||||
primaryColorStyle = document.createElement('style');
|
||||
primaryColorStyle.id = 'harvester-prime-primary-color';
|
||||
document.head.appendChild(primaryColorStyle);
|
||||
primaryColorStyle.sheet.insertRule('body.theme-light, body.theme-dark {}', 0);
|
||||
}
|
||||
|
||||
const colors = createCssVars('#4dd192', isDark ? 'dark' : 'light');
|
||||
const rule = primaryColorStyle.sheet.cssRules[0];
|
||||
|
||||
Object.entries(colors).forEach(([property, color]) => rule.style.setProperty(property.trim(), color));
|
||||
} else {
|
||||
primaryColorStyle?.remove();
|
||||
}
|
||||
|
||||
const primeLabelKey = privateLabel ? 'harvester.branding.primeLabel' : 'harvester.branding.primeEmptyLabel';
|
||||
|
||||
store.dispatch('setIsSingleProduct', {
|
||||
@@ -169,6 +153,19 @@ export function init($plugin, store) {
|
||||
},
|
||||
{ immediate: true }
|
||||
);
|
||||
|
||||
const updateBrand = primeBrandUpdater();
|
||||
|
||||
// The value is read too: a change event from the server is loaded into the same setting object
|
||||
store.watch(
|
||||
(_state, getters) => {
|
||||
const brandSetting = getters['management/byId'](MANAGEMENT.SETTING, SETTING.BRAND);
|
||||
|
||||
return [!!getters['harvester-common/isHarvesterPrime'], brandSetting, brandSetting?.value];
|
||||
},
|
||||
([isHarvesterPrime, brandSetting]) => updateBrand(brandSetting, isHarvesterPrime),
|
||||
{ immediate: true }
|
||||
);
|
||||
}
|
||||
|
||||
product({
|
||||
|
||||
Reference in New Issue
Block a user