Skip to content

Commit 1f7a392

Browse files
authored
Configure left logo in the cBioPortal header via 'skin.left_logo' property (#4747)
The left logo in the header can be configured in the portal.properties file via the 'skin.left_logo' property.
1 parent 358cbca commit 1f7a392

File tree

3 files changed

+25
-14
lines changed

3 files changed

+25
-14
lines changed

src/appShell/App/PortalHeader.tsx

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@ import { Link, NavLink } from 'react-router-dom';
44
import { If, Then, Else } from 'react-if';
55
import { AppStore } from '../../AppStore';
66
import { observer } from 'mobx-react';
7-
import { getInstituteLogoUrl } from '../../shared/api/urls';
7+
import {
8+
getcBioPortalLogoUrl,
9+
getInstituteLogoUrl,
10+
} from '../../shared/api/urls';
811
import SocialAuthButton from '../../shared/components/SocialAuthButton';
912
import { Dropdown } from 'react-bootstrap';
1013
import { DataAccessTokensDropdown } from '../../shared/components/dataAccessTokens/DataAccessTokensDropdown';
@@ -119,7 +122,11 @@ export default class PortalHeader extends React.Component<
119122
<div id="leftHeaderContent">
120123
<Link to="/" id="cbioportal-logo">
121124
<img
122-
src={require('../../globalStyles/images/cbioportal_logo.png')}
125+
src={
126+
!!getcBioPortalLogoUrl()
127+
? getcBioPortalLogoUrl()
128+
: require('../../globalStyles/images/cbioportal_logo.png')
129+
}
123130
alt="cBioPortal Logo"
124131
/>
125132
</Link>
@@ -171,10 +178,10 @@ export default class PortalHeader extends React.Component<
171178
</Else>
172179
</If>
173180
</If>
174-
<If condition={getInstituteLogoUrl()}>
181+
<If condition={!!getInstituteLogoUrl()}>
175182
<img
176183
id="institute-logo"
177-
src={getInstituteLogoUrl()}
184+
src={getInstituteLogoUrl()!}
178185
alt="Institute Logo"
179186
/>
180187
</If>

src/config/IAppConfig.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ export interface IServerConfig {
9999
skin_documentation_news: string | null;
100100
skin_documentation_oql: string | null;
101101
skin_query_max_tree_depth: string;
102+
skin_left_logo: string | null;
102103
skin_right_logo: string | null;
103104
skin_right_nav_show_data_sets: boolean;
104105
skin_right_nav_show_examples: boolean;

src/shared/api/urls.ts

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -214,18 +214,21 @@ export function getOncoKbApiUrl() {
214214
);
215215
}
216216

217+
export function getcBioPortalLogoUrl() {
218+
return getLogoUrl(getServerConfig().skin_left_logo);
219+
}
220+
217221
export function getInstituteLogoUrl() {
218-
if (getServerConfig().skin_right_logo) {
219-
if (/^http/.test(getServerConfig().skin_right_logo || '')) {
220-
return getServerConfig().skin_right_logo!;
221-
} else {
222-
return buildCBioPortalPageUrl(
223-
`images/${getServerConfig().skin_right_logo}`
224-
);
225-
}
226-
} else {
227-
return undefined;
222+
return getLogoUrl(getServerConfig().skin_right_logo);
223+
}
224+
225+
function getLogoUrl(logo_path: string | null) {
226+
if (logo_path) {
227+
return /^http/.test(logo_path || '')
228+
? logo_path!
229+
: buildCBioPortalPageUrl(`images/${logo_path}`);
228230
}
231+
return undefined;
229232
}
230233

231234
export function getGenomeNexusApiUrl() {

0 commit comments

Comments
 (0)