fix: whiteLabeling should support component creation by passing React to defined fn (#1659)
This commit is contained in:
parent
b1dad6b61b
commit
2093a00365
@ -11,7 +11,25 @@ are:
|
|||||||
```js
|
```js
|
||||||
window.config = {
|
window.config = {
|
||||||
routerBasename: '/',
|
routerBasename: '/',
|
||||||
whiteLabelling: {},
|
whiteLabeling: {
|
||||||
|
/* Optional: Should return a React component to be rendered in the "Logo" section of the application's Top Navigation bar */
|
||||||
|
createLogoComponentFn: function(React) {
|
||||||
|
return React.createElement('a', {
|
||||||
|
target: '_self',
|
||||||
|
rel: 'noopener noreferrer',
|
||||||
|
className: 'header-brand',
|
||||||
|
href: '/',
|
||||||
|
style: {
|
||||||
|
display: 'block',
|
||||||
|
textIndent: '-9999px',
|
||||||
|
background: 'url(/svg-file-hosted-at-domain-root.svg)',
|
||||||
|
backgroundSize: 'contain',
|
||||||
|
backgroundRepeat: 'no-repeat',
|
||||||
|
width: '200px',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
extensions: [],
|
extensions: [],
|
||||||
showStudyList: true,
|
showStudyList: true,
|
||||||
filterQueryParam: false,
|
filterQueryParam: false,
|
||||||
|
|||||||
@ -66,11 +66,11 @@ open to pull requests and discussion issues.
|
|||||||
|
|
||||||
Current white-labeling options are limited. We expose the ability to replace the
|
Current white-labeling options are limited. We expose the ability to replace the
|
||||||
"Logo" section of the application with a custom "Logo" component. You can do
|
"Logo" section of the application with a custom "Logo" component. You can do
|
||||||
this by adding a `whiteLabelling` key to your
|
this by adding a `whiteLabeling` key to your
|
||||||
[configuration file](./configuration.md).
|
[configuration file](./configuration.md).
|
||||||
|
|
||||||
```js
|
```js
|
||||||
function RadicalImagingLogo() {
|
function RadicalImagingLogo(React) {
|
||||||
return React.createElement(
|
return React.createElement(
|
||||||
'a',
|
'a',
|
||||||
{
|
{
|
||||||
@ -83,8 +83,8 @@ function RadicalImagingLogo() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
props.whiteLabelling = {
|
props.whiteLabeling = {
|
||||||
logoComponent: RadicalImagingLogo(),
|
createLogoComponentFn: RadicalImagingLogo,
|
||||||
};
|
};
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@ -378,7 +378,7 @@ class MetadataProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
metadata = {
|
metadata = {
|
||||||
overlays
|
overlays,
|
||||||
};
|
};
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|||||||
@ -1,7 +1,6 @@
|
|||||||
window.config = {
|
window.config = {
|
||||||
// default: '/'
|
// default: '/'
|
||||||
routerBasename: '/',
|
routerBasename: '/',
|
||||||
whiteLabelling: {},
|
|
||||||
extensions: [],
|
extensions: [],
|
||||||
showStudyList: true,
|
showStudyList: true,
|
||||||
filterQueryParam: false,
|
filterQueryParam: false,
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
window.config = {
|
window.config = {
|
||||||
routerBasename: '/',
|
routerBasename: '/',
|
||||||
whiteLabelling: {},
|
|
||||||
extensions: [],
|
extensions: [],
|
||||||
showStudyList: true,
|
showStudyList: true,
|
||||||
servers: {
|
servers: {
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
window.config = {
|
window.config = {
|
||||||
routerBasename: '/',
|
routerBasename: '/',
|
||||||
whiteLabelling: {},
|
|
||||||
showStudyList: true,
|
showStudyList: true,
|
||||||
servers: {
|
servers: {
|
||||||
dicomWeb: [
|
dicomWeb: [
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
window.config = {
|
window.config = {
|
||||||
routerBasename: '/',
|
routerBasename: '/',
|
||||||
whiteLabelling: {},
|
|
||||||
showStudyList: true,
|
showStudyList: true,
|
||||||
servers: {
|
servers: {
|
||||||
// This is an array, but we'll only use the first entry for now
|
// This is an array, but we'll only use the first entry for now
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
window.config = {
|
window.config = {
|
||||||
routerBasename: '/',
|
routerBasename: '/',
|
||||||
whiteLabelling: {},
|
|
||||||
showStudyList: true,
|
showStudyList: true,
|
||||||
servers: {
|
servers: {
|
||||||
// This is an array, but we'll only use the first entry for now
|
// This is an array, but we'll only use the first entry for now
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
window.config = {
|
window.config = {
|
||||||
routerBasename: '/',
|
routerBasename: '/',
|
||||||
whiteLabelling: {},
|
|
||||||
enableGoogleCloudAdapter: true,
|
enableGoogleCloudAdapter: true,
|
||||||
healthcareApiEndpoint: 'https://healthcare.googleapis.com/v1beta1',
|
healthcareApiEndpoint: 'https://healthcare.googleapis.com/v1beta1',
|
||||||
servers: {
|
servers: {
|
||||||
|
|||||||
@ -1,7 +1,6 @@
|
|||||||
window.config = {
|
window.config = {
|
||||||
// default: '/'
|
// default: '/'
|
||||||
routerBasename: '/',
|
routerBasename: '/',
|
||||||
whiteLabelling: {},
|
|
||||||
// default: ''
|
// default: ''
|
||||||
showStudyList: true,
|
showStudyList: true,
|
||||||
servers: {
|
servers: {
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
window.config = {
|
window.config = {
|
||||||
routerBasename: '/pwa',
|
routerBasename: '/pwa',
|
||||||
whiteLabelling: {},
|
|
||||||
showStudyList: true,
|
showStudyList: true,
|
||||||
servers: {
|
servers: {
|
||||||
dicomWeb: [
|
dicomWeb: [
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
window.config = {
|
window.config = {
|
||||||
routerBasename: '/',
|
routerBasename: '/',
|
||||||
whiteLabelling: {},
|
|
||||||
showStudyList: true,
|
showStudyList: true,
|
||||||
servers: {
|
servers: {
|
||||||
dicomWeb: [
|
dicomWeb: [
|
||||||
|
|||||||
@ -50,7 +50,7 @@ import { getActiveContexts } from './store/layout/selectors.js';
|
|||||||
import store from './store';
|
import store from './store';
|
||||||
|
|
||||||
/** Contexts */
|
/** Contexts */
|
||||||
import WhiteLabellingContext from './context/WhiteLabellingContext';
|
import WhiteLabelingContext from './context/WhiteLabelingContext';
|
||||||
import UserManagerContext from './context/UserManagerContext';
|
import UserManagerContext from './context/UserManagerContext';
|
||||||
import AppContext from './context/AppContext';
|
import AppContext from './context/AppContext';
|
||||||
|
|
||||||
@ -77,7 +77,9 @@ class App extends Component {
|
|||||||
PropTypes.shape({
|
PropTypes.shape({
|
||||||
routerBasename: PropTypes.string.isRequired,
|
routerBasename: PropTypes.string.isRequired,
|
||||||
oidc: PropTypes.array,
|
oidc: PropTypes.array,
|
||||||
whiteLabelling: PropTypes.object,
|
whiteLabeling: PropTypes.shape({
|
||||||
|
createLogoComponentFn: PropTypes.func,
|
||||||
|
}),
|
||||||
extensions: PropTypes.array,
|
extensions: PropTypes.array,
|
||||||
}),
|
}),
|
||||||
]).isRequired,
|
]).isRequired,
|
||||||
@ -87,7 +89,6 @@ class App extends Component {
|
|||||||
static defaultProps = {
|
static defaultProps = {
|
||||||
config: {
|
config: {
|
||||||
showStudyList: true,
|
showStudyList: true,
|
||||||
whiteLabelling: {},
|
|
||||||
oidc: [],
|
oidc: [],
|
||||||
extensions: [],
|
extensions: [],
|
||||||
},
|
},
|
||||||
@ -107,7 +108,6 @@ class App extends Component {
|
|||||||
cornerstoneExtensionConfig: {},
|
cornerstoneExtensionConfig: {},
|
||||||
extensions: [],
|
extensions: [],
|
||||||
routerBasename: '/',
|
routerBasename: '/',
|
||||||
whiteLabelling: {},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
this._appConfig = {
|
this._appConfig = {
|
||||||
@ -146,7 +146,7 @@ class App extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { whiteLabelling, routerBasename } = this._appConfig;
|
const { whiteLabeling, routerBasename } = this._appConfig;
|
||||||
const {
|
const {
|
||||||
UINotificationService,
|
UINotificationService,
|
||||||
UIDialogService,
|
UIDialogService,
|
||||||
@ -162,7 +162,7 @@ class App extends Component {
|
|||||||
<OidcProvider store={store} userManager={this._userManager}>
|
<OidcProvider store={store} userManager={this._userManager}>
|
||||||
<UserManagerContext.Provider value={this._userManager}>
|
<UserManagerContext.Provider value={this._userManager}>
|
||||||
<Router basename={routerBasename}>
|
<Router basename={routerBasename}>
|
||||||
<WhiteLabellingContext.Provider value={whiteLabelling}>
|
<WhiteLabelingContext.Provider value={whiteLabeling}>
|
||||||
<SnackbarProvider service={UINotificationService}>
|
<SnackbarProvider service={UINotificationService}>
|
||||||
<DialogProvider service={UIDialogService}>
|
<DialogProvider service={UIDialogService}>
|
||||||
<ModalProvider
|
<ModalProvider
|
||||||
@ -175,7 +175,7 @@ class App extends Component {
|
|||||||
</ModalProvider>
|
</ModalProvider>
|
||||||
</DialogProvider>
|
</DialogProvider>
|
||||||
</SnackbarProvider>
|
</SnackbarProvider>
|
||||||
</WhiteLabellingContext.Provider>
|
</WhiteLabelingContext.Provider>
|
||||||
</Router>
|
</Router>
|
||||||
</UserManagerContext.Provider>
|
</UserManagerContext.Provider>
|
||||||
</OidcProvider>
|
</OidcProvider>
|
||||||
@ -190,7 +190,7 @@ class App extends Component {
|
|||||||
<Provider store={store}>
|
<Provider store={store}>
|
||||||
<I18nextProvider i18n={i18n}>
|
<I18nextProvider i18n={i18n}>
|
||||||
<Router basename={routerBasename}>
|
<Router basename={routerBasename}>
|
||||||
<WhiteLabellingContext.Provider value={whiteLabelling}>
|
<WhiteLabelingContext.Provider value={whiteLabeling}>
|
||||||
<SnackbarProvider service={UINotificationService}>
|
<SnackbarProvider service={UINotificationService}>
|
||||||
<DialogProvider service={UIDialogService}>
|
<DialogProvider service={UIDialogService}>
|
||||||
<ModalProvider modal={OHIFModal} service={UIModalService}>
|
<ModalProvider modal={OHIFModal} service={UIModalService}>
|
||||||
@ -198,7 +198,7 @@ class App extends Component {
|
|||||||
</ModalProvider>
|
</ModalProvider>
|
||||||
</DialogProvider>
|
</DialogProvider>
|
||||||
</SnackbarProvider>
|
</SnackbarProvider>
|
||||||
</WhiteLabellingContext.Provider>
|
</WhiteLabelingContext.Provider>
|
||||||
</Router>
|
</Router>
|
||||||
</I18nextProvider>
|
</I18nextProvider>
|
||||||
</Provider>
|
</Provider>
|
||||||
|
|||||||
@ -4,8 +4,16 @@
|
|||||||
height: var(--top-bar-height);
|
height: var(--top-bar-height);
|
||||||
}
|
}
|
||||||
|
|
||||||
.dd-item {
|
.header-left-box {
|
||||||
width: 100%;
|
display: inline-block;
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
|
.header-brand {
|
||||||
|
text-decoration: none;
|
||||||
|
height: 30px;
|
||||||
|
float: left;
|
||||||
|
clear: both;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Home Page */
|
/* Home Page */
|
||||||
@ -17,35 +25,11 @@
|
|||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.header-left-box {
|
|
||||||
display: inline-block;
|
|
||||||
position: relative;
|
|
||||||
}
|
|
||||||
|
|
||||||
.header-viewerLink {
|
|
||||||
float: left;
|
|
||||||
}
|
|
||||||
|
|
||||||
.header-brand {
|
|
||||||
height: 30px;
|
|
||||||
text-decoration: none;
|
|
||||||
float: left;
|
|
||||||
clear: both;
|
|
||||||
}
|
|
||||||
|
|
||||||
.entry-header.header-big .header-brand {
|
.entry-header.header-big .header-brand {
|
||||||
height: auto;
|
height: 50px;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.header-logo-image {
|
|
||||||
fill: transparent;
|
|
||||||
height: 100%;
|
|
||||||
margin: 0 8px 0 0;
|
|
||||||
width: 30px;
|
|
||||||
float: left;
|
|
||||||
}
|
|
||||||
|
|
||||||
.entry-header.header-big .header-logo-image {
|
.entry-header.header-big .header-logo-image {
|
||||||
margin-right: 20px;
|
margin-right: 20px;
|
||||||
width: 50px;
|
width: 50px;
|
||||||
@ -57,6 +41,24 @@
|
|||||||
height: auto;
|
height: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** OTHER STYLES **/
|
||||||
|
|
||||||
|
.dd-item {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.header-viewerLink {
|
||||||
|
float: left;
|
||||||
|
}
|
||||||
|
|
||||||
|
.header-logo-image {
|
||||||
|
fill: transparent;
|
||||||
|
height: 100%;
|
||||||
|
margin: 0 8px 0 0;
|
||||||
|
width: 30px;
|
||||||
|
float: left;
|
||||||
|
}
|
||||||
|
|
||||||
.header-btn {
|
.header-btn {
|
||||||
color: var(--text-secondary-color);
|
color: var(--text-secondary-color);
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
@ -130,13 +132,6 @@
|
|||||||
width: 40%;
|
width: 40%;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Account for notification bar height */
|
|
||||||
.entry-header.header-big .header-brand {
|
|
||||||
}
|
|
||||||
|
|
||||||
.dd-menu {
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Toggle Notification Bar */
|
/* Toggle Notification Bar */
|
||||||
.notification-bar {
|
.notification-bar {
|
||||||
display: block;
|
display: block;
|
||||||
|
|||||||
@ -14,7 +14,7 @@ import SidePanel from './../components/SidePanel.js';
|
|||||||
import { extensionManager } from './../App.js';
|
import { extensionManager } from './../App.js';
|
||||||
|
|
||||||
// Contexts
|
// Contexts
|
||||||
import WhiteLabellingContext from '../context/WhiteLabellingContext.js';
|
import WhiteLabelingContext from '../context/WhiteLabelingContext.js';
|
||||||
import UserManagerContext from '../context/UserManagerContext';
|
import UserManagerContext from '../context/UserManagerContext';
|
||||||
import AppContext from '../context/AppContext';
|
import AppContext from '../context/AppContext';
|
||||||
|
|
||||||
@ -227,8 +227,8 @@ class Viewer extends Component {
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{/* HEADER */}
|
{/* HEADER */}
|
||||||
<WhiteLabellingContext.Consumer>
|
<WhiteLabelingContext.Consumer>
|
||||||
{whiteLabelling => (
|
{whiteLabeling => (
|
||||||
<UserManagerContext.Consumer>
|
<UserManagerContext.Consumer>
|
||||||
{userManager => (
|
{userManager => (
|
||||||
<AppContext.Consumer>
|
<AppContext.Consumer>
|
||||||
@ -244,14 +244,16 @@ class Viewer extends Component {
|
|||||||
}
|
}
|
||||||
userManager={userManager}
|
userManager={userManager}
|
||||||
>
|
>
|
||||||
{whiteLabelling.logoComponent}
|
{whiteLabeling &&
|
||||||
|
whiteLabeling.createLogoComponentFn &&
|
||||||
|
whiteLabeling.createLogoComponentFn(React)}
|
||||||
</ConnectedHeader>
|
</ConnectedHeader>
|
||||||
)}
|
)}
|
||||||
</AppContext.Consumer>
|
</AppContext.Consumer>
|
||||||
)}
|
)}
|
||||||
</UserManagerContext.Consumer>
|
</UserManagerContext.Consumer>
|
||||||
)}
|
)}
|
||||||
</WhiteLabellingContext.Consumer>
|
</WhiteLabelingContext.Consumer>
|
||||||
|
|
||||||
{/* TOOLBAR */}
|
{/* TOOLBAR */}
|
||||||
<ConnectedToolbarRow
|
<ConnectedToolbarRow
|
||||||
|
|||||||
10
platform/viewer/src/context/WhiteLabelingContext.js
Normal file
10
platform/viewer/src/context/WhiteLabelingContext.js
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
import OHIFLogo from '../components/OHIFLogo/OHIFLogo.js';
|
||||||
|
import React from 'react';
|
||||||
|
|
||||||
|
const defaultContextValues = {
|
||||||
|
createLogoComponentFn: React => OHIFLogo(),
|
||||||
|
};
|
||||||
|
|
||||||
|
const WhiteLabelingContext = React.createContext(defaultContextValues);
|
||||||
|
|
||||||
|
export default WhiteLabelingContext;
|
||||||
@ -1,10 +0,0 @@
|
|||||||
import OHIFLogo from '../components/OHIFLogo/OHIFLogo.js';
|
|
||||||
import React from 'react';
|
|
||||||
|
|
||||||
const defaultContextValues = {
|
|
||||||
logoComponent: OHIFLogo(),
|
|
||||||
};
|
|
||||||
|
|
||||||
const WhiteLabellingContext = React.createContext(defaultContextValues);
|
|
||||||
|
|
||||||
export default WhiteLabellingContext;
|
|
||||||
@ -19,7 +19,7 @@ import filesToStudies from '../lib/filesToStudies.js';
|
|||||||
|
|
||||||
// Contexts
|
// Contexts
|
||||||
import UserManagerContext from '../context/UserManagerContext';
|
import UserManagerContext from '../context/UserManagerContext';
|
||||||
import WhiteLabellingContext from '../context/WhiteLabellingContext';
|
import WhiteLabelingContext from '../context/WhiteLabelingContext';
|
||||||
import AppContext from '../context/AppContext';
|
import AppContext from '../context/AppContext';
|
||||||
|
|
||||||
const { urlUtil: UrlUtil } = OHIF.utils;
|
const { urlUtil: UrlUtil } = OHIF.utils;
|
||||||
@ -209,8 +209,8 @@ function StudyListRoute(props) {
|
|||||||
/>
|
/>
|
||||||
) : null}
|
) : null}
|
||||||
{healthCareApiWindows}
|
{healthCareApiWindows}
|
||||||
<WhiteLabellingContext.Consumer>
|
<WhiteLabelingContext.Consumer>
|
||||||
{whiteLabelling => (
|
{whiteLabeling => (
|
||||||
<UserManagerContext.Consumer>
|
<UserManagerContext.Consumer>
|
||||||
{userManager => (
|
{userManager => (
|
||||||
<ConnectedHeader
|
<ConnectedHeader
|
||||||
@ -218,12 +218,14 @@ function StudyListRoute(props) {
|
|||||||
user={user}
|
user={user}
|
||||||
userManager={userManager}
|
userManager={userManager}
|
||||||
>
|
>
|
||||||
{whiteLabelling.logoComponent}
|
{whiteLabeling &&
|
||||||
|
whiteLabeling.createLogoComponentFn &&
|
||||||
|
whiteLabeling.createLogoComponentFn(React)}
|
||||||
</ConnectedHeader>
|
</ConnectedHeader>
|
||||||
)}
|
)}
|
||||||
</UserManagerContext.Consumer>
|
</UserManagerContext.Consumer>
|
||||||
)}
|
)}
|
||||||
</WhiteLabellingContext.Consumer>
|
</WhiteLabelingContext.Consumer>
|
||||||
<div className="study-list-header">
|
<div className="study-list-header">
|
||||||
<div className="header">
|
<div className="header">
|
||||||
<h1 style={{ fontWeight: 300, fontSize: '22px' }}>
|
<h1 style={{ fontWeight: 300, fontSize: '22px' }}>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user