Kill old icons logic

This commit is contained in:
dannyrb 2019-05-28 14:50:22 -04:00
parent 97899570ae
commit ac44228b94
4 changed files with 18 additions and 50 deletions

View File

@ -29,7 +29,7 @@ class ToolbarModule extends Component {
active={this.state.cineDialogOpen} active={this.state.cineDialogOpen}
onClick={this.onClickCineToolbarButton} onClick={this.onClickCineToolbarButton}
text={'CINE'} text={'CINE'}
iconClasses={'fab fa-youtube'} icon="tool-cineplay-toggle"
/> />
<div className="CineDialogContainer" style={cineDialogContainerStyle}> <div className="CineDialogContainer" style={cineDialogContainerStyle}>
<ConnectedCineDialog /> <ConnectedCineDialog />

View File

@ -3,7 +3,6 @@ import { ToolbarSection } from 'react-viewerbase';
import OHIF from 'ohif-core'; import OHIF from 'ohif-core';
const { setToolActive } = OHIF.redux.actions; const { setToolActive } = OHIF.redux.actions;
const Icons = `${window.config.routerBasename}/icons.svg`.replace('//', '/');
const mapStateToProps = state => { const mapStateToProps = state => {
const activeButton = state.tools.buttons.find(tool => tool.active === true); const activeButton = state.tools.buttons.find(tool => tool.active === true);
@ -14,7 +13,7 @@ const mapStateToProps = state => {
command: 'Rotate', command: 'Rotate',
type: 'tool', type: 'tool',
text: 'Rotate', text: 'Rotate',
svgUrl: `${Icons}#3d-rotate`, icon: '3d-rotate',
active: true active: true
} }
], ],

View File

@ -1,115 +1,101 @@
/** export default function() {
*
* @param {String} [baseDirectory='/']
*/
export default function(baseDirectory = '/') {
const iconsFileName = 'icons.svg'
const sanitizedBaseDirectory =
baseDirectory[baseDirectory.length - 1] === '/'
? baseDirectory
: `${baseDirectory}/`
const relativePathToIcons = `${sanitizedBaseDirectory}${iconsFileName}`.replace(
'//',
'/'
)
return [ return [
{ {
command: 'StackScroll', command: 'StackScroll',
type: 'tool', type: 'tool',
text: 'Stack Scroll', text: 'Stack Scroll',
svgUrl: `${relativePathToIcons}#icon-tools-stack-scroll`, icon: 'tool-stack-scroll',
active: false, active: false,
}, },
{ {
command: 'Zoom', command: 'Zoom',
type: 'tool', type: 'tool',
text: 'Zoom', text: 'Zoom',
svgUrl: `${relativePathToIcons}#icon-tools-zoom`, icon: 'tool-zoom',
active: false, active: false,
}, },
{ {
command: 'Wwwc', command: 'Wwwc',
type: 'tool', type: 'tool',
text: 'Levels', text: 'Levels',
svgUrl: `${relativePathToIcons}#icon-tools-levels`, icon: 'tool-levels',
active: true, active: true,
}, },
{ {
command: 'Pan', command: 'Pan',
type: 'tool', type: 'tool',
text: 'Pan', text: 'Pan',
svgUrl: `${relativePathToIcons}#icon-tools-pan`, icon: 'tool-pan',
active: false, active: false,
}, },
{ {
command: 'Length', command: 'Length',
type: 'tool', type: 'tool',
text: 'Length', text: 'Length',
svgUrl: `${relativePathToIcons}#icon-tools-measure-temp`, icon: 'tool-measure-temp',
active: false, active: false,
}, },
/*{ /*{
command: 'Annotate', command: 'Annotate',
type: 'tool', type: 'tool',
text: 'Annotate', text: 'Annotate',
svgUrl: `${Icons}#icon-tools-measure-non-target`, icon: `${Icons}#icon-tools-measure-non-target`,
active: false active: false
},*/ },*/
{ {
command: 'Angle', command: 'Angle',
type: 'tool', type: 'tool',
text: 'Angle', text: 'Angle',
iconClasses: 'fa fa-angle-left', icon: 'angle-left',
active: false, active: false,
}, },
{ {
command: 'Bidirectional', command: 'Bidirectional',
type: 'tool', type: 'tool',
text: 'Bidirectional', text: 'Bidirectional',
svgUrl: `${relativePathToIcons}#icon-tools-measure-target`, icon: 'tool-measure-target',
active: false, active: false,
}, },
{ {
command: 'Brush', command: 'Brush',
type: 'tool', type: 'tool',
text: 'Brush', text: 'Brush',
iconClasses: 'fa fa-circle', icon: 'circle',
active: false, active: false,
}, },
{ {
command: 'FreehandMouse', command: 'FreehandMouse',
type: 'tool', type: 'tool',
text: 'Freehand', text: 'Freehand',
iconClasses: 'fa fa-star', icon: 'star',
active: false, active: false,
}, },
{ {
command: 'EllipticalRoi', command: 'EllipticalRoi',
type: 'tool', type: 'tool',
text: 'EllipticalRoi', text: 'EllipticalRoi',
iconClasses: 'far fa-circle', icon: 'circle',
active: false, active: false,
}, },
{ {
command: 'CircleRoi', command: 'CircleRoi',
type: 'tool', type: 'tool',
text: 'CircleRoi', text: 'CircleRoi',
iconClasses: 'far fa-dot-circle', icon: 'dot-circle',
active: false, active: false,
}, },
{ {
command: 'RectangleRoi', command: 'RectangleRoi',
type: 'tool', type: 'tool',
text: 'RectangleRoi', text: 'RectangleRoi',
iconClasses: 'far fa-square', icon: 'square',
active: false, active: false,
}, },
{ {
command: 'reset', command: 'reset',
type: 'command', type: 'command',
text: 'Reset', text: 'Reset',
svgUrl: `${relativePathToIcons}#icon-tools-reset`, icon: 'tool-reset',
active: false, active: false,
}, },
] ]

View File

@ -2,25 +2,8 @@ import getDefaultToolbarButtons from './getDefaultToolbarButtons.js'
describe('getDefaultToolbarButtons.js', () => { describe('getDefaultToolbarButtons.js', () => {
it('returns a non-empty array', () => { it('returns a non-empty array', () => {
const basePath = '/' const buttons = getDefaultToolbarButtons()
const buttons = getDefaultToolbarButtons(basePath)
expect(buttons.length).toBeGreaterThan(0) expect(buttons.length).toBeGreaterThan(0)
}) })
it('uses the provided basePath in buttons with an svgUrl property', () => {
const basePath = '/demo/'
const buttons = getDefaultToolbarButtons(basePath)
const hasOneOrMoreButtonsWithSvgUrlProperty = buttons.some(btn =>
btn.hasOwnProperty('svgUrl')
)
const usesBasePathInButtonSvgUrls = buttons.every(
btn => !btn.hasOwnProperty('svgUrl') || btn.svgUrl.includes(basePath)
)
expect(hasOneOrMoreButtonsWithSvgUrlProperty).toBeTruthy()
expect(usesBasePathInButtonSvgUrls).toBeTruthy()
})
}) })