Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions shell/components/BannerGraphic.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
<script>
import Closeable from '@shell/mixins/closeable';
import BrandImage from '@shell/components/BrandImage';
import { MANAGEMENT } from '@shell/config/types';
import { SETTING } from '@shell/config/settings';
import { getBrandMeta } from '@shell/utils/brand';

export default {
Expand All @@ -21,9 +19,7 @@ export default {
},

data() {
const globalSettings = this.$store.getters['management/all'](MANAGEMENT.SETTING);
const setting = globalSettings?.find((gs) => gs.id === SETTING.BRAND);
const brandMeta = getBrandMeta(setting?.value);
const brandMeta = getBrandMeta(this.$store.getters['management/brand']);
const banner = brandMeta?.banner || {};
const align = banner.textAlign || 'center';
const bannerClass = banner.bannerClass || '';
Expand Down
23 changes: 17 additions & 6 deletions shell/components/BrandImage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ export default {
};
},
computed: {
...mapGetters({ theme: 'prefs/theme' }),
...mapGetters({ theme: 'prefs/theme', brand: 'management/brand' }),

brand() {
brandBase() {
const setting = this.managementSettings.filter((setting) => setting.id === SETTING.BRAND)[0] || {};

return setting.value;
Expand Down Expand Up @@ -78,19 +78,30 @@ export default {
}
},

isDark() {
return this.theme === 'dark';
},

pathToBrandedImage() {
if (this.fileName === 'rancher-logo.svg' || this.supportCustomLogo) {
if (this.theme === 'dark' && this.uiLogoDark) {
if (this.isDark && this.uiLogoDark) {
return this.uiLogoDark;
}

if (this.uiLogoLight) {
return this.uiLogoLight;
}

// csp, rgs, and federal map to SUSE, but have their own custom logos
if (this.brandBase !== this.brand) {
try {
return require(`~shell/assets/brand/${ this.brandBase }/${ this.isDark ? 'dark/' : '' }${ this.fileName }`);
} catch { }
}
}

if (this.fileName === 'banner.svg') {
if (this.theme === 'dark' && this.uiBannerDark) {
if (this.isDark && this.uiBannerDark) {
return this.uiBannerDark;
}

Expand All @@ -100,7 +111,7 @@ export default {
}

if (this.fileName === 'login-landscape.svg') {
if (this.theme === 'dark' && this.uiLoginBackgroundDark) {
if (this.isDark && this.uiLoginBackgroundDark) {
return this.uiLoginBackgroundDark;
}

Expand All @@ -112,7 +123,7 @@ export default {
if (!this.brand) {
return this.defaultPathToBrandedImage;
} else {
if (this.theme === 'dark' || this.dark) {
if (this.isDark || this.dark) {
try {
return require(`~shell/assets/brand/${ this.brand }/dark/${ this.fileName }`);
} catch {}
Expand Down
7 changes: 7 additions & 0 deletions shell/config/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,13 @@ export const MANAGEMENT = {
OIDC_CLIENT: 'management.cattle.io.oidcclient'
};

export const BRAND = {
SUSE: 'suse',
CSP: 'csp',
FEDERAL: 'federal',
RGS: 'rgs',
};

export const EXT = { USER_ACTIVITY: 'ext.cattle.io.useractivity' };

export const CAPI = {
Expand Down
8 changes: 1 addition & 7 deletions shell/mixins/brand.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export default {
},

computed: {
...mapGetters({ loggedIn: 'auth/loggedIn' }),
...mapGetters({ loggedIn: 'auth/loggedIn', brand: 'management/brand' }),

// added to fix https://github.com/rancher/dashboard/issues/10788
// because on logout the brand mixin is mounted, but then a management store reset happens
Expand All @@ -46,12 +46,6 @@ export default {
return this.$store.getters['management/all'](MANAGEMENT.SETTING);
},

brand() {
const setting = this.globalSettings?.find((gs) => gs.id === SETTING.BRAND);

return setting?.value;
},

color() {
const setting = this.globalSettings?.find((gs) => gs.id === SETTING.PRIMARY_COLOR);

Expand Down
4 changes: 1 addition & 3 deletions shell/pages/auth/login.vue
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,7 @@ export default {
},
customizations() {
const globalSettings = this.$store.getters['management/all'](MANAGEMENT.SETTING);
const setting = globalSettings?.find((gs) => gs.id === SETTING.BRAND);
const brandMeta = getBrandMeta(setting?.value);
const brandMeta = getBrandMeta(this.$store.getters['management/brand']);
const login = brandMeta?.login || {};
return {
Expand Down
19 changes: 18 additions & 1 deletion shell/plugins/dashboard-store/getters.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@

import { SCHEMA, COUNT, POD } from '@shell/config/types';
import {
SCHEMA, COUNT, POD, MANAGEMENT, BRAND
} from '@shell/config/types';
import { SETTING } from '@shell/config/settings';

import { matches } from '@shell/utils/selector';
import { typeMunge, typeRef, SIMPLE_TYPES } from '@shell/utils/create-yaml';
Expand Down Expand Up @@ -204,6 +207,20 @@ export default {
}
},

brand: (state, getters) => {
const brand = getters['byId'](MANAGEMENT.SETTING, SETTING.BRAND);

if (!brand?.value) {
return undefined;
}

if ([BRAND.CSP, BRAND.FEDERAL, BRAND.RGS].includes(brand.value)) {
return BRAND.SUSE;
}

return brand.value;
},

/**
* Checks a schema for the given path
*
Expand Down
9 changes: 4 additions & 5 deletions shell/store/prefs.js
Original file line number Diff line number Diff line change
Expand Up @@ -523,15 +523,14 @@ export const actions = {
setBrandStyle({ rootState, rootGetters }, dark = false) {
if (rootState.managementReady) {
try {
const brandSetting = rootGetters['management/byId'](MANAGEMENT.SETTING, SETTING.BRAND);
const brandSetting = rootGetters['management/brand'];

if (brandSetting && brandSetting.value && brandSetting.value !== '') {
const brand = brandSetting.value;
const brandMeta = getBrandMeta(brand);
if (brandSetting !== '') {
const brandMeta = getBrandMeta(brandSetting);
const hasStylesheet = brandMeta.hasStylesheet === 'true';

if (hasStylesheet) {
document.body.classList.add(brand);
document.body.classList.add(brandMeta);
} else {
// TODO option apply color at runtime
}
Expand Down
8 changes: 4 additions & 4 deletions shell/utils/favicon.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@ export function haveSetFavIcon() {

export function setFavIcon(store) {
const res = store.getters['management/byId'](MANAGEMENT.SETTING, SETTING.FAVICON);
const brandSetting = store.getters['management/byId'](MANAGEMENT.SETTING, SETTING.BRAND);
const brandSetting = store.getters['management/brand'];
const link = findIconLink(document.head.getElementsByTagName('link'));

if (link) {
let brandImage;

if (brandSetting?.value === 'suse') {
if (brandSetting === 'suse') {
brandImage = require('~shell/assets/brand/suse/favicon.png');
} else if (brandSetting?.value === 'csp') {
} else if (brandSetting === 'csp') {
brandImage = require('~shell/assets/brand/csp/favicon.png');
} else if (brandSetting?.value === 'harvester') {
} else if (brandSetting === 'harvester') {
brandImage = require('~shell/assets/brand/harvester/favicon.png');
}

Expand Down